diff --git a/assets/css/activation.css b/assets/css/activation.css index 6b78b8f6130..d11bc8d1d1a 100644 --- a/assets/css/activation.css +++ b/assets/css/activation.css @@ -1 +1 @@ -.woocommerce-message{overflow:hidden;position:relative;border-left-color:#cc99c2!important}.woocommerce-message a.button-primary,p.woocommerce-actions a.button-primary{background:#cc99c2;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);border-color:#b366a4;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);color:#fff;text-shadow:0 -1px 1px #8a4f7f,1px 0 1px #8a4f7f,0 1px 1px #8a4f7f,-1px 0 1px #8a4f7f}.woocommerce-message a.button-primary:hover,p.woocommerce-actions a.button-primary:hover{background:#bb77ae;border-color:#aa559a;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15)}.woocommerce-message a.button-primary:active,p.woocommerce-actions a.button-primary:active{background:#aa559a;border-color:#aa559a}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:absolute;top:10px;right:10px;padding:10px 15px 10px 21px;font-size:13px;line-height:1.23076923;text-decoration:none}.woocommerce-message a.woocommerce-message-close:before,p.woocommerce-actions a.woocommerce-message-close:before{position:absolute;top:8px;left:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message a.button-primary,.woocommerce-message a.button-secondary,p.woocommerce-actions a.button-primary,p.woocommerce-actions a.button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-left:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}div.woocommerce-legacy-shipping-notice,div.woocommerce-no-shipping-methods-notice{overflow:hidden;padding:1px 12px}div.woocommerce-legacy-shipping-notice p,div.woocommerce-no-shipping-methods-notice p{position:relative;z-index:1;max-width:700px;line-height:1.5em;margin:12px 0}div.woocommerce-legacy-shipping-notice p.main,div.woocommerce-no-shipping-methods-notice p.main{font-size:1.1em}div.woocommerce-legacy-shipping-notice:before,div.woocommerce-no-shipping-methods-notice:before{content:"\e01b";font-family:WooCommerce;text-align:center;line-height:1;color:#F7F1F6;display:block;width:1em;font-size:20em;top:36px;right:12px;position:absolute} \ No newline at end of file +div.woocommerce-message{overflow:hidden;position:relative;border-left-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}.woocommerce-message a.button-primary,p.woocommerce-actions a.button-primary{background:#cc99c2;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);border-color:#b366a4;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);color:#fff;text-shadow:0 -1px 1px #8a4f7f,1px 0 1px #8a4f7f,0 1px 1px #8a4f7f,-1px 0 1px #8a4f7f}.woocommerce-message a.button-primary:hover,p.woocommerce-actions a.button-primary:hover{background:#bb77ae;border-color:#aa559a;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15)}.woocommerce-message a.button-primary:active,p.woocommerce-actions a.button-primary:active{background:#aa559a;border-color:#aa559a}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:absolute;top:0;right:0;padding:10px 15px 10px 21px;font-size:13px;line-height:1.23076923;text-decoration:none}.woocommerce-message a.woocommerce-message-close:before,p.woocommerce-actions a.woocommerce-message-close:before{position:absolute;top:8px;left:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message a.button-primary,.woocommerce-message a.button-secondary,p.woocommerce-actions a.button-primary,p.woocommerce-actions a.button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-left:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}div.woocommerce-legacy-shipping-notice,div.woocommerce-no-shipping-methods-notice{overflow:hidden;padding:1px 12px}div.woocommerce-legacy-shipping-notice p,div.woocommerce-no-shipping-methods-notice p{position:relative;z-index:1;max-width:700px;line-height:1.5em;margin:12px 0}div.woocommerce-legacy-shipping-notice p.main,div.woocommerce-no-shipping-methods-notice p.main{font-size:1.1em}div.woocommerce-legacy-shipping-notice:before,div.woocommerce-no-shipping-methods-notice:before{content:"\e01b";font-family:WooCommerce;text-align:center;line-height:1;color:#F7F1F6;display:block;width:1em;font-size:20em;top:36px;right:12px;position:absolute} \ No newline at end of file diff --git a/assets/css/activation.scss b/assets/css/activation.scss index 44d88a207ed..569a38b9efb 100644 --- a/assets/css/activation.scss +++ b/assets/css/activation.scss @@ -11,10 +11,13 @@ /** * Styling begins */ -.woocommerce-message { +div.woocommerce-message { overflow: hidden; position: relative; border-left-color: #cc99c2 !important; + p { + max-width: 700px; + } } p.woocommerce-actions, @@ -42,8 +45,8 @@ p.woocommerce-actions, a.woocommerce-message-close { position: absolute; - top: 10px; - right: 10px; + top: 0; + right: 0; padding: 10px 15px 10px 21px; font-size: 13px; line-height: 1.23076923; diff --git a/assets/css/wc-setup.css b/assets/css/wc-setup.css index 4708a819ef8..58ba9a1d20d 100644 --- a/assets/css/wc-setup.css +++ b/assets/css/wc-setup.css @@ -1 +1 @@ -.wc-setup-content p,.wc-setup-content table{font-size:1em;line-height:1.75em;color:#666}body{margin:100px auto 24px;box-shadow:none;background:#f1f1f1;padding:0}#wc-logo{border:0;margin:0 0 24px;padding:0;text-align:center}#wc-logo img{max-width:50%}.wc-setup-content{box-shadow:0 1px 3px rgba(0,0,0,.13);padding:24px 24px 0;background:#fff;overflow:hidden;zoom:1}.wc-setup-content h1,.wc-setup-content h2,.wc-setup-content h3,.wc-setup-content table{margin:0 0 24px;border:0;padding:0;color:#666;clear:none}.wc-setup-content p{margin:0 0 24px}.wc-setup-content a{color:#a16696}.wc-setup-content a:focus,.wc-setup-content a:hover{color:#111}.wc-setup-content .form-table th{width:35%;vertical-align:top;font-weight:400}.wc-setup-content .form-table td{vertical-align:top}.wc-setup-content .form-table td input,.wc-setup-content .form-table td select{width:100%;box-sizing:border-box}.wc-setup-content .form-table td input[size]{width:auto}.wc-setup-content .form-table td .description{line-height:1.5em;display:block;margin-top:.25em;color:#999;font-style:italic}.wc-setup-content .form-table td .input-checkbox,.wc-setup-content .form-table td .input-radio{width:auto;box-sizing:inherit;padding:inherit;margin:0 .5em 0 0;box-shadow:none}.wc-setup-content .form-table .section_title td{padding:0}.wc-setup-content .form-table .section_title td h2,.wc-setup-content .form-table .section_title td p{margin:12px 0 0}.wc-setup-content .form-table td,.wc-setup-content .form-table th{padding:12px 0;margin:0;border:0}.wc-setup-content .form-table td:first-child,.wc-setup-content .form-table th:first-child{padding-right:1em}.wc-setup-content table.tax-rates{width:100%;font-size:.92em}.wc-setup-content table.tax-rates th{padding:0;text-align:center;width:auto;vertical-align:middle}.wc-setup-content table.tax-rates td{border:1px solid #f5f5f5;padding:6px;text-align:center;vertical-align:middle}.wc-setup-content table.tax-rates td input{outline:0;border:0;padding:0;box-shadow:none;text-align:center;width:100%}.wc-setup-content table.tax-rates .add,.wc-setup-content table.tax-rates .remove{padding:1em 0 0 1em;line-height:1em;width:0;height:0;display:inline-block;font-size:1em;overflow:hidden}.wc-setup-content table.tax-rates td.sort{cursor:move;color:#ccc}.wc-setup-content table.tax-rates td.sort:before{content:"\f333";font-family:dashicons}.wc-setup-content table.tax-rates td.readonly{background:#f5f5f5}.wc-setup-content table.tax-rates .add{margin:6px 0 0;position:relative}.wc-setup-content table.tax-rates .add:before{content:"\f502";font-family:dashicons;position:absolute;left:0;top:0}.wc-setup-content table.tax-rates .remove{margin:0;position:relative}.wc-setup-content table.tax-rates .remove:before{content:"\f182";font-family:dashicons;position:absolute;left:0;top:0}.wc-setup-content .wc-setup-pages{width:100%;border-top:1px solid #eee}.wc-setup-content .wc-setup-pages thead th{display:none}.wc-setup-content .wc-setup-pages .page-name{width:30%;font-weight:700}.wc-setup-content .wc-setup-pages td,.wc-setup-content .wc-setup-pages th{padding:14px 0;border-bottom:1px solid #eee}.wc-setup-content .wc-setup-pages td:first-child,.wc-setup-content .wc-setup-pages th:first-child{padding-right:9px}.wc-setup-content .wc-setup-pages th{padding-top:0}.wc-setup-content .wc-setup-pages .page-options p{color:#777;margin:6px 0 0 24px;line-height:1.75em}.wc-setup-content .wc-setup-pages .page-options p input{vertical-align:middle;margin:1px 0 0;height:1.75em;width:1.75em;line-height:1.75em}.wc-setup-content .wc-setup-pages .page-options p label{line-height:1}@media screen and (max-width:782px){.wc-setup-content .form-table tbody th{width:auto}}.wc-setup-content .twitter-share-button{float:right}.wc-setup-content .wc-setup-next-steps{overflow:hidden;margin:0 0 24px}.wc-setup-content .wc-setup-next-steps h2{margin-bottom:12px}.wc-setup-content .wc-setup-next-steps .wc-setup-next-steps-first{float:left;width:50%;box-sizing:border-box}.wc-setup-content .wc-setup-next-steps .wc-setup-next-steps-last{float:right;width:50%;box-sizing:border-box}.wc-setup-content .wc-setup-next-steps ul{padding:0 2em 0 0;list-style:none;margin:0 0 -.75em}.wc-setup-content .wc-setup-next-steps ul li a{display:block;padding:0 0 .75em}.wc-setup-content .wc-setup-next-steps ul .setup-product a{background-color:#a16696;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);font-size:1em;height:auto;line-height:1.75em;margin:0 0 .75em;opacity:1;padding:1em;text-align:center;text-shadow:0 -1px 1px #8a4f7f,1px 0 1px #8a4f7f,0 1px 1px #8a4f7f,-1px 0 1px #8a4f7f}.wc-setup-content .wc-setup-next-steps ul li a:before{color:#82878c;font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0 10px 0 0;top:1px;position:relative;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;vertical-align:top}.wc-setup-content .wc-setup-next-steps ul .learn-more a:before{content:"\f105"}.wc-setup-content .wc-setup-next-steps ul .video-walkthrough a:before{content:"\f126"}.wc-setup-content .wc-setup-next-steps ul {content:"\f118"}.wc-setup-content .wc-setup-next-steps ul .newsletter a:before{content:"\f465"}.wc-setup-content .updated,.wc-setup-content .woocommerce-tracker{padding:24px 24px 0;margin:0 0 24px;overflow:hidden;background:#f5f5f5}.wc-setup-content .updated p,.wc-setup-content .woocommerce-tracker p{padding:0;margin:0 0 12px}.wc-setup-content .updated p:last-child,.wc-setup-content .woocommerce-tracker p:last-child{margin:0 0 24px}.wc-setup-steps{padding:0 0 24px;margin:0;list-style:none;overflow:hidden;color:#ccc;width:100%;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex}.wc-setup-steps li{width:20%;float:left;padding:0 0 .8em;margin:0;text-align:center;position:relative;border-bottom:4px solid #ccc;line-height:1.4em}.wc-setup-steps li:before{content:"";border:4px solid #ccc;border-radius:100%;width:4px;height:4px;position:absolute;bottom:0;left:50%;margin-left:-6px;margin-bottom:-8px;background:#fff}.wc-setup-steps li.active{border-color:#a16696;color:#a16696}.wc-setup-steps li.active:before{border-color:#a16696}.wc-setup-steps li.done{border-color:#a16696;color:#a16696}.wc-setup-steps li.done:before{border-color:#a16696;background:#a16696}.wc-setup .wc-setup-actions{overflow:hidden}.wc-setup .wc-setup-actions .button{float:right;font-size:1.25em;padding:.5em 1em;line-height:1em;margin-right:.5em;height:auto}.wc-setup .wc-setup-actions .button-primary{background-color:#a16696;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);float:right;margin:0;opacity:1;text-shadow:0 -1px 1px #8a4f7f,1px 0 1px #8a4f7f,0 1px 1px #8a4f7f,-1px 0 1px #8a4f7f}.wc-return-to-dashboard{font-size:.85em;color:#b5b5b5;margin:1.18em 0;display:block;text-align:center} +.wc-setup-content p,.wc-setup-content table{font-size:1em;line-height:1.75em;color:#666}body{margin:100px auto 24px;box-shadow:none;background:#f1f1f1;padding:0}#wc-logo{border:0;margin:0 0 24px;padding:0;text-align:center}#wc-logo img{max-width:50%}.wc-setup-content{box-shadow:0 1px 3px rgba(0,0,0,.13);padding:24px 24px 0;background:#fff;overflow:hidden;zoom:1}.wc-setup-content h1,.wc-setup-content h2,.wc-setup-content h3,.wc-setup-content table{margin:0 0 24px;border:0;padding:0;color:#666;clear:none}.wc-setup-content p{margin:0 0 24px}.wc-setup-content a{color:#a16696}.wc-setup-content a:focus,.wc-setup-content a:hover{color:#111}.wc-setup-content .form-table th{width:35%;vertical-align:top;font-weight:400}.wc-setup-content .form-table td{vertical-align:top}.wc-setup-content .form-table td input,.wc-setup-content .form-table td select{width:100%;box-sizing:border-box}.wc-setup-content .form-table td input[size]{width:auto}.wc-setup-content .form-table td .description{line-height:1.5em;display:block;margin-top:.25em;color:#999;font-style:italic}.wc-setup-content .form-table td .input-checkbox,.wc-setup-content .form-table td .input-radio{width:auto;box-sizing:inherit;padding:inherit;margin:0 .5em 0 0;box-shadow:none}.wc-setup-content .form-table .section_title td{padding:0}.wc-setup-content .form-table .section_title td h2,.wc-setup-content .form-table .section_title td p{margin:12px 0 0}.wc-setup-content .form-table td,.wc-setup-content .form-table th{padding:12px 0;margin:0;border:0}.wc-setup-content .form-table td:first-child,.wc-setup-content .form-table th:first-child{padding-right:1em}.wc-setup-content table.tax-rates{width:100%;font-size:.92em}.wc-setup-content table.tax-rates th{padding:0;text-align:center;width:auto;vertical-align:middle}.wc-setup-content table.tax-rates td{border:1px solid #f5f5f5;padding:6px;text-align:center;vertical-align:middle}.wc-setup-content table.tax-rates td input{outline:0;border:0;padding:0;box-shadow:none;text-align:center;width:100%}.wc-setup-content table.tax-rates .add,.wc-setup-content table.tax-rates .remove{padding:1em 0 0 1em;line-height:1em;width:0;height:0;display:inline-block;font-size:1em;overflow:hidden}.wc-setup-content table.tax-rates td.sort{cursor:move;color:#ccc}.wc-setup-content table.tax-rates td.sort:before{content:"\f333";font-family:dashicons}.wc-setup-content table.tax-rates td.readonly{background:#f5f5f5}.wc-setup-content table.tax-rates .add{margin:6px 0 0;position:relative}.wc-setup-content table.tax-rates .add:before{content:"\f502";font-family:dashicons;position:absolute;left:0;top:0}.wc-setup-content table.tax-rates .remove{margin:0;position:relative}.wc-setup-content table.tax-rates .remove:before{content:"\f182";font-family:dashicons;position:absolute;left:0;top:0}.wc-setup-content .wc-setup-pages{width:100%;border-top:1px solid #eee}.wc-setup-content .wc-setup-pages thead th{display:none}.wc-setup-content .wc-setup-pages .page-name{width:30%;font-weight:700}.wc-setup-content .wc-setup-pages td,.wc-setup-content .wc-setup-pages th{padding:14px 0;border-bottom:1px solid #eee}.wc-setup-content .wc-setup-pages td:first-child,.wc-setup-content .wc-setup-pages th:first-child{padding-right:9px}.wc-setup-content .wc-setup-pages th{padding-top:0}.wc-setup-content .wc-setup-pages .page-options p{color:#777;margin:6px 0 0 24px;line-height:1.75em}.wc-setup-content .wc-setup-pages .page-options p input{vertical-align:middle;margin:1px 0 0;height:1.75em;width:1.75em;line-height:1.75em}.wc-setup-content .wc-setup-pages .page-options p label{line-height:1}@media screen and (max-width:782px){.wc-setup-content .form-table tbody th{width:auto}}.wc-setup-content .twitter-share-button{float:right}.wc-setup-content .wc-setup-next-steps{overflow:hidden;margin:0 0 24px}.wc-setup-content .wc-setup-next-steps h2{margin-bottom:12px}.wc-setup-content .wc-setup-next-steps .wc-setup-next-steps-first{float:left;width:50%;box-sizing:border-box}.wc-setup-content .wc-setup-next-steps .wc-setup-next-steps-last{float:right;width:50%;box-sizing:border-box}.wc-setup-content .wc-setup-next-steps ul{padding:0 2em 0 0;list-style:none;margin:0 0 -.75em}.wc-setup-content .wc-setup-next-steps ul li a{display:block;padding:0 0 .75em}.wc-setup-content .wc-setup-next-steps ul .setup-product a{background-color:#a16696;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);font-size:1em;height:auto;line-height:1.75em;margin:0 0 .75em;opacity:1;padding:1em;text-align:center;text-shadow:0 -1px 1px #8a4f7f,1px 0 1px #8a4f7f,0 1px 1px #8a4f7f,-1px 0 1px #8a4f7f}.wc-setup-content .wc-setup-next-steps ul li a:before{color:#82878c;font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0 10px 0 0;top:1px;position:relative;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;vertical-align:top}.wc-setup-content .wc-setup-next-steps ul .learn-more a:before{content:"\f105"}.wc-setup-content .wc-setup-next-steps ul .video-walkthrough a:before{content:"\f126"}.wc-setup-content .wc-setup-next-steps ul .newsletter a:before{content:"\f465"}.wc-setup-content .updated,.wc-setup-content .woocommerce-tracker{padding:24px 24px 0;margin:0 0 24px;overflow:hidden;background:#f5f5f5}.wc-setup-content .updated p,.wc-setup-content .woocommerce-tracker p{padding:0;margin:0 0 12px}.wc-setup-content .updated p:last-child,.wc-setup-content .woocommerce-tracker p:last-child{margin:0 0 24px}.wc-setup-steps{padding:0 0 24px;margin:0;list-style:none;overflow:hidden;color:#ccc;width:100%;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex}.wc-setup-steps li{width:20%;float:left;padding:0 0 .8em;margin:0;text-align:center;position:relative;border-bottom:4px solid #ccc;line-height:1.4em}.wc-setup-steps li:before{content:"";border:4px solid #ccc;border-radius:100%;width:4px;height:4px;position:absolute;bottom:0;left:50%;margin-left:-6px;margin-bottom:-8px;background:#fff}.wc-setup-steps li.active{border-color:#a16696;color:#a16696}.wc-setup-steps li.active:before{border-color:#a16696}.wc-setup-steps li.done{border-color:#a16696;color:#a16696}.wc-setup-steps li.done:before{border-color:#a16696;background:#a16696}.wc-setup .wc-setup-actions{overflow:hidden}.wc-setup .wc-setup-actions .button{float:right;font-size:1.25em;padding:.5em 1em;line-height:1em;margin-right:.5em;height:auto}.wc-setup .wc-setup-actions .button-primary{background-color:#a16696;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);float:right;margin:0;opacity:1;text-shadow:0 -1px 1px #8a4f7f,1px 0 1px #8a4f7f,0 1px 1px #8a4f7f,-1px 0 1px #8a4f7f}.wc-return-to-dashboard{font-size:.85em;color:#b5b5b5;margin:1.18em 0;display:block;text-align:center}ul.wc-wizard-payment-gateways{border:1px solid #eee;border-bottom-width:2px;padding:0;margin:0 0 1em;list-style:none;border-radius:4px}ul.wc-wizard-payment-gateways li.wc-wizard-gateway{padding:1.5em 1em 1em 4em;border-top:1px solid #eee;list-style:none;cursor:pointer;color:#555;box-sizing:border-box;clear:both}ul.wc-wizard-payment-gateways li.wc-wizard-gateway:first-child{border-top:0}ul.wc-wizard-payment-gateways li.wc-wizard-gateway.featured{width:50%;float:left;clear:none;border-right:1px solid #eee;border-top:0}ul.wc-wizard-payment-gateways li.wc-wizard-gateway.featured-row-last{border-right:0}ul.wc-wizard-payment-gateways li.wc-wizard-gateway .wc-wizard-gateway-settings{display:none;margin-bottom:0;cursor:default}ul.wc-wizard-payment-gateways li.wc-wizard-gateway.checked{background:#F7F1F6}ul.wc-wizard-payment-gateways li.wc-wizard-gateway.checked .wc-wizard-gateway-settings{display:table}ul.wc-wizard-payment-gateways li.wc-wizard-gateway .wc-wizard-gateway-description{font-style:italic}ul.wc-wizard-payment-gateways li.wc-wizard-gateway .wc-wizard-gateway-description p,ul.wc-wizard-payment-gateways li.wc-wizard-gateway .wc-wizard-gateway-enable{margin:0 0 .5em}ul.wc-wizard-payment-gateways li.wc-wizard-gateway .wc-wizard-gateway-enable label{display:block;font-weight:700;vertical-align:middle}ul.wc-wizard-payment-gateways li.wc-wizard-gateway .wc-wizard-gateway-enable label img{max-height:2em;vertical-align:middle}ul.wc-wizard-payment-gateways li.wc-wizard-gateway .wc-wizard-gateway-enable label:before{content:'';background:#fff;border:2px solid #eee;display:inline-block;float:left;vertical-align:middle;width:2em;height:2em;padding:0;box-sizing:border-box;line-height:1.8em;text-align:center;margin:0 1em 0 -3em;border-radius:4px}ul.wc-wizard-payment-gateways li.wc-wizard-gateway .wc-wizard-gateway-enable input{opacity:0;width:0;position:absolute}ul.wc-wizard-payment-gateways li.wc-wizard-gateway .wc-wizard-gateway-enable input:checked+label:before{content:"\f147";font-family:dashicons;color:#fff;border-color:#a46497;background:#a46497}ul.wc-wizard-payment-gateways li.wc-wizard-gateway .wc-wizard-gateway-enable input:focus+label{outline:#ddd solid 1px} \ No newline at end of file diff --git a/assets/css/wc-setup.scss b/assets/css/wc-setup.scss index 93151f6b000..8560ad38cb1 100644 --- a/assets/css/wc-setup.scss +++ b/assets/css/wc-setup.scss @@ -367,3 +367,108 @@ body { display: block; text-align: center; } + +ul.wc-wizard-payment-gateways { + border: 1px solid #eee; + border-bottom-width: 2px; + padding: 0; + margin: 0 0 1em; + list-style: none outside; + border-radius: 4px; + + li.wc-wizard-gateway { + padding: 1.5em 1em 1em 4em; + border-top: 1px solid #eee; + list-style: none outside; + cursor: pointer; + color: #555; + box-sizing: border-box; + clear: both; + + &:first-child { + border-top: 0; + } + + &.featured { + width: 50%; + float: left; + clear: none; + border-right: 1px solid #eee; + border-top: 0; + } + + &.featured-row-last { + border-right: 0; + } + + .wc-wizard-gateway-settings { + display: none; + margin-bottom: 0; + cursor: default; + } + + &.checked { + background: #F7F1F6; + + .wc-wizard-gateway-settings { + display: table; + } + } + + .wc-wizard-gateway-description { + font-style: italic; + + p { + margin: 0 0 .5em; + } + } + + .wc-wizard-gateway-enable { + margin: 0 0 .5em; + + label { + display: block; + font-weight: bold; + vertical-align: middle; + + img { + max-height: 2em; + vertical-align: middle; + } + } + label:before { + content: ''; + background: #fff; + border: 2px solid #eee; + display: inline-block; + float: left; + vertical-align: middle; + width: 2em; + height: 2em; + padding: 0; + box-sizing: border-box; + line-height: 1.8em; + text-align: center; + margin: 0 1em 0 -3em; + border-radius: 4px; + } + input { + opacity: 0; + width: 0; + position: absolute; + + &:checked + label:before { + content: "\f147"; + font-family: 'dashicons'; + color: #fff; + border-color: #a46497; + background: #a46497; + } + + &:focus + label { + outline: 1px solid #ddd; /* focus style */ + } + } + } + } +} diff --git a/assets/images/paypal-braintree.png b/assets/images/paypal-braintree.png new file mode 100644 index 00000000000..2eb31c6136f Binary files /dev/null and b/assets/images/paypal-braintree.png differ diff --git a/assets/images/paypal.png b/assets/images/paypal.png new file mode 100644 index 00000000000..a892ac1d876 Binary files /dev/null and b/assets/images/paypal.png differ diff --git a/assets/images/stripe.png b/assets/images/stripe.png new file mode 100644 index 00000000000..9d0ad7a535a Binary files /dev/null and b/assets/images/stripe.png differ diff --git a/assets/js/admin/wc-setup.js b/assets/js/admin/wc-setup.js index 9ab675215de..96145eaac7f 100644 --- a/assets/js/admin/wc-setup.js +++ b/assets/js/admin/wc-setup.js @@ -46,4 +46,21 @@ jQuery( function( $ ) { return true; } ); + $( '.wc-wizard-payment-gateways' ).on( 'change', '.wc-wizard-gateway-enable input', function() { + if ( $( this ).is( ':checked' ) ) { + $( this ).closest( 'li' ).addClass( 'checked' ); + } else { + $( this ).closest( 'li' ).removeClass( 'checked' ); + } + } ); + + $( '.wc-wizard-payment-gateways' ).on( 'click', 'li.wc-wizard-gateway', function() { + var $enabled = $( this ).find( '.wc-wizard-gateway-enable input' ); + + $enabled.prop( 'checked', ! $enabled.prop( 'checked' ) ).change(); + } ); + + $( '.wc-wizard-payment-gateways' ).on( 'click', 'li.wc-wizard-gateway table, li.wc-wizard-gateway a', function( e ) { + e.stopPropagation(); + } ); } ); diff --git a/assets/js/admin/wc-setup.min.js b/assets/js/admin/wc-setup.min.js index fdb451c1978..5dcaf11b467 100644 --- a/assets/js/admin/wc-setup.min.js +++ b/assets/js/admin/wc-setup.min.js @@ -1 +1 @@ -jQuery(function(a){var b=a.parseJSON(wc_setup_params.locale_info);a('select[name="store_location"]').change(function(){var c=a(this).val(),d=c.split(":")[0],e=b[d],f=["thousand_sep","decimal_sep","num_decimals","currency_pos"];e?a.each(e,function(b,c){a(':input[name="'+b+'"]').val(c).change(),-1!==a.inArray(b,f)&&a(':input[name="'+b+'"]').closest("tr").hide()}):(a(':input[name="currency_pos"]').closest("tr").show(),a(':input[name="thousand_sep"]').closest("tr").show(),a(':input[name="decimal_sep"]').closest("tr").show(),a(':input[name="num_decimals"]').closest("tr").show())}).change(),a('input[name="woocommerce_calc_taxes"]').change(function(){a(this).is(":checked")?(a(':input[name="woocommerce_prices_include_tax"], :input[name="woocommerce_import_tax_rates"]').closest("tr").show(),a("tr.tax-rates").show()):(a(':input[name="woocommerce_prices_include_tax"], :input[name="woocommerce_import_tax_rates"]').closest("tr").hide(),a("tr.tax-rates").hide())}).change(),a(".button-next").on("click",function(){return a(".wc-setup-content").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),!0})}); \ No newline at end of file +jQuery(function(a){var b=a.parseJSON(wc_setup_params.locale_info);a('select[name="store_location"]').change(function(){var c=a(this).val(),d=c.split(":")[0],e=b[d],f=["thousand_sep","decimal_sep","num_decimals","currency_pos"];e?a.each(e,function(b,c){a(':input[name="'+b+'"]').val(c).change(),-1!==a.inArray(b,f)&&a(':input[name="'+b+'"]').closest("tr").hide()}):(a(':input[name="currency_pos"]').closest("tr").show(),a(':input[name="thousand_sep"]').closest("tr").show(),a(':input[name="decimal_sep"]').closest("tr").show(),a(':input[name="num_decimals"]').closest("tr").show())}).change(),a('input[name="woocommerce_calc_taxes"]').change(function(){a(this).is(":checked")?(a(':input[name="woocommerce_prices_include_tax"], :input[name="woocommerce_import_tax_rates"]').closest("tr").show(),a("tr.tax-rates").show()):(a(':input[name="woocommerce_prices_include_tax"], :input[name="woocommerce_import_tax_rates"]').closest("tr").hide(),a("tr.tax-rates").hide())}).change(),a(".button-next").on("click",function(){return a(".wc-setup-content").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),!0}),a(".wc-wizard-payment-gateways").on("change",".wc-wizard-gateway-enable input",function(){a(this).is(":checked")?a(this).closest("li").addClass("checked"):a(this).closest("li").removeClass("checked")}),a(".wc-wizard-payment-gateways").on("click","li.wc-wizard-gateway",function(){var b=a(this).find(".wc-wizard-gateway-enable input");b.prop("checked",!b.prop("checked")).change()}),a(".wc-wizard-payment-gateways").on("click","li.wc-wizard-gateway table, li.wc-wizard-gateway a",function(a){a.stopPropagation()})}); \ No newline at end of file diff --git a/assets/js/frontend/single-product.js b/assets/js/frontend/single-product.js index 698d03ea67a..65578194dbe 100644 --- a/assets/js/frontend/single-product.js +++ b/assets/js/frontend/single-product.js @@ -7,8 +7,8 @@ jQuery( function( $ ) { } // Tabs - $( '.wc-tabs-wrapper, .woocommerce-tabs' ) - .on( 'init', function() { + $( 'body' ) + .on( 'init', '.wc-tabs-wrapper, .woocommerce-tabs', function() { $( '.wc-tab, .woocommerce-tabs .panel:not(.panel .panel)' ).hide(); var hash = window.location.hash; @@ -35,17 +35,15 @@ jQuery( function( $ ) { $tab.closest( 'li' ).addClass( 'active' ); $tabs_wrapper.find( $tab.attr( 'href' ) ).show(); }) - .trigger( 'init' ); - - $( 'a.woocommerce-review-link' ).click( function() { - $( '.reviews_tab a' ).click(); - return true; - }); - - // Star ratings for comments - $( '#rating' ).hide().before( '
' ); - - $( 'body' ) + // Review link + .on( 'click', 'a.woocommerce-review-link', function() { + $( '.reviews_tab a' ).click(); + return true; + }) + // Star ratings for comments + .on( 'init', '#rating', function() { + $( '#rating' ).hide().before( '' ); + }) .on( 'click', '#respond p.stars a', function() { var $star = $( this ), $rating = $( this ).closest( '#respond' ).find( '#rating' ), @@ -68,4 +66,7 @@ jQuery( function( $ ) { return false; } }); + + //Init Tabs and Star Ratings + $( '.wc-tabs-wrapper, .woocommerce-tabs, #rating' ).trigger( 'init' ); }); diff --git a/assets/js/frontend/single-product.min.js b/assets/js/frontend/single-product.min.js index ddce18dec6b..7f9cce13f12 100644 --- a/assets/js/frontend/single-product.min.js +++ b/assets/js/frontend/single-product.min.js @@ -1 +1 @@ -jQuery(function(a){return"undefined"==typeof wc_single_product_params?!1:(a(".wc-tabs-wrapper, .woocommerce-tabs").on("init",function(){a(".wc-tab, .woocommerce-tabs .panel:not(.panel .panel)").hide();var b=window.location.hash,c=window.location.href,d=a(this).find(".wc-tabs, ul.tabs").first();b.toLowerCase().indexOf("comment-")>=0||"#reviews"===b||"#tab-reviews"===b?d.find("li.reviews_tab a").click():c.indexOf("comment-page-")>0||c.indexOf("cpage=")>0?d.find("li.reviews_tab a").click():d.find("li:first a").click()}).on("click",".wc-tabs li a, ul.tabs li a",function(b){b.preventDefault();var c=a(this),d=c.closest(".wc-tabs-wrapper, .woocommerce-tabs"),e=d.find(".wc-tabs, ul.tabs");e.find("li").removeClass("active"),d.find(".wc-tab, .panel:not(.panel .panel)").hide(),c.closest("li").addClass("active"),d.find(c.attr("href")).show()}).trigger("init"),a("a.woocommerce-review-link").click(function(){return a(".reviews_tab a").click(),!0}),a("#rating").hide().before(''),void a("body").on("click","#respond p.stars a",function(){var b=a(this),c=a(this).closest("#respond").find("#rating"),d=a(this).closest(".stars");return c.val(b.text()),b.siblings("a").removeClass("active"),b.addClass("active"),d.addClass("selected"),!1}).on("click","#respond #submit",function(){var b=a(this).closest("#respond").find("#rating"),c=b.val();return b.length>0&&!c&&"yes"===wc_single_product_params.review_rating_required?(window.alert(wc_single_product_params.i18n_required_rating_text),!1):void 0}))}); \ No newline at end of file +jQuery(function(a){return"undefined"==typeof wc_single_product_params?!1:(a("body").on("init",".wc-tabs-wrapper, .woocommerce-tabs",function(){a(".wc-tab, .woocommerce-tabs .panel:not(.panel .panel)").hide();var b=window.location.hash,c=window.location.href,d=a(this).find(".wc-tabs, ul.tabs").first();b.toLowerCase().indexOf("comment-")>=0||"#reviews"===b||"#tab-reviews"===b?d.find("li.reviews_tab a").click():c.indexOf("comment-page-")>0||c.indexOf("cpage=")>0?d.find("li.reviews_tab a").click():d.find("li:first a").click()}).on("click",".wc-tabs li a, ul.tabs li a",function(b){b.preventDefault();var c=a(this),d=c.closest(".wc-tabs-wrapper, .woocommerce-tabs"),e=d.find(".wc-tabs, ul.tabs");e.find("li").removeClass("active"),d.find(".wc-tab, .panel:not(.panel .panel)").hide(),c.closest("li").addClass("active"),d.find(c.attr("href")).show()}).on("click","a.woocommerce-review-link",function(){return a(".reviews_tab a").click(),!0}).on("init","#rating",function(){a("#rating").hide().before('')}).on("click","#respond p.stars a",function(){var b=a(this),c=a(this).closest("#respond").find("#rating"),d=a(this).closest(".stars");return c.val(b.text()),b.siblings("a").removeClass("active"),b.addClass("active"),d.addClass("selected"),!1}).on("click","#respond #submit",function(){var b=a(this).closest("#respond").find("#rating"),c=b.val();return b.length>0&&!c&&"yes"===wc_single_product_params.review_rating_required?(window.alert(wc_single_product_params.i18n_required_rating_text),!1):void 0}),void a(".wc-tabs-wrapper, .woocommerce-tabs, #rating").trigger("init"))}); \ No newline at end of file diff --git a/includes/abstracts/abstract-wc-rest-posts-controller.php b/includes/abstracts/abstract-wc-rest-posts-controller.php new file mode 100644 index 00000000000..bb3a96f7497 --- /dev/null +++ b/includes/abstracts/abstract-wc-rest-posts-controller.php @@ -0,0 +1,678 @@ +post_type, 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to create an item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function create_item_permissions_check( $request ) { + if ( ! wc_rest_check_post_permissions( $this->post_type, 'create' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to read an item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_item_permissions_check( $request ) { + $post = get_post( (int) $request['id'] ); + + if ( $post && ! wc_rest_check_post_permissions( $this->post_type, 'read', $post->ID ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to update an item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function update_item_permissions_check( $request ) { + $post = get_post( $request['id'] ); + + if ( $post && ! wc_rest_check_post_permissions( $this->post_type, 'edit', $post->ID ) ) { + return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to delete an item. + * + * @param WP_REST_Request $request Full details about the request. + * @return bool|WP_Error + */ + public function delete_item_permissions_check( $request ) { + $post = get_post( $request['id'] ); + + if ( $post && ! wc_rest_check_post_permissions( $this->post_type, 'delete', $post->ID ) ) { + return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Get a single item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_item( $request ) { + $id = (int) $request['id']; + $post = get_post( $id ); + + if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) { + return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'Invalid id.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $data = $this->prepare_item_for_response( $post, $request ); + $response = rest_ensure_response( $data ); + + if ( $this->public ) { + $response->link_header( 'alternate', get_permalink( $id ), array( 'type' => 'text/html' ) ); + } + + return $response; + } + + /** + * Create a single item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function create_item( $request ) { + if ( ! empty( $request['id'] ) ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) ); + } + + $post = $this->prepare_item_for_database( $request ); + if ( is_wp_error( $post ) ) { + return $post; + } + + $post->post_type = $this->post_type; + $post_id = wp_insert_post( $post, true ); + + if ( is_wp_error( $post_id ) ) { + + if ( in_array( $post_id->get_error_code(), array( 'db_insert_error' ) ) ) { + $post_id->add_data( array( 'status' => 500 ) ); + } else { + $post_id->add_data( array( 'status' => 400 ) ); + } + return $post_id; + } + $post->ID = $post_id; + $schema = $this->get_item_schema(); + $post = get_post( $post_id ); + + $this->update_additional_fields_for_object( $post, $request ); + + // Add meta fields. + $meta_fields = $this->add_post_meta_fields( $post, $request ); + if ( is_wp_error( $meta_fields ) ) { + // Remove post. + $this->delete_post( $post ); + + return $meta_fields; + } + + /** + * Fires after a single item is created or updated via the REST API. + * + * @param object $post Inserted object (not a WP_Post object). + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating item, false when updating. + */ + do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, true ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $post, $request ); + $response = rest_ensure_response( $response ); + $response->set_status( 201 ); + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $post_id ) ) ); + + return $response; + } + + /** + * Add post meta fields. + * + * @param WP_Post $post + * @param WP_REST_Request $request + * @return bool|WP_Error + */ + protected function add_post_meta_fields( $post, $request ) { + return true; + } + + /** + * Delete post. + * + * @param WP_Post $post + */ + protected function delete_post( $post ) { + wp_delete_post( $post->ID, true ); + } + + /** + * Update a single post. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function update_item( $request ) { + $id = (int) $request['id']; + $post = get_post( $id ); + + if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + $post = $this->prepare_item_for_database( $request ); + if ( is_wp_error( $post ) ) { + return $post; + } + // Convert the post object to an array, otherwise wp_update_post will expect non-escaped input. + $post_id = wp_update_post( (array) $post, true ); + if ( is_wp_error( $post_id ) ) { + if ( in_array( $post_id->get_error_code(), array( 'db_update_error' ) ) ) { + $post_id->add_data( array( 'status' => 500 ) ); + } else { + $post_id->add_data( array( 'status' => 400 ) ); + } + return $post_id; + } + + $schema = $this->get_item_schema(); + + $post = get_post( $post_id ); + $this->update_additional_fields_for_object( $post, $request ); + + // Update meta fields. + $meta_fields = $this->update_post_meta_fields( $post, $request ); + if ( is_wp_error( $meta_fields ) ) { + return $meta_fields; + } + + /** + * Fires after a single item is created or updated via the REST API. + * + * @param object $post Inserted object (not a WP_Post object). + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating item, false when updating. + */ + do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, false ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $post, $request ); + return rest_ensure_response( $response ); + } + + /** + * Get a collection of posts. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_items( $request ) { + $args = array(); + $args['offset'] = $request['offset']; + $args['order'] = $request['order']; + $args['orderby'] = $request['orderby']; + $args['paged'] = $request['page']; + $args['post__in'] = $request['include']; + $args['post__not_in'] = $request['exclude']; + $args['posts_per_page'] = $request['per_page']; + $args['name'] = $request['slug']; + $args['post_parent__in'] = $request['parent']; + $args['post_parent__not_in'] = $request['parent_exclude']; + $args['s'] = $request['search']; + + $args['date_query'] = array(); + // Set before into date query. Date query must be specified as an array of an array. + if ( isset( $request['before'] ) ) { + $args['date_query'][0]['before'] = $request['before']; + } + + // Set after into date query. Date query must be specified as an array of an array. + if ( isset( $request['after'] ) ) { + $args['date_query'][0]['after'] = $request['after']; + } + + if ( is_array( $request['filter'] ) ) { + $args = array_merge( $args, $request['filter'] ); + unset( $args['filter'] ); + } + + // Force the post_type argument, since it's not a user input variable. + $args['post_type'] = $this->post_type; + + /** + * Filter the query arguments for a request. + * + * Enables adding extra arguments or setting defaults for a post + * collection request. + * + * @param array $args Key value array of query var to query value. + * @param WP_REST_Request $request The request used. + */ + $args = apply_filters( "woocommerce_rest_{$this->post_type}_query", $args, $request ); + $query_args = $this->prepare_items_query( $args, $request ); + + $posts_query = new WP_Query(); + $query_result = $posts_query->query( $query_args ); + + $posts = array(); + foreach ( $query_result as $post ) { + if ( ! wc_rest_check_post_permissions( $this->post_type, 'read', $post->ID ) ) { + continue; + } + + $data = $this->prepare_item_for_response( $post, $request ); + $posts[] = $this->prepare_response_for_collection( $data ); + } + + $page = (int) $query_args['paged']; + $total_posts = $posts_query->found_posts; + + if ( $total_posts < 1 ) { + // Out-of-bounds, run the query again without LIMIT for total count + unset( $query_args['paged'] ); + $count_query = new WP_Query(); + $count_query->query( $query_args ); + $total_posts = $count_query->found_posts; + } + + $max_pages = ceil( $total_posts / (int) $query_args['posts_per_page'] ); + + $response = rest_ensure_response( $posts ); + $response->header( 'X-WP-Total', (int) $total_posts ); + $response->header( 'X-WP-TotalPages', (int) $max_pages ); + + $request_params = $request->get_query_params(); + if ( ! empty( $request_params['filter'] ) ) { + // Normalize the pagination params. + unset( $request_params['filter']['posts_per_page'] ); + unset( $request_params['filter']['paged'] ); + } + $base = add_query_arg( $request_params, rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) ); + + if ( $page > 1 ) { + $prev_page = $page - 1; + if ( $prev_page > $max_pages ) { + $prev_page = $max_pages; + } + $prev_link = add_query_arg( 'page', $prev_page, $base ); + $response->link_header( 'prev', $prev_link ); + } + if ( $max_pages > $page ) { + $next_page = $page + 1; + $next_link = add_query_arg( 'page', $next_page, $base ); + $response->link_header( 'next', $next_link ); + } + + return $response; + } + + /** + * Delete a single item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error + */ + public function delete_item( $request ) { + $id = (int) $request['id']; + $force = (bool) $request['force']; + $post = get_post( $id ); + + if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid post id.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $supports_trash = EMPTY_TRASH_DAYS > 0; + + /** + * Filter whether an item is trashable. + * + * Return false to disable trash support for the item. + * + * @param boolean $supports_trash Whether the item type support trashing. + * @param WP_Post $post The Post object being considered for trashing support. + */ + $supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_trashable", $supports_trash, $post ); + + if ( ! wc_rest_check_post_permissions( $this->post_type, 'delete', $post->ID ) ) { + return new WP_Error( "woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ), array( 'status' => rest_authorization_required_code() ) ); + } + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $post, $request ); + + // If we're forcing, then delete permanently. + if ( $force ) { + $result = wp_delete_post( $id, true ); + } else { + // If we don't support trashing for this type, error out. + if ( ! $supports_trash ) { + return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array( 'status' => 501 ) ); + } + + // Otherwise, only trash if we haven't already. + if ( 'trash' === $post->post_status ) { + return new WP_Error( 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 410 ) ); + } + + // (Note that internally this falls through to `wp_delete_post` if + // the trash is disabled.) + $result = wp_trash_post( $id ); + } + + if ( ! $result ) { + return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 500 ) ); + } + + /** + * Fires after a single item is deleted or trashed via the REST API. + * + * @param object $post The deleted or trashed item. + * @param WP_REST_Response $response The response data. + * @param WP_REST_Request $request The request sent to the API. + */ + do_action( "woocommerce_rest_delete_{$this->post_type}", $post, $response, $request ); + + return $response; + } + + /** + * Prepare links for the request. + * + * @param WP_Post $post Post object. + * @return array Links for the given post. + */ + protected function prepare_links( $post ) { + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $post->ID ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), + ), + ); + + return $links; + } + + /** + * Determine the allowed query_vars for a get_items() response and + * prepare for WP_Query. + * + * @param array $prepared_args + * @param WP_REST_Request $request + * @return array $query_args + */ + protected function prepare_items_query( $prepared_args = array(), $request = null ) { + + $valid_vars = array_flip( $this->get_allowed_query_vars() ); + $query_args = array(); + foreach ( $valid_vars as $var => $index ) { + if ( isset( $prepared_args[ $var ] ) ) { + /** + * Filter the query_vars used in `get_items` for the constructed query. + * + * The dynamic portion of the hook name, $var, refers to the query_var key. + * + * @param mixed $prepared_args[ $var ] The query_var value. + * + */ + $query_args[ $var ] = apply_filters( "woocommerce_rest_query_var-{$var}", $prepared_args[ $var ] ); + } + } + + $query_args['ignore_sticky_posts'] = true; + + if ( 'include' === $query_args['orderby'] ) { + $query_args['orderby'] = 'post__in'; + } + + return $query_args; + } + + /** + * Get all the WP Query vars that are allowed for the API request. + * + * @return array + */ + protected function get_allowed_query_vars() { + global $wp; + + /** + * Filter the publicly allowed query vars. + * + * Allows adjusting of the default query vars that are made public. + * + * @param array Array of allowed WP_Query query vars. + */ + $valid_vars = apply_filters( 'query_vars', $wp->public_query_vars ); + + $post_type_obj = get_post_type_object( $this->post_type ); + if ( current_user_can( $post_type_obj->cap->edit_posts ) ) { + /** + * Filter the allowed 'private' query vars for authorized users. + * + * If the user has the `edit_posts` capability, we also allow use of + * private query parameters, which are only undesirable on the + * frontend, but are safe for use in query strings. + * + * To disable anyway, use + * `add_filter( 'woocommerce_rest_private_query_vars', '__return_empty_array' );` + * + * @param array $private_query_vars Array of allowed query vars for authorized users. + * } + */ + $private = apply_filters( 'woocommerce_rest_private_query_vars', $wp->private_query_vars ); + $valid_vars = array_merge( $valid_vars, $private ); + } + // Define our own in addition to WP's normal vars. + $rest_valid = array( + 'date_query', + 'ignore_sticky_posts', + 'offset', + 'post__in', + 'post__not_in', + 'post_parent', + 'post_parent__in', + 'post_parent__not_in', + 'posts_per_page', + 'meta_query', + 'tax_query', + ); + $valid_vars = array_merge( $valid_vars, $rest_valid ); + + /** + * Filter allowed query vars for the REST API. + * + * This filter allows you to add or remove query vars from the final allowed + * list for all requests, including unauthenticated ones. To alter the + * vars for editors only. + * + * @param array { + * Array of allowed WP_Query query vars. + * + * @param string $allowed_query_var The query var to allow. + * } + */ + $valid_vars = apply_filters( 'woocommerce_rest_query_vars', $valid_vars ); + + return $valid_vars; + } + + /** + * Get the query params for collections of attachments. + * + * @return array + */ + public function get_collection_params() { + $params = parent::get_collection_params(); + + $params['context']['default'] = 'view'; + + $params['after'] = array( + 'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'date-time', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['before'] = array( + 'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'date-time', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['exclude'] = array( + 'description' => __( 'Ensure result set excludes specific ids.', 'woocommerce' ), + 'type' => 'array', + 'default' => array(), + 'sanitize_callback' => 'wp_parse_id_list', + ); + $params['include'] = array( + 'description' => __( 'Limit result set to specific ids.', 'woocommerce' ), + 'type' => 'array', + 'default' => array(), + 'sanitize_callback' => 'wp_parse_id_list', + ); + $params['offset'] = array( + 'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['order'] = array( + 'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'desc', + 'enum' => array( 'asc', 'desc' ), + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['orderby'] = array( + 'description' => __( 'Sort collection by object attribute.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'date', + 'enum' => array( + 'date', + 'id', + 'include', + 'title', + 'slug', + ), + 'validate_callback' => 'rest_validate_request_arg', + ); + + $post_type_obj = get_post_type_object( $this->post_type ); + if ( $post_type_obj->hierarchical ) { + $params['parent'] = array( + 'description' => __( 'Limit result set to those of particular parent ids.', 'woocommerce' ), + 'type' => 'array', + 'sanitize_callback' => 'wp_parse_id_list', + 'default' => array(), + ); + $params['parent_exclude'] = array( + 'description' => __( 'Limit result set to all items except those of a particular parent id.', 'woocommerce' ), + 'type' => 'array', + 'sanitize_callback' => 'wp_parse_id_list', + 'default' => array(), + ); + } + + $params['slug'] = array( + 'description' => __( 'Limit result set to posts with a specific slug.', 'woocommerce', 'woocommerce' ), + 'type' => 'string', + 'validate_callback' => 'rest_validate_request_arg', + ); + + $params['filter'] = array( + 'description' => __( 'Use WP Query arguments to modify the response; private query vars require appropriate authorization.', 'woocommerce' ), + ); + + return $params; + } + + /** + * Update post meta fields. + * + * @param WP_Post $post + * @param WP_REST_Request $request + * @return bool|WP_Error + */ + protected function update_post_meta_fields( $post, $request ) { + return true; + } +} diff --git a/includes/abstracts/abstract-wc-rest-terms-controller.php b/includes/abstracts/abstract-wc-rest-terms-controller.php new file mode 100644 index 00000000000..4b7ec89d9b4 --- /dev/null +++ b/includes/abstracts/abstract-wc-rest-terms-controller.php @@ -0,0 +1,750 @@ +namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( + 'name' => array( + 'required' => true, + ), + ) ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + )); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P