From 2f6afe92dfe6844e78098585ff2d43c2d6226b43 Mon Sep 17 00:00:00 2001 From: Josh Cunningham Date: Tue, 31 Jul 2018 12:50:29 -0700 Subject: [PATCH] Add constant notice; clear settings that are constants from saving; refactor radio button render; fix CSS --- assets/css/initial-setup.css | 2 +- assets/css/initial-setup/main.styl | 3 +- .../css/initial-setup/partials/_colors.styl | 2 +- circle.yml | 4 +- lib/WP_Auth0_Options_Generic.php | 3 + lib/admin/WP_Auth0_Admin.php | 23 +++++- lib/admin/WP_Auth0_Admin_Advanced.php | 1 + lib/admin/WP_Auth0_Admin_Appearance.php | 19 +++-- lib/admin/WP_Auth0_Admin_Basic.php | 10 ++- lib/admin/WP_Auth0_Admin_Features.php | 23 ++++-- lib/admin/WP_Auth0_Admin_Generic.php | 78 ++++++++++++++----- phpcs-test-ruleset.xml | 16 ++-- templates/back-to-auth0.php | 2 +- tests/bootstrap.php | 10 +-- tests/testConstantSettings.php | 75 +++++++++++++++++- tests/testCustomDomains.php | 7 ++ tests/testLockOptions.php | 7 ++ tests/testWPAuth0DbMigrations.php | 7 ++ tests/testWPAuth0Helpers.php | 7 ++ tests/testWPAuth0Options.php | 39 ++-------- tests/traits/domDocumentHelpers.php | 6 ++ tests/traits/setUpTestDb.php | 6 ++ 22 files changed, 257 insertions(+), 93 deletions(-) diff --git a/assets/css/initial-setup.css b/assets/css/initial-setup.css index 5c255c37..74983c64 100644 --- a/assets/css/initial-setup.css +++ b/assets/css/initial-setup.css @@ -1 +1 @@ -@font-face{font-family:'avenir roman';src:url("https://cdn.auth0.com/fonts/avenir/avenir-roman.eot");src:url("https://cdn.auth0.com/fonts/avenir/avenir-roman.eot?#iefix") format('embedded-opentype'),url("https://cdn.auth0.com/fonts/avenir/avenir-roman.woff") format('woff'),url("https://cdn.auth0.com/fonts/avenir/avenir-roman.ttf") format('truetype');font-weight:300;font-style:normal}#lock-wrapper{width:300px;margin:30px auto}.modal-open .modal{background:rgba(0,0,0,0.5)}.modal-open .modal-backdrop{display:none}#wpwrap{background-color:#fff;}#wpwrap .a0-wrap{font-family:'avenir roman';margin-left:-10px;padding-left:2%;padding-right:2%;color:rgba(0,0,0,0.86);}#wpwrap .a0-wrap a,#wpwrap .a0-wrap .link{color:#0094c1}#wpwrap .a0-wrap .row > .a0-separator,#wpwrap .a0-wrap .a0-feedback > .a0-separator{border-bottom:1px solid rgba(0,0,0,0.05);margin:30px 0}#wpwrap .a0-wrap .a0-header{text-align:center;border-bottom:1px solid rgba(0,0,0,0.05);}#wpwrap .a0-wrap .a0-header a{outline:none;border:none;box-shadow:none}#wpwrap .a0-wrap .a0-header img.a0-header-logo{height:55px;margin:30px auto}#wpwrap .a0-wrap .modal-body.no-padding-bottom{padding-bottom:0}#wpwrap .a0-wrap #connections .loading{margin:0 -15px 30px;background:#f8edb5;color:#a78e11;text-align:center;line-height:41px;border-radius:3px;}#wpwrap .a0-wrap #connections .loading .a0-spinner-css{width:25px;height:25px;position:relative;top:7px;margin-right:10px;border-top-color:rgba(167,142,17,0.3);border-right-color:rgba(167,142,17,0.3);border-bottom-color:rgba(167,142,17,0.3);border-left-color:rgba(167,142,17,0.9)}@media (min-width:768px){#wpwrap .a0-wrap{margin-left:-20px}}#wpwrap .a0-wrap small,#wpwrap .a0-wrap .small{font-size:70%}#wpwrap .a0-wrap h1,#wpwrap .a0-wrap h2,#wpwrap .a0-wrap p{color:rgba(0,0,0,0.86)}#wpwrap .a0-wrap h1,#wpwrap .a0-wrap .h1,#wpwrap .a0-wrap h2,#wpwrap .a0-wrap .h2,#wpwrap .a0-wrap h3,#wpwrap .a0-wrap .h3{margin-top:0}#wpwrap .a0-wrap h3{background:transparent;padding:0}#wpwrap .a0-wrap h1{font-size:32px}#wpwrap .a0-wrap p{font-size:17px;color:rgba(0,0,0,0.36)}#wpwrap .a0-wrap ul.list{font-size:17px;color:rgba(0,0,0,0.36);}#wpwrap .a0-wrap ul.list li{list-style-type:disc;margin-left:25px}#wpwrap .a0-wrap code{background:#f1f1f1;color:#777;line-height:2em}#wpwrap .a0-wrap textarea.code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:12px;line-height:19px;padding:10px}#wpwrap .a0-wrap .modal-dialog input[type=text],#wpwrap .a0-wrap .modal-dialog input[type=password],#wpwrap .a0-wrap .modal-dialog textarea{border:1px solid #ccc;line-height:1em;height:40px;padding:0 10px;border-radius:3px 3px 3px 3px;width:100%;color:rgba(0,0,0,0.86)}#wpwrap .a0-wrap .a0-buttons{margin:20px 0;}#wpwrap .a0-wrap .a0-buttons.extra-space{margin-top:50px}#wpwrap .a0-wrap form{margin:0;}#wpwrap .a0-wrap form [disabled]{font-size:.9em;margin:.3em}#wpwrap .a0-wrap .container-fluid{padding-top:50px;max-width:750px}#wpwrap .a0-wrap .modal-dialog{margin:100px auto}#wpwrap .a0-wrap .modal-body{padding:30px;font-size:16px}#wpwrap .a0-wrap .modal-header h4{text-align:center;font-weight:bold}#wpwrap .a0-wrap .modal-header .close{margin-top:2px}#wpwrap .a0-wrap .modal-footer{padding:25px}#wpwrap .a0-wrap .bg-danger{padding:17px;font-size:15px;margin:30px 0}#wpwrap .a0-wrap .updated.settings-error{margin:5px 0;}#wpwrap .a0-wrap .updated.settings-error p{font-size:14px;text-align:left;color:rgba(0,0,0,0.86)}#wpwrap .a0-step-text{margin:30px 0 0}#wpwrap .a0-settings-form[data-tab-showing="help"] #submit{display:none}#wpwrap .a0-button,#wpwrap #wpa0_choose_icon{border-radius:3px;border:none;line-height:45px;min-width:150px;text-transform:uppercase;text-decoration:none;font-size:13px;display:inline-block;text-align:center;padding:0 30px;transition:background-color .2s ease;}#wpwrap .a0-button:focus,#wpwrap #wpa0_choose_icon:focus{box-shadow:none;outline:none}#wpwrap .a0-button.link,#wpwrap #wpa0_choose_icon.link{text-transform:none;text-decoration:underline;cursor:pointer;min-width:0;padding:0 10px}#wpwrap .a0-button.primary,#wpwrap #wpa0_choose_icon.primary{color:#fff;background-color:#eb5424;}#wpwrap .a0-button.primary:hover,#wpwrap #wpa0_choose_icon.primary:hover{color:#fff}#wpwrap .a0-button.secondary,#wpwrap #wpa0_choose_icon.secondary{font-weight:bold;color:#32759a;background-color:transparent;text-decoration:underline;}#wpwrap .a0-button.secondary:hover,#wpwrap #wpa0_choose_icon.secondary:hover{color:#32759a}#wpwrap .a0-button.default,#wpwrap #wpa0_choose_icon.default{background:#fff;color:rgba(0,0,0,0.86);border-color:#d0d2d3;text-decoration:none;}#wpwrap .a0-button.default:hover,#wpwrap #wpa0_choose_icon.default:hover{background:#d0d2d3}#wpwrap #wpa0_choose_icon{height:42px;color:#fff;background-color:#eb5424}#wpwrap .a0-steps{background-color:#f2f5f8;padding-top:120px;padding-bottom:120px;height:0;}#wpwrap .a0-steps .a0-progress{border-top:4px solid #dcdfe1;margin:auto;float:none}#wpwrap .a0-steps .steps{position:relative;top:-27px;text-align:center;}#wpwrap .a0-steps .steps span{display:inline-block;width:50px;height:50px;border-radius:30px;line-height:50px;text-align:center;background-color:#dcdfe1;color:#fff;font-weight:bold;font-size:15px}#wpwrap .a0-steps .steps p{display:none;color:#575c60;font-weight:bold;padding-top:10px;font-size:15px;width:105px;margin:auto}#wpwrap .a0-steps .steps .active span{background-color:#eb5424}#wpwrap .a0-steps .steps .active p{display:block}#wpwrap .consent-disclaimer .logo{width:100px;margin:20px 0}#wpwrap .a0-message{line-height:24px;font-size:12px;border-radius:3px;position:relative;color:rgba(0,0,0,0.86);padding:15px;}#wpwrap .a0-message.a0-step-text{font-size:14px}#wpwrap .a0-message.multiline{line-height:25px;padding:10px 20px}#wpwrap .a0-message.a0-notice{background-color:#d0e8f4;color:#32759a}#wpwrap .a0-message.a0-tip{background-color:#e4e6e8;}#wpwrap .a0-message.a0-tip a{color:rgba(0,0,0,0.86)}#wpwrap .a0-message.a0-warning{background:#fff7c9;color:#786600;}#wpwrap .a0-message.a0-warning a.link{color:#786600;font-decoration:underline}#wpwrap .a0-message b{font-weight:bold;text-transform:uppercase}#wpwrap .a0-message a{text-decoration:underline}#wpwrap .a0-message img{position:absolute;left:20px;top:20px}#wpwrap .a0-message .a0-button{border:0;margin:-4px;margin-left:10px;font-size:12px;line-height:12px;padding:10px 15px}#wpwrap .modal-content .a0-message{margin:20px 0}#wpwrap .modal-content .link{line-height:25px;margin-bottom:20px;cursor:pointer}#wpwrap .a0-profiles{margin-top:30px;margin-bottom:30px;}@media (min-width:768px){#wpwrap .a0-profiles .col:nth-of-type(1){padding-left:0;padding-right:10px}#wpwrap .a0-profiles .col:nth-of-type(2){padding-left:10px;padding-right:0}}#wpwrap .a0-profiles .profile{background-color:#f2f5f8;border-radius:3px;padding:25px;text-align:center;margin-bottom:20px;}#wpwrap .a0-profiles .profile h2{font-size:22px}#wpwrap .a0-profiles .profile p{font-size:14px;margin:20px 10px;min-height:6em}#wpwrap .a0-profiles .profile img{width:100px;height:100px;border-radius:50px;margin-bottom:20px}#wpwrap .modal-footer{text-align:center}#wpwrap .enterprise-connections{margin-top:30px;padding:0;}#wpwrap .enterprise-connections .connection{background-color:#f5f7f9;text-align:center;border-radius:3px;padding:20px;margin-bottom:30px;}#wpwrap .enterprise-connections .connection .title-wrapper{min-height:50px}#wpwrap .enterprise-connections .connection h4{line-height:24px;font-size:17px}#wpwrap .enterprise-connections .connection .logo{width:100px;height:100px;border-radius:50px;background-size:55% !important;margin:0 auto 20px}#wpwrap .enterprise-connections .connection a{color:rgba(0,0,0,0.86);cursor:pointer}#wpwrap .connections-wrapper{margin-top:30px;padding:0 15px;}@media (min-width:768px){#wpwrap .connections-wrapper{height:600px;overflow-y:scroll}#wpwrap .connections-wrapper::-webkit-scrollbar{width:14px}#wpwrap .connections-wrapper::-webkit-scrollbar-track{background:#f3f3f3;border-radius:8px;border:3px solid #fff}#wpwrap .connections-wrapper::-webkit-scrollbar-thumb{border:3px solid #fff;border-radius:8px;background:#d9d9de}}#wpwrap .connections{border-top:1px #d0d2d3 solid;border-left:1px #d0d2d3 solid;}#wpwrap .connections .connection{float:left;border-top:none;background-color:#f7f7f7;border-right:1px #d0d2d3 solid;border-bottom:1px #d0d2d3 solid;}#wpwrap .connections .connection .a0-switch{float:right;position:relative;top:35px;right:15px}#wpwrap .connections .connection .logo{width:100px;height:70px;margin:15px;padding-right:15px;padding-left:15px;}#wpwrap .connections .connection .logo .logo-child{width:100px;height:70px;background-repeat:no-repeat;background-position:center center;background-size:80%}#wpwrap .connections .connection .logo[data-logo="SAP"] .logo-child{background-size:80%}#wpwrap .connections .connection .logo[data-logo="Twitter"] .logo-child{background-size:60%}#wpwrap .connections .connection .logo[data-logo="Box"] .logo-child{background-size:70%;transform:translateX(-10%)}#wpwrap .connections .connection .logo[data-logo="vk"] .logo-child{background-size:55%}#wpwrap .a0-switch{display:inline-block;}#wpwrap .a0-switch input{display:none}#wpwrap .a0-switch label{position:relative;display:block;width:50px;height:30px;border-radius:15px;background-color:#a9a9a9}#wpwrap .a0-switch input:checked + label{background-color:#45db5e}#wpwrap .a0-switch label::before{position:absolute;content:" ";width:26px;height:26px;border-radius:13px;top:2px;left:2px;background-color:#fff;box-shadow:0 0 1px 0 rgba(0,0,0,0.25),0 4px 11px 0 rgba(0,0,0,0.08),-1px 3px 3px 0 rgba(0,0,0,0.14);transition:left 300ms cubic-bezier(.42,.8,.58,1.2)}#wpwrap .a0-switch input:checked + label::before{left:22px}#wpwrap .a0-db-connection{padding-right:90px;position:relative;}#wpwrap .a0-db-connection .a0-step-text{margin:30px 0}#wpwrap .a0-db-connection .a0-switch{position:absolute;right:20px;top:60px}@-webkit-keyframes loaderAnim{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@-moz-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);transform:rotate(360deg)}}#wpwrap .a0-spinner-css{display:inline-block;font-size:10px;position:relative;text-indent:-9999em;border-top:2px solid rgba(0,0,0,0.3);border-right:2px solid rgba(0,0,0,0.3);border-bottom:2px solid rgba(0,0,0,0.3);border-left:2px solid rgba(0,0,0,0.9);-webkit-animation:loaderAnim .8s infinite linear;animation:loaderAnim .8s infinite linear;-webkit-border-radius:50%;border-radius:50%;background-clip:padding-box;width:40px;height:40px}#wpwrap .lock{padding-top:30px;position:relative;}#wpwrap .lock .loading{position:absolute;top:30px;bottom:0;background:rgba(255,255,255,0.5);z-index:9999;margin:auto;width:300px;display:none;}#wpwrap .lock .loading .vcenter-wrapper{display:table;height:100%;margin:auto}#wpwrap .lock .loading .centrix{display:table-cell;vertical-align:middle}#wpwrap .lock.loading .loading{display:block}#wpwrap .lock.loading #a0-lock{overflow:hidden}#wpwrap .lock #a0-lock{margin:auto;width:300px}#wpwrap .a0-admin-creation{margin-top:20px;}#wpwrap .a0-admin-creation input[type=text],#wpwrap .a0-admin-creation input[type=password]{width:100%;border:1px solid rgba(91,102,111,0.54);height:50px;line-height:1em;padding:10px;}#wpwrap .a0-admin-creation input[type=text]#admin-email,#wpwrap .a0-admin-creation input[type=password]#admin-email{border-radius:3px 3px 0 0;background-color:#e5e5e5}#wpwrap .a0-admin-creation input[type=text]#admin-password,#wpwrap .a0-admin-creation input[type=password]#admin-password{border-top:none;border-radius:0 0 3px 3px}#wpwrap .a0-final-step{text-align:center;}#wpwrap .a0-final-step h1{margin-bottom:0;margin-top:30px}@-webkit-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}#wpwrap .a0-final-step .checkmark{width:90px;height:90px;border-radius:50%;display:block;stroke-width:2;stroke:#fff;stroke-miterlimit:10;margin:0 auto;box-shadow:inset 0 0 0 #7ac142;-webkit-animation:fill .4s ease-in-out .7s forwards,scale .3s ease-in-out 1.1s both;animation:fill .4s ease-in-out .7s forwards,scale .3s ease-in-out 1.1s both;}#wpwrap .a0-final-step .checkmark .checkmark__check{transform-origin:50% 50%}#wpwrap .a0-final-step .checkmark .checkmark__circle{stroke-dasharray:166;stroke-dashoffset:166;stroke-width:2;stroke-miterlimit:10;stroke:#7ac142;-webkit-animation:stroke .6s .4s cubic-bezier(.65,0,.45,1) forwards;animation:stroke .6s .4s cubic-bezier(.65,0,.45,1) forwards}@-moz-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}@-webkit-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}@-o-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}@keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}#wpwrap .settings h3{margin:30px 0 10px}#wpwrap .settings .a0-message.manage{margin-bottom:30px;margin-top:30px}#wpwrap .settings .nav-tabs{margin:30px 0;}#wpwrap .settings .nav-tabs a{color:#4a4a4a;box-shadow:none;font-size:17px}#wpwrap .settings .a0-step-text{margin:0 0 30px}#wpwrap .settings .top-margin{margin-top:30px}#wpwrap .settings .no-bottom-margin{margin-bottom:0}#wpwrap .settings .form-table th,#wpwrap .settings .form-table label,#wpwrap .settings .form-wrap label{color:rgba(0,0,0,0.86)}#wpwrap .settings input[type=text],#wpwrap .settings input[type=password],#wpwrap .settings textarea{border:1px solid #ccc;padding:0 10px;border-radius:3px 3px 3px 3px;width:100%;color:rgba(0,0,0,0.86)}#wpwrap .settings input[type=text],#wpwrap .settings input[type=password]{line-height:1em;height:40px}#wpwrap .settings #wpa0_icon_url{width:50%;display:inline-block}#wpwrap .settings .subelement{padding:5px 0}#wpwrap .settings .link{font-weight:bold;text-decoration:underline;cursor:pointer}#wpwrap .settings .nav>li>a{padding:10px 0;margin-right:40px;font-size:15px;}@media (max-width:768px){#wpwrap .settings .nav>li>a{margin-right:10px}}#wpwrap .settings .nav>li>a:hover,#wpwrap .settings .nav>li>a:focus{text-decoration:none;background-color:#fff;border-color:transparent transparent #ddd}#wpwrap .settings .nav-tabs>li.active>a,#wpwrap .settings .nav-tabs>li.active>a:hover,#wpwrap .settings .nav-tabs>li.active>a:focus{color:#33b6e3;border-color:transparent transparent #33b6e3}#wpwrap .settings .form-wrap p,#wpwrap .settings p.description,#wpwrap .settings p.help,#wpwrap .settings span.description{font-style:normal;color:rgba(0,0,0,0.36)}#wpwrap .settings label{margin-right:10px}#wpwrap .settings .connections{margin-top:30px}#wpwrap .a0-table{margin:30px;width:initial}#wpwrap #manuallySetToken{margin-right:15px}#wpwrap .a0-feedback{background-color:#f2f5f8;padding:30px;margin-top:30px;border-radius:3px;}#wpwrap .a0-feedback h2{font-size:18px;margin-bottom:15px;}#wpwrap .a0-feedback h2.message{margin:0}#wpwrap .a0-feedback .a0-separator{margin:20px 0}#wpwrap .a0-feedback input.feedback_calification{display:none}#wpwrap .a0-feedback input:checked + .feedback-face{opacity:1}#wpwrap .a0-feedback .a0-buttons{margin:15px 0 0;}#wpwrap .a0-feedback .a0-buttons .a0-button{min-width:auto;cursor:pointer}#wpwrap .a0-feedback textarea{padding:10px;height:90px}#wpwrap .a0-feedback .feedback-face{width:40px;height:40px;display:inline-block;background-size:contain;opacity:.4;margin-right:30px;cursor:pointer;}#wpwrap .a0-feedback .feedback-face:hover{opacity:.7}#wpwrap .a0-feedback .feedback-face.calification-1{background-image:url("../img/rates/01.svg")}#wpwrap .a0-feedback .feedback-face.calification-2{background-image:url("../img/rates/02.svg")}#wpwrap .a0-feedback .feedback-face.calification-3{background-image:url("../img/rates/03.svg")}#wpwrap .a0-feedback .feedback-face.calification-4{background-image:url("../img/rates/04.svg")}#wpwrap .a0-feedback .feedback-face.calification-5{background-image:url("../img/rates/05.svg")}@-moz-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}}@-webkit-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}}@-o-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}} \ No newline at end of file +@font-face{font-family:'avenir roman';src:url("https://cdn.auth0.com/fonts/avenir/avenir-roman.eot");src:url("https://cdn.auth0.com/fonts/avenir/avenir-roman.eot?#iefix") format('embedded-opentype'),url("https://cdn.auth0.com/fonts/avenir/avenir-roman.woff") format('woff'),url("https://cdn.auth0.com/fonts/avenir/avenir-roman.ttf") format('truetype');font-weight:300;font-style:normal}#lock-wrapper{width:300px;margin:30px auto}.modal-open .modal{background:rgba(0,0,0,0.5)}.modal-open .modal-backdrop{display:none}#wpwrap{background-color:#fff;}#wpwrap .a0-wrap{font-family:'avenir roman';margin-left:-10px;padding-left:2%;padding-right:2%;color:rgba(0,0,0,0.86);}#wpwrap .a0-wrap a,#wpwrap .a0-wrap .link{color:#0094c1}#wpwrap .a0-wrap .row > .a0-separator,#wpwrap .a0-wrap .a0-feedback > .a0-separator{border-bottom:1px solid rgba(0,0,0,0.05);margin:30px 0}#wpwrap .a0-wrap .a0-header{text-align:center;border-bottom:1px solid rgba(0,0,0,0.05);}#wpwrap .a0-wrap .a0-header a{outline:none;border:none;box-shadow:none}#wpwrap .a0-wrap .a0-header img.a0-header-logo{height:55px;margin:30px auto}#wpwrap .a0-wrap .modal-body.no-padding-bottom{padding-bottom:0}#wpwrap .a0-wrap #connections .loading{margin:0 -15px 30px;background:#f8edb5;color:#a78e11;text-align:center;line-height:41px;border-radius:3px;}#wpwrap .a0-wrap #connections .loading .a0-spinner-css{width:25px;height:25px;position:relative;top:7px;margin-right:10px;border-top-color:rgba(167,142,17,0.3);border-right-color:rgba(167,142,17,0.3);border-bottom-color:rgba(167,142,17,0.3);border-left-color:rgba(167,142,17,0.9)}@media (min-width:768px){#wpwrap .a0-wrap{margin-left:-20px}}#wpwrap .a0-wrap small,#wpwrap .a0-wrap .small{font-size:70%}#wpwrap .a0-wrap h1,#wpwrap .a0-wrap h2,#wpwrap .a0-wrap p{color:rgba(0,0,0,0.86)}#wpwrap .a0-wrap h1,#wpwrap .a0-wrap .h1,#wpwrap .a0-wrap h2,#wpwrap .a0-wrap .h2,#wpwrap .a0-wrap h3,#wpwrap .a0-wrap .h3{margin-top:0}#wpwrap .a0-wrap h3{background:transparent;padding:0}#wpwrap .a0-wrap h1{font-size:32px}#wpwrap .a0-wrap p{font-size:17px;color:rgba(0,0,0,0.5)}#wpwrap .a0-wrap ul.list{font-size:17px;color:rgba(0,0,0,0.5);}#wpwrap .a0-wrap ul.list li{list-style-type:disc;margin-left:25px}#wpwrap .a0-wrap code{background:#f1f1f1;color:#777;line-height:2em}#wpwrap .a0-wrap textarea.code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:12px;line-height:19px;padding:10px}#wpwrap .a0-wrap .modal-dialog input[type=text],#wpwrap .a0-wrap .modal-dialog input[type=password],#wpwrap .a0-wrap .modal-dialog textarea{border:1px solid #ccc;line-height:1em;height:40px;padding:0 10px;border-radius:3px 3px 3px 3px;width:100%;color:rgba(0,0,0,0.86)}#wpwrap .a0-wrap .a0-buttons{margin:20px 0;}#wpwrap .a0-wrap .a0-buttons.extra-space{margin-top:50px}#wpwrap .a0-wrap form{margin:0;}#wpwrap .a0-wrap form [disabled]{opacity:.5;font-size:.9em;margin-top:.3em}#wpwrap .a0-wrap .container-fluid{padding-top:50px;max-width:750px}#wpwrap .a0-wrap .modal-dialog{margin:100px auto}#wpwrap .a0-wrap .modal-body{padding:30px;font-size:16px}#wpwrap .a0-wrap .modal-header h4{text-align:center;font-weight:bold}#wpwrap .a0-wrap .modal-header .close{margin-top:2px}#wpwrap .a0-wrap .modal-footer{padding:25px}#wpwrap .a0-wrap .bg-danger{padding:17px;font-size:15px;margin:30px 0}#wpwrap .a0-wrap .updated.settings-error{margin:5px 0;}#wpwrap .a0-wrap .updated.settings-error p{font-size:14px;text-align:left;color:rgba(0,0,0,0.86)}#wpwrap .a0-step-text{margin:30px 0 0}#wpwrap .a0-settings-form[data-tab-showing="help"] #submit{display:none}#wpwrap .a0-button,#wpwrap #wpa0_choose_icon{border-radius:3px;border:none;line-height:45px;min-width:150px;text-transform:uppercase;text-decoration:none;font-size:13px;display:inline-block;text-align:center;padding:0 30px;transition:background-color .2s ease;}#wpwrap .a0-button:focus,#wpwrap #wpa0_choose_icon:focus{box-shadow:none;outline:none}#wpwrap .a0-button.link,#wpwrap #wpa0_choose_icon.link{text-transform:none;text-decoration:underline;cursor:pointer;min-width:0;padding:0 10px}#wpwrap .a0-button.primary,#wpwrap #wpa0_choose_icon.primary{color:#fff;background-color:#eb5424;}#wpwrap .a0-button.primary:hover,#wpwrap #wpa0_choose_icon.primary:hover{color:#fff}#wpwrap .a0-button.secondary,#wpwrap #wpa0_choose_icon.secondary{font-weight:bold;color:#32759a;background-color:transparent;text-decoration:underline;}#wpwrap .a0-button.secondary:hover,#wpwrap #wpa0_choose_icon.secondary:hover{color:#32759a}#wpwrap .a0-button.default,#wpwrap #wpa0_choose_icon.default{background:#fff;color:rgba(0,0,0,0.86);border-color:#d0d2d3;text-decoration:none;}#wpwrap .a0-button.default:hover,#wpwrap #wpa0_choose_icon.default:hover{background:#d0d2d3}#wpwrap #wpa0_choose_icon{height:42px;color:#fff;background-color:#eb5424}#wpwrap .a0-steps{background-color:#f2f5f8;padding-top:120px;padding-bottom:120px;height:0;}#wpwrap .a0-steps .a0-progress{border-top:4px solid #dcdfe1;margin:auto;float:none}#wpwrap .a0-steps .steps{position:relative;top:-27px;text-align:center;}#wpwrap .a0-steps .steps span{display:inline-block;width:50px;height:50px;border-radius:30px;line-height:50px;text-align:center;background-color:#dcdfe1;color:#fff;font-weight:bold;font-size:15px}#wpwrap .a0-steps .steps p{display:none;color:#575c60;font-weight:bold;padding-top:10px;font-size:15px;width:105px;margin:auto}#wpwrap .a0-steps .steps .active span{background-color:#eb5424}#wpwrap .a0-steps .steps .active p{display:block}#wpwrap .consent-disclaimer .logo{width:100px;margin:20px 0}#wpwrap .a0-message{line-height:24px;font-size:12px;border-radius:3px;position:relative;color:rgba(0,0,0,0.86);padding:15px;}#wpwrap .a0-message.a0-step-text{font-size:14px}#wpwrap .a0-message.multiline{line-height:25px;padding:10px 20px}#wpwrap .a0-message.a0-notice{background-color:#d0e8f4;color:#32759a}#wpwrap .a0-message.a0-tip{background-color:#e4e6e8;}#wpwrap .a0-message.a0-tip a{color:rgba(0,0,0,0.86)}#wpwrap .a0-message.a0-warning{background:#fff7c9;color:#786600;}#wpwrap .a0-message.a0-warning a.link{color:#786600;font-decoration:underline}#wpwrap .a0-message b{font-weight:bold;text-transform:uppercase}#wpwrap .a0-message a{text-decoration:underline}#wpwrap .a0-message img{position:absolute;left:20px;top:20px}#wpwrap .a0-message .a0-button{border:0;margin:-4px;margin-left:10px;font-size:12px;line-height:12px;padding:10px 15px}#wpwrap .modal-content .a0-message{margin:20px 0}#wpwrap .modal-content .link{line-height:25px;margin-bottom:20px;cursor:pointer}#wpwrap .a0-profiles{margin-top:30px;margin-bottom:30px;}@media (min-width:768px){#wpwrap .a0-profiles .col:nth-of-type(1){padding-left:0;padding-right:10px}#wpwrap .a0-profiles .col:nth-of-type(2){padding-left:10px;padding-right:0}}#wpwrap .a0-profiles .profile{background-color:#f2f5f8;border-radius:3px;padding:25px;text-align:center;margin-bottom:20px;}#wpwrap .a0-profiles .profile h2{font-size:22px}#wpwrap .a0-profiles .profile p{font-size:14px;margin:20px 10px;min-height:6em}#wpwrap .a0-profiles .profile img{width:100px;height:100px;border-radius:50px;margin-bottom:20px}#wpwrap .modal-footer{text-align:center}#wpwrap .enterprise-connections{margin-top:30px;padding:0;}#wpwrap .enterprise-connections .connection{background-color:#f5f7f9;text-align:center;border-radius:3px;padding:20px;margin-bottom:30px;}#wpwrap .enterprise-connections .connection .title-wrapper{min-height:50px}#wpwrap .enterprise-connections .connection h4{line-height:24px;font-size:17px}#wpwrap .enterprise-connections .connection .logo{width:100px;height:100px;border-radius:50px;background-size:55% !important;margin:0 auto 20px}#wpwrap .enterprise-connections .connection a{color:rgba(0,0,0,0.86);cursor:pointer}#wpwrap .connections-wrapper{margin-top:30px;padding:0 15px;}@media (min-width:768px){#wpwrap .connections-wrapper{height:600px;overflow-y:scroll}#wpwrap .connections-wrapper::-webkit-scrollbar{width:14px}#wpwrap .connections-wrapper::-webkit-scrollbar-track{background:#f3f3f3;border-radius:8px;border:3px solid #fff}#wpwrap .connections-wrapper::-webkit-scrollbar-thumb{border:3px solid #fff;border-radius:8px;background:#d9d9de}}#wpwrap .connections{border-top:1px #d0d2d3 solid;border-left:1px #d0d2d3 solid;}#wpwrap .connections .connection{float:left;border-top:none;background-color:#f7f7f7;border-right:1px #d0d2d3 solid;border-bottom:1px #d0d2d3 solid;}#wpwrap .connections .connection .a0-switch{float:right;position:relative;top:35px;right:15px}#wpwrap .connections .connection .logo{width:100px;height:70px;margin:15px;padding-right:15px;padding-left:15px;}#wpwrap .connections .connection .logo .logo-child{width:100px;height:70px;background-repeat:no-repeat;background-position:center center;background-size:80%}#wpwrap .connections .connection .logo[data-logo="SAP"] .logo-child{background-size:80%}#wpwrap .connections .connection .logo[data-logo="Twitter"] .logo-child{background-size:60%}#wpwrap .connections .connection .logo[data-logo="Box"] .logo-child{background-size:70%;transform:translateX(-10%)}#wpwrap .connections .connection .logo[data-logo="vk"] .logo-child{background-size:55%}#wpwrap .a0-switch{display:inline-block;}#wpwrap .a0-switch input{display:none}#wpwrap .a0-switch label{position:relative;display:block;width:50px;height:30px;border-radius:15px;background-color:#a9a9a9}#wpwrap .a0-switch input:checked + label{background-color:#45db5e}#wpwrap .a0-switch label::before{position:absolute;content:" ";width:26px;height:26px;border-radius:13px;top:2px;left:2px;background-color:#fff;box-shadow:0 0 1px 0 rgba(0,0,0,0.25),0 4px 11px 0 rgba(0,0,0,0.08),-1px 3px 3px 0 rgba(0,0,0,0.14);transition:left 300ms cubic-bezier(.42,.8,.58,1.2)}#wpwrap .a0-switch input:checked + label::before{left:22px}#wpwrap .a0-db-connection{padding-right:90px;position:relative;}#wpwrap .a0-db-connection .a0-step-text{margin:30px 0}#wpwrap .a0-db-connection .a0-switch{position:absolute;right:20px;top:60px}@-webkit-keyframes loaderAnim{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@-moz-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);transform:rotate(360deg)}}#wpwrap .a0-spinner-css{display:inline-block;font-size:10px;position:relative;text-indent:-9999em;border-top:2px solid rgba(0,0,0,0.3);border-right:2px solid rgba(0,0,0,0.3);border-bottom:2px solid rgba(0,0,0,0.3);border-left:2px solid rgba(0,0,0,0.9);-webkit-animation:loaderAnim .8s infinite linear;animation:loaderAnim .8s infinite linear;-webkit-border-radius:50%;border-radius:50%;background-clip:padding-box;width:40px;height:40px}#wpwrap .lock{padding-top:30px;position:relative;}#wpwrap .lock .loading{position:absolute;top:30px;bottom:0;background:rgba(255,255,255,0.5);z-index:9999;margin:auto;width:300px;display:none;}#wpwrap .lock .loading .vcenter-wrapper{display:table;height:100%;margin:auto}#wpwrap .lock .loading .centrix{display:table-cell;vertical-align:middle}#wpwrap .lock.loading .loading{display:block}#wpwrap .lock.loading #a0-lock{overflow:hidden}#wpwrap .lock #a0-lock{margin:auto;width:300px}#wpwrap .a0-admin-creation{margin-top:20px;}#wpwrap .a0-admin-creation input[type=text],#wpwrap .a0-admin-creation input[type=password]{width:100%;border:1px solid rgba(91,102,111,0.54);height:50px;line-height:1em;padding:10px;}#wpwrap .a0-admin-creation input[type=text]#admin-email,#wpwrap .a0-admin-creation input[type=password]#admin-email{border-radius:3px 3px 0 0;background-color:#e5e5e5}#wpwrap .a0-admin-creation input[type=text]#admin-password,#wpwrap .a0-admin-creation input[type=password]#admin-password{border-top:none;border-radius:0 0 3px 3px}#wpwrap .a0-final-step{text-align:center;}#wpwrap .a0-final-step h1{margin-bottom:0;margin-top:30px}@-webkit-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}#wpwrap .a0-final-step .checkmark{width:90px;height:90px;border-radius:50%;display:block;stroke-width:2;stroke:#fff;stroke-miterlimit:10;margin:0 auto;box-shadow:inset 0 0 0 #7ac142;-webkit-animation:fill .4s ease-in-out .7s forwards,scale .3s ease-in-out 1.1s both;animation:fill .4s ease-in-out .7s forwards,scale .3s ease-in-out 1.1s both;}#wpwrap .a0-final-step .checkmark .checkmark__check{transform-origin:50% 50%}#wpwrap .a0-final-step .checkmark .checkmark__circle{stroke-dasharray:166;stroke-dashoffset:166;stroke-width:2;stroke-miterlimit:10;stroke:#7ac142;-webkit-animation:stroke .6s .4s cubic-bezier(.65,0,.45,1) forwards;animation:stroke .6s .4s cubic-bezier(.65,0,.45,1) forwards}@-moz-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}@-webkit-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}@-o-keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}@keyframes fill{100%{box-shadow:inset 0 0 0 45px #7ac142}}#wpwrap .settings h3{margin:30px 0 10px}#wpwrap .settings .a0-message.manage{margin-bottom:30px;margin-top:30px}#wpwrap .settings .nav-tabs{margin:30px 0;}#wpwrap .settings .nav-tabs a{color:#4a4a4a;box-shadow:none;font-size:17px}#wpwrap .settings .a0-step-text{margin:0 0 30px}#wpwrap .settings .top-margin{margin-top:30px}#wpwrap .settings .no-bottom-margin{margin-bottom:0}#wpwrap .settings .form-table th,#wpwrap .settings .form-table label,#wpwrap .settings .form-wrap label{color:rgba(0,0,0,0.86)}#wpwrap .settings input[type=text],#wpwrap .settings input[type=password],#wpwrap .settings textarea{border:1px solid #ccc;padding:0 10px;border-radius:3px 3px 3px 3px;width:100%;color:rgba(0,0,0,0.86)}#wpwrap .settings input[type=text],#wpwrap .settings input[type=password]{line-height:1em;height:40px}#wpwrap .settings #wpa0_icon_url{width:50%;display:inline-block}#wpwrap .settings .subelement{padding:5px 0}#wpwrap .settings .link{font-weight:bold;text-decoration:underline;cursor:pointer}#wpwrap .settings .nav>li>a{padding:10px 0;margin-right:40px;font-size:15px;}@media (max-width:768px){#wpwrap .settings .nav>li>a{margin-right:10px}}#wpwrap .settings .nav>li>a:hover,#wpwrap .settings .nav>li>a:focus{text-decoration:none;background-color:#fff;border-color:transparent transparent #ddd}#wpwrap .settings .nav-tabs>li.active>a,#wpwrap .settings .nav-tabs>li.active>a:hover,#wpwrap .settings .nav-tabs>li.active>a:focus{color:#33b6e3;border-color:transparent transparent #33b6e3}#wpwrap .settings .form-wrap p,#wpwrap .settings p.description,#wpwrap .settings p.help,#wpwrap .settings span.description{font-style:normal;color:rgba(0,0,0,0.5)}#wpwrap .settings label{margin-right:10px}#wpwrap .settings .connections{margin-top:30px}#wpwrap .a0-table{margin:30px;width:initial}#wpwrap #manuallySetToken{margin-right:15px}#wpwrap .a0-feedback{background-color:#f2f5f8;padding:30px;margin-top:30px;border-radius:3px;}#wpwrap .a0-feedback h2{font-size:18px;margin-bottom:15px;}#wpwrap .a0-feedback h2.message{margin:0}#wpwrap .a0-feedback .a0-separator{margin:20px 0}#wpwrap .a0-feedback input.feedback_calification{display:none}#wpwrap .a0-feedback input:checked + .feedback-face{opacity:1}#wpwrap .a0-feedback .a0-buttons{margin:15px 0 0;}#wpwrap .a0-feedback .a0-buttons .a0-button{min-width:auto;cursor:pointer}#wpwrap .a0-feedback textarea{padding:10px;height:90px}#wpwrap .a0-feedback .feedback-face{width:40px;height:40px;display:inline-block;background-size:contain;opacity:.4;margin-right:30px;cursor:pointer;}#wpwrap .a0-feedback .feedback-face:hover{opacity:.7}#wpwrap .a0-feedback .feedback-face.calification-1{background-image:url("../img/rates/01.svg")}#wpwrap .a0-feedback .feedback-face.calification-2{background-image:url("../img/rates/02.svg")}#wpwrap .a0-feedback .feedback-face.calification-3{background-image:url("../img/rates/03.svg")}#wpwrap .a0-feedback .feedback-face.calification-4{background-image:url("../img/rates/04.svg")}#wpwrap .a0-feedback .feedback-face.calification-5{background-image:url("../img/rates/05.svg")}@-moz-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}}@-webkit-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}}@-o-keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes loaderAnim{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}} \ No newline at end of file diff --git a/assets/css/initial-setup/main.styl b/assets/css/initial-setup/main.styl index a82c0cab..3e36594b 100644 --- a/assets/css/initial-setup/main.styl +++ b/assets/css/initial-setup/main.styl @@ -154,8 +154,9 @@ margin:0; [disabled] { + opacity: 0.5; font-size: 0.9em; - margin: 0.3em; + margin-top: 0.3em; } } diff --git a/assets/css/initial-setup/partials/_colors.styl b/assets/css/initial-setup/partials/_colors.styl index e68f2218..8010e211 100644 --- a/assets/css/initial-setup/partials/_colors.styl +++ b/assets/css/initial-setup/partials/_colors.styl @@ -7,7 +7,7 @@ tipBG = #E4E6E8; aText=rgb(0,148,193); text = rgba(0,0,0,.86); -softText = rgba(0,0,0,0.36); +softText = rgba(0,0,0,0.5); formFieldsText = rgba(0,0,0,.86) buttonPrimaryText = #FFFFFF; diff --git a/circle.yml b/circle.yml index 108fb7df..f18150ba 100644 --- a/circle.yml +++ b/circle.yml @@ -19,9 +19,9 @@ test: phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs,$HOME/.composer/vendor/wimg/php-compatibility override: - phpcs --standard=$HOME/wp-auth0/phpcs-compat-ruleset.xml $HOME/wp-auth0 -pn -d memory_limit=-1 - - phpcs --standard=$HOME/wp-auth0/phpcs-test-ruleset.xml $HOME/wp-auth0/tests -pn -d memory_limit=-1 - phpcbf --standard=$HOME/wp-auth0/phpcs-ruleset.xml $HOME/wp-auth0 -p -d memory_limit=-1 - - phpcbf --standard=$HOME/wp-auth0/phpcs-test-ruleset.xml $HOME/wp-auth0 -p -d memory_limit=-1 + - phpcs --standard=$HOME/wp-auth0/phpcs-test-ruleset.xml $HOME/wp-auth0/tests -pn -d memory_limit=-1 + - phpcbf --standard=$HOME/wp-auth0/phpcs-test-ruleset.xml $HOME/wp-auth0/tests -p -d memory_limit=-1 - | rm -rf $WP_TESTS_DIR $WP_CORE_DIR bash bin/install-wp-tests.sh wordpress_test ubuntu '' 127.0.0.1 3.8 diff --git a/lib/WP_Auth0_Options_Generic.php b/lib/WP_Auth0_Options_Generic.php index 26995c04..e5709d88 100644 --- a/lib/WP_Auth0_Options_Generic.php +++ b/lib/WP_Auth0_Options_Generic.php @@ -176,6 +176,9 @@ public function set( $key, $value, $should_update = true ) { * @return bool */ public function update_all() { + foreach ( $this->get_all_constant_keys() as $key ) { + unset( $this->_opts[ $key ] ); + } return update_option( $this->_options_name, $this->_opts ); } diff --git a/lib/admin/WP_Auth0_Admin.php b/lib/admin/WP_Auth0_Admin.php index fe980ade..9ea76698 100755 --- a/lib/admin/WP_Auth0_Admin.php +++ b/lib/admin/WP_Auth0_Admin.php @@ -97,12 +97,29 @@ public function init_admin() { ); } - public function input_validator( $input ) { + /** + * Main validator for settings page inputs. + * Delegates validation to settings sections in self::init_admin(). + * + * @param array $input - Incoming array of settings fields to validate. + * + * @return mixed + */ + public function input_validator( array $input ) { + $constant_keys = $this->a0_options->get_all_constant_keys(); - $old_options = $this->a0_options->get_options(); + // Look for and set constant overrides so validation is still possible. + foreach ( $constant_keys as $key ) { + $input[ $key ] = $this->a0_options->get_constant_val( $key ); + } foreach ( $this->sections as $name => $section ) { - $input = $section->input_validator( $input, $old_options ); + $input = $section->input_validator( $input ); + } + + // Remove constant overrides so they are not saved to the database. + foreach ( $constant_keys as $key ) { + unset( $input[ $key ] ); } return $input; diff --git a/lib/admin/WP_Auth0_Admin_Advanced.php b/lib/admin/WP_Auth0_Admin_Advanced.php index 696aaf75..b6552ca3 100644 --- a/lib/admin/WP_Auth0_Admin_Advanced.php +++ b/lib/admin/WP_Auth0_Admin_Advanced.php @@ -360,6 +360,7 @@ public function render_migration_ws( $args = array() ) { $this->get_dashboard_link() ); $this->render_field_description( 'Security token:' ); + $this->render_const_notice( 'migration_token' ); printf( '', $this->_textarea_rows, diff --git a/lib/admin/WP_Auth0_Admin_Appearance.php b/lib/admin/WP_Auth0_Admin_Appearance.php index d3e2592b..6260a540 100644 --- a/lib/admin/WP_Auth0_Admin_Appearance.php +++ b/lib/admin/WP_Auth0_Admin_Appearance.php @@ -196,12 +196,19 @@ public function render_custom_js( $args = array() ) { * @see add_settings_field() */ public function render_username_style( $args = array() ) { - $opt_name = $args['opt_name']; - $id_attr = $args['label_for']; - $value = $this->options->get( $opt_name ); - $this->render_radio_button( $id_attr . '_au', $opt_name, '', 'Auto', empty( $value ) ); - $this->render_radio_button( $id_attr . '_em', $opt_name, 'email', '', 'email' === $value ); - $this->render_radio_button( $id_attr . '_un', $opt_name, 'username', '', 'username' === $value ); + $this->render_radio_buttons( + array( + array( + 'label' => 'Auto', + 'value' => '', + ), + 'email', + 'username', + ), + $args['label_for'], + $args['opt_name'], + $this->options->get( $args['opt_name'], '' ) + ); $this->render_field_description( __( 'To allow the user to use either email or username to login, leave this as "Auto." ', 'wp-auth0' ) . __( 'Only database connections that require a username will allow username logins', 'wp-auth0' ) diff --git a/lib/admin/WP_Auth0_Admin_Basic.php b/lib/admin/WP_Auth0_Admin_Basic.php index 8597b061..31412817 100755 --- a/lib/admin/WP_Auth0_Admin_Basic.php +++ b/lib/admin/WP_Auth0_Admin_Basic.php @@ -193,9 +193,13 @@ public function render_client_secret_b64_encoded( $args = array() ) { * @see add_settings_field() */ public function render_client_signing_algorithm( $args = array() ) { - $value = $this->options->get( $args['opt_name'], WP_Auth0_Api_Client::DEFAULT_CLIENT_ALG ); - $this->render_radio_button( $args['label_for'] . '_hs', $args['opt_name'], 'HS256', '', 'HS256' === $value ); - $this->render_radio_button( $args['label_for'] . '_rs', $args['opt_name'], 'RS256', '', 'RS256' === $value ); + $curr_value = $this->options->get( $args['opt_name'] ) ?: WP_Auth0_Api_Client::DEFAULT_CLIENT_ALG; + $this->render_radio_buttons( + array( 'HS256', 'RS256' ), + $args['label_for'], + $args['opt_name'], + $curr_value + ); $this->render_field_description( __( 'This value can be found the Application settings in the ' ) . $this->get_dashboard_link( 'applications' ) . diff --git a/lib/admin/WP_Auth0_Admin_Features.php b/lib/admin/WP_Auth0_Admin_Features.php index 87ef7684..232e724e 100644 --- a/lib/admin/WP_Auth0_Admin_Features.php +++ b/lib/admin/WP_Auth0_Admin_Features.php @@ -112,14 +112,21 @@ public function init() { * @see add_settings_field() */ public function render_password_policy( $args = array() ) { - $opt_name = $args['opt_name']; - $id_attr = $args['label_for']; - $curr_val = $this->options->get( $opt_name ); - - $this->render_radio_button( $id_attr . '_none', $opt_name, '', 'None', empty( $curr_val ) ); - foreach ( array( 'low', 'fair', 'good', 'excellent' ) as $val ) { - $this->render_radio_button( $id_attr . '_' . $val, $opt_name, $val, '', $val === $curr_val ); - } + $this->render_radio_buttons( + array( + array( + 'label' => 'None', + 'value' => '', + ), + 'low', + 'fair', + 'good', + 'excellent', + ), + $args['label_for'], + $args['opt_name'], + $this->options->get( $args['opt_name'], 'fair' ) + ); $this->render_field_description( __( 'Password security policy for the database connection used by this application. ', 'wp-auth0' ) . __( 'Changing the policy here will change it for all other applications using this database. ', 'wp-auth0' ) . diff --git a/lib/admin/WP_Auth0_Admin_Generic.php b/lib/admin/WP_Auth0_Admin_Generic.php index 2a0455f2..487b5ef7 100644 --- a/lib/admin/WP_Auth0_Admin_Generic.php +++ b/lib/admin/WP_Auth0_Admin_Generic.php @@ -124,14 +124,18 @@ protected function rule_validation( $old_options, $input, $key, $rule_name, $rul */ protected function render_switch( $id, $input_name, $expand_id = '' ) { $value = $this->options->get( $input_name ); + if ( $field_is_const = $this->options->has_constant_val( $input_name ) ) { + $this->render_const_notice( $input_name ); + } printf( - '
+ '
', esc_attr( $this->_option_name ), esc_attr( $input_name ), esc_attr( $id ), ! empty( $expand_id ) ? esc_attr( $expand_id ) : '', checked( empty( $value ), false, false ), + $field_is_const ? 'disabled' : '', esc_attr( $id ) ); } @@ -147,20 +151,25 @@ protected function render_switch( $id, $input_name, $expand_id = '' ) { */ protected function render_text_field( $id, $input_name, $type = 'text', $placeholder = '', $style = '' ) { $value = $this->options->get( $input_name ); + // Secure fields are not output by default; validation keeps last value if a new one is not entered if ( 'password' === $type ) { $placeholder = ! empty( $value ) ? 'Not visible' : ''; $value = ''; } + if ( $field_is_const = $this->options->has_constant_val( $input_name ) ) { + $this->render_const_notice( $input_name ); + } printf( - '', + '', esc_attr( $type ), esc_attr( $this->_option_name ), esc_attr( $input_name ), esc_attr( $id ), esc_attr( $value ), $placeholder ? esc_attr( $placeholder ) : '', - $style ? esc_attr( $style ) : '' + $style ? esc_attr( $style ) : '', + $field_is_const ? 'disabled' : '' ); } @@ -172,36 +181,48 @@ protected function render_text_field( $id, $input_name, $type = 'text', $placeho */ protected function render_textarea_field( $id, $input_name ) { $value = $this->options->get( $input_name ); + if ( $field_is_const = $this->options->has_constant_val( $input_name ) ) { + $this->render_const_notice( $input_name ); + } printf( - '', + '', esc_attr( $this->_option_name ), esc_attr( $input_name ), esc_attr( $id ), $this->_textarea_rows, + $field_is_const ? 'disabled' : '', esc_textarea( $value ) ); } /** - * Output a radio button + * Output one or many radio buttons associated to the same option key. * - * @param string $id - input id attribute - * @param string $input_name - input name attribute - * @param string|integer|float $value - input value attribute - * @param string $label - input label text - * @param bool $selected - is it active? + * @param array $buttons - Array of buttons to output; items can be strings or arrays with "label" and "value" keys. + * @param string $id - Input ID attribute. + * @param string $input_name - Option name saved to the options array. + * @param int|float|string $curr_value - Current option value. */ - protected function render_radio_button( $id, $input_name, $value, $label = '', $selected = false ) { - printf( - '', - esc_attr( $id ), - esc_attr( $this->_option_name ), - esc_attr( $input_name ), - esc_attr( $id ), - esc_attr( $value ), - checked( $selected, true, false ), - sanitize_text_field( ! empty( $label ) ? $label : ucfirst( $value ) ) - ); + protected function render_radio_buttons( array $buttons, $id, $input_name, $curr_value ) { + if ( $field_is_const = $this->options->has_constant_val( $input_name ) ) { + $this->render_const_notice( $input_name ); + } + foreach ( $buttons as $index => $button ) { + $id_attr = $id . '_' . $index; + $label = is_array( $button ) ? $button['label'] : ucfirst( $button ); + $value = is_array( $button ) ? $button['value'] : $button; + printf( + '', + esc_attr( $id_attr ), + esc_attr( $this->_option_name ), + esc_attr( $input_name ), + esc_attr( $id_attr ), + esc_attr( $value ), + checked( $value === $curr_value, true, false ), + $field_is_const ? 'disabled' : '', + sanitize_text_field( $label ) + ); + } } /** @@ -213,6 +234,21 @@ protected function render_field_description( $text ) { printf( '
%s.
', $text ); } + /** + * Check if the setting is provided by a constant and indicate. + * + * @param string $input_name - Input name for the field, used as option key. + */ + protected function render_const_notice( $input_name ) { + if ( $this->options->has_constant_val( $input_name ) ) { + printf( + '

%s %s

', + __( 'Value is set in the constant ', 'wp-auth0' ), + $this->options->get_constant_name( $input_name ) + ); + } + } + /** * Output translated dashboard HTML link * diff --git a/phpcs-test-ruleset.xml b/phpcs-test-ruleset.xml index 3fcb4f4b..c74ca821 100644 --- a/phpcs-test-ruleset.xml +++ b/phpcs-test-ruleset.xml @@ -2,12 +2,8 @@ A custom coding standard for WP-Auth0 tests - - /tests/* - - @@ -17,8 +13,14 @@ - - - + + + + + + + + + \ No newline at end of file diff --git a/templates/back-to-auth0.php b/templates/back-to-auth0.php index 55d147bd..a9eeacaa 100644 --- a/templates/back-to-auth0.php +++ b/templates/back-to-auth0.php @@ -13,5 +13,5 @@ }
- +
diff --git a/tests/bootstrap.php b/tests/bootstrap.php index a1b0e3c4..ef64e500 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,7 +2,7 @@ /** * PHPUnit bootstrap file * - * @package Auth0 + * @package WP-Auth0 */ $_tests_dir = getenv( 'WP_TESTS_DIR' ); @@ -31,10 +31,10 @@ function _manually_load_plugin() { require $_tests_dir . '/includes/bootstrap.php'; spl_autoload_register( - function( $className ) { - $fileName = stream_resolve_include_path( 'traits/' . $className . '.php' ); - if ( false !== $fileName ) { - include $fileName; + function( $class_name ) { + $file_name = stream_resolve_include_path( 'traits/' . $class_name . '.php' ); + if ( false !== $file_name ) { + include $file_name; } } ); diff --git a/tests/testConstantSettings.php b/tests/testConstantSettings.php index 2afb701c..a0cda35b 100644 --- a/tests/testConstantSettings.php +++ b/tests/testConstantSettings.php @@ -1,18 +1,42 @@ get_options_name() ); $this->assertEquals( $expected_val_2, $db_options[ $opt_name ] ); } + /** * Test that options cannot be set when a constant is present. */ @@ -115,4 +140,50 @@ public function testSetWithConstant() { $this->assertFalse( $result ); $this->assertNotEquals( $expected_val, $opts->get( $opt_name ) ); } + + /** + * Test that commonly-overridden settings will show a notice. + */ + public function testConstantSettingNoticeBasic() { + $opts = new WP_Auth0_Options(); + $admin = new WP_Auth0_Admin_Basic( $opts ); + + $fields = [ + [ + 'opt_name' => 'domain', + 'label_for' => 'wpa0_domain', + 'render_function' => 'render_domain', + ], + [ + 'opt_name' => 'client_id', + 'label_for' => 'wpa0_client_id', + 'render_function' => 'render_client_id', + ], + [ + 'opt_name' => 'client_secret', + 'label_for' => 'wpa0_client_secret', + 'render_function' => 'render_client_secret', + ], + [ + 'opt_name' => 'auth0_app_token', + 'label_for' => 'wpa0_auth0_app_token', + 'render_function' => 'render_auth0_app_token', + ], + ]; + + foreach ( $fields as $field ) { + $constant_name = self::DEFAULT_CONSTANT_PREFIX . strtoupper( $field['opt_name'] ); + $override_val = self::FILTER_TEST_STRING . rand(); + define( $constant_name, $override_val ); + + ob_start(); + $admin->{$field['render_function']}( $field ); + $field_html = ob_get_clean(); + + $input = $this->getDomListFromTagName( $field_html, 'input' ); + $this->assertTrue( $input->item( 0 )->hasAttribute( 'disabled' ) ); + $this->assertNotFalse( strpos( $field_html, self::CONSTANT_NOTICE_TEXT ) ); + $this->assertNotFalse( strpos( $field_html, $constant_name ) ); + } + } } diff --git a/tests/testCustomDomains.php b/tests/testCustomDomains.php index a2ee6869..f512054c 100644 --- a/tests/testCustomDomains.php +++ b/tests/testCustomDomains.php @@ -1,4 +1,11 @@ assertTrue( $opts->delete() ); $this->assertFalse( get_option( $opts->get_options_name() ) ); } - - /** - * Test that default getting works. - */ - public function testDefaults() { - $opts_defaults = self::getMethod( 'WP_Auth0_Options', 'defaults' ); - $opts = new WP_Auth0_Options(); - $opts_defaults_val = $opts_defaults->invoke( $opts ); - $this->assertCount( self::DEFAULT_OPTIONS_COUNT, $opts_defaults_val ); - $this->assertEquals( $opts->get_defaults(), $opts_defaults_val ); - $this->assertEquals( $opts->get_defaults( true ), array_keys( $opts_defaults_val ) ); - - $opts_defaults = self::getMethod( 'WP_Auth0_Options_Generic', 'defaults' ); - $opts = new WP_Auth0_Options_Generic(); - $opts_defaults_val = $opts_defaults->invoke( $opts ); - $this->assertEmpty( $opts_defaults_val ); - } - - /** - * Create a public version of a protected method. - * - * @param string $class - Class to use. - * @param string $method - Method to reflect. - * - * @return ReflectionMethod - */ - protected static function getMethod( $class, $method ) { - $class = new ReflectionClass( $class ); - $method = $class->getMethod( $method ); - $method->setAccessible( true ); - return $method; - } } diff --git a/tests/traits/domDocumentHelpers.php b/tests/traits/domDocumentHelpers.php index 5e139097..dfb5d38c 100644 --- a/tests/traits/domDocumentHelpers.php +++ b/tests/traits/domDocumentHelpers.php @@ -1,4 +1,10 @@