diff --git a/.github/assets/screenshot-1.jpg b/.github/assets/screenshot-1.jpg index 2dc30899..60472060 100644 Binary files a/.github/assets/screenshot-1.jpg and b/.github/assets/screenshot-1.jpg differ diff --git a/.github/assets/screenshot-10.jpg b/.github/assets/screenshot-10.jpg index 1fe828c0..80309a97 100644 Binary files a/.github/assets/screenshot-10.jpg and b/.github/assets/screenshot-10.jpg differ diff --git a/.github/assets/screenshot-11.jpg b/.github/assets/screenshot-11.jpg index eb874b70..48cc8514 100644 Binary files a/.github/assets/screenshot-11.jpg and b/.github/assets/screenshot-11.jpg differ diff --git a/.github/assets/screenshot-12.jpg b/.github/assets/screenshot-12.jpg index c7a86e4a..3179f3ce 100644 Binary files a/.github/assets/screenshot-12.jpg and b/.github/assets/screenshot-12.jpg differ diff --git a/.github/assets/screenshot-2.jpg b/.github/assets/screenshot-2.jpg index a2cae606..183ab08c 100644 Binary files a/.github/assets/screenshot-2.jpg and b/.github/assets/screenshot-2.jpg differ diff --git a/.github/assets/screenshot-4.jpg b/.github/assets/screenshot-4.jpg index 6c58549e..c23aa0d6 100644 Binary files a/.github/assets/screenshot-4.jpg and b/.github/assets/screenshot-4.jpg differ diff --git a/.github/assets/screenshot-5.jpg b/.github/assets/screenshot-5.jpg index 756e2b6b..28c36bf9 100644 Binary files a/.github/assets/screenshot-5.jpg and b/.github/assets/screenshot-5.jpg differ diff --git a/.github/assets/screenshot-7.jpg b/.github/assets/screenshot-7.jpg index 6b09366c..dfea4a15 100644 Binary files a/.github/assets/screenshot-7.jpg and b/.github/assets/screenshot-7.jpg differ diff --git a/.github/assets/screenshot-8.jpg b/.github/assets/screenshot-8.jpg index 0eb56cf8..1d32c321 100644 Binary files a/.github/assets/screenshot-8.jpg and b/.github/assets/screenshot-8.jpg differ diff --git a/.github/assets/screenshot-9.jpg b/.github/assets/screenshot-9.jpg index ec18a8ba..bfd65752 100644 Binary files a/.github/assets/screenshot-9.jpg and b/.github/assets/screenshot-9.jpg differ diff --git a/assets/css/view-admin-as.css b/assets/css/view-admin-as.css index f51bcfc0..e39e2ea1 100644 --- a/assets/css/view-admin-as.css +++ b/assets/css/view-admin-as.css @@ -5,7 +5,7 @@ * @author Jory Hogeveen * @package View_Admin_As * @since 1.1.0 - * @version 1.8.1 + * @version 1.8.2 * @preserve */ @@ -288,8 +288,9 @@ #wpadminbar #wp-admin-bar-vaa .ab-item .vaa-radio-wrapper:last-of-type {margin-bottom: 6px;} /* Multipleselect */ -#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect {max-height: 400px; min-width: 250px; overflow: hidden; overflow-y: auto; margin: 6px 0; padding: 0; border: solid transparent; border-width: 0 10px;} -#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect .ab-empty-item {height: auto; overflow: hidden; margin: 0; padding: 5px 10px; background-color: #fff;} +#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect {max-height: 400px; min-width: 250px; overflow: hidden; overflow-y: auto; margin: 6px 10px; padding: 0; background-color: #fff;} +#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect:empty {height: 0; margin: 0; padding: 0;} +#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect .ab-empty-item {height: auto; overflow: hidden; margin: 0; padding: 5px 10px;} #wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect .ab-empty-item .ab-item {color: #333;} #wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect.vaa-small {max-height: 100px;} #wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect .remove:before {color: #333;} diff --git a/assets/css/view-admin-as.min.css b/assets/css/view-admin-as.min.css index 8750c059..303f2861 100644 --- a/assets/css/view-admin-as.min.css +++ b/assets/css/view-admin-as.min.css @@ -5,7 +5,7 @@ * @author Jory Hogeveen * @package View_Admin_As * @since 1.1.0 - * @version 1.8.1 + * @version 1.8.2 * @preserve */ -.vaa-loader-icon{width:96px;height:96px;background:transparent url('../img/loader.gif') center center no-repeat;background-size:contain}#vaa-overlay{position:fixed;top:0;left:0;height:100%;width:100%;background:rgba(255,255,255,0.85);display:none;z-index:999999999}#vaa-overlay .vaa-loader-icon{position:fixed;top:50%;left:50%;margin:-48px 0 0 -48px;display:block}#vaa-overlay .vaa-popup{max-width:75%;min-width:50%;max-height:50%;min-height:20px;margin:0 25%;padding:10px;top:10%;background:#fcfcfc;box-shadow:0 1px 1px rgba(0,0,0,0.15),0 0 1px 3px #fff;border:2px solid #666;position:relative}#vaa-overlay .vaa-popup>.remove{position:absolute;right:-10px;top:-10px;background:#FFF;width:20px;height:20px;cursor:pointer}#vaa-overlay .vaa-popup .vaa-popup-content{overflow:hidden;overflow-y:auto}#vaa-overlay .vaa-popup .vaa-popup-content ul li{margin-left:20px;list-style:disc outside}#vaa-overlay .vaa-popup .vaa-popup-content .button .icon{line-height:inherit;height:auto;width:auto}#vaa-overlay .vaa-popup.vaa-message{border-color:#0075b3}#vaa-overlay .vaa-popup.vaa-warning{border-color:#c8730c}#vaa-overlay .vaa-popup.vaa-error{border-color:#dc3232}#vaa-overlay .vaa-popup.vaa-success{border-color:#46b450}#wpadminbar .vaa-notice{display:inline-block;padding:0 5px 0 10px;background:#fff}#wpadminbar .vaa-notice.vaa-message,#wpadminbar .vaa-notice.vaa-message .ab-icon:before{color:#0075b3 !important}#wpadminbar .vaa-notice.vaa-warning,#wpadminbar .vaa-notice.vaa-warning .ab-icon:before{color:#c8730c !important}#wpadminbar .vaa-notice.vaa-error,#wpadminbar .vaa-notice.vaa-error .ab-icon:before{color:#dc3232 !important}#wpadminbar .vaa-notice.vaa-success,#wpadminbar .vaa-notice.vaa-success .ab-icon:before{color:#46b450 !important}#wpadminbar #wp-admin-bar-vaa .vaa-notice{display:block;clear:both;margin-bottom:3px}#wpadminbar #wp-admin-bar-vaa .vaa-notice button{vertical-align:baseline;margin:0 0 0 -5px;padding:1px 10px}#wpadminbar .vaa-notice .remove,#wpadminbar #wp-admin-bar-vaa .remove{cursor:pointer;top:2px;float:right;margin-right:0;margin-left:6px}#wpadminbar #wp-admin-bar-vaa ul li,#wpadminbar #wp-admin-bar-vaa .ab-item{clear:both;z-index:auto}#wpadminbar #wp-admin-bar-vaa .ab-sub-wrapper .ab-item>span{line-height:26px}#wpadminbar #wp-admin-bar-vaa .ab-item>span.remove{font-size:16px;line-height:16px;top:1px}#wpadminbar #wp-admin-bar-vaa b,#wpadminbar #wp-admin-bar-vaa strong,#wpadminbar #wp-admin-bar-vaa .ab-item.ab-bold,#wpadminbar #wp-admin-bar-vaa .ab-item .ab-bold,#wpadminbar #wp-admin-bar-vaa .ab-bold>.ab-item,#wpadminbar #wp-admin-bar-vaa .ab-bold>.ab-item *{font-weight:bold !important}#wpadminbar #wp-admin-bar-vaa i,#wpadminbar #wp-admin-bar-vaa em,#wpadminbar #wp-admin-bar-vaa .ab-item.ab-italic,#wpadminbar #wp-admin-bar-vaa .ab-item .ab-italic,#wpadminbar #wp-admin-bar-vaa .ab-italic>.ab-item,#wpadminbar #wp-admin-bar-vaa .ab-italic>.ab-item *{font-style:italic !important}#wpadminbar #wp-admin-bar-vaa .vaa-highlight,#wpadminbar #wp-admin-bar-vaa code{background:rgba(0,0,0,0.1);padding:1px 5px 2px;line-height:normal}#wpadminbar #wp-admin-bar-vaa code{font-family:Consolas,Monaco,monospace}#wpadminbar #wp-admin-bar-vaa .vaa-sub-transparent>*{opacity:.5;transition:opacity .2s}#wpadminbar #wp-admin-bar-vaa .vaa-sub-transparent:hover>*,#wpadminbar #wp-admin-bar-vaa .vaa-sub-transparent .active,#wpadminbar #wp-admin-bar-vaa .vaa-sub-transparent .active ~ *{opacity:1}#wpadminbar #wp-admin-bar-vaa .ab-vaa-results{margin:6px 0;padding:0}#wpadminbar #wp-admin-bar-vaa .ab-vaa-results.vaa-auto-max-height{margin-right:10px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-results:empty{display:none}#wpadminbar #wp-admin-bar-vaa ul.ab-sub-secondary+ul.ab-sub-secondary{margin-top:3px}#wpadminbar #wp-admin-bar-vaa .menupop ul+ul,#wpadminbar #wp-admin-bar-vaa .menupop ul.ab-sub-secondary+ul.ab-sub-secondary{margin-top:2px}#wpadminbar #wp-admin-bar-vaa .menupop .menupop ul+ul,#wpadminbar #wp-admin-bar-vaa .menupop .menupop ul.ab-sub-secondary+ul.ab-sub-secondary{margin-top:1px}#wpadminbar #wp-admin-bar-vaa ul:not(.ab-sub-secondary)+ul.ab-sub-secondary,#wpadminbar #wp-admin-bar-vaa ul.ab-sub-secondary+ul:not(.ab-sub-secondary){margin-top:0}#wpadminbar #wp-admin-bar-vaa .menupop .ab-sub-wrapper ul.vaa-toggle-group{padding:3px 0 4px}#wpadminbar #wp-admin-bar-vaa .menupop .ab-sub-wrapper ul.vaa-toggle-group li.active ~ li:last-child{padding-bottom:3px}#wpadminbar #wp-admin-bar-vaa .auto-height>.ab-item{height:auto}#wpadminbar #wp-admin-bar-vaa .ab-item .description{height:auto;line-height:1.2;font-size:.8em;font-style:italic;margin-bottom:7px;white-space:normal;color:inherit}#wpadminbar #wp-admin-bar-vaa .ab-item .description:first-child:not(:only-child){margin-bottom:0}#wpadminbar #wp-admin-bar-vaa .ab-item .description .ab-icon{line-height:1 !important;font-size:1em !important;padding:1px 0;margin-right:3px;width:auto;height:1em}#wpadminbar #wp-admin-bar-vaa.menupop .ab-vaa-title>.ab-item{font-weight:bold;line-height:26px;font-size:1.1em;text-transform:uppercase}#wpadminbar #wp-admin-bar-vaa .current>.ab-item,#wpadminbar #wp-admin-bar-vaa .current>.ab-item .vaa-view-data,#wpadminbar #wp-admin-bar-vaa .current>input:checked+label,#wpadminbar #wp-admin-bar-vaa .current-parent>.ab-item,#wpadminbar #wp-admin-bar-vaa .current-parent>.ab-item .vaa-view-data,#wpadminbar #wp-admin-bar-vaa .current-parent>label{font-weight:bold}#wpadminbar #wp-admin-bar-vaa .current>.ab-item::after,#wpadminbar #wp-admin-bar-vaa .current>label::after{content:'\f177';font-family:'dashicons';margin:0 5px;font-size:17px;vertical-align:middle;font-weight:normal}#wpadminbar #wp-admin-bar-vaa .current.ab-vaa-title>.ab-item::after{vertical-align:top}#wpadminbar #wp-admin-bar-vaa .ab-item .ab-icon.alignright{float:right;margin-right:0;margin-left:6px}#wpadminbar #wp-admin-bar-vaa>.ab-item .ab-icon{top:2px}#wpadminbar #wp-admin-bar-vaa>.ab-item .ab-label{float:left}#wpadminbar #wp-admin-bar-vaa>.ab-item .ab-label .ab-icon{margin-right:-3px}#wpadminbar #wp-admin-bar-vaa .ab-icon.vaa-icon-image{width:16px;height:16px;background-size:100% auto !important;background:center left no-repeat;display:inline-block}#wpadminbar>#wp-toolbar>#wp-admin-bar-root-default #wp-admin-bar-vaa .vaa-has-icon>.ab-item>.ab-icon,#wpadminbar #wp-admin-bar-vaa .vaa-has-icon>.ab-item .ab-icon{float:none;font-weight:normal !important;font-size:16px;line-height:16px;vertical-align:text-bottom;padding:0}#wpadminbar #wp-admin-bar-vaa .vaa-has-icon>.ab-item::before{display:none}#wpadminbar #wp-admin-bar-vaa .vaa-has-icon.menupop>.ab-item{padding-left:10px;padding-right:10px}#wpadminbar #wp-admin-bar-vaa .vaa-has-icon.ab-vaa-title>.ab-item>.ab-icon{font-size:18px;line-height:20px;margin:0 5px 0 -1px}#wpadminbar #wp-admin-bar-vaa .vaa-has-icon.ab-vaa-title>.ab-item>.ab-icon.vaa-icon-image{width:18px;height:18px}#wpadminbar .ab-top-secondary .menupop .vaa-menupop>.ab-item{padding-left:2em;padding-right:1em}#wpadminbar .ab-top-secondary .menupop .vaa-menupop>.ab-item .ab-icon{margin-left:-20px;margin-right:4px}#wpadminbar #wp-admin-bar-vaa.menupop ul.ab-sub-secondary{position:static}#wpadminbar #wp-admin-bar-vaa.menupop .menupop>.ab-item:before{top:1px}#wpadminbar #vaa-combine-views-selection .ab-item{padding-right:28px}#wpadminbar #vaa-combine-views-selection .ab-item .remove{position:absolute;right:4px}#wpadminbar #wp-admin-bar-vaa button>.ab-icon{margin:0 5px 0 -5px;padding:0;top:0}#wpadminbar #wp-admin-bar-vaa .ab-item>label+button{margin:0 0 0 12px;vertical-align:baseline}#wpadminbar #wp-admin-bar-vaa .vaa-button-container>.ab-item{overflow:hidden;height:auto}#wpadminbar #wp-admin-bar-vaa button{float:none;text-decoration:none;font-size:13px;line-height:20px;height:20px;margin:3px 0;padding:0 10px 1px;vertical-align:middle;cursor:pointer}#wpadminbar #wp-admin-bar-vaa .vaa-icon{padding:0 2px 1px}#wpadminbar #wp-admin-bar-vaa .vaa-icon .ab-icon{margin:0}#wpadminbar #wp-admin-bar-vaa button.vaa-icon .ab-icon{padding:0}#wpadminbar #wp-admin-bar-vaa .vaa-tooltip{position:absolute !important;display:none;opacity:0;transition:all .2s;right:12px;top:0;padding:10px 15px;width:140px;height:auto;font-size:11px;line-height:1.2em;text-align:center;white-space:normal;border-radius:3px;border:1px solid rgba(175,175,175,0.5);box-shadow:0 0 15px rgba(0,0,0,0.2);z-index:99999}#wpadminbar>#wp-toolbar>#wp-admin-bar-root-default #wp-admin-bar-vaa .vaa-help,#wpadminbar #wp-admin-bar-vaa .vaa-help{float:right;text-align:right;padding:0;font-size:16px;line-height:inherit !important;margin:0 0 0 5px}#wpadminbar #wp-admin-bar-vaa .vaa-help ~ label+select,#wpadminbar #wp-admin-bar-vaa .vaa-help ~ label+input,#wpadminbar #wp-admin-bar-vaa .vaa-help ~ input+label{margin-right:20px}#wpadminbar #wp-admin-bar-vaa .vaa-help:hover{cursor:help}#wpadminbar #wp-admin-bar-vaa .vaa-help:hover .vaa-tooltip{display:inline-block;opacity:1}#wpadminbar #wp-admin-bar-vaa .vaa-auto-max-height{min-height:26px;overflow-y:auto;transition:max-height .3s}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect .ab-item,#wpadminbar #wp-admin-bar-vaa .ab-vaa-input .ab-item,#wpadminbar #wp-admin-bar-vaa .ab-vaa-file .ab-item,#wpadminbar #wp-admin-bar-vaa .ab-vaa-search .ab-item,#wpadminbar #wp-admin-bar-vaa .ab-vaa-filter .ab-item,#wpadminbar #wp-admin-bar-vaa .ab-vaa-select .ab-item{height:auto;clear:both}#wpadminbar #wp-admin-bar-vaa .ab-vaa-input .ab-item input,#wpadminbar #wp-admin-bar-vaa .ab-vaa-file .ab-item input,#wpadminbar #wp-admin-bar-vaa .ab-vaa-search .ab-item input,#wpadminbar #wp-admin-bar-vaa .ab-vaa-filter .ab-item input,#wpadminbar #wp-admin-bar-vaa .ab-vaa-select .ab-item select{display:inline-block;background:#fff;color:#555;margin:5px 0;padding:3px;border:0;line-height:normal;height:auto;width:100%;box-sizing:border-box}#wpadminbar #wp-admin-bar-vaa .ab-vaa-select .ab-item select{padding:2px 3px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-select .ab-item label+input,#wpadminbar #wp-admin-bar-vaa .ab-vaa-select .ab-item label+select{margin-top:0}#wpadminbar #wp-admin-bar-vaa .ab-vaa-textarea .ab-item{height:auto;line-height:normal}#wpadminbar #wp-admin-bar-vaa .ab-vaa-textarea .ab-item textarea{width:100%;padding:5px;margin-top:5px;box-sizing:border-box;line-height:normal}#wpadminbar #wp-admin-bar-vaa .ab-item input.vaa-wide,#wpadminbar #wp-admin-bar-vaa .ab-item select.vaa-wide{display:block;box-sizing:border-box;width:100%;margin:5px 0}#wpadminbar #wp-admin-bar-vaa .ab-item select+button.input-overlay,#wpadminbar #wp-admin-bar-vaa .ab-item input+button.input-overlay{position:absolute;right:10px;margin:5px 0}#wpadminbar #wp-admin-bar-vaa input.checkbox,#wpadminbar #wp-admin-bar-vaa input.radio{display:inline-block;height:16px;width:16px;vertical-align:text-bottom;box-sizing:border-box;cursor:pointer}#wpadminbar #wp-admin-bar-vaa .ab-item input.checkbox,#wpadminbar #wp-admin-bar-vaa .ab-item input.radio{margin:0 6px 0 0}#wpadminbar #wp-admin-bar-vaa .ab-item input.radio{border-radius:100%}#wpadminbar #wp-admin-bar-vaa .ab-item input.checkbox+label,#wpadminbar #wp-admin-bar-vaa .ab-item input.checkbox+label *,#wpadminbar #wp-admin-bar-vaa .ab-item input.radio+label,#wpadminbar #wp-admin-bar-vaa .ab-item input.radio+label *{line-height:18px;vertical-align:text-top;display:inline-block}#wpadminbar #wp-admin-bar-vaa .ab-item input.checkbox+label:hover,#wpadminbar #wp-admin-bar-vaa .ab-item input.radio+label:hover{cursor:pointer}#wpadminbar #wp-admin-bar-vaa .ab-item input.radio+label+br{line-height:0}#wpadminbar #wp-admin-bar-vaa input.checkbox.vaa-right,#wpadminbar #wp-admin-bar-vaa input.radio.vaa-right{position:absolute;top:5px;right:1em;z-index:99}#wpadminbar #wp-admin-bar-vaa .ab-item .vaa-radio-wrapper{line-height:20px}#wpadminbar #wp-admin-bar-vaa .ab-item .vaa-radio-wrapper p.description,#wpadminbar #wp-admin-bar-vaa .ab-item .vaa-radio-wrapper:first-of-type{margin-top:6px}#wpadminbar #wp-admin-bar-vaa .ab-item .vaa-radio-wrapper:last-of-type{margin-bottom:6px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect{max-height:400px;min-width:250px;overflow:hidden;overflow-y:auto;margin:6px 0;padding:0;border:solid transparent;border-width:0 10px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect .ab-empty-item{height:auto;overflow:hidden;margin:0;padding:5px 10px;background-color:#fff}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect .ab-empty-item .ab-item{color:#333}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect.vaa-small{max-height:100px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect .remove:before{color:#333}#wpadminbar #wp-admin-bar-vaa .vaa-column-one-half{width:50%;display:block;float:left;clear:none}#wpadminbar #wp-admin-bar-vaa .vaa-column-one-half .ab-item{min-width:0}#wpadminbar #wp-admin-bar-vaa .vaa-column-one-half.vaa-column-first .ab-item{padding-right:1px}#wpadminbar #wp-admin-bar-vaa .vaa-column-one-half.vaa-column-last .ab-item{padding-left:1px}#wpadminbar #wp-admin-bar-vaa .vaa-clear-float{clear:both}#wpadminbar #wp-admin-bar-vaa .ab-vaa-toggle>.ab-item{padding-right:34px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-toggle>.ab-item:hover{cursor:pointer}#wpadminbar #wp-admin-bar-vaa .ab-vaa-toggle>.ab-item::after{content:"\f140";font-family:'dashicons';position:absolute;right:10px;margin:0;font-size:20px;font-weight:normal}#wpadminbar #wp-admin-bar-vaa .ab-vaa-toggle.active>.ab-item::after{content:"\f142"}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper,#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper .ab-item{display:none}#wpadminbar #wp-admin-bar-vaa.fullPopupActive>.ab-sub-wrapper{display:block}#wpadminbar #wp-admin-bar-vaa.fullPopupActive>.ab-sub-wrapper>.ab-submenu{padding:0}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup{position:fixed;display:block;visibility:visible;overflow:hidden;z-index:999;max-height:90%;width:90%;margin:5%;top:0;left:0;box-shadow:0 0 50px rgba(0,0,0,0.3)}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup .ab-item{display:block}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup>ul::after{display:table;clear:both;content:' '}#wpadminbar #wp-admin-bar-vaa #wp-admin-bar-vaa-caps #apply-caps-view{float:left;margin-right:5px}#wpadminbar #wp-admin-bar-vaa #wp-admin-bar-vaa-caps #reset-caps-view,#wpadminbar #wp-admin-bar-vaa #wp-admin-bar-vaa-caps #open-caps-popup,#wpadminbar #wp-admin-bar-vaa #wp-admin-bar-vaa-caps #close-caps-popup{float:right;margin-left:5px;height:auto}#wpadminbar #wp-admin-bar-vaa #wp-admin-bar-vaa-caps #close-caps-popup{display:none}#wpadminbar #wp-admin-bar-vaa.fullPopupActive #wp-admin-bar-vaa-caps .ab-sub-wrapper.fullPopup #close-caps-popup{display:block}#wpadminbar #wp-admin-bar-vaa.fullPopupActive #wp-admin-bar-vaa-caps .ab-sub-wrapper.fullPopup #open-caps-popup{display:none}#wpadminbar #wp-admin-bar-vaa.fullPopupActive #wp-admin-bar-vaa-caps .ab-sub-wrapper.fullPopup #wp-admin-bar-vaa-caps-select-options .vaa-cap-item{width:250px;float:left;clear:none}#wpadminbar #wp-admin-bar-vaa.fullPopupActive #wp-admin-bar-vaa-caps .ab-sub-wrapper.fullPopup #wp-admin-bar-vaa-caps-select-options .vaa-cap-item .remove{margin-right:6px}#wpadminbar #wp-admin-bar-vaa #wp-admin-bar-vaa-caps-popup:hover{cursor:pointer}#wpadminbar #wp-admin-bar-my-account-default{z-index:999999}#wpadminbar #wp-admin-bar-my-account #wp-admin-bar-vaa>.ab-item .ab-label{line-height:26px}#wpadminbar #wp-admin-bar-my-account #wp-admin-bar-vaa>.ab-item .ab-icon{top:0}#vaa_toolbar #wpadminbar{position:fixed !important;width:auto;min-width:0;right:0;left:auto;border-radius:0 0 0 5px}#vaa_toolbar #wpadminbar #wp-admin-bar-vaa>.ab-item .ab-icon{margin-left:0}#vaa_toolbar #wpadminbar #wp-admin-bar-vaa>.ab-item .ab-label{display:none}#vaa_toolbar #wpadminbar #wp-admin-bar-vaa:hover>.ab-item .ab-icon{margin-left:6px}#vaa_toolbar #wpadminbar #wp-admin-bar-vaa:hover>.ab-item .ab-label{display:inline-block}@media screen and (min-width:783px){#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul{overflow:hidden}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul li.ab-vaa-input,#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul li.ab-vaa-select{float:left;clear:none;width:auto}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul li.ab-vaa-input button{margin:5px 0}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul li.ab-vaa-input input,#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul li.ab-vaa-select select{width:auto}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul li.ab-vaa-input input+button.input-overlay,#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul li.ab-vaa-select select+button.input-overlay{position:static;vertical-align:top}}@media screen and (max-width:782px){#wpadminbar #wp-admin-bar-vaa{display:block;position:static}#wpadminbar #wp-admin-bar-vaa>.ab-item>.ab-icon{margin-left:0}#wpadminbar #wp-admin-bar-vaa .ab-sub-wrapper{width:100%}#wpadminbar #wp-admin-bar-vaa .ab-sub-wrapper .ab-sub-wrapper{position:static;top:auto;margin:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}#wpadminbar #wp-admin-bar-vaa.menupop .menupop>.ab-item:before{content:''}#wpadminbar #wp-admin-bar-vaa .ab-item .vaa-hide-responsive{display:none}#wpadminbar #wp-admin-bar-vaa .menupop>.ab-sub-wrapper .ab-item.description,#wpadminbar #wp-admin-bar-vaa .ab-item p.description{display:block !important;padding-left:0;padding-right:0;margin-bottom:0}#wpadminbar #wp-admin-bar-vaa .vaa-help{display:block;padding:8px 0;float:none;text-align:left;margin:0}#wpadminbar #wp-admin-bar-vaa .ab-item .vaa-help:empty{display:none}#wpadminbar #wp-admin-bar-vaa .vaa-tooltip{font-size:13px;display:inline-block;position:static !important;opacity:1;border:0;padding:0 !important;margin-left:5px !important;width:auto;vertical-align:text-top;line-height:20px}#wpadminbar #wp-admin-bar-vaa .vaa-notice{line-height:42px;font-size:16px}#wpadminbar #wp-admin-bar-vaa .vaa-notice .ab-icon{height:auto}#wpadminbar #wp-admin-bar-vaa>div>ul,#wpadminbar #wp-admin-bar-vaa .menupop>.ab-sub-wrapper .ab-submenu{padding:5px 0}#wpadminbar #wp-admin-bar-vaa .menupop>.ab-sub-wrapper .ab-item{padding:8px 44px;white-space:normal;height:auto}#wpadminbar #wp-admin-bar-vaa .menupop>.ab-sub-wrapper .ab-item>.ab-item{padding:8px 0}#wpadminbar #wp-admin-bar-vaa .menupop>.ab-sub-wrapper:last-child .ab-item.description{margin-bottom:0}#wpadminbar #wp-admin-bar-vaa .ab-item>span.remove,#wpadminbar #wp-admin-bar-vaa .vaa-has-icon .ab-item .ab-icon{width:auto;height:auto;font-size:22px !important;margin-right:10px;vertical-align:text-top}#wpadminbar #wp-admin-bar-vaa .vaa-has-icon .ab-item .ab-icon.vaa-icon-image{width:22px;height:22px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-title.vaa-has-icon>.ab-item>.ab-icon{font-size:30px !important;margin-left:-6px;margin-top:-1px;vertical-align:top}#wpadminbar #wp-admin-bar-vaa .ab-vaa-title.vaa-has-icon>.ab-item>.ab-icon.vaa-icon-image{width:30px;height:30px}#wpadminbar #wp-admin-bar-vaa .vaa-has-icon.menupop>.ab-item{padding-left:12px;padding-right:12px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-title.vaa-has-icon.menupop>.ab-item{padding-left:16px}#wpadminbar #wp-admin-bar-vaa .vaa-menupop div li{margin-left:12px}#wpadminbar #vaa-combine-views-selection .ab-item{padding-right:48px}#wpadminbar #vaa-combine-views-selection .ab-item>span.remove{margin-right:0;padding:10px;top:0;right:0}#wpadminbar #wp-admin-bar-vaa .ab-sub-wrapper .vaa-role-item.menupop>.ab-item{padding-left:15px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-toggle>.ab-item::after,#wpadminbar #wp-admin-bar-vaa .ab-sub-wrapper .vaa-menupop.menupop>.ab-item:after{content:"\f140";font-family:'dashicons';position:absolute;right:10px;top:8px;margin:0;font-size:30px;font-weight:normal}#wpadminbar #wp-admin-bar-vaa .ab-vaa-toggle.active>.ab-item::after,#wpadminbar #wp-admin-bar-vaa .ab-sub-wrapper .vaa-menupop.menupop.active>.ab-item:after{content:"\f142"}#wpadminbar #wp-admin-bar-vaa button{font-size:16px;padding:5px 15px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-input .ab-item input,#wpadminbar #wp-admin-bar-vaa .ab-vaa-search .ab-item input,#wpadminbar #wp-admin-bar-vaa .ab-vaa-filter .ab-item input{padding:8px 12px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-select .ab-item select{padding:7px 12px}#wpadminbar #wp-admin-bar-vaa .ab-item select+button.input-overlay,#wpadminbar #wp-admin-bar-vaa .ab-item input+button.input-overlay{right:44px;padding:6px 10px 7px;font-size:14px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect{border-width:0 44px;max-height:300px !important}#wpadminbar #wp-admin-bar-vaa .menupop>.ab-sub-wrapper .ab-vaa-multipleselect>.ab-item{padding:8px 16px}#wpadminbar #wp-admin-bar-vaa input.checkbox,#wpadminbar #wp-admin-bar-vaa input.radio{width:24px;height:24px}#wpadminbar #wp-admin-bar-vaa input.checkbox.vaa-right,#wpadminbar #wp-admin-bar-vaa input.radio.vaa-right{top:9px;right:11px}#wpadminbar #wp-admin-bar-vaa .ab-item .vaa-radio-wrapper{margin:6px 0}#vaa_toolbar{display:none !important}} \ No newline at end of file +.vaa-loader-icon{width:96px;height:96px;background:transparent url('../img/loader.gif') center center no-repeat;background-size:contain}#vaa-overlay{position:fixed;top:0;left:0;height:100%;width:100%;background:rgba(255,255,255,0.85);display:none;z-index:999999999}#vaa-overlay .vaa-loader-icon{position:fixed;top:50%;left:50%;margin:-48px 0 0 -48px;display:block}#vaa-overlay .vaa-popup{max-width:75%;min-width:50%;max-height:50%;min-height:20px;margin:0 25%;padding:10px;top:10%;background:#fcfcfc;box-shadow:0 1px 1px rgba(0,0,0,0.15),0 0 1px 3px #fff;border:2px solid #666;position:relative}#vaa-overlay .vaa-popup>.remove{position:absolute;right:-10px;top:-10px;background:#FFF;width:20px;height:20px;cursor:pointer}#vaa-overlay .vaa-popup .vaa-popup-content{overflow:hidden;overflow-y:auto}#vaa-overlay .vaa-popup .vaa-popup-content ul li{margin-left:20px;list-style:disc outside}#vaa-overlay .vaa-popup .vaa-popup-content .button .icon{line-height:inherit;height:auto;width:auto}#vaa-overlay .vaa-popup.vaa-message{border-color:#0075b3}#vaa-overlay .vaa-popup.vaa-warning{border-color:#c8730c}#vaa-overlay .vaa-popup.vaa-error{border-color:#dc3232}#vaa-overlay .vaa-popup.vaa-success{border-color:#46b450}#wpadminbar .vaa-notice{display:inline-block;padding:0 5px 0 10px;background:#fff}#wpadminbar .vaa-notice.vaa-message,#wpadminbar .vaa-notice.vaa-message .ab-icon:before{color:#0075b3 !important}#wpadminbar .vaa-notice.vaa-warning,#wpadminbar .vaa-notice.vaa-warning .ab-icon:before{color:#c8730c !important}#wpadminbar .vaa-notice.vaa-error,#wpadminbar .vaa-notice.vaa-error .ab-icon:before{color:#dc3232 !important}#wpadminbar .vaa-notice.vaa-success,#wpadminbar .vaa-notice.vaa-success .ab-icon:before{color:#46b450 !important}#wpadminbar #wp-admin-bar-vaa .vaa-notice{display:block;clear:both;margin-bottom:3px}#wpadminbar #wp-admin-bar-vaa .vaa-notice button{vertical-align:baseline;margin:0 0 0 -5px;padding:1px 10px}#wpadminbar .vaa-notice .remove,#wpadminbar #wp-admin-bar-vaa .remove{cursor:pointer;top:2px;float:right;margin-right:0;margin-left:6px}#wpadminbar #wp-admin-bar-vaa ul li,#wpadminbar #wp-admin-bar-vaa .ab-item{clear:both;z-index:auto}#wpadminbar #wp-admin-bar-vaa .ab-sub-wrapper .ab-item>span{line-height:26px}#wpadminbar #wp-admin-bar-vaa .ab-item>span.remove{font-size:16px;line-height:16px;top:1px}#wpadminbar #wp-admin-bar-vaa b,#wpadminbar #wp-admin-bar-vaa strong,#wpadminbar #wp-admin-bar-vaa .ab-item.ab-bold,#wpadminbar #wp-admin-bar-vaa .ab-item .ab-bold,#wpadminbar #wp-admin-bar-vaa .ab-bold>.ab-item,#wpadminbar #wp-admin-bar-vaa .ab-bold>.ab-item *{font-weight:bold !important}#wpadminbar #wp-admin-bar-vaa i,#wpadminbar #wp-admin-bar-vaa em,#wpadminbar #wp-admin-bar-vaa .ab-item.ab-italic,#wpadminbar #wp-admin-bar-vaa .ab-item .ab-italic,#wpadminbar #wp-admin-bar-vaa .ab-italic>.ab-item,#wpadminbar #wp-admin-bar-vaa .ab-italic>.ab-item *{font-style:italic !important}#wpadminbar #wp-admin-bar-vaa .vaa-highlight,#wpadminbar #wp-admin-bar-vaa code{background:rgba(0,0,0,0.1);padding:1px 5px 2px;line-height:normal}#wpadminbar #wp-admin-bar-vaa code{font-family:Consolas,Monaco,monospace}#wpadminbar #wp-admin-bar-vaa .vaa-sub-transparent>*{opacity:.5;transition:opacity .2s}#wpadminbar #wp-admin-bar-vaa .vaa-sub-transparent:hover>*,#wpadminbar #wp-admin-bar-vaa .vaa-sub-transparent .active,#wpadminbar #wp-admin-bar-vaa .vaa-sub-transparent .active ~ *{opacity:1}#wpadminbar #wp-admin-bar-vaa .ab-vaa-results{margin:6px 0;padding:0}#wpadminbar #wp-admin-bar-vaa .ab-vaa-results.vaa-auto-max-height{margin-right:10px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-results:empty{display:none}#wpadminbar #wp-admin-bar-vaa ul.ab-sub-secondary+ul.ab-sub-secondary{margin-top:3px}#wpadminbar #wp-admin-bar-vaa .menupop ul+ul,#wpadminbar #wp-admin-bar-vaa .menupop ul.ab-sub-secondary+ul.ab-sub-secondary{margin-top:2px}#wpadminbar #wp-admin-bar-vaa .menupop .menupop ul+ul,#wpadminbar #wp-admin-bar-vaa .menupop .menupop ul.ab-sub-secondary+ul.ab-sub-secondary{margin-top:1px}#wpadminbar #wp-admin-bar-vaa ul:not(.ab-sub-secondary)+ul.ab-sub-secondary,#wpadminbar #wp-admin-bar-vaa ul.ab-sub-secondary+ul:not(.ab-sub-secondary){margin-top:0}#wpadminbar #wp-admin-bar-vaa .menupop .ab-sub-wrapper ul.vaa-toggle-group{padding:3px 0 4px}#wpadminbar #wp-admin-bar-vaa .menupop .ab-sub-wrapper ul.vaa-toggle-group li.active ~ li:last-child{padding-bottom:3px}#wpadminbar #wp-admin-bar-vaa .auto-height>.ab-item{height:auto}#wpadminbar #wp-admin-bar-vaa .ab-item .description{height:auto;line-height:1.2;font-size:.8em;font-style:italic;margin-bottom:7px;white-space:normal;color:inherit}#wpadminbar #wp-admin-bar-vaa .ab-item .description:first-child:not(:only-child){margin-bottom:0}#wpadminbar #wp-admin-bar-vaa .ab-item .description .ab-icon{line-height:1 !important;font-size:1em !important;padding:1px 0;margin-right:3px;width:auto;height:1em}#wpadminbar #wp-admin-bar-vaa.menupop .ab-vaa-title>.ab-item{font-weight:bold;line-height:26px;font-size:1.1em;text-transform:uppercase}#wpadminbar #wp-admin-bar-vaa .current>.ab-item,#wpadminbar #wp-admin-bar-vaa .current>.ab-item .vaa-view-data,#wpadminbar #wp-admin-bar-vaa .current>input:checked+label,#wpadminbar #wp-admin-bar-vaa .current-parent>.ab-item,#wpadminbar #wp-admin-bar-vaa .current-parent>.ab-item .vaa-view-data,#wpadminbar #wp-admin-bar-vaa .current-parent>label{font-weight:bold}#wpadminbar #wp-admin-bar-vaa .current>.ab-item::after,#wpadminbar #wp-admin-bar-vaa .current>label::after{content:'\f177';font-family:'dashicons';margin:0 5px;font-size:17px;vertical-align:middle;font-weight:normal}#wpadminbar #wp-admin-bar-vaa .current.ab-vaa-title>.ab-item::after{vertical-align:top}#wpadminbar #wp-admin-bar-vaa .ab-item .ab-icon.alignright{float:right;margin-right:0;margin-left:6px}#wpadminbar #wp-admin-bar-vaa>.ab-item .ab-icon{top:2px}#wpadminbar #wp-admin-bar-vaa>.ab-item .ab-label{float:left}#wpadminbar #wp-admin-bar-vaa>.ab-item .ab-label .ab-icon{margin-right:-3px}#wpadminbar #wp-admin-bar-vaa .ab-icon.vaa-icon-image{width:16px;height:16px;background-size:100% auto !important;background:center left no-repeat;display:inline-block}#wpadminbar>#wp-toolbar>#wp-admin-bar-root-default #wp-admin-bar-vaa .vaa-has-icon>.ab-item>.ab-icon,#wpadminbar #wp-admin-bar-vaa .vaa-has-icon>.ab-item .ab-icon{float:none;font-weight:normal !important;font-size:16px;line-height:16px;vertical-align:text-bottom;padding:0}#wpadminbar #wp-admin-bar-vaa .vaa-has-icon>.ab-item::before{display:none}#wpadminbar #wp-admin-bar-vaa .vaa-has-icon.menupop>.ab-item{padding-left:10px;padding-right:10px}#wpadminbar #wp-admin-bar-vaa .vaa-has-icon.ab-vaa-title>.ab-item>.ab-icon{font-size:18px;line-height:20px;margin:0 5px 0 -1px}#wpadminbar #wp-admin-bar-vaa .vaa-has-icon.ab-vaa-title>.ab-item>.ab-icon.vaa-icon-image{width:18px;height:18px}#wpadminbar .ab-top-secondary .menupop .vaa-menupop>.ab-item{padding-left:2em;padding-right:1em}#wpadminbar .ab-top-secondary .menupop .vaa-menupop>.ab-item .ab-icon{margin-left:-20px;margin-right:4px}#wpadminbar #wp-admin-bar-vaa.menupop ul.ab-sub-secondary{position:static}#wpadminbar #wp-admin-bar-vaa.menupop .menupop>.ab-item:before{top:1px}#wpadminbar #vaa-combine-views-selection .ab-item{padding-right:28px}#wpadminbar #vaa-combine-views-selection .ab-item .remove{position:absolute;right:4px}#wpadminbar #wp-admin-bar-vaa button>.ab-icon{margin:0 5px 0 -5px;padding:0;top:0}#wpadminbar #wp-admin-bar-vaa .ab-item>label+button{margin:0 0 0 12px;vertical-align:baseline}#wpadminbar #wp-admin-bar-vaa .vaa-button-container>.ab-item{overflow:hidden;height:auto}#wpadminbar #wp-admin-bar-vaa button{float:none;text-decoration:none;font-size:13px;line-height:20px;height:20px;margin:3px 0;padding:0 10px 1px;vertical-align:middle;cursor:pointer}#wpadminbar #wp-admin-bar-vaa .vaa-icon{padding:0 2px 1px}#wpadminbar #wp-admin-bar-vaa .vaa-icon .ab-icon{margin:0}#wpadminbar #wp-admin-bar-vaa button.vaa-icon .ab-icon{padding:0}#wpadminbar #wp-admin-bar-vaa .vaa-tooltip{position:absolute !important;display:none;opacity:0;transition:all .2s;right:12px;top:0;padding:10px 15px;width:140px;height:auto;font-size:11px;line-height:1.2em;text-align:center;white-space:normal;border-radius:3px;border:1px solid rgba(175,175,175,0.5);box-shadow:0 0 15px rgba(0,0,0,0.2);z-index:99999}#wpadminbar>#wp-toolbar>#wp-admin-bar-root-default #wp-admin-bar-vaa .vaa-help,#wpadminbar #wp-admin-bar-vaa .vaa-help{float:right;text-align:right;padding:0;font-size:16px;line-height:inherit !important;margin:0 0 0 5px}#wpadminbar #wp-admin-bar-vaa .vaa-help ~ label+select,#wpadminbar #wp-admin-bar-vaa .vaa-help ~ label+input,#wpadminbar #wp-admin-bar-vaa .vaa-help ~ input+label{margin-right:20px}#wpadminbar #wp-admin-bar-vaa .vaa-help:hover{cursor:help}#wpadminbar #wp-admin-bar-vaa .vaa-help:hover .vaa-tooltip{display:inline-block;opacity:1}#wpadminbar #wp-admin-bar-vaa .vaa-auto-max-height{min-height:26px;overflow-y:auto;transition:max-height .3s}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect .ab-item,#wpadminbar #wp-admin-bar-vaa .ab-vaa-input .ab-item,#wpadminbar #wp-admin-bar-vaa .ab-vaa-file .ab-item,#wpadminbar #wp-admin-bar-vaa .ab-vaa-search .ab-item,#wpadminbar #wp-admin-bar-vaa .ab-vaa-filter .ab-item,#wpadminbar #wp-admin-bar-vaa .ab-vaa-select .ab-item{height:auto;clear:both}#wpadminbar #wp-admin-bar-vaa .ab-vaa-input .ab-item input,#wpadminbar #wp-admin-bar-vaa .ab-vaa-file .ab-item input,#wpadminbar #wp-admin-bar-vaa .ab-vaa-search .ab-item input,#wpadminbar #wp-admin-bar-vaa .ab-vaa-filter .ab-item input,#wpadminbar #wp-admin-bar-vaa .ab-vaa-select .ab-item select{display:inline-block;background:#fff;color:#555;margin:5px 0;padding:3px;border:0;line-height:normal;height:auto;width:100%;box-sizing:border-box}#wpadminbar #wp-admin-bar-vaa .ab-vaa-select .ab-item select{padding:2px 3px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-select .ab-item label+input,#wpadminbar #wp-admin-bar-vaa .ab-vaa-select .ab-item label+select{margin-top:0}#wpadminbar #wp-admin-bar-vaa .ab-vaa-textarea .ab-item{height:auto;line-height:normal}#wpadminbar #wp-admin-bar-vaa .ab-vaa-textarea .ab-item textarea{width:100%;padding:5px;margin-top:5px;box-sizing:border-box;line-height:normal}#wpadminbar #wp-admin-bar-vaa .ab-item input.vaa-wide,#wpadminbar #wp-admin-bar-vaa .ab-item select.vaa-wide{display:block;box-sizing:border-box;width:100%;margin:5px 0}#wpadminbar #wp-admin-bar-vaa .ab-item select+button.input-overlay,#wpadminbar #wp-admin-bar-vaa .ab-item input+button.input-overlay{position:absolute;right:10px;margin:5px 0}#wpadminbar #wp-admin-bar-vaa input.checkbox,#wpadminbar #wp-admin-bar-vaa input.radio{display:inline-block;height:16px;width:16px;vertical-align:text-bottom;box-sizing:border-box;cursor:pointer}#wpadminbar #wp-admin-bar-vaa .ab-item input.checkbox,#wpadminbar #wp-admin-bar-vaa .ab-item input.radio{margin:0 6px 0 0}#wpadminbar #wp-admin-bar-vaa .ab-item input.radio{border-radius:100%}#wpadminbar #wp-admin-bar-vaa .ab-item input.checkbox+label,#wpadminbar #wp-admin-bar-vaa .ab-item input.checkbox+label *,#wpadminbar #wp-admin-bar-vaa .ab-item input.radio+label,#wpadminbar #wp-admin-bar-vaa .ab-item input.radio+label *{line-height:18px;vertical-align:text-top;display:inline-block}#wpadminbar #wp-admin-bar-vaa .ab-item input.checkbox+label:hover,#wpadminbar #wp-admin-bar-vaa .ab-item input.radio+label:hover{cursor:pointer}#wpadminbar #wp-admin-bar-vaa .ab-item input.radio+label+br{line-height:0}#wpadminbar #wp-admin-bar-vaa input.checkbox.vaa-right,#wpadminbar #wp-admin-bar-vaa input.radio.vaa-right{position:absolute;top:5px;right:1em;z-index:99}#wpadminbar #wp-admin-bar-vaa .ab-item .vaa-radio-wrapper{line-height:20px}#wpadminbar #wp-admin-bar-vaa .ab-item .vaa-radio-wrapper p.description,#wpadminbar #wp-admin-bar-vaa .ab-item .vaa-radio-wrapper:first-of-type{margin-top:6px}#wpadminbar #wp-admin-bar-vaa .ab-item .vaa-radio-wrapper:last-of-type{margin-bottom:6px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect{max-height:400px;min-width:250px;overflow:hidden;overflow-y:auto;margin:6px 10px;padding:0;background-color:#fff}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect:empty{height:0;margin:0;padding:0}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect .ab-empty-item{height:auto;overflow:hidden;margin:0;padding:5px 10px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect .ab-empty-item .ab-item{color:#333}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect.vaa-small{max-height:100px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect .remove:before{color:#333}#wpadminbar #wp-admin-bar-vaa .vaa-column-one-half{width:50%;display:block;float:left;clear:none}#wpadminbar #wp-admin-bar-vaa .vaa-column-one-half .ab-item{min-width:0}#wpadminbar #wp-admin-bar-vaa .vaa-column-one-half.vaa-column-first .ab-item{padding-right:1px}#wpadminbar #wp-admin-bar-vaa .vaa-column-one-half.vaa-column-last .ab-item{padding-left:1px}#wpadminbar #wp-admin-bar-vaa .vaa-clear-float{clear:both}#wpadminbar #wp-admin-bar-vaa .ab-vaa-toggle>.ab-item{padding-right:34px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-toggle>.ab-item:hover{cursor:pointer}#wpadminbar #wp-admin-bar-vaa .ab-vaa-toggle>.ab-item::after{content:"\f140";font-family:'dashicons';position:absolute;right:10px;margin:0;font-size:20px;font-weight:normal}#wpadminbar #wp-admin-bar-vaa .ab-vaa-toggle.active>.ab-item::after{content:"\f142"}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper,#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper .ab-item{display:none}#wpadminbar #wp-admin-bar-vaa.fullPopupActive>.ab-sub-wrapper{display:block}#wpadminbar #wp-admin-bar-vaa.fullPopupActive>.ab-sub-wrapper>.ab-submenu{padding:0}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup{position:fixed;display:block;visibility:visible;overflow:hidden;z-index:999;max-height:90%;width:90%;margin:5%;top:0;left:0;box-shadow:0 0 50px rgba(0,0,0,0.3)}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup .ab-item{display:block}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup>ul::after{display:table;clear:both;content:' '}#wpadminbar #wp-admin-bar-vaa #wp-admin-bar-vaa-caps #apply-caps-view{float:left;margin-right:5px}#wpadminbar #wp-admin-bar-vaa #wp-admin-bar-vaa-caps #reset-caps-view,#wpadminbar #wp-admin-bar-vaa #wp-admin-bar-vaa-caps #open-caps-popup,#wpadminbar #wp-admin-bar-vaa #wp-admin-bar-vaa-caps #close-caps-popup{float:right;margin-left:5px;height:auto}#wpadminbar #wp-admin-bar-vaa #wp-admin-bar-vaa-caps #close-caps-popup{display:none}#wpadminbar #wp-admin-bar-vaa.fullPopupActive #wp-admin-bar-vaa-caps .ab-sub-wrapper.fullPopup #close-caps-popup{display:block}#wpadminbar #wp-admin-bar-vaa.fullPopupActive #wp-admin-bar-vaa-caps .ab-sub-wrapper.fullPopup #open-caps-popup{display:none}#wpadminbar #wp-admin-bar-vaa.fullPopupActive #wp-admin-bar-vaa-caps .ab-sub-wrapper.fullPopup #wp-admin-bar-vaa-caps-select-options .vaa-cap-item{width:250px;float:left;clear:none}#wpadminbar #wp-admin-bar-vaa.fullPopupActive #wp-admin-bar-vaa-caps .ab-sub-wrapper.fullPopup #wp-admin-bar-vaa-caps-select-options .vaa-cap-item .remove{margin-right:6px}#wpadminbar #wp-admin-bar-vaa #wp-admin-bar-vaa-caps-popup:hover{cursor:pointer}#wpadminbar #wp-admin-bar-my-account-default{z-index:999999}#wpadminbar #wp-admin-bar-my-account #wp-admin-bar-vaa>.ab-item .ab-label{line-height:26px}#wpadminbar #wp-admin-bar-my-account #wp-admin-bar-vaa>.ab-item .ab-icon{top:0}#vaa_toolbar #wpadminbar{position:fixed !important;width:auto;min-width:0;right:0;left:auto;border-radius:0 0 0 5px}#vaa_toolbar #wpadminbar #wp-admin-bar-vaa>.ab-item .ab-icon{margin-left:0}#vaa_toolbar #wpadminbar #wp-admin-bar-vaa>.ab-item .ab-label{display:none}#vaa_toolbar #wpadminbar #wp-admin-bar-vaa:hover>.ab-item .ab-icon{margin-left:6px}#vaa_toolbar #wpadminbar #wp-admin-bar-vaa:hover>.ab-item .ab-label{display:inline-block}@media screen and (min-width:783px){#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul{overflow:hidden}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul li.ab-vaa-input,#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul li.ab-vaa-select{float:left;clear:none;width:auto}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul li.ab-vaa-input button{margin:5px 0}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul li.ab-vaa-input input,#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul li.ab-vaa-select select{width:auto}#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul li.ab-vaa-input input+button.input-overlay,#wpadminbar #wp-admin-bar-vaa.fullPopupActive .ab-sub-wrapper.fullPopup ul li.ab-vaa-select select+button.input-overlay{position:static;vertical-align:top}}@media screen and (max-width:782px){#wpadminbar #wp-admin-bar-vaa{display:block;position:static}#wpadminbar #wp-admin-bar-vaa>.ab-item>.ab-icon{margin-left:0}#wpadminbar #wp-admin-bar-vaa .ab-sub-wrapper{width:100%}#wpadminbar #wp-admin-bar-vaa .ab-sub-wrapper .ab-sub-wrapper{position:static;top:auto;margin:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}#wpadminbar #wp-admin-bar-vaa.menupop .menupop>.ab-item:before{content:''}#wpadminbar #wp-admin-bar-vaa .ab-item .vaa-hide-responsive{display:none}#wpadminbar #wp-admin-bar-vaa .menupop>.ab-sub-wrapper .ab-item.description,#wpadminbar #wp-admin-bar-vaa .ab-item p.description{display:block !important;padding-left:0;padding-right:0;margin-bottom:0}#wpadminbar #wp-admin-bar-vaa .vaa-help{display:block;padding:8px 0;float:none;text-align:left;margin:0}#wpadminbar #wp-admin-bar-vaa .ab-item .vaa-help:empty{display:none}#wpadminbar #wp-admin-bar-vaa .vaa-tooltip{font-size:13px;display:inline-block;position:static !important;opacity:1;border:0;padding:0 !important;margin-left:5px !important;width:auto;vertical-align:text-top;line-height:20px}#wpadminbar #wp-admin-bar-vaa .vaa-notice{line-height:42px;font-size:16px}#wpadminbar #wp-admin-bar-vaa .vaa-notice .ab-icon{height:auto}#wpadminbar #wp-admin-bar-vaa>div>ul,#wpadminbar #wp-admin-bar-vaa .menupop>.ab-sub-wrapper .ab-submenu{padding:5px 0}#wpadminbar #wp-admin-bar-vaa .menupop>.ab-sub-wrapper .ab-item{padding:8px 44px;white-space:normal;height:auto}#wpadminbar #wp-admin-bar-vaa .menupop>.ab-sub-wrapper .ab-item>.ab-item{padding:8px 0}#wpadminbar #wp-admin-bar-vaa .menupop>.ab-sub-wrapper:last-child .ab-item.description{margin-bottom:0}#wpadminbar #wp-admin-bar-vaa .ab-item>span.remove,#wpadminbar #wp-admin-bar-vaa .vaa-has-icon .ab-item .ab-icon{width:auto;height:auto;font-size:22px !important;margin-right:10px;vertical-align:text-top}#wpadminbar #wp-admin-bar-vaa .vaa-has-icon .ab-item .ab-icon.vaa-icon-image{width:22px;height:22px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-title.vaa-has-icon>.ab-item>.ab-icon{font-size:30px !important;margin-left:-6px;margin-top:-1px;vertical-align:top}#wpadminbar #wp-admin-bar-vaa .ab-vaa-title.vaa-has-icon>.ab-item>.ab-icon.vaa-icon-image{width:30px;height:30px}#wpadminbar #wp-admin-bar-vaa .vaa-has-icon.menupop>.ab-item{padding-left:12px;padding-right:12px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-title.vaa-has-icon.menupop>.ab-item{padding-left:16px}#wpadminbar #wp-admin-bar-vaa .vaa-menupop div li{margin-left:12px}#wpadminbar #vaa-combine-views-selection .ab-item{padding-right:48px}#wpadminbar #vaa-combine-views-selection .ab-item>span.remove{margin-right:0;padding:10px;top:0;right:0}#wpadminbar #wp-admin-bar-vaa .ab-sub-wrapper .vaa-role-item.menupop>.ab-item{padding-left:15px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-toggle>.ab-item::after,#wpadminbar #wp-admin-bar-vaa .ab-sub-wrapper .vaa-menupop.menupop>.ab-item:after{content:"\f140";font-family:'dashicons';position:absolute;right:10px;top:8px;margin:0;font-size:30px;font-weight:normal}#wpadminbar #wp-admin-bar-vaa .ab-vaa-toggle.active>.ab-item::after,#wpadminbar #wp-admin-bar-vaa .ab-sub-wrapper .vaa-menupop.menupop.active>.ab-item:after{content:"\f142"}#wpadminbar #wp-admin-bar-vaa button{font-size:16px;padding:5px 15px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-input .ab-item input,#wpadminbar #wp-admin-bar-vaa .ab-vaa-search .ab-item input,#wpadminbar #wp-admin-bar-vaa .ab-vaa-filter .ab-item input{padding:8px 12px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-select .ab-item select{padding:7px 12px}#wpadminbar #wp-admin-bar-vaa .ab-item select+button.input-overlay,#wpadminbar #wp-admin-bar-vaa .ab-item input+button.input-overlay{right:44px;padding:6px 10px 7px;font-size:14px}#wpadminbar #wp-admin-bar-vaa .ab-vaa-multipleselect{border-width:0 44px;max-height:300px !important}#wpadminbar #wp-admin-bar-vaa .menupop>.ab-sub-wrapper .ab-vaa-multipleselect>.ab-item{padding:8px 16px}#wpadminbar #wp-admin-bar-vaa input.checkbox,#wpadminbar #wp-admin-bar-vaa input.radio{width:24px;height:24px}#wpadminbar #wp-admin-bar-vaa input.checkbox.vaa-right,#wpadminbar #wp-admin-bar-vaa input.radio.vaa-right{top:9px;right:11px}#wpadminbar #wp-admin-bar-vaa .ab-item .vaa-radio-wrapper{margin:6px 0}#vaa_toolbar{display:none !important}} \ No newline at end of file diff --git a/assets/js/view-admin-as.js b/assets/js/view-admin-as.js index 4aa9e6b6..3e2329fc 100644 --- a/assets/js/view-admin-as.js +++ b/assets/js/view-admin-as.js @@ -6,7 +6,7 @@ * @author Jory Hogeveen * @package View_Admin_As * @since 0.1.0 - * @version 1.8.1 + * @version 1.8.2 * @preserve */ /* eslint-enable no-extra-semi */ @@ -39,12 +39,12 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { ( function( $ ) { VAA_View_Admin_As.prefix = '#wpadminbar #wp-admin-bar-vaa '; - VAA_View_Admin_As.root = '#wp-admin-bar-vaa'; + VAA_View_Admin_As.root = '#wp-admin-bar-vaa'; var $document = $( document ), - $window = $( window ), - $body = $('body'), - $vaa = $( VAA_View_Admin_As.prefix ); // Validated in load(). + $window = $( window ), + $body = $('body'), + $vaa = $( VAA_View_Admin_As.prefix ); // Validated in load(). VAA_View_Admin_As.maxHeightListenerElements = null; VAA_View_Admin_As._mobile = false; @@ -169,7 +169,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { */ $( '[vaa-showhide]', $vaa ).each( function() { var $this = $(this), - args = VAA_View_Admin_As.maybe_json_decode( $this.attr('vaa-showhide') ), + args = VAA_View_Admin_As.maybe_json_decode( $this.attr('vaa-showhide') ), delay = 200; if ( 'object' !== typeof args ) { args = { 0: { target: args, delay: delay } }; @@ -241,14 +241,57 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { } ); // @since 1.7.4 Auto resizable. + // @since 1.8.2 Enhance height calc + provide trigger for content changes $( '.vaa-resizable', $vaa ).each( function() { - var $this = $(this), - height = $this.css( 'max-height' ); - $this.css( { - 'max-height': 'none', - 'height': height, - 'resize': 'vertical' - } ); + var $this = $(this), + maxHeight = parseInt( $this.css( 'max-heights' ), 10 ), + height, innerHeight, newHeight; + + // Check for empty containers. + $this.find( '.ab-empty-item:empty' ).remove(); + + $this.on( 'vaa-resizable', function() { + if ( $this.is( ':empty' ) ) { + $this.css( { + 'max-height': '', + 'height': '', + 'resize': '' + } ); + return; + } + newHeight = maxHeight; + height = $this.height(); + $this.css( { + 'max-height': '', + 'height': '', + 'resize': '' + } ); + if ( height ) { + $this.css( { 'max-height': 'none' } ); + innerHeight = $this.height(); + $this.css( { 'max-height': '' } ); + if ( innerHeight < maxHeight ) { + // New content height is reduces below max height. + newHeight = innerHeight; + } else if ( height >= maxHeight ) { + // Box was resized and new content is still higher than the max height. + if ( innerHeight < height ) { + // The new content is lower than the current resized height. + newHeight = innerHeight; + } else { + // Content is above current height, keep it as is. + newHeight = height; + } + } + } + if ( newHeight && ( ! height || newHeight >= maxHeight ) ) { + $this.css( { + 'max-height': 'none', + 'height': ( newHeight ) ? newHeight + 'px' : '', + 'resize': 'vertical' + } ); + } + } ).trigger('vaa-resizable'); // Trigger on load. } ); // Process reset. @@ -400,13 +443,13 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { $overlay.fadeIn('fast'); // Remove overlay. - $( '.remove', $overlay ).click( function() { + $overlay.find( '.remove' ).click( function() { VAA_View_Admin_As.overlay( false ); } ); // Remove overlay on click outside of container. $document.on( 'mouseup.vaa_overlay', function( e ) { - $( '.vaa-popup', $overlay ).each( function() { + $overlay.find( '.vaa-popup' ).each( function() { if ( ! $(this).is( e.target ) && 0 === $(this).has( e.target ).length ) { VAA_View_Admin_As.overlay( false ); return false; @@ -465,7 +508,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { $.post( VAA_View_Admin_As.ajaxurl, post_data, function( response ) { var success = ( response.hasOwnProperty( 'success' ) && true === response.success ), - data = {}, + data = {}, display = false; // Maybe show debug info in console. @@ -587,8 +630,8 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { * @return {void} Nothing. */ VAA_View_Admin_As.item_notice = function( parent, notice, type, timeout ) { - var root = '.vaa-notice', - html = notice + '', + var root = '.vaa-notice', + html = notice + '', $element = $( parent ); type = ( 'undefined' === typeof type ) ? 'notice' : type; @@ -649,10 +692,10 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { html += '

' + String( data.text ) + '

'; } // List items. - if ( data.hasOwnProperty( 'list' ) ) { + if ( data.hasOwnProperty( 'list' ) && 'object' === typeof data.list ) { html += '
    '; - data.list.forEach( function( item ) { - html += '
  • ' + String( item ) + '
  • '; + $.each( data.list, function ( key, value ) { + html += '
  • ' + String( value ) + '
  • '; } ); html += '
'; } @@ -670,9 +713,9 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { /* * Overlay handlers. */ - var root = '#vaa-overlay', - $overlay = $( root ), - $popup = $( root + ' .vaa-popup' ), + var root = '#vaa-overlay', + $overlay = $( root ), + $popup = $( root + ' .vaa-popup' ), $popup_content = $( root + ' .vaa-popup-content' ); var textarea = $( 'textarea', $popup_content ); @@ -706,7 +749,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { * @return {void} Nothing. */ VAA_View_Admin_As.download = function( data ) { - var content = '', + var content = '', filename = ''; if ( 'string' === typeof data ) { content = data; @@ -751,7 +794,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { $( VAA_View_Admin_As.root + ' [vaa-auto-js]' ).each( function() { var $this = $(this), - data = VAA_View_Admin_As.maybe_json_decode( $this.attr('vaa-auto-js') ); + data = VAA_View_Admin_As.maybe_json_decode( $this.attr('vaa-auto-js') ); if ( 'object' !== typeof data ) { return; } @@ -797,10 +840,10 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { if ( 'object' !== typeof data ) { return; } - var $elem = $( elem ), - setting = ( data.hasOwnProperty( 'setting' ) ) ? String( data.setting ) : null, - confirm = ( data.hasOwnProperty( 'confirm' ) ) ? Boolean( data.confirm ) : false, - refresh = ( data.hasOwnProperty( 'refresh' ) ) ? Boolean( data.refresh ) : false; + var $elem = $( elem ), + setting = ( data.hasOwnProperty( 'setting' ) ) ? String( data.setting ) : null, + confirm = ( data.hasOwnProperty( 'confirm' ) ) ? Boolean( data.confirm ) : false, + refresh = ( data.hasOwnProperty( 'refresh' ) ) ? Boolean( data.refresh ) : false; // Callback overwrite. if ( data.hasOwnProperty('callback') ) { @@ -857,7 +900,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { return null; } var stop = false, - val = null; + val = null; if ( data.hasOwnProperty( 'values' ) ) { val = {}; $.each( data.values, function( val_key, auto_js ) { @@ -871,7 +914,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { if ( null !== val_val ) { val[ val_key ] = val_val; } else if ( auto_js.required ) { - val = null; + val = null; stop = true; return false; } @@ -972,9 +1015,9 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { data = {}; } var $elem = $( elem ), - val = null, - attr = ( data.hasOwnProperty( 'attr' ) ) ? String( data.attr ) : false, - json = ( data.hasOwnProperty( 'json' ) ) ? Boolean( data.json ) : false, + val = null, + attr = ( data.hasOwnProperty( 'attr' ) ) ? String( data.attr ) : false, + json = ( data.hasOwnProperty( 'json' ) ) ? Boolean( data.json ) : false, value = ( attr ) ? $elem.attr( attr ) : $elem.val(); if ( 'checkbox' === $elem.attr( 'type' ) ) { @@ -1014,33 +1057,42 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { **/ VAA_View_Admin_As.init_users = function() { - var root = VAA_View_Admin_As.root + '-users', - root_prefix = VAA_View_Admin_As.prefix + root, - $root = $( root_prefix ), - $search_node = $( root_prefix + ' .ab-vaa-search.search-users' ); - - if ( ! $search_node.length ) { - return; - } - - var search_ajax = $search_node.hasClass('search-ajax'), - ajax_delay_timer, - $search_results = $search_node.find( '.ab-vaa-results' ), - no_results = '
' + VAA_View_Admin_As.__no_users_found + '
'; - - // Search users. - $root.on( 'keyup', '.ab-vaa-search.search-users input', function() { - $search_results.empty(); - var $this = $(this), - search = $this.val(); - if ( 1 <= search.trim().length ) { - if ( search_ajax ) { - search_users_ajax( search ); + var root = VAA_View_Admin_As.root + '-users', + root_prefix = VAA_View_Admin_As.prefix + root, + $root = $( root_prefix ), + $search_node = $( root_prefix + ' .ab-vaa-search.search-users' ), + ajax_delay_timer; + + if ( $search_node.length ) { + + var search_ajax = $search_node.hasClass('search-ajax'), + $search_results = $search_node.find( '.ab-vaa-results' ), + no_results = '
' + VAA_View_Admin_As.__no_users_found + '
'; + + // Search users. + $root.on( 'keyup', '.ab-vaa-search.search-users input', function() { + var $this = $(this), + search = $this.val(); + + if ( 1 <= search.trim().length ) { + if ( search_ajax ) { + search = { + 'search': search, + 'return': 'links' + }; + var search_by = $root.find( '.ab-vaa-search.search-users select' ).val(); + if ( search_by ) { + search[ 'search_by' ] = search_by; + } + VAA_View_Admin_As.search_users_ajax( search, $search_results ); + } else { + search_users( search ); + } } else { - search_users( search ); + VAA_View_Admin_As.search_users_ajax( null, $search_results ); } - } - } ); + } ); + } /** * Search users from the DOM. @@ -1051,22 +1103,24 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { * @return {void} Nothing. */ function search_users( search ) { + $search_results.empty(); $( VAA_View_Admin_As.prefix + '.vaa-user-item' ).each( function() { - var name = $( '.ab-item', this ).text(); + var $this = $(this), + name = $this.find( '.ab-item' ).text(); if ( -1 < name.toLowerCase().indexOf( search.toLowerCase() ) ) { var exists = false; - $( '.vaa-user-item .ab-item', $search_results ).each(function() { + $search_results.find( '.vaa-user-item .ab-item' ).each(function() { if ( -1 < $(this).text().indexOf( name ) ) { exists = $(this); } } ); - var role = $(this).parents('.vaa-role-item').find('> .ab-item > .vaa-view-data'); + var role = $this.parents('.vaa-role-item').find( '> .ab-item > .vaa-view-data' ); role = ( role ) ? role.text() : ''; if ( role && false !== exists && exists.length ) { exists.find('.user-role').text( exists.find('.user-role').text().replace( ')', ', ' + role + ')' ) ); } else { role = ( role ) ? '  (' + role + ')' : ''; - $(this).clone() + $this.clone() .appendTo( $search_results ) .children('.ab-item') .append( role ); @@ -1083,26 +1137,29 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { * Search users with AJAX. * * @since 1.8.0 - * @param {string} search The search value. + * @since 1.8.2 Refactored for general use. + * @param {object} search The search parameters. Pass empty value to reset results container. + * @param {object|function} results_container The results container element. Can also be a callback. * @return {void} Nothing. */ - function search_users_ajax( search ) { + VAA_View_Admin_As.search_users_ajax = function( search, results_container ) { clearTimeout( ajax_delay_timer ); + var $results_container = $( results_container ); - var search_by = $( '.ab-vaa-search.search-users select', $root ).val(); - if ( search_by ) { - search = { - 'search': search, - 'search_by': search_by - }; + // Reset. + if ( ! search ) { + $results_container.empty(); + if ( $results_container.hasClass( 'vaa-resizable' ) ) { + $results_container.trigger('vaa-resizable'); + } + return; } ajax_delay_timer = setTimeout( function() { + $results_container.html( '
. . .
' ); - $search_results.html( '
. . .
' ); - - var $loading = $( '.ab-item', $search_results ), - loading = '. . . ', + var $loading = $( '.ab-item', $results_container ), + loading = '. . . ', loading_interval = setInterval( function() { if ( 20 < loading.length ) { loading = '. . . '; @@ -1120,13 +1177,28 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { $.post( VAA_View_Admin_As.ajaxurl, post_data, function( response ) { clearInterval( loading_interval ); clearTimeout( ajax_delay_timer ); + + // Run optional callback. + if ( 'function' === typeof results_container ) { + results_container( response ); + return; + } + if ( response.hasOwnProperty( 'success' ) && response.success ) { - $search_results.html( response.data ); + $results_container.html( response.data ); VAA_View_Admin_As.reinit_combine_views(); } else { - $search_results.html( no_results ); + $results_container.html( no_results ); + if ( response.hasOwnProperty( 'data' ) && 'string' === typeof response.data ) { + $results_container.children().first().html( response.data ); + } + } + if ( $results_container.hasClass( 'vaa-resizable' ) ) { + $results_container.trigger('vaa-resizable'); + } + if ( $results_container.hasClass( 'vaa-auto-max-height' ) ) { + VAA_View_Admin_As.autoMaxHeight(); } - VAA_View_Admin_As.autoMaxHeight(); } ); }, 500 ); @@ -1140,9 +1212,9 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { **/ VAA_View_Admin_As.init_caps = function() { - var root = VAA_View_Admin_As.root + '-caps', + var root = VAA_View_Admin_As.root + '-caps', root_prefix = VAA_View_Admin_As.prefix + root, - $root = $( root_prefix ); + $root = $( root_prefix ); VAA_View_Admin_As.caps_filter_settings = { selectedRole : 'default', @@ -1153,12 +1225,12 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { // Filter capability handler. VAA_View_Admin_As.filter_capabilities = function() { - var reverse = ( true === VAA_View_Admin_As.caps_filter_settings.selectedRoleReverse ), - isDefault = ( 'default' === VAA_View_Admin_As.caps_filter_settings.selectedRole ), + var reverse = ( true === VAA_View_Admin_As.caps_filter_settings.selectedRoleReverse ), + isDefault = ( 'default' === VAA_View_Admin_As.caps_filter_settings.selectedRole ), filterString = VAA_View_Admin_As.caps_filter_settings.filterString; $( root_prefix + '-select-options .vaa-cap-item' ).each( function() { - var $this = $(this), + var $this = $(this), exists = ( $( 'input', this ).attr('value') in VAA_View_Admin_As.caps_filter_settings.selectedRoleCaps ), name; @@ -1290,7 +1362,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { /** * Combine views tool. * @since 1.8.0 - * @return {null} Nothing. + * @return {void} Nothing. */ VAA_View_Admin_As.init_combine_views = function() { @@ -1298,12 +1370,12 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { prefix = 'vaa-combine-views', root_prefix = VAA_View_Admin_As.prefix + root, $root = $( root_prefix ), + is_active = false, combine_types = $.extend( [], VAA_View_Admin_As.view_types ), combine_selectors = [], selection = {}, $selection_container = root_prefix + ' #' + prefix + '-selection', - $combine_items, - is_active = false; + $combine_items; if ( ! $root.length ) { return; @@ -1380,24 +1452,24 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { // Late selection init needed for frontend. var $elements = $( elements ); $elements.each( function () { - var $this = $( this ), - $parent = $this.parent(), - val = null, - text = $this.text(), + var $this = $( this ), + $parent = $this.parent(), + val = null, + text = $this.text(), $data_el = $this.find('.vaa-view-data'), - type_label, + label, attr; if ( $parent.find('.vaa-combine-item').length ) { // Already exists. return true; } if ( $data_el.length ) { - val = $data_el.attr('vaa-view-value'); - text = $data_el.text(); - type_label = $data_el.attr('vaa-view-type-label'); + val = $data_el.attr('vaa-view-value'); + text = $data_el.text(); + label = $data_el.attr('vaa-view-type-label'); } if ( 'caps' === type ) { - val = ''; + val = ''; text = $( VAA_View_Admin_As.root + '-caps-title > .ab-item' ).text(); } attr = [ @@ -1408,8 +1480,8 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { 'vaa-view-text="' + text + '"', 'style="display:none;"' ]; - if ( type_label ) { - attr.push( 'vaa-view-type-label="' + type_label + '"' ); + if ( label ) { + attr.push( 'vaa-view-type-label="' + label + '"' ); } $parent.prepend( '' ); } ); @@ -1470,8 +1542,8 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { */ function deactivate_combine_type( types, update ) { if ( 'object' !== typeof types ) { - type = types; - types = {}; + type = types; + types = {}; types[ type ] = 0; } for ( var type in types ) { @@ -1491,7 +1563,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { // Remove view types that are deselected. $( root_prefix + ' .vaa-combine-selection' ).each( function() { var $this = $(this), - type = $this.attr('vaa-view-type'); + type = $this.attr('vaa-view-type'); if ( ! selection.hasOwnProperty( type ) ) { $this.slideUp( 'fast', function() { $( this ).remove() } ); } @@ -1499,9 +1571,9 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { // Append or update view types selection. $.each( selection, function( type, data ) { - var text = data.el.attr('vaa-view-text') + '', + var text = data.el.attr('vaa-view-text') + '', $existing = $( root_prefix + ' .vaa-combine-selection-' + type ), - label = data.el.attr( 'vaa-view-type-label' ); + label = data.el.attr( 'vaa-view-type-label' ); if ( label ) { text = '' + label + ': ' + text; } @@ -1551,7 +1623,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { return; } var $this = $( this ), - type = $this.attr('vaa-view-type'); + type = $this.attr('vaa-view-type'); if ( this.checked ) { parse_combine_type( $this, type ); } else { @@ -1632,10 +1704,10 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { */ VAA_View_Admin_As.init_module_role_defaults = function() { - var root = VAA_View_Admin_As.root + '-role-defaults', - prefix = 'vaa-role-defaults', + var root = VAA_View_Admin_As.root + '-role-defaults', + prefix = 'vaa-role-defaults', root_prefix = VAA_View_Admin_As.prefix + root, - $root = $( root_prefix ); + $root = $( root_prefix ); if ( ! $root.length ) { return; @@ -1647,9 +1719,9 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { return; } e.preventDefault(); - var val = $( root_prefix + '-meta-add input#' + prefix + '-meta-new' ).val(); - var item = $( root_prefix + '-meta-add #' + prefix + '-meta-template' ).html().toString(); - val = val.replace( / /g, '_' ); + var val = $( root_prefix + '-meta-add input#' + prefix + '-meta-new' ).val(), + item = $( root_prefix + '-meta-add #' + prefix + '-meta-template' ).html().toString(); + val = val.replace( / /g, '_' ); item = item.replace( /vaa_new_item/g, val ); if ( $( root_prefix + '-meta-select input[value="' + val + '"]' ).length ) { VAA_View_Admin_As.item_notice( $(this).parent(), VAA_View_Admin_As.__key_already_exists, 'error', 2000 ); @@ -1659,24 +1731,51 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { } ); // @since 1.4.0 Filter users. - $root.on( 'keyup', root + '-bulk-users-filter input#' + prefix + '-bulk-users-filter', function( e ) { - e.preventDefault(); - if ( 1 <= $(this).val().length ) { - var input_text = $(this).val(); - $( root_prefix + '-bulk-users-select .ab-item.vaa-item' ).each( function() { - var name = $('.user-name', this).text(); - if ( -1 < name.toLowerCase().indexOf( input_text.toLowerCase() ) ) { + if ( $root.find( root + '-bulk-users-filter' ).length ) { + $root.on( 'keyup', root + '-bulk-users-filter input#' + prefix + '-bulk-users-filter', function( e ) { + e.preventDefault(); + var $items = $( root_prefix + '-bulk-users-select .ab-item.vaa-item' ); + if ( 1 <= $(this).val().length ) { + var input_text = $(this).val(); + $items.each( function() { + var name = $('.user-name', this).text(); + if ( -1 < name.toLowerCase().indexOf( input_text.toLowerCase() ) ) { + $(this).show(); + } else { + $(this).hide(); + } + } ); + } else { + $items.each( function() { $(this).show(); - } else { - $(this).hide(); + } ); + } + } ); + } + + // @since 1.8.2 AJAX search users. + var $search = $root.find( root + '-bulk-users-search' ); + if ( $search.length ) { + var $search_results = $root.find( root + '-bulk-users-select' ); + $search.on( 'keyup', 'input#' + prefix + '-bulk-users-search', function() { + var $this = $(this), + search = $this.val(); + + if ( 1 <= search.trim().length ) { + search = { + 'search': search, + 'return': 'role_defaults' + }; + var search_by = $search.find( 'select#' + prefix + '-bulk-users-search-by' ).val(); + if ( search_by ) { + search[ 'search_by' ] = search_by; } - } ); - } else { - $( root_prefix + '-bulk-users-select .ab-item.vaa-item' ).each( function() { - $(this).show(); - } ); - } - } ); + VAA_View_Admin_As.search_users_ajax( search, $search_results ); + } else { + VAA_View_Admin_As.search_users_ajax( null, $search_results ); + } + } ); + } }; /** @@ -1689,10 +1788,10 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { /** * Capability functions. */ - var root = VAA_View_Admin_As.root + '-caps-manager-role-manager', - prefix = 'vaa-caps-manager-role-manager', + var root = VAA_View_Admin_As.root + '-caps-manager-role-manager', + prefix = 'vaa-caps-manager-role-manager', root_prefix = VAA_View_Admin_As.prefix + root, - $root = $( root_prefix ); + $root = $( root_prefix ); if ( ! $root.length ) { return; @@ -1700,17 +1799,17 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { // @since 1.7.0 Update capabilities when selecting a role. $root.on( 'change', 'select#' + prefix + '-edit-role', function() { - var $this = $(this), - role = $this.val(), - caps = {}, + var $this = $(this), + role = $this.val(), + caps = {}, $selected_role = $( root_prefix + ' select#' + prefix + '-edit-role option[value="' + role + '"]' ); if ( $selected_role.attr('data-caps') ) { caps = JSON.parse( $selected_role.attr('data-caps') ); } // Reset role filters. - VAA_View_Admin_As.caps_filter_settings.selectedRole = 'default'; - VAA_View_Admin_As.caps_filter_settings.selectedRoleCaps = {}; + VAA_View_Admin_As.caps_filter_settings.selectedRole = 'default'; + VAA_View_Admin_As.caps_filter_settings.selectedRoleCaps = {}; VAA_View_Admin_As.caps_filter_settings.selectedRoleReverse = false; VAA_View_Admin_As.filter_capabilities(); @@ -1723,13 +1822,13 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { return; } e.preventDefault(); - var role = $( root_prefix + ' select#' + prefix + '-edit-role' ).val(), + var role = $( root_prefix + ' select#' + prefix + '-edit-role' ).val(), refresh = ( VAA_View_Admin_As.view.hasOwnProperty( 'role' ) && role === VAA_View_Admin_As.view.role ); if ( ! role ) { return false; } if ( '__new__' === role ) { - role = $( root_prefix + ' input#' + prefix + '-new-role' ).val(); + role = $( root_prefix + ' input#' + prefix + '-new-role' ).val(); refresh = true; } var data = { @@ -1746,10 +1845,10 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { return; } e.preventDefault(); - var existing = VAA_View_Admin_As.get_selected_capabilities(); - var val = $( root_prefix + '-new-cap input#' + prefix + '-new-cap' ).val(); - var item = $( root_prefix + '-new-cap #' + prefix + '-cap-template' ).html().toString(); - val = val.replace( / /g, '_' ); + var existing = VAA_View_Admin_As.get_selected_capabilities(), + val = $( root_prefix + '-new-cap input#' + prefix + '-new-cap' ).val(), + item = $( root_prefix + '-new-cap #' + prefix + '-cap-template' ).html().toString(); + val = val.replace( / /g, '_' ); item = item.replace( /vaa_new_item/g, val ); if ( 'undefined' !== typeof existing[ val ] ) { VAA_View_Admin_As.item_notice( $(this).parent(), VAA_View_Admin_As.__key_already_exists, 'error', 2000 ); diff --git a/assets/js/view-admin-as.min.js b/assets/js/view-admin-as.min.js index 5d83ee80..e57df90c 100644 --- a/assets/js/view-admin-as.min.js +++ b/assets/js/view-admin-as.min.js @@ -5,7 +5,7 @@ * @author Jory Hogeveen * @package View_Admin_As * @since 0.1.0 - * @version 1.8.1 + * @version 1.8.2 * @preserve */ -if("undefined"===typeof VAA_View_Admin_As){var VAA_View_Admin_As={}}(function($){VAA_View_Admin_As.prefix="#wpadminbar #wp-admin-bar-vaa ";VAA_View_Admin_As.root="#wp-admin-bar-vaa";var $document=$(document),$window=$(window),$body=$("body"),$vaa=$(VAA_View_Admin_As.prefix);VAA_View_Admin_As.maxHeightListenerElements=null;VAA_View_Admin_As._mobile=false;if(!VAA_View_Admin_As.hasOwnProperty("_debug")){VAA_View_Admin_As._debug=false}if(!VAA_View_Admin_As.hasOwnProperty("ajaxurl")){if("undefined"===typeof ajaxurl){var ajaxurl=window.location.origin+"/wp-admin/admin-ajax.php"}VAA_View_Admin_As.ajaxurl=ajaxurl}VAA_View_Admin_As._touchmove=false;$document.on("touchmove",function(){VAA_View_Admin_As._touchmove=true});$document.on("touchstart",function(){VAA_View_Admin_As._touchmove=false});VAA_View_Admin_As.maybe_json_decode=function(val){if(0===val.indexOf("{")||0===val.indexOf("[")){try{val=JSON.parse(val)}catch(err){}}return val};VAA_View_Admin_As.init=function(){if(!$vaa.length){$vaa=$(VAA_View_Admin_As.prefix)}if(VAA_View_Admin_As._loader_icon){var loader_icon=new Image;loader_icon.src=VAA_View_Admin_As._loader_icon}VAA_View_Admin_As.maxHeightListenerElements=$(VAA_View_Admin_As.prefix+".vaa-auto-max-height");VAA_View_Admin_As.init_caps();VAA_View_Admin_As.init_users();VAA_View_Admin_As.init_combine_views();VAA_View_Admin_As.init_module_role_defaults();VAA_View_Admin_As.init_module_role_manager();VAA_View_Admin_As.init_auto_js();$(".ab-vaa-toggle",$vaa).each(function(){var $this=$(this),$toggle=$this.parent().children().not(".ab-vaa-toggle");if(!$this.hasClass("active")){$toggle.hide()}$this.on("click touchend",function(e){e.preventDefault();e.stopPropagation();if(true===VAA_View_Admin_As._touchmove){return}if($(this).hasClass("active")){$toggle.slideUp("fast");$(this).removeClass("active")}else{$toggle.slideDown("fast");$(this).addClass("active")}VAA_View_Admin_As.autoMaxHeight()});$this.on("keyup",function(e){e.preventDefault();var key=parseInt(e.which,10);if($(this).hasClass("active")&&(13===key||32===key||38===key)){$toggle.slideUp("fast");$(this).removeClass("active")}else if(13===key||32===key||40===key){$toggle.slideDown("fast");$(this).addClass("active")}VAA_View_Admin_As.autoMaxHeight()})});$("[vaa-showhide]",$vaa).each(function(){var $this=$(this),args=VAA_View_Admin_As.maybe_json_decode($this.attr("vaa-showhide")),delay=200;if("object"!==typeof args){args={0:{target:args,delay:delay}}}$.each(args,function(key,data){var timeout=null,$target=$(data.target);if(!data.hasOwnProperty("delay")){data.delay=delay}$target.hide();$this.on("mouseenter",function(){timeout=setTimeout(function(){$target.slideDown("fast")},data.delay)}).on("mouseleave",function(){if(timeout){clearTimeout(timeout)}$target.slideUp("fast")})})});$("[vaa-condition-target]",$vaa).each(function(){var $this=$(this),$target=$($this.attr("vaa-condition-target")),checkbox="checkbox"===$target.attr("type"),compare=$this.attr("vaa-condition");if(checkbox){if("undefined"!==typeof compare){compare=Boolean(compare)}else{compare=true}}$this.hide();$target.on("change.vaa",function(){if(checkbox&&$target.is(":checked")){if(compare){$this.slideDown("fast")}else{$this.slideUp("fast")}}else if(!checkbox&&compare===$target.val()){$this.slideDown("fast")}else{$this.slideUp("fast")}VAA_View_Admin_As.autoMaxHeight()}).trigger("change.vaa")});if($body.hasClass("mobile")||783>$body.innerWidth()){$body.addClass("vaa-mobile");VAA_View_Admin_As._mobile=true;VAA_View_Admin_As.init_touch()}VAA_View_Admin_As.maxHeightListenerElements.each(function(){$(this).parents(".menupop").on("mouseenter",VAA_View_Admin_As.autoMaxHeight)});$(".vaa-resizable",$vaa).each(function(){var $this=$(this),height=$this.css("max-height");$this.css({"max-height":"none",height:height,resize:"vertical"})});$vaa.on("click touchend",".vaa-reset-item > .ab-item",function(e){e.preventDefault();if(true===VAA_View_Admin_As._touchmove){return}if("vaa_reload"===$("button",this).attr("name")){window.location.reload()}else{VAA_View_Admin_As.ajax({reset:true},true);return false}});$.each(VAA_View_Admin_As.view_types,function(index,type){$vaa.on("click touchend",".vaa-"+type+"-item > a.ab-item",function(e){e.preventDefault();if(true===VAA_View_Admin_As._touchmove){return}var $this=$(this);if(VAA_View_Admin_As._mobile){var $parent=$this.parent();if($parent.hasClass("menupop")&&!$parent.hasClass("active")){$parent.addClass("active");$this.next().show();return false}}$this.data("vaa-continue-event",true).trigger("vaa-apply-view");if(!$this.parent().hasClass("not-a-view")&&$this.data("vaa-continue-event")){var view_data={},val=$this.find(".vaa-view-data").attr("vaa-view-value");view_data[type]=VAA_View_Admin_As.maybe_json_decode(val);if("object"===typeof view_data[type]){view_data=view_data[type]}VAA_View_Admin_As.ajax(view_data,true);return false}})});$vaa.on("click touchend",".remove",function(e){e.preventDefault();if(true===VAA_View_Admin_As._touchmove){return}$(this).parent().slideUp("fast",function(){$(this).remove()})})};VAA_View_Admin_As.init_touch=function(){var $root=$(".vaa-mobile "+VAA_View_Admin_As.prefix);$root.on("click touchend"," > .ab-sub-wrapper .ab-item",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();e.stopPropagation();var $sub=$(this).parent(".menupop").children(".ab-sub-wrapper");if($sub.length){if($sub.hasClass("active")){$sub.slideUp("fast").removeClass("active")}else{$sub.slideDown("fast").addClass("active")}}});$root.on("click touchend","input, textarea, select",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.stopPropagation();var $this=$(this);if($this.is('[type="checkbox"]')){e.preventDefault();if($this.is(":checked")){$this.prop("checked",false)}else{$this.prop("checked",true)}$this.trigger("change");return false}else if($this.is('[type="radio"]')){e.preventDefault();$('input[name="'+$this.attr["name"]+'"]').removeAttr("checked");$this.prop("checked",true);$this.trigger("change");return false}return true});$root.on("click touchend","label",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();e.stopPropagation();$("#"+$(this).attr("for")).trigger(e.type);return false})};VAA_View_Admin_As.overlay=function(html){var $overlay=$("#vaa-overlay");if(false===html){$overlay.fadeOut("fast",function(){$(this).remove()});$document.off("mouseup.vaa_overlay");return}if(!$overlay.length){html='
'+html+"
";$body.append(html);$overlay=$("body #vaa-overlay")}else if(html.length){$overlay.html(html)}$overlay.fadeIn("fast");$(".remove",$overlay).click(function(){VAA_View_Admin_As.overlay(false)});$document.on("mouseup.vaa_overlay",function(e){$(".vaa-popup",$overlay).each(function(){if(!$(this).is(e.target)&&0===$(this).has(e.target).length){VAA_View_Admin_As.overlay(false);return false}})})};VAA_View_Admin_As.ajax=function(data,refresh){$(".vaa-notice","#wpadminbar").remove();var loader_icon="";if(VAA_View_Admin_As._loader_icon){loader_icon=' style="background-image: url('+VAA_View_Admin_As._loader_icon+')"'}VAA_View_Admin_As.overlay('");var post_data={action:"view_admin_as",_vaa_nonce:VAA_View_Admin_As._vaa_nonce,view_admin_as:JSON.stringify(data)};var isView=false;$.each(VAA_View_Admin_As.view_types,function(index,type){if("undefined"!==typeof data[type]){isView=true;return true}});if($(VAA_View_Admin_As.prefix+"#vaa-settings-view-mode-single").is(":checked")&&isView){$body.append('');var $form=$("#vaa_single_mode_form");$form.append('');$form.append('');$form.append('');$form.find("#data").val(post_data.view_admin_as);$form.submit()}else{$.post(VAA_View_Admin_As.ajaxurl,post_data,function(response){var success=response.hasOwnProperty("success")&&true===response.success,data={},display=false;VAA_View_Admin_As.debug(response);if(response.hasOwnProperty("data")){if("object"===typeof response.data){data=response.data;if(data.hasOwnProperty("display")){display=data.display}}}if(success){if("download"===refresh){VAA_View_Admin_As.download(data);VAA_View_Admin_As.overlay(false);return}else if(refresh){VAA_View_Admin_As.refresh(data);return}else{if(!data.hasOwnProperty("text")){data.text=VAA_View_Admin_As.__success}}}if(!data.hasOwnProperty("type")){data.type=success?"success":"error"}if("popup"===display){VAA_View_Admin_As.popup(data,data.type)}else{if(!data.hasOwnProperty("text")){data.text=response.data}VAA_View_Admin_As.notice(String(data.text),data.type,5e3);$("body #vaa-overlay").addClass(data.type).fadeOut("fast",function(){$(this).remove()})}})}};VAA_View_Admin_As.refresh=function(data){if(data.hasOwnProperty("redirect")){window.location.replace(String(data.redirect))}else{window.location.hash="";window.location.reload()}};VAA_View_Admin_As.notice=function(notice,type,timeout){var root="#wpadminbar .vaa-notice",html=notice+'';type="undefined"===typeof type?"notice":type;timeout="undefined"===typeof timeout?5e3:timeout;if(VAA_View_Admin_As._mobile){html='";$(VAA_View_Admin_As.prefix+"> .ab-sub-wrapper").prepend(html).children(".vaa-notice").slideDown("fast");$("html, body").animate({scrollTop:"0"});if(timeout){setTimeout(function(){$(root).slideUp("fast",function(){$(this).remove()})},timeout)}}else{html='
  • '+html+"
  • ";$("#wp-admin-bar-top-secondary").append(html);$(root+" .remove").click(function(){$(this).parent().remove()});if(timeout){setTimeout(function(){$(root).fadeOut("fast",function(){$(this).remove()})},timeout)}}};VAA_View_Admin_As.item_notice=function(parent,notice,type,timeout){var root=".vaa-notice",html=notice+'',$element=$(parent);type="undefined"===typeof type?"notice":type;timeout="undefined"===typeof timeout?5e3:timeout;html='";$element.append(html).children(".vaa-notice").slideDown("fast");if(timeout){setTimeout(function(){$(root,$element).slideUp("fast",function(){$(this).remove()})},timeout)}};VAA_View_Admin_As.item_confirm=function(parent,text){$(parent).find(".vaa-notice").slideUp("fast",function(){$(this).remove()});text='";VAA_View_Admin_As.item_notice(parent,text,"warning",0);return $(parent).find(".vaa-confirm")};VAA_View_Admin_As.popup=function(data,type){type="undefined"===typeof type?"notice":type;var html="";html+='
    ';html+='';html+='
    ';if("object"!==typeof data){data={text:data}}if(data.hasOwnProperty("text")){html+="

    "+String(data.text)+"

    "}if(data.hasOwnProperty("list")){html+="
      ";data.list.forEach(function(item){html+="
    • "+String(item)+"
    • "});html+="
    "}if(data.hasOwnProperty("textarea")){html+='"}html+="
    ";VAA_View_Admin_As.overlay(html);var root="#vaa-overlay",$overlay=$(root),$popup=$(root+" .vaa-popup"),$popup_content=$(root+" .vaa-popup-content");var textarea=$("textarea",$popup_content);if(textarea.length){textarea.on("click",function(){$(this).select()})}var popupMaxHeight=function(){if(textarea.length){textarea.each(function(){$(this).css({height:"auto","overflow-y":"hidden"}).height(this.scrollHeight)})}var max_height=$overlay.height()*.8-24;$popup.css("max-height",max_height);$popup_content.css("max-height",max_height)};popupMaxHeight();$window.on("resize",function(){popupMaxHeight()})};VAA_View_Admin_As.download=function(data){var content="",filename="";if("string"===typeof data){content=data}else{if(data.hasOwnProperty("download")){content=String(data.download)}else if(data.hasOwnProperty("textarea")){content=String(data.textarea)}else if(data.hasOwnProperty("content")){content=String(data.content)}}content=VAA_View_Admin_As.maybe_json_decode(content);if("object"===typeof content){content=JSON.stringify(content,null,"\t")}if(!content){return}if(data.hasOwnProperty("filename")){filename=data.filename}var link="data:application/octet-stream;charset=utf-8,"+encodeURIComponent(content);$body.append('');document.getElementById("vaa_temp_download").click();$("a#vaa_temp_download").remove()};VAA_View_Admin_As.init_auto_js=function(){$(VAA_View_Admin_As.root+" [vaa-auto-js]").each(function(){var $this=$(this),data=VAA_View_Admin_As.maybe_json_decode($this.attr("vaa-auto-js"));if("object"!==typeof data){return}if(!data.hasOwnProperty("event")){data.event="change"}if("click"===data.event){data.event="click touchend"}$this.on(data.event,function(e){if("change"!==data.event&&true===VAA_View_Admin_As._touchmove){return}e.preventDefault();VAA_View_Admin_As.do_auto_js(data,this);return false})});VAA_View_Admin_As.do_auto_js=function(data,elem){if("object"!==typeof data){return}var $elem=$(elem),setting=data.hasOwnProperty("setting")?String(data.setting):null,confirm=data.hasOwnProperty("confirm")?Boolean(data.confirm):false,refresh=data.hasOwnProperty("refresh")?Boolean(data.refresh):false;if(data.hasOwnProperty("callback")){VAA_View_Admin_As[data.callback](data);return}var val=VAA_View_Admin_As.get_auto_js_values_recursive(data,elem);if(null!==val){if(!setting){return}var view_data={};view_data[setting]=val;if(data.hasOwnProperty("download")&&data.download){refresh="download"}if(confirm){confirm=VAA_View_Admin_As.item_confirm($elem.parent(),VAA_View_Admin_As.__confirm);$(confirm).on("click",function(){VAA_View_Admin_As.ajax(view_data,refresh)})}else{VAA_View_Admin_As.ajax(view_data,refresh)}}else{}};VAA_View_Admin_As.get_auto_js_values_recursive=function(data,elem){if("object"!==typeof data){return null}var stop=false,val=null;if(data.hasOwnProperty("values")){val={};$.each(data.values,function(val_key,auto_js){if("object"!==typeof auto_js||null===auto_js){auto_js={}}auto_js.required=auto_js.hasOwnProperty("required")?Boolean(auto_js.required):true;var val_val=VAA_View_Admin_As.get_auto_js_values_recursive(auto_js,elem);if(null!==val_val){val[val_key]=val_val}else if(auto_js.required){val=null;stop=true;return false}});if(stop){return null}}else{val=VAA_View_Admin_As.parse_auto_js_value(data,elem)}return val};VAA_View_Admin_As.parse_auto_js_value=function(data,elem){if("object"!==typeof data){return null}var $elem=data.hasOwnProperty("element")?$(data.element):$(elem),parser=data.hasOwnProperty("parser")?String(data.parser):"",val=null;switch(parser){case"multiple":case"multi":val={};$elem.each(function(){var $this=$(this),value;if("checkbox"===$this.attr("type")){value=data.hasOwnProperty("attr")?$this.attr(data.attr):$this.val();val[value]=this.checked}else{value=VAA_View_Admin_As.get_auto_js_value(this,data);val[$this.attr("name")]=value}});break;case"selected":val=[];$elem.each(function(){var $this=$(this),value;if("checkbox"===$this.attr("type")){value=data.hasOwnProperty("attr")?$this.attr(data.attr):$this.val();if(this.checked&&value){val.push(value)}}else{value=VAA_View_Admin_As.get_auto_js_value(this,data);if(value){val.push(value)}}});break;default:val=VAA_View_Admin_As.get_auto_js_value($elem,data);break}return val};VAA_View_Admin_As.get_auto_js_value=function(elem,data){if("object"!==typeof data){data={}}var $elem=$(elem),val=null,attr=data.hasOwnProperty("attr")?String(data.attr):false,json=data.hasOwnProperty("json")?Boolean(data.json):false,value=attr?$elem.attr(attr):$elem.val();if("checkbox"===$elem.attr("type")){var checked=$elem.is(":checked");if(attr){if(checked&&value){val=value}}else{val=checked}}else{if(value){val=value}}if(json){try{val=JSON.parse(val)}catch(err){val=null;VAA_View_Admin_As.popup("
    "+err+"
    ","error")}}return val}};VAA_View_Admin_As.init_users=function(){var root=VAA_View_Admin_As.root+"-users",root_prefix=VAA_View_Admin_As.prefix+root,$root=$(root_prefix),$search_node=$(root_prefix+" .ab-vaa-search.search-users");if(!$search_node.length){return}var search_ajax=$search_node.hasClass("search-ajax"),ajax_delay_timer,$search_results=$search_node.find(".ab-vaa-results"),no_results='
    '+VAA_View_Admin_As.__no_users_found+"
    ";$root.on("keyup",".ab-vaa-search.search-users input",function(){$search_results.empty();var $this=$(this),search=$this.val();if(1<=search.trim().length){if(search_ajax){search_users_ajax(search)}else{search_users(search)}}});function search_users(search){$(VAA_View_Admin_As.prefix+".vaa-user-item").each(function(){var name=$(".ab-item",this).text();if(-1 .ab-item > .vaa-view-data");role=role?role.text():"";if(role&&false!==exists&&exists.length){exists.find(".user-role").text(exists.find(".user-role").text().replace(")",", "+role+")"))}else{role=role?'  ('+role+")":"";$(this).clone().appendTo($search_results).children(".ab-item").append(role)}}});if(""===$.trim($search_results.html())){$search_results.html(no_results)}VAA_View_Admin_As.autoMaxHeight()}function search_users_ajax(search){clearTimeout(ajax_delay_timer);var search_by=$(".ab-vaa-search.search-users select",$root).val();if(search_by){search={search:search,search_by:search_by}}ajax_delay_timer=setTimeout(function(){$search_results.html('
    . . .
    ');var $loading=$(".ab-item",$search_results),loading=". . . ",loading_interval=setInterval(function(){if(20 .ab-item"}}combine_types.push("caps");combine_selectors["caps"]=VAA_View_Admin_As.prefix+VAA_View_Admin_As.root+"-caps > .menupop > .ab-item";VAA_View_Admin_As.reinit_combine_views=function(){if(is_active){enable_combine_views()}else{add_combine_checkboxes()}$.each(selection,function(type,data){data.el=$(data.el);if(!data.el.length||!data.el.closest("body").length){data.el=$(VAA_View_Admin_As.prefix+".vaa-combine-item[vaa-view-type="+data.type+"][vaa-view-value="+data.value+"]")}if(data.el.length){data.el.prop("checked",true);activate_combine_type(data.el,data.type,data.value)}})};function enable_combine_views(){is_active=true;add_combine_checkboxes();$combine_items=$(VAA_View_Admin_As.prefix+".vaa-combine-item");$combine_items.fadeIn("fast");update_selection_list()}function disable_combine_views(){is_active=false;$(VAA_View_Admin_As.prefix+".vaa-combine-item").fadeOut("fast");if($selection_container.is(":visible")){$selection_container.slideUp("fast")}else{$selection_container.hide()}}function add_combine_checkboxes(elements,type){if(!elements||!type){for(var key in combine_selectors){if(combine_selectors.hasOwnProperty(key)){add_combine_checkboxes(combine_selectors[key],key)}}return}var $elements=$(elements);$elements.each(function(){var $this=$(this),$parent=$this.parent(),val=null,text=$this.text(),$data_el=$this.find(".vaa-view-data"),type_label,attr;if($parent.find(".vaa-combine-item").length){return true}if($data_el.length){val=$data_el.attr("vaa-view-value");text=$data_el.text();type_label=$data_el.attr("vaa-view-type-label")}if("caps"===type){val="";text=$(VAA_View_Admin_As.root+"-caps-title > .ab-item").text()}attr=['type="checkbox"','class="checkbox vaa-right vaa-combine-item vaa-combine-'+type+'"','vaa-view-type="'+type+'"',"vaa-view-value='"+val+"'",'vaa-view-text="'+text+'"','style="display:none;"'];if(type_label){attr.push('vaa-view-type-label="'+type_label+'"')}$parent.prepend("")})}function parse_combine_type(element,type){var $element=$(element),val;if("caps"===type){val=type}else{val=VAA_View_Admin_As.maybe_json_decode($element.attr("vaa-view-value"));if("object"===typeof val){$.each(val,function(val_type,data){var $val_element=$(VAA_View_Admin_As.prefix+".vaa-combine-"+val_type+"[vaa-view-value="+data+"]");activate_combine_type($val_element,val_type,data)});$element.prop({checked:true,disabled:false});return}}activate_combine_type($element,type,val)}function activate_combine_type(element,type,value){var $element=$(element);deactivate_combine_type(type,false);selection[type]={el:$element,type:type,value:value};$(VAA_View_Admin_As.prefix+".vaa-combine-"+type).prop({checked:false,disabled:true});$element.prop({checked:true,disabled:false});update_selection_list()}function deactivate_combine_type(types,update){if("object"!==typeof types){type=types;types={};types[type]=0}for(var type in types){if(types.hasOwnProperty(type)){delete selection[type];$(VAA_View_Admin_As.prefix+".vaa-combine-"+type).prop({checked:false,disabled:false})}}if(update){update_selection_list()}}function update_selection_list(){$(root_prefix+" .vaa-combine-selection").each(function(){var $this=$(this),type=$this.attr("vaa-view-type");if(!selection.hasOwnProperty(type)){$this.slideUp("fast",function(){$(this).remove()})}});$.each(selection,function(type,data){var text=data.el.attr("vaa-view-text")+'',$existing=$(root_prefix+" .vaa-combine-selection-"+type),label=data.el.attr("vaa-view-type-label");if(label){text=''+label+": "+text}if($existing.length){$existing.html(text);if("none"===$existing.css("display")||!$existing.is(":visible")){$existing.slideDown("fast")}}else{var attr=['class="ab-item ab-empty-item vaa-combine-selection vaa-combine-selection-'+type+'"','vaa-view-type="'+type+'"','style="display:none;"'];var html="
  • "+text+"
  • ";$selection_container.append(html);$(root_prefix+" .vaa-combine-selection-"+type).slideDown("fast")}});if(is_active&&!$.isEmptyObject(selection)){if("none"===$selection_container.css("display")||!$selection_container.is(":visible")){$selection_container.slideDown("fast")}}else{$selection_container.slideUp("fast")}}$root.on("change","input#"+prefix,function(){$selection_container=$($selection_container);if(true===VAA_View_Admin_As._touchmove){return}if(this.checked){enable_combine_views()}else{disable_combine_views()}});$vaa.on("change","input.vaa-combine-item",function(){if(true===VAA_View_Admin_As._touchmove){return}var $this=$(this),type=$this.attr("vaa-view-type");if(this.checked){parse_combine_type($this,type)}else{var val=VAA_View_Admin_As.maybe_json_decode($this.attr("vaa-view-value"));if("object"===typeof val){deactivate_combine_type(val,true);return}deactivate_combine_type(type,true)}});$root.on("click touchend",".vaa-combine-selection .remove",function(){if(true===VAA_View_Admin_As._touchmove){return}deactivate_combine_type($(this).parent().attr("vaa-view-type"),true)});$root.on("click touchend","button#"+prefix+"-apply",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();var view_data={};for(var type in selection){if(selection.hasOwnProperty(type)){if("caps"===type){view_data[type]=VAA_View_Admin_As.get_selected_capabilities()}else{view_data[type]=selection[type].value}}}if(!$.isEmptyObject(view_data)){VAA_View_Admin_As.ajax(view_data,true)}else{}});$.each(combine_types,function(index,type){$vaa.on("vaa-apply-view",".vaa-"+type+"-item > a.ab-item",function(e){if(!is_active){return}e.preventDefault();var $this=$(this);if(!$this.parent().hasClass("not-a-view")){if(!VAA_View_Admin_As._mobile){var $combine_item=$this.parent().children(".vaa-combine-item");if($combine_item.is(":checked")){$combine_item.prop("checked",false)}else{$combine_item.prop("checked",true)}$combine_item.trigger("change")}e.stopPropagation();e.stopImmediatePropagation();$this.data("vaa-continue-event",false);return false}})})};VAA_View_Admin_As.init_module_role_defaults=function(){var root=VAA_View_Admin_As.root+"-role-defaults",prefix="vaa-role-defaults",root_prefix=VAA_View_Admin_As.prefix+root,$root=$(root_prefix);if(!$root.length){return}$root.on("click touchend",root+"-meta-add button#"+prefix+"-meta-add",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();var val=$(root_prefix+"-meta-add input#"+prefix+"-meta-new").val();var item=$(root_prefix+"-meta-add #"+prefix+"-meta-template").html().toString();val=val.replace(/ /g,"_");item=item.replace(/vaa_new_item/g,val);if($(root_prefix+'-meta-select input[value="'+val+'"]').length){VAA_View_Admin_As.item_notice($(this).parent(),VAA_View_Admin_As.__key_already_exists,"error",2e3)}else{$(root_prefix+"-meta-select > .ab-item").prepend(item)}});$root.on("keyup",root+"-bulk-users-filter input#"+prefix+"-bulk-users-filter",function(e){e.preventDefault();if(1<=$(this).val().length){var input_text=$(this).val();$(root_prefix+"-bulk-users-select .ab-item.vaa-item").each(function(){var name=$(".user-name",this).text();if(-1 .ab-item").prepend(item)}})};VAA_View_Admin_As.assign_file_content=function(data){if("function"!==typeof FileReader){return}var param=data.hasOwnProperty("param")?data.param:{},$target=param.hasOwnProperty("target")?$(param.target):null,$element=param.hasOwnProperty("element")?$(param.element):null,wait=true;if(!$target||!$element){return}var files=$element[0].files,length=files.length,val="";if(length){$.each(files,function(key,file){var reader=new FileReader;reader.onload=function(){var content=VAA_View_Admin_As.maybe_json_decode(this.result);if("object"===typeof content){content=JSON.stringify(content)}val+=content;length--;if(!length){wait=false}};reader.readAsText(file)})}var areWeThereYet=setInterval(function(){if(!wait){$target.val(val);clearInterval(areWeThereYet)}},100)};VAA_View_Admin_As.autoMaxHeight=function(){if(!VAA_View_Admin_As.maxHeightListenerElements){return null}setTimeout(function(){var scroll_top="undefined"!==typeof window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;VAA_View_Admin_As.maxHeightListenerElements.each(function(){var $element=$(this),count=0,wait=setInterval(function(){var offset=$element.offset(),offset_top=offset.top-scroll_top;if($element.is(":visible")&&0$body.innerWidth()){$body.addClass("vaa-mobile");VAA_View_Admin_As._mobile=true;VAA_View_Admin_As.init_touch()}VAA_View_Admin_As.maxHeightListenerElements.each(function(){$(this).parents(".menupop").on("mouseenter",VAA_View_Admin_As.autoMaxHeight)});$(".vaa-resizable",$vaa).each(function(){var $this=$(this),maxHeight=parseInt($this.css("max-heights"),10),height,innerHeight,newHeight;$this.find(".ab-empty-item:empty").remove();$this.on("vaa-resizable",function(){if($this.is(":empty")){$this.css({"max-height":"",height:"",resize:""});return}newHeight=maxHeight;height=$this.height();$this.css({"max-height":"",height:"",resize:""});if(height){$this.css({"max-height":"none"});innerHeight=$this.height();$this.css({"max-height":""});if(innerHeight=maxHeight){if(innerHeight=maxHeight)){$this.css({"max-height":"none",height:newHeight?newHeight+"px":"",resize:"vertical"})}}).trigger("vaa-resizable")});$vaa.on("click touchend",".vaa-reset-item > .ab-item",function(e){e.preventDefault();if(true===VAA_View_Admin_As._touchmove){return}if("vaa_reload"===$("button",this).attr("name")){window.location.reload()}else{VAA_View_Admin_As.ajax({reset:true},true);return false}});$.each(VAA_View_Admin_As.view_types,function(index,type){$vaa.on("click touchend",".vaa-"+type+"-item > a.ab-item",function(e){e.preventDefault();if(true===VAA_View_Admin_As._touchmove){return}var $this=$(this);if(VAA_View_Admin_As._mobile){var $parent=$this.parent();if($parent.hasClass("menupop")&&!$parent.hasClass("active")){$parent.addClass("active");$this.next().show();return false}}$this.data("vaa-continue-event",true).trigger("vaa-apply-view");if(!$this.parent().hasClass("not-a-view")&&$this.data("vaa-continue-event")){var view_data={},val=$this.find(".vaa-view-data").attr("vaa-view-value");view_data[type]=VAA_View_Admin_As.maybe_json_decode(val);if("object"===typeof view_data[type]){view_data=view_data[type]}VAA_View_Admin_As.ajax(view_data,true);return false}})});$vaa.on("click touchend",".remove",function(e){e.preventDefault();if(true===VAA_View_Admin_As._touchmove){return}$(this).parent().slideUp("fast",function(){$(this).remove()})})};VAA_View_Admin_As.init_touch=function(){var $root=$(".vaa-mobile "+VAA_View_Admin_As.prefix);$root.on("click touchend"," > .ab-sub-wrapper .ab-item",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();e.stopPropagation();var $sub=$(this).parent(".menupop").children(".ab-sub-wrapper");if($sub.length){if($sub.hasClass("active")){$sub.slideUp("fast").removeClass("active")}else{$sub.slideDown("fast").addClass("active")}}});$root.on("click touchend","input, textarea, select",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.stopPropagation();var $this=$(this);if($this.is('[type="checkbox"]')){e.preventDefault();if($this.is(":checked")){$this.prop("checked",false)}else{$this.prop("checked",true)}$this.trigger("change");return false}else if($this.is('[type="radio"]')){e.preventDefault();$('input[name="'+$this.attr["name"]+'"]').removeAttr("checked");$this.prop("checked",true);$this.trigger("change");return false}return true});$root.on("click touchend","label",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();e.stopPropagation();$("#"+$(this).attr("for")).trigger(e.type);return false})};VAA_View_Admin_As.overlay=function(html){var $overlay=$("#vaa-overlay");if(false===html){$overlay.fadeOut("fast",function(){$(this).remove()});$document.off("mouseup.vaa_overlay");return}if(!$overlay.length){html='
    '+html+"
    ";$body.append(html);$overlay=$("body #vaa-overlay")}else if(html.length){$overlay.html(html)}$overlay.fadeIn("fast");$overlay.find(".remove").click(function(){VAA_View_Admin_As.overlay(false)});$document.on("mouseup.vaa_overlay",function(e){$overlay.find(".vaa-popup").each(function(){if(!$(this).is(e.target)&&0===$(this).has(e.target).length){VAA_View_Admin_As.overlay(false);return false}})})};VAA_View_Admin_As.ajax=function(data,refresh){$(".vaa-notice","#wpadminbar").remove();var loader_icon="";if(VAA_View_Admin_As._loader_icon){loader_icon=' style="background-image: url('+VAA_View_Admin_As._loader_icon+')"'}VAA_View_Admin_As.overlay('");var post_data={action:"view_admin_as",_vaa_nonce:VAA_View_Admin_As._vaa_nonce,view_admin_as:JSON.stringify(data)};var isView=false;$.each(VAA_View_Admin_As.view_types,function(index,type){if("undefined"!==typeof data[type]){isView=true;return true}});if($(VAA_View_Admin_As.prefix+"#vaa-settings-view-mode-single").is(":checked")&&isView){$body.append('');var $form=$("#vaa_single_mode_form");$form.append('');$form.append('');$form.append('');$form.find("#data").val(post_data.view_admin_as);$form.submit()}else{$.post(VAA_View_Admin_As.ajaxurl,post_data,function(response){var success=response.hasOwnProperty("success")&&true===response.success,data={},display=false;VAA_View_Admin_As.debug(response);if(response.hasOwnProperty("data")){if("object"===typeof response.data){data=response.data;if(data.hasOwnProperty("display")){display=data.display}}}if(success){if("download"===refresh){VAA_View_Admin_As.download(data);VAA_View_Admin_As.overlay(false);return}else if(refresh){VAA_View_Admin_As.refresh(data);return}else{if(!data.hasOwnProperty("text")){data.text=VAA_View_Admin_As.__success}}}if(!data.hasOwnProperty("type")){data.type=success?"success":"error"}if("popup"===display){VAA_View_Admin_As.popup(data,data.type)}else{if(!data.hasOwnProperty("text")){data.text=response.data}VAA_View_Admin_As.notice(String(data.text),data.type,5e3);$("body #vaa-overlay").addClass(data.type).fadeOut("fast",function(){$(this).remove()})}})}};VAA_View_Admin_As.refresh=function(data){if(data.hasOwnProperty("redirect")){window.location.replace(String(data.redirect))}else{window.location.hash="";window.location.reload()}};VAA_View_Admin_As.notice=function(notice,type,timeout){var root="#wpadminbar .vaa-notice",html=notice+'';type="undefined"===typeof type?"notice":type;timeout="undefined"===typeof timeout?5e3:timeout;if(VAA_View_Admin_As._mobile){html='";$(VAA_View_Admin_As.prefix+"> .ab-sub-wrapper").prepend(html).children(".vaa-notice").slideDown("fast");$("html, body").animate({scrollTop:"0"});if(timeout){setTimeout(function(){$(root).slideUp("fast",function(){$(this).remove()})},timeout)}}else{html='
  • '+html+"
  • ";$("#wp-admin-bar-top-secondary").append(html);$(root+" .remove").click(function(){$(this).parent().remove()});if(timeout){setTimeout(function(){$(root).fadeOut("fast",function(){$(this).remove()})},timeout)}}};VAA_View_Admin_As.item_notice=function(parent,notice,type,timeout){var root=".vaa-notice",html=notice+'',$element=$(parent);type="undefined"===typeof type?"notice":type;timeout="undefined"===typeof timeout?5e3:timeout;html='";$element.append(html).children(".vaa-notice").slideDown("fast");if(timeout){setTimeout(function(){$(root,$element).slideUp("fast",function(){$(this).remove()})},timeout)}};VAA_View_Admin_As.item_confirm=function(parent,text){$(parent).find(".vaa-notice").slideUp("fast",function(){$(this).remove()});text='";VAA_View_Admin_As.item_notice(parent,text,"warning",0);return $(parent).find(".vaa-confirm")};VAA_View_Admin_As.popup=function(data,type){type="undefined"===typeof type?"notice":type;var html="";html+='
    ';html+='';html+='
    ';if("object"!==typeof data){data={text:data}}if(data.hasOwnProperty("text")){html+="

    "+String(data.text)+"

    "}if(data.hasOwnProperty("list")&&"object"===typeof data.list){html+="
      ";$.each(data.list,function(key,value){html+="
    • "+String(value)+"
    • "});html+="
    "}if(data.hasOwnProperty("textarea")){html+='"}html+="
    ";VAA_View_Admin_As.overlay(html);var root="#vaa-overlay",$overlay=$(root),$popup=$(root+" .vaa-popup"),$popup_content=$(root+" .vaa-popup-content");var textarea=$("textarea",$popup_content);if(textarea.length){textarea.on("click",function(){$(this).select()})}var popupMaxHeight=function(){if(textarea.length){textarea.each(function(){$(this).css({height:"auto","overflow-y":"hidden"}).height(this.scrollHeight)})}var max_height=$overlay.height()*.8-24;$popup.css("max-height",max_height);$popup_content.css("max-height",max_height)};popupMaxHeight();$window.on("resize",function(){popupMaxHeight()})};VAA_View_Admin_As.download=function(data){var content="",filename="";if("string"===typeof data){content=data}else{if(data.hasOwnProperty("download")){content=String(data.download)}else if(data.hasOwnProperty("textarea")){content=String(data.textarea)}else if(data.hasOwnProperty("content")){content=String(data.content)}}content=VAA_View_Admin_As.maybe_json_decode(content);if("object"===typeof content){content=JSON.stringify(content,null,"\t")}if(!content){return}if(data.hasOwnProperty("filename")){filename=data.filename}var link="data:application/octet-stream;charset=utf-8,"+encodeURIComponent(content);$body.append('');document.getElementById("vaa_temp_download").click();$("a#vaa_temp_download").remove()};VAA_View_Admin_As.init_auto_js=function(){$(VAA_View_Admin_As.root+" [vaa-auto-js]").each(function(){var $this=$(this),data=VAA_View_Admin_As.maybe_json_decode($this.attr("vaa-auto-js"));if("object"!==typeof data){return}if(!data.hasOwnProperty("event")){data.event="change"}if("click"===data.event){data.event="click touchend"}$this.on(data.event,function(e){if("change"!==data.event&&true===VAA_View_Admin_As._touchmove){return}e.preventDefault();VAA_View_Admin_As.do_auto_js(data,this);return false})});VAA_View_Admin_As.do_auto_js=function(data,elem){if("object"!==typeof data){return}var $elem=$(elem),setting=data.hasOwnProperty("setting")?String(data.setting):null,confirm=data.hasOwnProperty("confirm")?Boolean(data.confirm):false,refresh=data.hasOwnProperty("refresh")?Boolean(data.refresh):false;if(data.hasOwnProperty("callback")){VAA_View_Admin_As[data.callback](data);return}var val=VAA_View_Admin_As.get_auto_js_values_recursive(data,elem);if(null!==val){if(!setting){return}var view_data={};view_data[setting]=val;if(data.hasOwnProperty("download")&&data.download){refresh="download"}if(confirm){confirm=VAA_View_Admin_As.item_confirm($elem.parent(),VAA_View_Admin_As.__confirm);$(confirm).on("click",function(){VAA_View_Admin_As.ajax(view_data,refresh)})}else{VAA_View_Admin_As.ajax(view_data,refresh)}}else{}};VAA_View_Admin_As.get_auto_js_values_recursive=function(data,elem){if("object"!==typeof data){return null}var stop=false,val=null;if(data.hasOwnProperty("values")){val={};$.each(data.values,function(val_key,auto_js){if("object"!==typeof auto_js||null===auto_js){auto_js={}}auto_js.required=auto_js.hasOwnProperty("required")?Boolean(auto_js.required):true;var val_val=VAA_View_Admin_As.get_auto_js_values_recursive(auto_js,elem);if(null!==val_val){val[val_key]=val_val}else if(auto_js.required){val=null;stop=true;return false}});if(stop){return null}}else{val=VAA_View_Admin_As.parse_auto_js_value(data,elem)}return val};VAA_View_Admin_As.parse_auto_js_value=function(data,elem){if("object"!==typeof data){return null}var $elem=data.hasOwnProperty("element")?$(data.element):$(elem),parser=data.hasOwnProperty("parser")?String(data.parser):"",val=null;switch(parser){case"multiple":case"multi":val={};$elem.each(function(){var $this=$(this),value;if("checkbox"===$this.attr("type")){value=data.hasOwnProperty("attr")?$this.attr(data.attr):$this.val();val[value]=this.checked}else{value=VAA_View_Admin_As.get_auto_js_value(this,data);val[$this.attr("name")]=value}});break;case"selected":val=[];$elem.each(function(){var $this=$(this),value;if("checkbox"===$this.attr("type")){value=data.hasOwnProperty("attr")?$this.attr(data.attr):$this.val();if(this.checked&&value){val.push(value)}}else{value=VAA_View_Admin_As.get_auto_js_value(this,data);if(value){val.push(value)}}});break;default:val=VAA_View_Admin_As.get_auto_js_value($elem,data);break}return val};VAA_View_Admin_As.get_auto_js_value=function(elem,data){if("object"!==typeof data){data={}}var $elem=$(elem),val=null,attr=data.hasOwnProperty("attr")?String(data.attr):false,json=data.hasOwnProperty("json")?Boolean(data.json):false,value=attr?$elem.attr(attr):$elem.val();if("checkbox"===$elem.attr("type")){var checked=$elem.is(":checked");if(attr){if(checked&&value){val=value}}else{val=checked}}else{if(value){val=value}}if(json){try{val=JSON.parse(val)}catch(err){val=null;VAA_View_Admin_As.popup("
    "+err+"
    ","error")}}return val}};VAA_View_Admin_As.init_users=function(){var root=VAA_View_Admin_As.root+"-users",root_prefix=VAA_View_Admin_As.prefix+root,$root=$(root_prefix),$search_node=$(root_prefix+" .ab-vaa-search.search-users"),ajax_delay_timer;if($search_node.length){var search_ajax=$search_node.hasClass("search-ajax"),$search_results=$search_node.find(".ab-vaa-results"),no_results='
    '+VAA_View_Admin_As.__no_users_found+"
    ";$root.on("keyup",".ab-vaa-search.search-users input",function(){var $this=$(this),search=$this.val();if(1<=search.trim().length){if(search_ajax){search={search:search,return:"links"};var search_by=$root.find(".ab-vaa-search.search-users select").val();if(search_by){search["search_by"]=search_by}VAA_View_Admin_As.search_users_ajax(search,$search_results)}else{search_users(search)}}else{VAA_View_Admin_As.search_users_ajax(null,$search_results)}})}function search_users(search){$search_results.empty();$(VAA_View_Admin_As.prefix+".vaa-user-item").each(function(){var $this=$(this),name=$this.find(".ab-item").text();if(-1 .ab-item > .vaa-view-data");role=role?role.text():"";if(role&&false!==exists&&exists.length){exists.find(".user-role").text(exists.find(".user-role").text().replace(")",", "+role+")"))}else{role=role?'  ('+role+")":"";$this.clone().appendTo($search_results).children(".ab-item").append(role)}}});if(""===$.trim($search_results.html())){$search_results.html(no_results)}VAA_View_Admin_As.autoMaxHeight()}VAA_View_Admin_As.search_users_ajax=function(search,results_container){clearTimeout(ajax_delay_timer);var $results_container=$(results_container);if(!search){$results_container.empty();if($results_container.hasClass("vaa-resizable")){$results_container.trigger("vaa-resizable")}return}ajax_delay_timer=setTimeout(function(){$results_container.html('
    . . .
    ');var $loading=$(".ab-item",$results_container),loading=". . . ",loading_interval=setInterval(function(){if(20 .ab-item"}}combine_types.push("caps");combine_selectors["caps"]=VAA_View_Admin_As.prefix+VAA_View_Admin_As.root+"-caps > .menupop > .ab-item";VAA_View_Admin_As.reinit_combine_views=function(){if(is_active){enable_combine_views()}else{add_combine_checkboxes()}$.each(selection,function(type,data){data.el=$(data.el);if(!data.el.length||!data.el.closest("body").length){data.el=$(VAA_View_Admin_As.prefix+".vaa-combine-item[vaa-view-type="+data.type+"][vaa-view-value="+data.value+"]")}if(data.el.length){data.el.prop("checked",true);activate_combine_type(data.el,data.type,data.value)}})};function enable_combine_views(){is_active=true;add_combine_checkboxes();$combine_items=$(VAA_View_Admin_As.prefix+".vaa-combine-item");$combine_items.fadeIn("fast");update_selection_list()}function disable_combine_views(){is_active=false;$(VAA_View_Admin_As.prefix+".vaa-combine-item").fadeOut("fast");if($selection_container.is(":visible")){$selection_container.slideUp("fast")}else{$selection_container.hide()}}function add_combine_checkboxes(elements,type){if(!elements||!type){for(var key in combine_selectors){if(combine_selectors.hasOwnProperty(key)){add_combine_checkboxes(combine_selectors[key],key)}}return}var $elements=$(elements);$elements.each(function(){var $this=$(this),$parent=$this.parent(),val=null,text=$this.text(),$data_el=$this.find(".vaa-view-data"),label,attr;if($parent.find(".vaa-combine-item").length){return true}if($data_el.length){val=$data_el.attr("vaa-view-value");text=$data_el.text();label=$data_el.attr("vaa-view-type-label")}if("caps"===type){val="";text=$(VAA_View_Admin_As.root+"-caps-title > .ab-item").text()}attr=['type="checkbox"','class="checkbox vaa-right vaa-combine-item vaa-combine-'+type+'"','vaa-view-type="'+type+'"',"vaa-view-value='"+val+"'",'vaa-view-text="'+text+'"','style="display:none;"'];if(label){attr.push('vaa-view-type-label="'+label+'"')}$parent.prepend("")})}function parse_combine_type(element,type){var $element=$(element),val;if("caps"===type){val=type}else{val=VAA_View_Admin_As.maybe_json_decode($element.attr("vaa-view-value"));if("object"===typeof val){$.each(val,function(val_type,data){var $val_element=$(VAA_View_Admin_As.prefix+".vaa-combine-"+val_type+"[vaa-view-value="+data+"]");activate_combine_type($val_element,val_type,data)});$element.prop({checked:true,disabled:false});return}}activate_combine_type($element,type,val)}function activate_combine_type(element,type,value){var $element=$(element);deactivate_combine_type(type,false);selection[type]={el:$element,type:type,value:value};$(VAA_View_Admin_As.prefix+".vaa-combine-"+type).prop({checked:false,disabled:true});$element.prop({checked:true,disabled:false});update_selection_list()}function deactivate_combine_type(types,update){if("object"!==typeof types){type=types;types={};types[type]=0}for(var type in types){if(types.hasOwnProperty(type)){delete selection[type];$(VAA_View_Admin_As.prefix+".vaa-combine-"+type).prop({checked:false,disabled:false})}}if(update){update_selection_list()}}function update_selection_list(){$(root_prefix+" .vaa-combine-selection").each(function(){var $this=$(this),type=$this.attr("vaa-view-type");if(!selection.hasOwnProperty(type)){$this.slideUp("fast",function(){$(this).remove()})}});$.each(selection,function(type,data){var text=data.el.attr("vaa-view-text")+'',$existing=$(root_prefix+" .vaa-combine-selection-"+type),label=data.el.attr("vaa-view-type-label");if(label){text=''+label+": "+text}if($existing.length){$existing.html(text);if("none"===$existing.css("display")||!$existing.is(":visible")){$existing.slideDown("fast")}}else{var attr=['class="ab-item ab-empty-item vaa-combine-selection vaa-combine-selection-'+type+'"','vaa-view-type="'+type+'"','style="display:none;"'];var html="
  • "+text+"
  • ";$selection_container.append(html);$(root_prefix+" .vaa-combine-selection-"+type).slideDown("fast")}});if(is_active&&!$.isEmptyObject(selection)){if("none"===$selection_container.css("display")||!$selection_container.is(":visible")){$selection_container.slideDown("fast")}}else{$selection_container.slideUp("fast")}}$root.on("change","input#"+prefix,function(){$selection_container=$($selection_container);if(true===VAA_View_Admin_As._touchmove){return}if(this.checked){enable_combine_views()}else{disable_combine_views()}});$vaa.on("change","input.vaa-combine-item",function(){if(true===VAA_View_Admin_As._touchmove){return}var $this=$(this),type=$this.attr("vaa-view-type");if(this.checked){parse_combine_type($this,type)}else{var val=VAA_View_Admin_As.maybe_json_decode($this.attr("vaa-view-value"));if("object"===typeof val){deactivate_combine_type(val,true);return}deactivate_combine_type(type,true)}});$root.on("click touchend",".vaa-combine-selection .remove",function(){if(true===VAA_View_Admin_As._touchmove){return}deactivate_combine_type($(this).parent().attr("vaa-view-type"),true)});$root.on("click touchend","button#"+prefix+"-apply",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();var view_data={};for(var type in selection){if(selection.hasOwnProperty(type)){if("caps"===type){view_data[type]=VAA_View_Admin_As.get_selected_capabilities()}else{view_data[type]=selection[type].value}}}if(!$.isEmptyObject(view_data)){VAA_View_Admin_As.ajax(view_data,true)}else{}});$.each(combine_types,function(index,type){$vaa.on("vaa-apply-view",".vaa-"+type+"-item > a.ab-item",function(e){if(!is_active){return}e.preventDefault();var $this=$(this);if(!$this.parent().hasClass("not-a-view")){if(!VAA_View_Admin_As._mobile){var $combine_item=$this.parent().children(".vaa-combine-item");if($combine_item.is(":checked")){$combine_item.prop("checked",false)}else{$combine_item.prop("checked",true)}$combine_item.trigger("change")}e.stopPropagation();e.stopImmediatePropagation();$this.data("vaa-continue-event",false);return false}})})};VAA_View_Admin_As.init_module_role_defaults=function(){var root=VAA_View_Admin_As.root+"-role-defaults",prefix="vaa-role-defaults",root_prefix=VAA_View_Admin_As.prefix+root,$root=$(root_prefix);if(!$root.length){return}$root.on("click touchend",root+"-meta-add button#"+prefix+"-meta-add",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();var val=$(root_prefix+"-meta-add input#"+prefix+"-meta-new").val(),item=$(root_prefix+"-meta-add #"+prefix+"-meta-template").html().toString();val=val.replace(/ /g,"_");item=item.replace(/vaa_new_item/g,val);if($(root_prefix+'-meta-select input[value="'+val+'"]').length){VAA_View_Admin_As.item_notice($(this).parent(),VAA_View_Admin_As.__key_already_exists,"error",2e3)}else{$(root_prefix+"-meta-select > .ab-item").prepend(item)}});if($root.find(root+"-bulk-users-filter").length){$root.on("keyup",root+"-bulk-users-filter input#"+prefix+"-bulk-users-filter",function(e){e.preventDefault();var $items=$(root_prefix+"-bulk-users-select .ab-item.vaa-item");if(1<=$(this).val().length){var input_text=$(this).val();$items.each(function(){var name=$(".user-name",this).text();if(-1 .ab-item").prepend(item)}})};VAA_View_Admin_As.assign_file_content=function(data){if("function"!==typeof FileReader){return}var param=data.hasOwnProperty("param")?data.param:{},$target=param.hasOwnProperty("target")?$(param.target):null,$element=param.hasOwnProperty("element")?$(param.element):null,wait=true;if(!$target||!$element){return}var files=$element[0].files,length=files.length,val="";if(length){$.each(files,function(key,file){var reader=new FileReader;reader.onload=function(){var content=VAA_View_Admin_As.maybe_json_decode(this.result);if("object"===typeof content){content=JSON.stringify(content)}val+=content;length--;if(!length){wait=false}};reader.readAsText(file)})}var areWeThereYet=setInterval(function(){if(!wait){$target.val(val);clearInterval(areWeThereYet)}},100)};VAA_View_Admin_As.autoMaxHeight=function(){if(!VAA_View_Admin_As.maxHeightListenerElements){return null}setTimeout(function(){var scroll_top="undefined"!==typeof window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;VAA_View_Admin_As.maxHeightListenerElements.each(function(){var $element=$(this),count=0,wait=setInterval(function(){var offset=$element.offset(),offset_top=offset.top-scroll_top;if($element.is(":visible")&&0 * @package View_Admin_As * @since 1.6.0 - * @version 1.8.0 + * @version 1.8.2 */ final class VAA_API { @@ -164,10 +164,10 @@ public static function get_superior_admins() { * @param array * @return int[] Requires a returned array of user ID's */ - $superior_admins = array_unique( array_map( 'absint', array_filter( - (array) apply_filters( 'view_admin_as_superior_admins', array() ), - 'is_numeric' // Only allow numeric values (user id's) - ) ) ); + $superior_admins = (array) apply_filters( 'view_admin_as_superior_admins', array() ); + + // Only allow unique numeric values (user id's). + $superior_admins = array_unique( array_map( 'absint', array_filter( $superior_admins, 'is_numeric' ) ) ); return $superior_admins; } @@ -327,26 +327,33 @@ public static function is_view_type_enabled( $type ) { * Generate a VAA action link. * * @since 1.7.0 + * @since 1.8.2 Switched $nonce and $url parameters order. * @access public * @static * @api * * @param array $data View type data. - * @param string $nonce The nonce. * @param string $url (optional) A URL. Of not passed it will generate a link from the current URL. + * @param string $nonce (optional) Use a different nonce. Pass `false` to omit nonce. * @return string */ - public static function get_vaa_action_link( $data, $nonce, $url = null ) { + public static function get_vaa_action_link( $data, $url = null, $nonce = null ) { $params = array( 'action' => 'view_admin_as', 'view_admin_as' => $data, // wp_json_encode( array( $type, $data ) ), - '_vaa_nonce' => (string) $nonce, ); + if ( null === $nonce ) { + $nonce = view_admin_as()->store()->get_nonce( true ); + } + if ( $nonce ) { + $params['_vaa_nonce'] = (string) $nonce; + } + // @todo fix WP referrer/nonce checks and allow switching on any page without ajax. // @see https://codex.wordpress.org/Function_Reference/check_admin_referer - if ( empty( $url ) ) { + if ( null === $url ) { if ( is_admin() ) { $url = is_network_admin() ? network_admin_url() : admin_url(); } else { @@ -693,7 +700,7 @@ public static function exists_callable( $callable, $do_notice = false, $syntax_o $do_notice = ( defined( 'WP_DEBUG' ) && WP_DEBUG ); } if ( ! is_string( $do_notice ) ) { - $callable = self::callable_to_string( $callable ); + $callable = self::callable_to_string( $callable ); $do_notice = sprintf( // Translators: %s stands for the requested class, method or function. __( '%s does not exist or is not callable.', VIEW_ADMIN_AS_DOMAIN ), @@ -728,7 +735,7 @@ public static function callable_to_string( $callable ) { if ( is_array( $callable ) ) { if ( is_object( $callable[0] ) ) { $callable[0] = get_class( $callable[0] ); - $callable = implode( '->', $callable ); + $callable = implode( '->', $callable ); } else { $callable = implode( '::', $callable ); } diff --git a/includes/class-compat.php b/includes/class-compat.php index e3bdb208..d8554ecb 100644 --- a/includes/class-compat.php +++ b/includes/class-compat.php @@ -211,16 +211,15 @@ public function get_wordpress_capabilities( $caps = array() ) { /** * Other WordPress capabilities. - * @since 1.7.4 + * @since 1.7.4 WordPress 4.9 capabilities. */ - $caps = array_merge( array( - // @since 4.9 - 'activate_plugin', - 'deactivate_plugin', - 'deactivate_plugins', - 'install_languages', - 'update_languages', - ), $caps ); + if ( VAA_API::validate_wp_version( '4.9' ) ) { + $caps['activate_plugin'] = 'activate_plugin'; + $caps['deactivate_plugin'] = 'deactivate_plugin'; + $caps['deactivate_plugins'] = 'deactivate_plugins'; + $caps['install_languages'] = 'install_languages'; + $caps['update_languages'] = 'update_languages'; + } /** * Network capabilities. @@ -339,7 +338,7 @@ public function get_plugin_capabilities( $caps = array() ) { // @since 1.7.4 Yoast SEO 5.5+ Load integration on front end. if ( ! is_admin() ) { /** - * @since 1.8.0 Yoast SEO - Check for API function. + * @since 1.8.0 Yoast SEO 8.3+ - Check for API function. * @link https://github.com/Yoast/wordpress-seo/pull/9365 */ if ( function_exists( 'wpseo_get_capabilities' ) ) { @@ -406,7 +405,8 @@ public function action_members_register_cap_group() { return; } // Register the vaa group. - members_register_cap_group( 'view_admin_as', + members_register_cap_group( + 'view_admin_as', array( 'label' => esc_html__( 'View Admin As', VIEW_ADMIN_AS_DOMAIN ), 'caps' => $this->get_vaa_capabilities(), @@ -428,6 +428,7 @@ public function action_members_register_cap_group() { */ public function filter_ure_capabilities_groups_tree( $groups ) { $groups = (array) $groups; + $groups['view_admin_as'] = array( 'caption' => esc_html__( 'View Admin As', VIEW_ADMIN_AS_DOMAIN ), 'parent' => 'custom', @@ -449,7 +450,7 @@ public function filter_ure_capabilities_groups_tree( $groups ) { */ public function filter_ure_custom_capability_groups( $groups, $cap_id ) { if ( in_array( $cap_id, $this->get_vaa_capabilities(), true ) ) { - $groups = (array) $groups; + $groups = (array) $groups; $groups[] = 'view_admin_as'; } return $groups; @@ -472,15 +473,15 @@ public function filter_ure_custom_capability_groups( $groups, $cap_id ) { public function filter_wauc_admin_bar_menu_add_nodes( $wauc_nodes, $all_nodes ) { $admin_menu_location = $this->store->get_userSettings( 'admin_menu_location' ); - $vaa_root = VAA_View_Admin_As_Admin_Bar::$root; + $vaa_root = VAA_View_Admin_As_Admin_Bar::$root; $check = array( 'depth' => 'main', ); if ( 'my-account' === $admin_menu_location ) { - $check['depth'] = 'sub'; + $check['depth'] = 'sub'; $check['location'] = 'right'; - $check['parent'] = $admin_menu_location; + $check['parent'] = $admin_menu_location; } // Compat when this node is added twice. @@ -490,9 +491,9 @@ public function filter_wauc_admin_bar_menu_add_nodes( $wauc_nodes, $all_nodes ) if ( isset( $node['id'] ) && $vaa_root === $node['id'] ) { $current = array( - 'depth' => $depth, + 'depth' => $depth, 'location' => $location, - 'parent' => $node['parent'], + 'parent' => $node['parent'], ); foreach ( $check as $key => $val ) { @@ -541,7 +542,7 @@ public function filter_wauc_admin_bar_filter_load( $all_nodes ) { } foreach ( $nodes as $key => $node ) { // Check if node ID starts with `vaa-` and node parent starts with `vaa`. - if ( 0 === strpos( $node->id , $slug . '-' ) && 0 === strpos( $node->parent , $slug ) ) { + if ( 0 === strpos( $node->id, $slug . '-' ) && 0 === strpos( $node->parent, $slug ) ) { unset( $all_nodes['right'][ $location ][ $key ] ); } } diff --git a/includes/class-controller.php b/includes/class-controller.php index 27029973..537da3ea 100644 --- a/includes/class-controller.php +++ b/includes/class-controller.php @@ -16,7 +16,7 @@ * @author Jory Hogeveen * @package View_Admin_As * @since 1.7.0 - * @version 1.8.1 + * @version 1.8.2 * @uses \VAA_View_Admin_As_Base Extends class */ final class VAA_View_Admin_As_Controller extends VAA_View_Admin_As_Base @@ -178,7 +178,7 @@ public function ajax_view_admin_as() { * @return array|bool */ private function ajax_handler( $data ) { - $success = false; + $success = false; $view_types = array(); // Stop selecting the same view! @@ -221,6 +221,7 @@ private function ajax_handler( $data ) { foreach ( $data as $key => $value ) { if ( $this->is_view_type( $key ) ) { $view_types[] = $key; + $success = apply_filters( 'view_admin_as_update_view_' . $key, null, $value, $key ); } else { $success = apply_filters( 'view_admin_as_handle_ajax_' . $key, null, $value, $key ); @@ -266,7 +267,7 @@ public function filter_update_view( $null, $data, $type ) { if ( $success && 'visitor' === $type && VAA_API::is_admin() ) { $success = array( 'success' => true, - 'data' => array( + 'data' => array( 'redirect' => esc_url( home_url() ), ), ); @@ -328,7 +329,7 @@ public function get_view_types() { static $view_types; if ( ! is_null( $view_types ) ) return $view_types; - $view_types = array_keys( (array) view_admin_as()->get_view_types() ); + $view_types = array_keys( (array) view_admin_as()->get_view_types() ); $view_types[] = 'visitor'; /** @@ -385,9 +386,9 @@ private function get_view() { // Trigger page refresh. // @todo fix WP referrer/nonce checks and allow switching on any page without ajax. See VAA_API. if ( is_network_admin() ) { - wp_redirect( network_admin_url() ); + wp_safe_redirect( network_admin_url(), 302, VIEW_ADMIN_AS_DOMAIN ); } else { - wp_redirect( admin_url() ); + wp_safe_redirect( admin_url(), 302, VIEW_ADMIN_AS_DOMAIN ); } die(); } @@ -429,7 +430,7 @@ private function update_view() { } // Add the new view metadata and expiration date. $meta[ $this->store->get_curUserSession() ] = array( - 'view' => $data, + 'view' => $data, 'expire' => ( time() + (int) $this->viewExpiration ), ); // Update metadata (returns: true on success, false on failure). diff --git a/includes/class-form.php b/includes/class-form.php index 5ac0dd78..d18c0559 100644 --- a/includes/class-form.php +++ b/includes/class-form.php @@ -38,16 +38,18 @@ class VAA_View_Admin_As_Form * @return string */ public static function do_view_title( $title, $type, $value, $attr = array(), $elem = 'span' ) { - $attr = (array) $attr; + $attr = (array) $attr; $class = ( ! empty( $attr['class'] ) ) ? ' ' . $attr['class'] : ''; + $attr['class'] = 'vaa-view-data' . $class; if ( $type instanceof VAA_View_Admin_As_Type ) { - $attr['vaa-view-type'] = $type->get_type(); + $attr['vaa-view-type'] = $type->get_type(); $attr['vaa-view-type-label'] = $type->get_label_singular(); } else { $attr['vaa-view-type'] = $type; } $attr['vaa-view-value'] = $value; + $attr = self::parse_to_html_attr( $attr ); return '<' . $elem . ' ' . $attr . '>' . $title . ''; } @@ -70,7 +72,7 @@ public static function do_multiple( $args ) { if ( is_callable( array( 'VAA_View_Admin_As_Form', $key ) ) ) { $return[] = self::$method( $value ); } elseif ( is_callable( array( 'VAA_View_Admin_As_Form', 'do_' . $key ) ) ) { - $method = 'do_' . $key; + $method = 'do_' . $key; $return[] = self::$method( $value ); } } @@ -99,14 +101,14 @@ public static function do_multiple( $args ) { * @return string */ public static function do_button( $args ) { - $id = esc_attr( ( ! empty( $args['id'] ) ) ? $args['id'] : $args['name'] ); - $name = str_replace( '-', '_', esc_attr( $args['name'] ) ); - $elem = ( ! empty( $args['element'] ) ) ? $args['element'] : 'button'; + $id = esc_attr( ( ! empty( $args['id'] ) ) ? $args['id'] : $args['name'] ); + $name = str_replace( '-', '_', esc_attr( $args['name'] ) ); + $elem = ( ! empty( $args['element'] ) ) ? $args['element'] : 'button'; $label = ( ! empty( $args['label'] ) ) ? $args['label'] : ''; $class = ( ! empty( $args['class'] ) ) ? ' ' . $args['class'] : ''; - $args['attr']['id'] = $id; - $args['attr']['name'] = $name; + $args['attr']['id'] = $id; + $args['attr']['name'] = $name; $args['attr']['class'] = 'button' . $class; if ( isset( $args['value'] ) ) { if ( is_bool( $args['value'] ) ) { @@ -155,25 +157,25 @@ public static function do_button( $args ) { public static function do_input( $args ) { $html = ''; - $id = esc_attr( ( ! empty( $args['id'] ) ) ? $args['id'] : $args['name'] ); - $name = str_replace( '-', '_', esc_attr( $args['name'] ) ); - $default = ( ! empty( $args['default'] ) ) ? $args['default'] : ''; + $id = esc_attr( ( ! empty( $args['id'] ) ) ? $args['id'] : $args['name'] ); + $name = str_replace( '-', '_', esc_attr( $args['name'] ) ); + $default = ( ! empty( $args['default'] ) ) ? $args['default'] : ''; $placeholder = ( ! empty( $args['placeholder'] ) ) ? $args['placeholder'] : ''; - $class = ( ! empty( $args['class'] ) ) ? $args['class'] : ''; + $class = ( ! empty( $args['class'] ) ) ? $args['class'] : ''; - $args['attr']['type'] = ( ! empty( $args['type'] ) ) ? $args['type'] : 'text'; - $args['attr']['id'] = $id; - $args['attr']['name'] = $name; + $args['attr']['type'] = ( ! empty( $args['type'] ) ) ? $args['type'] : 'text'; + $args['attr']['id'] = $id; + $args['attr']['name'] = $name; $args['attr']['placeholder'] = $placeholder; - $args['attr']['value'] = ( ! empty( $args['value'] ) ) ? $args['value'] : $default; - $args['attr']['class'] = $class; + $args['attr']['value'] = ( ! empty( $args['value'] ) ) ? $args['value'] : $default; + $args['attr']['class'] = $class; $attr = $args['attr']; $attr = self::enable_auto_js( $attr, $args ); $attr = self::parse_to_html_attr( $attr ); $label_attr = array(); - $desc_attr = array(); + $desc_attr = array(); self::enable_auto_showhide( $id . '-desc', $label_attr, $desc_attr, $args ); $html .= self::do_help( $args, array(), array(), $label_attr ); @@ -213,7 +215,7 @@ public static function do_input( $args ) { public static function do_checkbox( $args ) { $html = ''; - $id = esc_attr( ( ! empty( $args['id'] ) ) ? $args['id'] : $args['name'] ); + $id = esc_attr( ( ! empty( $args['id'] ) ) ? $args['id'] : $args['name'] ); $name = str_replace( '-', '_', esc_attr( $args['name'] ) ); if ( empty( $args['value'] ) ) { @@ -223,11 +225,11 @@ public static function do_checkbox( $args ) { $args['compare'] = 1; } $checked = checked( $args['value'], $args['compare'], false ); - $class = ( ! empty( $args['class'] ) ) ? ' ' . $args['class'] : ''; + $class = ( ! empty( $args['class'] ) ) ? ' ' . $args['class'] : ''; - $args['attr']['type'] = 'checkbox'; - $args['attr']['id'] = $id; - $args['attr']['name'] = $name; + $args['attr']['type'] = 'checkbox'; + $args['attr']['id'] = $id; + $args['attr']['name'] = $name; $args['attr']['value'] = ( ! empty( $args['checkbox_value'] ) ) ? $args['checkbox_value'] : '1'; $args['attr']['class'] = 'checkbox' . $class; @@ -236,7 +238,7 @@ public static function do_checkbox( $args ) { $attr = self::parse_to_html_attr( $attr ); $label_attr = array(); - $desc_attr = array(); + $desc_attr = array(); self::enable_auto_showhide( $id . '-desc', $label_attr, $desc_attr, $args ); $html .= self::do_help( $args, array(), array(), $label_attr ); @@ -295,19 +297,19 @@ public static function do_radio( $args ) { foreach ( $args['values'] as $val ) { - $id = esc_attr( ( ( ! empty( $args['id'] ) ) ? $args['id'] : $args['name'] ) . '-' . $val['compare'] ); + $id = esc_attr( ( ( ! empty( $args['id'] ) ) ? $args['id'] : $args['name'] ) . '-' . $val['compare'] ); $name = str_replace( '-', '_', esc_attr( $args['name'] ) ); if ( empty( $args['value'] ) ) { $args['value'] = null; } $checked = checked( $args['value'], $val['compare'], false ); - $class = ( ! empty( $val['class'] ) ) ? ' ' . $val['class'] : ''; - $class .= ' ' . esc_attr( $args['name'] ); + $class = ( ! empty( $val['class'] ) ) ? ' ' . $val['class'] : ''; + $class .= ' ' . esc_attr( $args['name'] ); - $val['attr']['type'] = 'radio'; - $val['attr']['id'] = $id; - $val['attr']['name'] = $name; + $val['attr']['type'] = 'radio'; + $val['attr']['id'] = $id; + $val['attr']['name'] = $name; $val['attr']['value'] = $val['compare']; $val['attr']['class'] = 'radio' . $class; @@ -316,10 +318,11 @@ public static function do_radio( $args ) { $attr = self::parse_to_html_attr( $attr ); $label_attr = array(); - $desc_attr = array(); + $desc_attr = array(); // Custom validation required. - if ( ( ! empty( $val['auto_showhide'] ) ) || - ( ! isset( $val['auto_showhide'] ) && ! empty( $args['auto_showhide'] ) ) + if ( + ( ! empty( $val['auto_showhide'] ) ) + || ( ! isset( $val['auto_showhide'] ) && ! empty( $args['auto_showhide'] ) ) ) { self::enable_auto_showhide( $id . '-desc', $label_attr, $desc_attr ); } @@ -378,11 +381,11 @@ public static function do_select( $args ) { $html = ''; if ( ! empty( $args['values'] ) ) { - $id = esc_attr( ( ! empty( $args['id'] ) ) ? $args['id'] : $args['name'] ); + $id = esc_attr( ( ! empty( $args['id'] ) ) ? $args['id'] : $args['name'] ); $name = str_replace( '-', '_', esc_attr( $args['name'] ) ); $label_attr = array(); - $desc_attr = array(); + $desc_attr = array(); self::enable_auto_showhide( $id . '-desc', $label_attr, $desc_attr, $args ); $html .= self::do_help( $args, array(), array(), $label_attr ); @@ -394,8 +397,8 @@ public static function do_select( $args ) { $class = ( ! empty( $args['class'] ) ) ? ' ' . $args['class'] : ''; - $args['attr']['id'] = $id; - $args['attr']['name'] = $name; + $args['attr']['id'] = $id; + $args['attr']['name'] = $name; $args['attr']['class'] = 'selectbox' . $class; $attr = $args['attr']; @@ -411,8 +414,8 @@ public static function do_select( $args ) { $selected = selected( $args['value'], $val['compare'], false ); $val['attr']['value'] = $val['compare']; - $attr = self::parse_to_html_attr( $val['attr'] ); + $attr = self::parse_to_html_attr( $val['attr'] ); $html .= ''; } @@ -442,16 +445,17 @@ public static function do_select( $args ) { public static function do_icon( $icon, $attr = array(), $content = '' ) { $class = 'ab-icon'; - if ( false === strpos( $icon, '/' ) && - 0 !== strpos( $icon, 'data:' ) && - 0 !== strpos( $icon, 'http' ) + if ( + false === strpos( $icon, '/' ) + && 0 !== strpos( $icon, 'data:' ) + && 0 !== strpos( $icon, 'http' ) ) { // It's an icon class. $class .= ' dashicons ' . $icon; } else { // It's a Base64 encoded string or file URL. $class .= ' vaa-icon-image'; - $attr = self::merge_attr( $attr, array( + $attr = self::merge_attr( $attr, array( 'style' => array( 'background-image: url("' . $icon . '") !important' ), ) ); } @@ -459,8 +463,9 @@ public static function do_icon( $icon, $attr = array(), $content = '' ) { if ( ! empty( $attr['class'] ) ) { $class .= ' ' . (string) $attr['class']; } - $attr['class'] = $class; + $attr['class'] = $class; $attr['aria-hidden'] = 'true'; + $attr = self::parse_to_html_attr( $attr ); return '' . $content . ''; } @@ -486,6 +491,7 @@ public static function do_label( $label, $for = '', $attr = array() ) { $label = $label['label']; } $attr['for'] = $for; + $attr = self::parse_to_html_attr( $attr ); return ''; } @@ -513,7 +519,8 @@ public static function do_description( $text, $attr = array(), $elem = 'p' ) { } elseif ( ! is_string( $text ) ) { return ''; } - $attr['class'] = 'ab-item description' . ( ( ! empty( $attr['class'] ) ) ? ' ' . $attr['class'] : ''); + $attr['class'] = 'ab-item description' . ( ( ! empty( $attr['class'] ) ) ? ' ' . $attr['class'] : '' ); + $attr = self::parse_to_html_attr( $attr ); return '<' . $elem . ' ' . $attr . '>' . $text . ''; } @@ -551,7 +558,7 @@ public static function do_help( $text, $help_attr = array(), $tooltip_attr = arr if ( ! isset( $showhide_attr['vaa-showhide'] ) ) { return ''; } - $help_attr['class'] .= ' ab-vaa-showhide'; + $help_attr['class'] .= ' ab-vaa-showhide'; $help_attr['vaa-showhide'] = $showhide_attr['vaa-showhide']; unset( $showhide_attr['vaa-showhide'] ); } @@ -562,6 +569,7 @@ public static function do_help( $text, $help_attr = array(), $tooltip_attr = arr 'class' => 'ab-item ab-sub-wrapper vaa-tooltip', ), $tooltip_attr ); $tooltip_attr = self::parse_to_html_attr( $tooltip_attr ); + $text = '' . $text . ''; } else { $text = ''; @@ -623,6 +631,7 @@ public static function enable_auto_js( $attr, $args ) { $value = array( 'values' => $args['auto_js']['values'] ); } $values = array( $args['auto_js']['key'] => $value ); + $args['auto_js']['values'] = $values; } unset( $args['auto_js']['key'] ); diff --git a/includes/class-hooks.php b/includes/class-hooks.php index 190d3710..47808e2d 100644 --- a/includes/class-hooks.php +++ b/includes/class-hooks.php @@ -17,7 +17,7 @@ * @package View_Admin_As * @link https://github.com/JoryHogeveen/view-admin-as/wiki/Actions-&-Filters * @since 1.8.0 - * @version 1.8.0 + * @version 1.8.2 */ class VAA_View_Admin_As_Hooks { @@ -340,7 +340,7 @@ protected function _remove_own( $hooks, $hook, $priority, $function, $class ) { protected function _validate_priority( $hooks, $hook, $callback, $priority ) { if ( ! is_numeric( $priority ) ) { $priority = $this->_find_priority( $hooks, $hook, $callback ); - if ( ! $priority ) { + if ( ! is_numeric( $priority ) ) { return 10; } } diff --git a/includes/class-module.php b/includes/class-module.php index 1969cbfc..f45cb08e 100644 --- a/includes/class-module.php +++ b/includes/class-module.php @@ -104,11 +104,11 @@ public function ajax_data_return( $success, $data, $type = null ) { } $data = wp_parse_args( $data, array( 'display' => 'notice', - 'type' => $type, + 'type' => $type, ) ); return array( 'success' => (bool) $success, - 'data' => $data, + 'data' => $data, ); } diff --git a/includes/class-settings.php b/includes/class-settings.php index ccf2507b..4133316c 100644 --- a/includes/class-settings.php +++ b/includes/class-settings.php @@ -171,8 +171,8 @@ protected function __construct( $id, $args = array() ) { } $args = wp_parse_args( $args, array( - 'default' => array(), - 'allowed' => array(), + 'default' => array(), + 'allowed' => array(), 'default_user' => array(), 'allowed_user' => array(), ) ); @@ -188,13 +188,13 @@ protected function __construct( $id, $args = array() ) { $this->set_optionKey( 'vaa_view_admin_as' ); $this->set_optionData( array( 'db_version' => null, - 'settings' => null, + 'settings' => null, ) ); $this->set_userMetaKey( 'vaa-view-admin-as' ); $this->set_userMeta( array( 'settings' => null, - 'views' => null, + 'views' => null, ) ); $default = array( @@ -242,8 +242,9 @@ protected function __construct( $id, $args = array() ) { __METHOD__, sprintf( // Translators: %1$s stands for an option key and %2$s stands for a class name. - __( 'The setting key %1$s is reserved for class %2$s', VIEW_ADMIN_AS_DOMAIN ), - $id, 'VAA_View_Admin_As_Store' + esc_html__( 'The setting key %1$s is reserved for class %2$s', VIEW_ADMIN_AS_DOMAIN ), + esc_html( $id ), + 'VAA_View_Admin_As_Store' ), '' ); @@ -419,10 +420,18 @@ public function update_settings( $settings, $type ) { $current = $defaults; } - $settings = apply_filters( - 'view_admin_as_update_' . $type . '_settings' . $this->_filter_postfix, - $settings, $current, $defaults, $allowed - ); + /** + * Filter the settings before they are validated. + * + * @since 1.8.0 + * @param array $settings New settings. + * @param array $current Current settings. + * @param array $defaults Default settings. + * @param array $allowed Allowed settings. + * @return array + */ + $filter = 'view_admin_as_update_' . $type . '_settings' . $this->_filter_postfix; + $settings = apply_filters( $filter, $settings, $current, $defaults, $allowed ); $settings = $this->validate_settings( $settings, $type, false ); @@ -528,10 +537,12 @@ public function update_other_user_meta( $value, $user_id, $column_id = null ) { $value = wp_parse_args( $value, array( 'settings' => array(), ) ); + $value['settings'] = $this->validate_settings( $value['settings'], 'user', true ); if ( ! isset( $this->allUserMeta[ $user_id ] ) ) { $column_id = 0; + $this->allUserMeta[ $user_id ] = array( $column_id => $value ); } diff --git a/includes/class-store.php b/includes/class-store.php index 92923b74..c567796a 100644 --- a/includes/class-store.php +++ b/includes/class-store.php @@ -167,7 +167,7 @@ public function init( $redo = false ) { $this->set_curUserSession( (string) wp_get_session_token() ); $this->curUserHasFullAccess = VAA_API::user_has_full_access( $this->get_curUser() ); - $this->curUserData = get_object_vars( $this->get_curUser() ); + $this->curUserData = get_object_vars( $this->get_curUser() ); // Get database settings. $this->store_optionData( VAA_View_Admin_As::is_network_active() ); @@ -447,7 +447,7 @@ public function set_data( $type, $val, $key = null, $append = false ) { $this->$method( $val, $key, $append ); return; } - $current = ( isset( $this->data[ $type ] ) ) ? $this->data[ $type ] : array(); + $current = ( isset( $this->data[ $type ] ) ) ? $this->data[ $type ] : array(); $this->data[ $type ] = (array) VAA_API::set_array_data( $current, $val, $key, $append ); } @@ -533,7 +533,7 @@ public function set_selectedCaps( $val ) { * @return void */ public function set_nonce( $val ) { - $this->nonce = (string) $val; + $this->nonce = (string) $val; $this->nonce_parsed = wp_create_nonce( (string) $val ); } diff --git a/includes/class-type.php b/includes/class-type.php index f220c406..600d68a4 100644 --- a/includes/class-type.php +++ b/includes/class-type.php @@ -422,7 +422,9 @@ final public function set_settings( $val, $key = null, $append = false ) { $this->settings = VAA_API::set_array_data( $this->settings, $val, $key, $append ); $view_types = (array) $this->store->get_settings( 'view_types' ); + $view_types[ $this->type ] = $this->get_settings(); + $settings = array( 'view_types' => $view_types, ); diff --git a/includes/class-vaa.php b/includes/class-vaa.php index 418866ce..74b2a49c 100644 --- a/includes/class-vaa.php +++ b/includes/class-vaa.php @@ -16,7 +16,7 @@ * @author Jory Hogeveen * @package View_Admin_As * @since 0.1.0 - * @version 1.8.0 + * @version 1.8.2 */ final class VAA_View_Admin_As { @@ -287,7 +287,7 @@ private function run() { */ public function set_enabled() { $this->enable = $this->validate_user(); - return $this->enable; + return $this->is_enabled(); } /** @@ -312,22 +312,25 @@ public function is_enabled() { * capability (of not the edit_users will return false). * @since 1.5.3 Enable on network pages for superior admins. * @since 1.6.3 Created this function. + * @since 1.8.2 Refactor (simplify) + remove check for user session. * @access public * * @return bool */ public function validate_user() { - $valid = false; - if ( ( VAA_API::is_super_admin() - || ( current_user_can( 'view_admin_as' ) && current_user_can( 'edit_users' ) ) ) - && ( ! is_network_admin() || VAA_API::is_superior_admin( $this->store->get_curUser()->ID ) ) - && $this->store->get_curUserSession() - ) { - $valid = true; + if ( is_network_admin() ) { + $valid = VAA_API::is_superior_admin( $this->store->get_curUser()->ID ); + } else { + $valid = ( + VAA_API::is_super_admin() + || ( current_user_can( 'view_admin_as' ) && current_user_can( 'edit_users' ) ) + ); } - return $valid; + //@todo Removed check for a session: Maybe add a debug notice? + + return (bool) $valid; } /** @@ -355,12 +358,15 @@ public function include_file( $file, $class = '' ) { if ( empty( $class ) || ! class_exists( $class, false ) ) { include_once $file; } else { - $this->add_error_notice( $class . '::' . __METHOD__, array( - 'type' => 'notice-error', - 'message' => __( 'Plugin not fully loaded because of a conflict with an other plugin or theme', VIEW_ADMIN_AS_DOMAIN ) - // Translators: %s stands for the class name. - . ' (' . sprintf( __( 'Class %s already exists', VIEW_ADMIN_AS_DOMAIN ), $class ) . ')', - ) ); + $this->add_error_notice( + $class . '::' . __METHOD__, + array( + 'type' => 'notice-error', + 'message' => __( 'Plugin not fully loaded because of a conflict with an other plugin or theme', VIEW_ADMIN_AS_DOMAIN ) + // Translators: %s stands for the class name. + . ' (' . sprintf( __( 'Class %s already exists', VIEW_ADMIN_AS_DOMAIN ), $class ) . ')', + ) + ); return false; } @@ -425,7 +431,7 @@ public function load_files( $includes, &$group = null ) { private function load_ui() { $includes = array( - 'ui' => array( + 'ui' => array( 'file' => 'ui/class-ui.php', 'class' => 'VAA_View_Admin_As_UI', ), @@ -457,11 +463,11 @@ private function load_ui() { private function load_modules() { $includes = array( - 'role_switcher' => array( + 'role_switcher' => array( 'file' => 'modules/class-roles.php', 'class' => 'VAA_View_Admin_As_Roles', ), - 'user_switcher' => array( + 'user_switcher' => array( 'file' => 'modules/class-users.php', 'class' => 'VAA_View_Admin_As_Users', ), @@ -469,15 +475,15 @@ private function load_modules() { 'file' => 'modules/class-caps.php', 'class' => 'VAA_View_Admin_As_Caps', ), - 'language_switcher' => array( + 'language_switcher' => array( 'file' => 'modules/class-languages.php', 'class' => 'VAA_View_Admin_As_Languages', ), - 'role_defaults' => array( + 'role_defaults' => array( 'file' => 'modules/class-role-defaults.php', 'class' => 'VAA_View_Admin_As_Role_Defaults', ), - 'role_manager' => array( + 'role_manager' => array( 'file' => 'modules/class-role-manager.php', 'class' => 'VAA_View_Admin_As_Role_Manager', ), @@ -629,8 +635,9 @@ public function get_view_types( $key = null, $check_access = true ) { * @return bool Successfully registered? */ public function register_view_type( $data ) { - if ( ! empty( $data['id'] ) && is_string( $data['id'] ) && - ! empty( $data['instance'] ) && $data['instance'] instanceof VAA_View_Admin_As_Type + if ( + ! empty( $data['id'] ) && is_string( $data['id'] ) && + ! empty( $data['instance'] ) && $data['instance'] instanceof VAA_View_Admin_As_Type ) { $this->view_types[ $data['id'] ] = $data['instance']; return true; @@ -664,8 +671,9 @@ public function get_modules( $key = null ) { * @return bool Successfully registered? */ public function register_module( $data ) { - if ( ! empty( $data['id'] ) && is_string( $data['id'] ) && - ! empty( $data['instance'] ) && $data['instance'] instanceof VAA_View_Admin_As_Module + if ( + ! empty( $data['id'] ) && is_string( $data['id'] ) && + ! empty( $data['instance'] ) && $data['instance'] instanceof VAA_View_Admin_As_Module ) { $this->modules[ $data['id'] ] = $data['instance']; return true; @@ -680,15 +688,18 @@ public function register_module( $data ) { * @access public */ public function welcome_notice() { - $this->add_notice( 'vaa-welcome', array( - 'type' => 'notice-success', - 'message' => sprintf( - // Translators: %s stands for `Dashboard` (link element). - __( 'For the best experience you can start from the %s since not all views are allowed to access all admin pages.', VIEW_ADMIN_AS_DOMAIN ), - '' . __( 'Dashboard' ) . '' - ), - 'prepend' => __( 'Thank you for installing View Admin As!', VIEW_ADMIN_AS_DOMAIN ), - ) ); + $this->add_notice( + 'vaa-welcome', + array( + 'type' => 'notice-success', + 'message' => sprintf( + // Translators: %s stands for `Dashboard` (link element). + __( 'For the best experience you can start from the %s since not all views are allowed to access all admin pages.', VIEW_ADMIN_AS_DOMAIN ), + '' . __( 'Dashboard' ) . '' + ), + 'prepend' => __( 'Thank you for installing View Admin As!', VIEW_ADMIN_AS_DOMAIN ), + ) + ); } /** @@ -720,6 +731,7 @@ public function add_error_notice( $id, $notice ) { 'title' => __( 'Error', VIEW_ADMIN_AS_DOMAIN ) . ': ' . $id, 'body' => $notice['message'], ); + $report_link = add_query_arg( $report, 'https://github.com/JoryHogeveen/view-admin-as/issues/new' ); $notice['message'] = $notice['message'] @@ -736,8 +748,8 @@ public function add_error_notice( $id, $notice ) { * @since 1.5.1 * @access public * - * @param string $id - * @param array $notice { + * @param string $id + * @param array|string $notice { * Required array. * @type string $message The notice message. * @type string $type (optional) The WP notice type class(es). @@ -747,15 +759,25 @@ public function add_error_notice( $id, $notice ) { * @return void */ public function add_notice( $id, $notice ) { - if ( ! empty( $notice['message'] ) ) { - $notice = array_merge( array( - 'type' => '', + if ( ! empty( $notice ) ) { + + if ( ! is_array( $notice ) ) { + $notice = array( + 'message' => $notice, + ); + } + + $defaults = array( + 'type' => '', 'prepend' => __( 'View Admin As', VIEW_ADMIN_AS_DOMAIN ), - ), $notice ); + ); + + $notice = array_merge( $defaults, $notice ); if ( $notice['prepend'] ) { $notice['message'] = '' . $notice['prepend'] . ': ' . $notice['message']; } + $this->notices[ $id ] = array( 'type' => $notice['type'], 'message' => $notice['message'], @@ -798,15 +820,18 @@ private function validate_versions() { // Validate WP. $min_wp_version = '4.1'; if ( version_compare( $wp_version, $min_wp_version, '<' ) ) { - $this->add_notice( 'wp-version', array( - 'type' => 'notice-error', - 'message' => sprintf( - // Translators: %1$s stands for "WordPress", %2$s stands for the version. - __( 'Plugin deactivated, %1$s version %2$s or higher is required', VIEW_ADMIN_AS_DOMAIN ), - 'WordPress', - $min_wp_version - ), - ) ); + $this->add_notice( + 'wp-version', + array( + 'type' => 'notice-error', + 'message' => sprintf( + // Translators: %1$s stands for "WordPress", %2$s stands for the version. + __( 'Plugin deactivated, %1$s version %2$s or higher is required', VIEW_ADMIN_AS_DOMAIN ), + 'WordPress', + $min_wp_version + ), + ) + ); $valid = false; } diff --git a/includes/class-view.php b/includes/class-view.php index f45a2cb3..08caa06b 100644 --- a/includes/class-view.php +++ b/includes/class-view.php @@ -107,6 +107,14 @@ private function do_view() { * Temporary modifications to the current user are set on priority 99. * This functionality has a separate action: `vaa_view_admin_as_modify_current_user`. * + * @hooked + * 2: user + * 5: role + * 8: caps + * 10: locale (Languages) + * 10: group (Groups) + * 10: rua_level (Restrict User Access) + * * @since 1.6.3 * @param array */ @@ -154,13 +162,13 @@ public function init_user_modifications() { * Prevent some meta updates for the current user while in modification to the current user are active. * @since 1.6.3 */ - $this->add_filter( 'update_user_metadata' , array( $this, 'filter_prevent_update_user_metadata' ), 999999999, 3 ); + $this->add_filter( 'update_user_metadata', array( $this, 'filter_prevent_update_user_metadata' ), 999999999, 3 ); /** * Get capabilities and user level from current user view object instead of database. * @since 1.6.4 */ - $this->add_filter( 'get_user_metadata' , array( $this, 'filter_overrule_get_user_metadata' ), 999999999, 3 ); + $this->add_filter( 'get_user_metadata', array( $this, 'filter_overrule_get_user_metadata' ), 999999999, 3 ); // `user_has_cap` priority. $priority = -999999999; @@ -201,10 +209,11 @@ public function init_user_modifications() { * @since 1.7.3 * @since 1.8.0 Check for multisite. */ - if ( is_multisite() && - ! is_network_admin() && - is_super_admin( $this->store->get_selectedUser()->ID ) && - $this->store->get_userSettings( 'disable_super_admin' ) + if ( + is_multisite() + && ! is_network_admin() + && is_super_admin( $this->store->get_selectedUser()->ID ) + && $this->store->get_userSettings( 'disable_super_admin' ) ) { $this->disable_super_admin(); } @@ -475,10 +484,11 @@ public function current_view_can( $cap, $caps = array() ) { $cap = (string) $cap; - if ( is_array( $caps ) && - ! empty( $caps[ $cap ] ) && - 'do_not_allow' !== $cap && - 'do_not_allow' !== $caps[ $cap ] + if ( + is_array( $caps ) + && ! empty( $caps[ $cap ] ) + && 'do_not_allow' !== $cap + && 'do_not_allow' !== $caps[ $cap ] ) { return true; } diff --git a/modules/class-caps.php b/modules/class-caps.php index 226b084e..60f4bf5f 100644 --- a/modules/class-caps.php +++ b/modules/class-caps.php @@ -17,7 +17,7 @@ * @package View_Admin_As * @since 1.3.0 View type existed in core. * @since 1.8.0 Created this class. - * @version 1.8.0 + * @version 1.8.2 * @uses \VAA_View_Admin_As_Type Extends class */ class VAA_View_Admin_As_Caps extends VAA_View_Admin_As_Type @@ -183,7 +183,7 @@ public function update_view( $null, $data, $type = null ) { // The user was in his default view, notify the user. $success = array( 'success' => false, - 'data' => array( + 'data' => array( 'type' => 'message', 'text' => esc_html__( 'These are your default capabilities!', VIEW_ADMIN_AS_DOMAIN ), ), @@ -197,7 +197,7 @@ public function update_view( $null, $data, $type = null ) { if ( VAA_API::array_equal( $this->selected, $new_caps ) ) { $success = array( 'success' => false, - 'data' => array( + 'data' => array( 'type' => 'message', 'text' => esc_html__( 'This view is already selected!', VIEW_ADMIN_AS_DOMAIN ), ), @@ -247,7 +247,7 @@ public function admin_bar_menu( $admin_bar, $root ) { $title_submenu = (bool) apply_filters( 'vaa_admin_bar_caps_do_title_submenu', true ); $main_root = $root; - $root = $main_root . '-caps'; + $root = $main_root . '-caps'; $admin_bar->add_group( array( 'id' => $root, @@ -289,7 +289,7 @@ public function admin_bar_menu( $admin_bar, $root ) { if ( $title_submenu ) { $admin_bar->add_group( array( - 'id' => $root . '-manager', + 'id' => $root . '-manager', 'parent' => $root . '-title', ) ); } else { @@ -310,9 +310,9 @@ public function admin_bar_menu( $admin_bar, $root ) { 'id' => $root . '-applycaps', 'parent' => $root . '-manager', 'title' => VAA_View_Admin_As_Form::do_button( array( - 'name' => 'apply-caps-view', - 'label' => __( 'Apply', VIEW_ADMIN_AS_DOMAIN ), - 'class' => 'button-primary', + 'name' => 'apply-caps-view', + 'label' => __( 'Apply view', VIEW_ADMIN_AS_DOMAIN ), + 'class' => 'button-primary', ) ) . VAA_View_Admin_As_Form::do_button( array( 'name' => 'close-caps-popup', diff --git a/modules/class-groups.php b/modules/class-groups.php index 0eff380a..6970f033 100644 --- a/modules/class-groups.php +++ b/modules/class-groups.php @@ -273,9 +273,10 @@ public function modify_user( $user ) { * @return bool|object */ public function groups_user_is_member( $result, $user_id, $group_id ) { - if ( (int) $user_id === (int) $this->store->get_curUser()->ID - && $this->selected - && (int) $group_id === (int) $this->selected->group->group_id + if ( + (int) $user_id === (int) $this->store->get_curUser()->ID + && $this->selected + && (int) $group_id === (int) $this->selected->group->group_id ) { $result = $this->selected->group; } @@ -310,9 +311,10 @@ public function groups_user_can( $result, $object = null, $cap = '' ) { return $result; } - if ( $this->selected && - is_callable( array( $this->selected, 'can' ) ) && - ! $this->selected->can( $cap ) + if ( + $this->selected + && is_callable( array( $this->selected, 'can' ) ) + && ! $this->selected->can( $cap ) ) { $result = false; } else { @@ -363,6 +365,7 @@ public function groups_post_access_user_can_read_post( $result, $post_id, $user_ } $post_access = Groups_Post_Access::get_read_group_ids( $post_id ); + $result = true; if ( ! empty( $post_access ) && ! in_array( $this->selected->group_id, $post_access, true ) ) { $result = false; @@ -429,14 +432,14 @@ public function shortcode_groups_non_member( $atts, $content ) { * @return string */ public function shortcode_member( $atts, $content, $reverse = false ) { - $output = ''; - $shortcode = ( $reverse ) ? 'groups_non_member' : 'groups_member'; - $options = shortcode_atts( array( 'group' => '' ), $atts ); //, $shortcode + $output = ''; + $shortcode = ( $reverse ) ? 'groups_non_member' : 'groups_member'; + $options = shortcode_atts( array( 'group' => '' ), $atts ); //, $shortcode $show_content = false; if ( null !== $content ) { $groups = explode( ',', $options['group'] ); foreach ( $groups as $group ) { - $group = trim( $group ); + $group = trim( $group ); $selected_group = $this->selected; $current_group = Groups_Group::read( $group ); if ( ! $current_group ) { @@ -532,7 +535,7 @@ public function admin_bar_menu( $admin_bar, $root ) { ), 'href' => menu_page_url( $this->groupsScreen, false ), 'meta' => array( - 'class' => 'auto-height', + 'class' => 'auto-height', ), ) ); @@ -550,14 +553,14 @@ public function admin_bar_menu( $admin_bar, $root ) { foreach ( $this->get_groups() as $group_key => $group ) { $view_value = $group->group_id; $view_data = array( $this->type => $view_value ); - $href = VAA_API::get_vaa_action_link( $view_data, $this->store->get_nonce( true ) ); - $class = 'vaa-' . $this->type . '-item'; - $title = VAA_View_Admin_As_Form::do_view_title( $group->name, $this, $view_value ); + $href = VAA_API::get_vaa_action_link( $view_data ); + $class = 'vaa-' . $this->type . '-item'; + $title = VAA_View_Admin_As_Form::do_view_title( $group->name, $this, $view_value ); // Check if this group is the current view. if ( $this->store->get_view( $this->type ) ) { if ( (int) $this->store->get_view( $this->type ) === (int) $group->group_id ) { $class .= ' current'; - $href = false; + $href = false; } else { $selected = $this->get_groups( $this->store->get_view( $this->type ) ); if ( (int) $selected->parent_id === (int) $group->group_id ) { diff --git a/modules/class-languages.php b/modules/class-languages.php index d7bfe120..5f80ab6f 100644 --- a/modules/class-languages.php +++ b/modules/class-languages.php @@ -189,7 +189,7 @@ public function admin_bar_menu( $admin_bar, $root ) { if ( $done ) return; $main_root = $root; - $root = $main_root . '-locale'; + $root = $main_root . '-locale'; $admin_bar->add_group( array( 'id' => $root, @@ -211,7 +211,7 @@ public function admin_bar_menu( $admin_bar, $root ) { ) ); $admin_bar->add_group( array( - 'id' => $root . '-languages', + 'id' => $root . '-languages', 'parent' => $root . '-title', 'meta' => array( 'class' => 'vaa-auto-max-height', @@ -257,7 +257,7 @@ public function store_data() { return; } - $existing = (array) $this->store->get_optionData( $this->optionKey ); + $existing = (array) $this->store->get_optionData( $this->optionKey ); $languages = $existing; if ( array_diff_key( array_flip( $installed ), $existing ) ) { diff --git a/modules/class-restrict-user-access.php b/modules/class-restrict-user-access.php index 028fb6c0..d20bb8bd 100644 --- a/modules/class-restrict-user-access.php +++ b/modules/class-restrict-user-access.php @@ -254,8 +254,9 @@ public function modify_user( $user ) { * @return array */ public function get_user_metadata( $null, $user_id, $meta_key ) { - if ( (int) $user_id === (int) $this->store->get_selectedUser()->ID - && $this->get_levels( $this->selected ) + if ( + (int) $user_id === (int) $this->store->get_selectedUser()->ID + && $this->get_levels( $this->selected ) ) { // @todo Check for future API updates in RUA plugin if ( $this->ruaMetaPrefix . 'level' === $meta_key ) { @@ -357,7 +358,7 @@ public function admin_bar_menu( $admin_bar, $root, $role = null, $role_obj = nul ), 'href' => menu_page_url( $this->ruaScreen, false ), 'meta' => array( - 'class' => 'auto-height', + 'class' => 'auto-height', ), ) ); @@ -395,7 +396,7 @@ public function admin_bar_menu( $admin_bar, $root, $role = null, $role_obj = nul if ( $role ) { $view_data['role'] = $role; } - $href = VAA_API::get_vaa_action_link( $view_data, $this->store->get_nonce( true ) ); + $href = VAA_API::get_vaa_action_link( $view_data ); $class = 'vaa-' . $this->type . '-item'; $title = VAA_View_Admin_As_Form::do_view_title( $level->post_title, $this, ( $role ) ? wp_json_encode( $view_data ) : $view_value ); // Check if this level is the current view. @@ -421,15 +422,15 @@ public function admin_bar_menu( $admin_bar, $root, $role = null, $role_obj = nul $parent = $root . '-' . $this->type . '-' . (int) $level->post_parent; } $admin_bar->add_node( array( - 'id' => $root . '-' . $this->type . '-' . $view_value, - 'parent' => $parent, - 'title' => $title, - 'href' => $href, - 'meta' => array( + 'id' => $root . '-' . $this->type . '-' . $view_value, + 'parent' => $parent, + 'title' => $title, + 'href' => $href, + 'meta' => array( // Translators: %s stands for the view type name. - 'title' => sprintf( __( 'View as %s', VIEW_ADMIN_AS_DOMAIN ), $level->post_title ) - . ( ( $role ) ? ' (' . $this->store->get_rolenames( $role_obj->name ) . ')' : '' ), - 'class' => $class, + 'title' => sprintf( __( 'View as %s', VIEW_ADMIN_AS_DOMAIN ), $level->post_title ) + . ( ( $role ) ? ' (' . $this->store->get_rolenames( $role_obj->name ) . ')' : '' ), + 'class' => $class, ), ) ); } // End foreach(). diff --git a/modules/class-role-defaults.php b/modules/class-role-defaults.php index b09adb79..c01fbb3c 100644 --- a/modules/class-role-defaults.php +++ b/modules/class-role-defaults.php @@ -21,7 +21,7 @@ * @author Jory Hogeveen * @package View_Admin_As * @since 1.4.0 - * @version 1.8.0 + * @version 1.8.2 * @uses \VAA_View_Admin_As_Module Extends class */ final class VAA_View_Admin_As_Role_Defaults extends VAA_View_Admin_As_Module @@ -69,14 +69,14 @@ final class VAA_View_Admin_As_Role_Defaults extends VAA_View_Admin_As_Module * @var bool[] Meta key as array key. */ private $meta_default = array( - 'admin_color' => true, // The admin color. - 'rich_editing' => true, // Enable/Disable rich editing. - 'metaboxhidden_%%' => true, // Hidden metaboxes. - 'meta-box-order_%%' => true, // Metabox order and locations. - 'closedpostboxes_%%' => true, // Hidden post boxes. - 'edit_%%_per_page' => true, // Amount of items per page in edit pages (overview). - 'manage%%columnshidden' => true, // Hidden columns in overview pages. - 'screen_layout_%%' => true, // Screen layout (num of columns). + 'admin_color' => true, // The admin color. + 'rich_editing' => true, // Enable/Disable rich editing. + 'metaboxhidden_%%' => true, // Hidden metaboxes. + 'meta-box-order_%%' => true, // Metabox order and locations. + 'closedpostboxes_%%' => true, // Hidden post boxes. + 'edit_%%_per_page' => true, // Amount of items per page in edit pages (overview). + 'manage%%columnshidden' => true, // Hidden columns in overview pages. + 'screen_layout_%%' => true, // Screen layout (num of columns). ); /** @@ -87,14 +87,14 @@ final class VAA_View_Admin_As_Role_Defaults extends VAA_View_Admin_As_Module * @var string[] */ private $meta_forbidden = array( - 'vaa-view-admin-as', // Meta value for this plugin. - '%%capabilities', // User capabilities. - '%%user_level', // User user level. - 'session_tokens', // User session tokens. - 'nickname', // User nickname. - 'first_name', // User first name. - 'last_name', // User last name. - 'description', // User description. + 'vaa-view-admin-as', // Meta value for this plugin. + '%%capabilities', // User capabilities. + '%%user_level', // User user level. + 'session_tokens', // User session tokens. + 'nickname', // User nickname. + 'first_name', // User first name. + 'last_name', // User last name. + 'description', // User description. ); /** @@ -147,6 +147,8 @@ protected function __construct( $vaa ) { if ( ! is_network_admin() && $this->current_user_can( 'view_admin_as_role_defaults' ) ) { $this->add_action( 'vaa_view_admin_as_init', array( $this, 'vaa_init' ) ); $this->add_filter( 'view_admin_as_handle_ajax_' . $this->moduleKey, array( $this, 'ajax_handler' ), 10, 2 ); + // @since 1.8.2 Filter ajax search return. + $this->add_filter( 'view_admin_as_ajax_search_users_return_' . $this->moduleKey, array( $this, 'ajax_search_users_return' ), 10, 4 ); } } @@ -261,9 +263,10 @@ public function admin_print_footer_scripts() { * @since 1.6.0 * @since 1.6.2 Improved conditions + check if sortable is enqueued and active. */ - if ( $this->get_optionData( 'lock_meta_boxes' ) - && ! $this->current_user_can( 'view_admin_as_role_defaults' ) - && wp_script_is( 'jquery-ui-sortable', 'enqueued' ) + if ( + $this->get_optionData( 'lock_meta_boxes' ) + && ! $this->current_user_can( 'view_admin_as_role_defaults' ) + && wp_script_is( 'jquery-ui-sortable', 'enqueued' ) ) { ?>