Ultimate Member – User Profile & Membership Plugin - Version 2.2.0

Version Description

Download this release

Release Info

Developer nsinelnikov
Plugin Icon 128x128 Ultimate Member – User Profile & Membership Plugin
Version 2.2.0
Comparing to
See all releases

Code changes from version 2.2.0-rc.1 to 2.2.0

assets/js/um-fileupload.js CHANGED
@@ -1,8 +1,8 @@
1
- /*!
2
- * jQuery Upload File Plugin
3
- * version: 3.1.2
4
- * @requires jQuery v1.5 or later & form plugin
5
- * Copyright (c) 2013 Ravishanker Kusuma
6
- * http://hayageek.com/
7
- */
8
- (function(b){if(b.fn.ajaxForm==undefined){}var a={};a.fileapi=b("<input type='file'/>").get(0).files!==undefined;a.formdata=window.FormData!==undefined;b.fn.uploadFile=function(t){var r=b.extend({url:"",method:"POST",enctype:"multipart/form-data",formData:null,returnType:null,allowedTypes:"*",fileName:"file",formData:{},dynamicFormData:function(){return{}},maxFileSize:-1,maxFileCount:-1,multiple:true,dragDrop:true,autoSubmit:true,showCancel:true,showAbort:true,showDone:true,showDelete:false,showError:true,showStatusAfterSuccess:true,showStatusAfterError:true,showFileCounter:true,fileCounterStyle:"). ",showProgress:false,onSelect:function(s){return true},onSubmit:function(s,u){},onSuccess:function(u,s,v){},onError:function(v,s,u){},deleteCallback:false,afterUploadAll:false,uploadButtonClass:"upload",dragDropStr:"",abortStr:"Abort",cancelStr:"Cancel",deletelStr:"Delete",doneStr:"Done",multiDragErrorStr:"Multiple File Drag &amp; Drop is not allowed.",extErrorStr:"",sizeErrorStr:"",uploadErrorStr:"Upload is not allowed",maxFileCountErrorStr:""},t);this.fileCounter=1;this.selectedFiles=0;this.fCounter=0;this.sCounter=0;this.tCounter=0;var d="upload-"+(new Date().getTime());this.formGroup=d;this.hide();this.errorLog=b("<div></div>");this.after(this.errorLog);this.responses=[];if(!a.formdata){r.dragDrop=false}if(!a.formdata){r.multiple=false}var m=this;var e=b("<div>"+b(this).html()+"</div>");b(e).addClass(r.uploadButtonClass);(function k(){if(b.fn.ajaxForm){if(r.dragDrop){var s=b('<div class="ajax-upload-dragdrop" style="vertical-align:top;"></div>');b(m).before(s);b(s).append(e);b(s).prepend(b(r.dragDropStr));f(m,r,s)}else{b(m).before(e)}q(m,d,r,e)}else{window.setTimeout(k,10)}})();this.startUpload=function(){b("."+this.formGroup).each(function(u,s){if(b(this).is("form")){b(this).submit()}})};this.stopUpload=function(){b(".upload-red").each(function(u,s){if(b(this).hasClass(m.formGroup)){b(this).click()}})};this.getResponses=function(){return this.responses};var g=false;function j(){if(r.afterUploadAll&&!g){g=true;(function s(){if(m.sCounter!=0&&(m.sCounter+m.fCounter==m.tCounter)){r.afterUploadAll(m);g=false}else{window.setTimeout(s,100)}})()}}function f(w,u,v){v.on("dragenter",function(s){s.stopPropagation();s.preventDefault();b(this).css("border","2px dashed #ddd")});v.on("dragover",function(s){s.stopPropagation();s.preventDefault()});v.on("drop",function(x){b(this).css("border","2px dashed #ddd");x.preventDefault();w.errorLog.html("");var s=x.originalEvent.dataTransfer.files;if(!u.multiple&&s.length>1){if(u.showError){b("<div class='um-error-block'>"+u.multiDragErrorStr+"</div>").appendTo(w.errorLog)}return}if(u.onSelect(s)==false){return}l(u,w,s)});b(document).on("dragenter",function(s){s.stopPropagation();s.preventDefault()});b(document).on("dragover",function(s){s.stopPropagation();s.preventDefault();v.css("border","2px dashed #ddd")});b(document).on("drop",function(s){s.stopPropagation();s.preventDefault();v.css("border","2px dashed #ddd")})}function i(s){var v="";var u=s/1024;if(parseInt(u)>1024){var w=u/1024;v=w.toFixed(2)+" MB"}else{v=u.toFixed(2)+" KB"}return v}function o(x){var y=[];if(jQuery.type(x)=="string"){y=x.split("&")}else{y=b.param(x).split("&")}var u=y.length;var s=[];var w,v;for(w=0;w<u;w++){y[w]=y[w].replace(/\+/g," ");v=y[w].split("=");s.push([decodeURIComponent(v[0]),decodeURIComponent(v[1])])}return s}function l(H,B,u){for(var C=0;C<u.length;C++){if(!c(B,H,u[C].name)){if(H.showError){b("<div class='um-error-block'>"+H.extErrorStr+"</div>").appendTo(B.errorLog)}continue}if(H.maxFileSize!=-1&&u[C].size>H.maxFileSize){if(H.showError){b("<div class='um-error-block'>"+H.sizeErrorStr+"</div>").appendTo(B.errorLog)}continue}if(H.maxFileCount!=-1&&B.selectedFiles>=H.maxFileCount){if(H.showError){b("<div class='um-error-block'>"+H.maxFileCountErrorStr+"</div>").appendTo(B.errorLog)}continue}B.selectedFiles++;var D=H;var w=new FormData();var A=H.fileName.replace("[]","");w.append(A,u[C]);var y=H.formData;if(y){var F=o(y);for(var z=0;z<F.length;z++){if(F[z]){w.append(F[z][0],F[z][1])}}}D.fileData=w;var E=new p(B,H);var G="";if(H.showFileCounter){G=B.fileCounter+H.fileCounterStyle+u[C].name}else{G=u[C].name}E.filename.html(G);var v=b("<form style='display:block; position:absolute;left: 150px;' class='"+B.formGroup+"' method='"+H.method+"' action='"+H.url+"' enctype='"+H.enctype+"'></form>");v.appendTo("body");var x=[];x.push(u[C].name);n(v,D,E,x,B);B.fileCounter++}}function c(w,v,y){var x=v.allowedTypes.toLowerCase().split(",");var u=y.split(".").pop().toLowerCase();if(v.allowedTypes!="*"&&jQuery.inArray(u,x)<0){return false}return true}function h(u,w){if(u.showFileCounter){var v=b(".upload-filename").length;w.fileCounter=v+1;b(".upload-filename").each(function(A,y){var s=b(this).html().split(u.fileCounterStyle);var x=parseInt(s[0])-1;var z=v+u.fileCounterStyle+s[1];b(this).html(z);v--})}}function q(y,B,D,u){var A="ajax-upload-id-"+(new Date().getTime());var w=b("<form method='"+D.method+"' action='"+D.url+"' enctype='"+D.enctype+"'></form>");var v="<input type='file' id='"+A+"' name='"+D.fileName+"'/>";if(D.multiple){if(D.fileName.indexOf("[]")!=D.fileName.length-2){D.fileName+="[]"}v="<input type='file' id='"+A+"' name='"+D.fileName+"' multiple/>"}var z=b(v).appendTo(w);z.change(function(){y.errorLog.html("");var K=D.allowedTypes.toLowerCase().split(",");var G=[];if(this.files){for(H=0;H<this.files.length;H++){G.push(this.files[H].name)}if(D.onSelect(this.files)==false){return}}else{var I=b(this).val();var F=[];G.push(I);if(!c(y,D,I)){if(D.showError){b("<div class='um-error-block'>"+D.extErrorStr+"</div>").appendTo(y.errorLog)}return}F.push({name:I,size:"NA"});if(D.onSelect(F)==false){return}}h(D,y);u.unbind("click");w.hide();q(y,B,D,u);w.addClass(B);if(a.fileapi&&a.formdata){w.removeClass(B);var J=this.files;l(D,y,J)}else{var E="";for(var H=0;H<G.length;H++){if(D.showFileCounter){E+=y.fileCounter+D.fileCounterStyle+G[H]+"<br>"}else{E+=G[H]+"<br>"}y.fileCounter++}if(D.maxFileCount!=-1&&(y.selectedFiles+G.length)>D.maxFileCount){if(D.showError){b("<div class='um-error-block'>"+D.maxFileCountErrorStr+"</div>").appendTo(y.errorLog)}return}y.selectedFiles+=G.length;var s=new p(y,D);s.filename.html(E);n(w,D,s,G,y)}});w.css({margin:0,padding:0});var C=b(u).width()+10;if(C==10){C=120}var x=u.height()+10;if(x==10){x=35}u.css({position:"relative",overflow:"hidden",cursor:"default"});z.css({position:"absolute",cursor:"pointer",top:"0px",width:'100%',height:'34px',left:"0px","z-index":"100",opacity:"0.0",filter:"alpha(opacity=0)","-ms-filter":"alpha(opacity=0)","-khtml-opacity":"0.0","-moz-opacity":"0.0"});w.appendTo(u)}function p(v,u){this.statusbar=b("<div class='upload-statusbar'></div>");this.filename=b("<div class='upload-filename'></div>").appendTo(this.statusbar);this.progressDiv=b("<div class='upload-progress'>").appendTo(this.statusbar).hide();this.progressbar=b("<div class='upload-bar "+v.formGroup+"'></div>").appendTo(this.progressDiv);this.abort=b("<div class='upload-red "+v.formGroup+"'>"+u.abortStr+"</div>").appendTo(this.statusbar).hide();this.cancel=b("<div class='upload-red'>"+u.cancelStr+"</div>").appendTo(this.statusbar).hide();this.done=b("<div class='upload-green'>"+u.doneStr+"</div>").appendTo(this.statusbar).hide();this.del=b("<div class='upload-red'>"+u.deletelStr+"</div>").appendTo(this.statusbar).hide();v.errorLog.after(this.statusbar);return this}function n(z,y,u,w,A){var x=null;var v={cache:false,contentType:false,processData:false,forceSync:false,data:y.formData,formData:y.fileData,dataType:y.returnType,beforeSubmit:function(F,C,E){if(y.onSubmit.call(this,w)!=false){var B=y.dynamicFormData();if(B){var s=o(B);if(s){for(var D=0;D<s.length;D++){if(s[D]){if(y.fileData!=undefined){E.formData.append(s[D][0],s[D][1])}else{E.data[s[D][0]]=s[D][1]}}}}}A.tCounter+=w.length;j();return true}u.statusbar.append("<div class='um-error-block'>"+y.uploadErrorStr+"</div>");u.cancel.show();z.remove();u.cancel.click(function(){u.statusbar.remove()});return false},beforeSend:function(B,s){u.progressDiv.show();u.cancel.hide();u.done.hide();if(y.showAbort){u.abort.show();u.abort.click(function(){B.abort();A.selectedFiles-=w.length})}if(!a.formdata){u.progressbar.width("5%")}else{u.progressbar.width("1%")}},uploadProgress:function(E,s,D,C){if(C>98){C=98}var B=C+"%";if(C>1){u.progressbar.width(B)}if(y.showProgress){u.progressbar.html(B);u.progressbar.css("text-align","center")}},success:function(B,s,C){A.responses.push(B);u.progressbar.width("100%");if(y.showProgress){u.progressbar.html("100%");u.progressbar.css("text-align","center")}u.abort.hide();y.onSuccess.call(this,w,B,C);if(y.showStatusAfterSuccess){if(y.showDone){u.done.show();u.done.click(function(){u.statusbar.hide("slow");u.statusbar.remove()})}else{u.done.hide()}if(y.showDelete){u.del.show();u.del.click(function(){u.statusbar.hide().remove();if(y.deleteCallback){y.deleteCallback.call(this,B,u)}A.selectedFiles-=w.length;h(y,A)})}else{u.del.hide()}}else{u.statusbar.hide("slow");u.statusbar.remove()}z.remove();A.sCounter+=w.length},error:function(C,s,B){u.abort.hide();if(C.statusText=="abort"){u.statusbar.hide("slow").remove();h(y,A)}else{y.onError.call(this,w,s,B);if(y.showStatusAfterError){u.progressDiv.hide();u.statusbar.append("<span class='um-error-block'>ERROR: "+B+"</span>")}else{u.statusbar.hide();u.statusbar.remove()}A.selectedFiles-=w.length}z.remove();A.fCounter+=w.length}};if(y.autoSubmit){z.ajaxSubmit(v)}else{if(y.showCancel){u.cancel.show();u.cancel.click(function(){z.remove();u.statusbar.remove();A.selectedFiles-=w.length;h(y,A)})}z.ajaxForm(v)}}return this}}(jQuery));
1
+ /*!
2
+ * jQuery Upload File Plugin
3
+ * version: 3.1.2
4
+ * @requires jQuery v1.5 or later & form plugin
5
+ * Copyright (c) 2013 Ravishanker Kusuma
6
+ * http://hayageek.com/
7
+ */
8
+ (function(b){if(b.fn.ajaxForm==undefined){}var a={};a.fileapi=b("<input type='file'/>").get(0).files!==undefined;a.formdata=window.FormData!==undefined;b.fn.uploadFile=function(t){var r=b.extend({url:"",method:"POST",enctype:"multipart/form-data",formData:null,returnType:null,allowedTypes:"*",fileName:"file",formData:{},dynamicFormData:function(){return{}},maxFileSize:-1,maxFileCount:-1,multiple:true,dragDrop:true,autoSubmit:true,showCancel:true,showAbort:true,showDone:true,showDelete:false,showError:true,showStatusAfterSuccess:true,showStatusAfterError:true,showFileCounter:true,fileCounterStyle:"). ",showProgress:false,onSelect:function(s){return true},onSubmit:function(s,u){},onSuccess:function(u,s,v){},onError:function(v,s,u){},deleteCallback:false,afterUploadAll:false,uploadButtonClass:"upload",dragDropStr:"",abortStr:"Abort",cancelStr:"Cancel",deletelStr:"Delete",doneStr:"Done",multiDragErrorStr:"Multiple File Drag &amp; Drop is not allowed.",extErrorStr:"",sizeErrorStr:"",uploadErrorStr:"Upload is not allowed",maxFileCountErrorStr:""},t);this.fileCounter=1;this.selectedFiles=0;this.fCounter=0;this.sCounter=0;this.tCounter=0;var d="upload-"+(new Date().getTime());this.formGroup=d;this.hide();this.errorLog=b("<div></div>");this.after(this.errorLog);this.responses=[];if(!a.formdata){r.dragDrop=false}if(!a.formdata){r.multiple=false}var m=this;var e=b("<div>"+b(this).html()+"</div>");b(e).addClass(r.uploadButtonClass);(function k(){if(b.fn.ajaxForm){if(r.dragDrop){var s=b('<div class="ajax-upload-dragdrop" style="vertical-align:top;"></div>');b(m).before(s);b(s).append(e);b(s).prepend(b(r.dragDropStr));f(m,r,s)}else{b(m).before(e)}q(m,d,r,e)}else{window.setTimeout(k,10)}})();this.startUpload=function(){b("."+this.formGroup).each(function(u,s){if(b(this).is("form")){b(this).submit()}})};this.stopUpload=function(){b(".upload-red").each(function(u,s){if(b(this).hasClass(m.formGroup)){b(this).click()}})};this.getResponses=function(){return this.responses};var g=false;function j(){if(r.afterUploadAll&&!g){g=true;(function s(){if(m.sCounter!=0&&(m.sCounter+m.fCounter==m.tCounter)){r.afterUploadAll(m);g=false}else{window.setTimeout(s,100)}})()}}function f(w,u,v){v.on("dragenter",function(s){s.stopPropagation();s.preventDefault();b(this).css("border","2px dashed #ddd")});v.on("dragover",function(s){s.stopPropagation();s.preventDefault()});v.on("drop",function(x){b(this).css("border","2px dashed #ddd");x.preventDefault();w.errorLog.html("");var s=x.originalEvent.dataTransfer.files;if(!u.multiple&&s.length>1){if(u.showError){b("<div class='um-error-block'>"+u.multiDragErrorStr+"</div>").appendTo(w.errorLog)}return}if(u.onSelect(s)==false){return}l(u,w,s)});b(document).on("dragenter",function(s){s.stopPropagation();s.preventDefault()});b(document).on("dragover",function(s){s.stopPropagation();s.preventDefault();v.css("border","2px dashed #ddd")});b(document).on("drop",function(s){s.stopPropagation();s.preventDefault();v.css("border","2px dashed #ddd")})}function i(s){var v="";var u=s/1024;if(parseInt(u)>1024){var w=u/1024;v=w.toFixed(2)+" MB"}else{v=u.toFixed(2)+" KB"}return v}function o(x){var y=[];if(jQuery.type(x)=="string"){y=x.split("&")}else{y=b.param(x).split("&")}var u=y.length;var s=[];var w,v;for(w=0;w<u;w++){y[w]=y[w].replace(/\+/g," ");v=y[w].split("=");s.push([decodeURIComponent(v[0]),decodeURIComponent(v[1])])}return s}function l(H,B,u){for(var C=0;C<u.length;C++){if(!c(B,H,u[C].name)){if(H.showError){b("<div class='um-error-block'>"+H.extErrorStr+"</div>").appendTo(B.errorLog)}continue}if(H.maxFileSize!=-1&&u[C].size>H.maxFileSize){if(H.showError){b("<div class='um-error-block'>"+H.sizeErrorStr+"</div>").appendTo(B.errorLog)}continue}if(H.maxFileCount!=-1&&B.selectedFiles>=H.maxFileCount){if(H.showError){b("<div class='um-error-block'>"+H.maxFileCountErrorStr+"</div>").appendTo(B.errorLog)}continue}B.selectedFiles++;var D=H;var w=new FormData();var A=H.fileName.replace("[]","");w.append(A,u[C]);var y=H.formData;if(y){var F=o(y);for(var z=0;z<F.length;z++){if(F[z]){w.append(F[z][0],F[z][1])}}}D.fileData=w;var E=new p(B,H);var G="";if(H.showFileCounter){G=B.fileCounter+H.fileCounterStyle+u[C].name}else{G=u[C].name}/*E.filename.html(G);*/var v=b("<form style='display:block; position:absolute;left: 150px;' class='"+B.formGroup+"' method='"+H.method+"' action='"+H.url+"' enctype='"+H.enctype+"'></form>");v.appendTo("body");var x=[];x.push(u[C].name);n(v,D,E,x,B);B.fileCounter++}}function c(w,v,y){var x=v.allowedTypes.toLowerCase().split(",");var u=y.split(".").pop().toLowerCase();if(v.allowedTypes!="*"&&jQuery.inArray(u,x)<0){return false}return true}function h(u,w){if(u.showFileCounter){var v=b(".upload-filename").length;w.fileCounter=v+1;b(".upload-filename").each(function(A,y){var s=b(this).html().split(u.fileCounterStyle);var x=parseInt(s[0])-1;var z=v+u.fileCounterStyle+s[1];b(this).html(z);v--})}}function q(y,B,D,u){var A="ajax-upload-id-"+(new Date().getTime());var w=b("<form method='"+D.method+"' action='"+D.url+"' enctype='"+D.enctype+"'></form>");var v="<input type='file' id='"+A+"' name='"+D.fileName+"'/>";if(D.multiple){if(D.fileName.indexOf("[]")!=D.fileName.length-2){D.fileName+="[]"}v="<input type='file' id='"+A+"' name='"+D.fileName+"' multiple/>"}var z=b(v).appendTo(w);z.change(function(){y.errorLog.html("");var K=D.allowedTypes.toLowerCase().split(",");var G=[];if(this.files){for(H=0;H<this.files.length;H++){G.push(this.files[H].name)}if(D.onSelect(this.files)==false){return}}else{var I=b(this).val();var F=[];G.push(I);if(!c(y,D,I)){if(D.showError){b("<div class='um-error-block'>"+D.extErrorStr+"</div>").appendTo(y.errorLog)}return}F.push({name:I,size:"NA"});if(D.onSelect(F)==false){return}}h(D,y);u.unbind("click");w.hide();q(y,B,D,u);w.addClass(B);if(a.fileapi&&a.formdata){w.removeClass(B);var J=this.files;l(D,y,J)}else{var E="";for(var H=0;H<G.length;H++){if(D.showFileCounter){E+=y.fileCounter+D.fileCounterStyle+G[H]+"<br>"}else{E+=G[H]+"<br>"}y.fileCounter++}if(D.maxFileCount!=-1&&(y.selectedFiles+G.length)>D.maxFileCount){if(D.showError){b("<div class='um-error-block'>"+D.maxFileCountErrorStr+"</div>").appendTo(y.errorLog)}return}y.selectedFiles+=G.length;var s=new p(y,D);s.filename.html(E);n(w,D,s,G,y)}});w.css({margin:0,padding:0});var C=b(u).width()+10;if(C==10){C=120}var x=u.height()+10;if(x==10){x=35}u.css({position:"relative",overflow:"hidden",cursor:"default"});z.css({position:"absolute",cursor:"pointer",top:"0px",width:'100%',height:'34px',left:"0px","z-index":"100",opacity:"0.0",filter:"alpha(opacity=0)","-ms-filter":"alpha(opacity=0)","-khtml-opacity":"0.0","-moz-opacity":"0.0"});w.appendTo(u)}function p(v,u){this.statusbar=b("<div class='upload-statusbar'></div>");/*this.filename=b("<div class='upload-filename'></div>").appendTo(this.statusbar);*/this.progressDiv=b("<div class='upload-progress'>").appendTo(this.statusbar).hide();this.progressbar=b("<div class='upload-bar "+v.formGroup+"'></div>").appendTo(this.progressDiv);this.abort=b("<div class='upload-red "+v.formGroup+"'>"+u.abortStr+"</div>").appendTo(this.statusbar).hide();this.cancel=b("<div class='upload-red'>"+u.cancelStr+"</div>").appendTo(this.statusbar).hide();this.done=b("<div class='upload-green'>"+u.doneStr+"</div>").appendTo(this.statusbar).hide();this.del=b("<div class='upload-red'>"+u.deletelStr+"</div>").appendTo(this.statusbar).hide();v.errorLog.after(this.statusbar);return this}function n(z,y,u,w,A){var x=null;var v={cache:false,contentType:false,processData:false,forceSync:false,data:y.formData,formData:y.fileData,dataType:y.returnType,beforeSubmit:function(F,C,E){if(y.onSubmit.call(this,w)!=false){var B=y.dynamicFormData();if(B){var s=o(B);if(s){for(var D=0;D<s.length;D++){if(s[D]){if(y.fileData!=undefined){E.formData.append(s[D][0],s[D][1])}else{E.data[s[D][0]]=s[D][1]}}}}}A.tCounter+=w.length;j();return true}u.statusbar.append("<div class='um-error-block'>"+y.uploadErrorStr+"</div>");u.cancel.show();z.remove();u.cancel.click(function(){u.statusbar.remove()});return false},beforeSend:function(B,s){u.progressDiv.show();u.cancel.hide();u.done.hide();if(y.showAbort){u.abort.show();u.abort.click(function(){B.abort();A.selectedFiles-=w.length})}if(!a.formdata){u.progressbar.width("5%")}else{u.progressbar.width("1%")}},uploadProgress:function(E,s,D,C){if(C>98){C=98}var B=C+"%";if(C>1){u.progressbar.width(B)}if(y.showProgress){u.progressbar.html(B);u.progressbar.css("text-align","center")}},success:function(B,s,C){A.responses.push(B);u.progressbar.width("100%");if(y.showProgress){u.progressbar.html("100%");u.progressbar.css("text-align","center")}u.abort.hide();y.onSuccess.call(this,w,B,C);if(y.showStatusAfterSuccess){if(y.showDone){u.done.show();u.done.click(function(){u.statusbar.hide("slow");u.statusbar.remove()})}else{u.done.hide()}if(y.showDelete){u.del.show();u.del.click(function(){u.statusbar.hide().remove();if(y.deleteCallback){y.deleteCallback.call(this,B,u)}A.selectedFiles-=w.length;h(y,A)})}else{u.del.hide()}}else{u.statusbar.hide("slow");u.statusbar.remove()}z.remove();A.sCounter+=w.length},error:function(C,s,B){u.abort.hide();if(C.statusText=="abort"){u.statusbar.hide("slow").remove();h(y,A)}else{y.onError.call(this,w,s,B);if(y.showStatusAfterError){u.progressDiv.hide();u.statusbar.append("<span class='um-error-block'>ERROR: "+B+"</span>")}else{u.statusbar.hide();u.statusbar.remove()}A.selectedFiles-=w.length}z.remove();A.fCounter+=w.length}};if(y.autoSubmit){z.ajaxSubmit(v)}else{if(y.showCancel){u.cancel.show();u.cancel.click(function(){z.remove();u.statusbar.remove();A.selectedFiles-=w.length;h(y,A)})}z.ajaxForm(v)}}return this}}(jQuery));
assets/js/um-fileupload.min.js DELETED
@@ -1 +0,0 @@
1
- !function(S){S.fn.ajaxForm;var C={};C.fileapi=void 0!==S("<input type='file'/>").get(0).files,C.formdata=void 0!==window.FormData,S.fn.uploadFile=function(e){var p=S.extend({url:"",method:"POST",enctype:"multipart/form-data",formData:null,returnType:null,allowedTypes:"*",fileName:"file",formData:{},dynamicFormData:function(){return{}},maxFileSize:-1,maxFileCount:-1,multiple:!0,dragDrop:!0,autoSubmit:!0,showCancel:!0,showAbort:!0,showDone:!0,showDelete:!1,showError:!0,showStatusAfterSuccess:!0,showStatusAfterError:!0,showFileCounter:!0,fileCounterStyle:"). ",showProgress:!1,onSelect:function(e){return!0},onSubmit:function(e,r){},onSuccess:function(e,r,t){},onError:function(e,r,t){},deleteCallback:!1,afterUploadAll:!1,uploadButtonClass:"upload",dragDropStr:"",abortStr:"Abort",cancelStr:"Cancel",deletelStr:"Delete",doneStr:"Done",multiDragErrorStr:"Multiple File Drag &amp; Drop is not allowed.",extErrorStr:"",sizeErrorStr:"",uploadErrorStr:"Upload is not allowed",maxFileCountErrorStr:""},e);this.fileCounter=1,this.selectedFiles=0,this.fCounter=0,this.sCounter=0,this.tCounter=0;var t="upload-"+(new Date).getTime();this.formGroup=t,this.hide(),this.errorLog=S("<div></div>"),this.after(this.errorLog),this.responses=[],C.formdata||(p.dragDrop=!1),C.formdata||(p.multiple=!1);var c=this,o=S("<div>"+S(this).html()+"</div>");S(o).addClass(p.uploadButtonClass),function e(){if(S.fn.ajaxForm){if(p.dragDrop){var r=S('<div class="ajax-upload-dragdrop" style="vertical-align:top;"></div>');S(c).before(r),S(r).append(o),S(r).prepend(S(p.dragDropStr)),function(t,o,r){r.on("dragenter",function(e){e.stopPropagation(),e.preventDefault(),S(this).css("border","2px dashed #ddd")}),r.on("dragover",function(e){e.stopPropagation(),e.preventDefault()}),r.on("drop",function(e){S(this).css("border","2px dashed #ddd"),e.preventDefault(),t.errorLog.html("");var r=e.originalEvent.dataTransfer.files;!o.multiple&&1<r.length?o.showError&&S("<div class='um-error-block'>"+o.multiDragErrorStr+"</div>").appendTo(t.errorLog):0!=o.onSelect(r)&&m(o,t,r)}),S(document).on("dragenter",function(e){e.stopPropagation(),e.preventDefault()}),S(document).on("dragover",function(e){e.stopPropagation(),e.preventDefault(),r.css("border","2px dashed #ddd")}),S(document).on("drop",function(e){e.stopPropagation(),e.preventDefault(),r.css("border","2px dashed #ddd")})}(c,p,r)}else S(c).before(o);!function l(n,d,u,p){var e="ajax-upload-id-"+(new Date).getTime();var c=S("<form method='"+u.method+"' action='"+u.url+"' enctype='"+u.enctype+"'></form>");var r="<input type='file' id='"+e+"' name='"+u.fileName+"'/>";u.multiple&&(u.fileName.indexOf("[]")!=u.fileName.length-2&&(u.fileName+="[]"),r="<input type='file' id='"+e+"' name='"+u.fileName+"' multiple/>");var t=S(r).appendTo(c);t.change(function(){n.errorLog.html("");u.allowedTypes.toLowerCase().split(",");var e=[];if(this.files){for(s=0;s<this.files.length;s++)e.push(this.files[s].name);if(0==u.onSelect(this.files))return}else{var r=S(this).val(),t=[];if(e.push(r),!v(n,u,r))return void(u.showError&&S("<div class='um-error-block'>"+u.extErrorStr+"</div>").appendTo(n.errorLog));if(t.push({name:r,size:"NA"}),0==u.onSelect(t))return}if(g(u,n),p.unbind("click"),c.hide(),l(n,d,u,p),c.addClass(d),C.fileapi&&C.formdata){c.removeClass(d);var o=this.files;m(u,n,o)}else{for(var a="",s=0;s<e.length;s++)u.showFileCounter?a+=n.fileCounter+u.fileCounterStyle+e[s]+"<br>":a+=e[s]+"<br>",n.fileCounter++;if(-1!=u.maxFileCount&&n.selectedFiles+e.length>u.maxFileCount)return void(u.showError&&S("<div class='um-error-block'>"+u.maxFileCountErrorStr+"</div>").appendTo(n.errorLog));n.selectedFiles+=e.length;var i=new b(n,u);i.filename.html(a),w(c,u,i,e,n)}});c.css({margin:0,padding:0});var o=S(p).width()+10;10==o&&(o=120);var a=p.height()+10;10==a&&(a=35);p.css({position:"relative",overflow:"hidden",cursor:"default"});t.css({position:"absolute",cursor:"pointer",top:"0px",width:"100%",height:"34px",left:"0px","z-index":"100",opacity:"0.0",filter:"alpha(opacity=0)","-ms-filter":"alpha(opacity=0)","-khtml-opacity":"0.0","-moz-opacity":"0.0"});c.appendTo(p)}(c,t,p,o)}else window.setTimeout(e,10)}(),this.startUpload=function(){S("."+this.formGroup).each(function(e,r){S(this).is("form")&&S(this).submit()})},this.stopUpload=function(){S(".upload-red").each(function(e,r){S(this).hasClass(c.formGroup)&&S(this).click()})};var h=!(this.getResponses=function(){return this.responses});function f(e){var r,t,o=[],a=(o="string"==jQuery.type(e)?e.split("&"):S.param(e).split("&")).length,s=[];for(r=0;r<a;r++)o[r]=o[r].replace(/\+/g," "),t=o[r].split("="),s.push([decodeURIComponent(t[0]),decodeURIComponent(t[1])]);return s}function m(e,r,t){for(var o=0;o<t.length;o++)if(v(r,e,t[o].name))if(-1!=e.maxFileSize&&t[o].size>e.maxFileSize)e.showError&&S("<div class='um-error-block'>"+e.sizeErrorStr+"</div>").appendTo(r.errorLog);else if(-1!=e.maxFileCount&&r.selectedFiles>=e.maxFileCount)e.showError&&S("<div class='um-error-block'>"+e.maxFileCountErrorStr+"</div>").appendTo(r.errorLog);else{r.selectedFiles++;var a=e,s=new FormData,i=e.fileName.replace("[]","");s.append(i,t[o]);var l=e.formData;if(l)for(var n=f(l),d=0;d<n.length;d++)n[d]&&s.append(n[d][0],n[d][1]);a.fileData=s;var u=new b(r,e),p="";p=e.showFileCounter?r.fileCounter+e.fileCounterStyle+t[o].name:t[o].name,u.filename.html(p);var c=S("<form style='display:block; position:absolute;left: 150px;' class='"+r.formGroup+"' method='"+e.method+"' action='"+e.url+"' enctype='"+e.enctype+"'></form>");c.appendTo("body");var h=[];h.push(t[o].name),w(c,a,u,h,r),r.fileCounter++}else e.showError&&S("<div class='um-error-block'>"+e.extErrorStr+"</div>").appendTo(r.errorLog)}function v(e,r,t){var o=r.allowedTypes.toLowerCase().split(","),a=t.split(".").pop().toLowerCase();return!("*"!=r.allowedTypes&&jQuery.inArray(a,o)<0)}function g(a,e){if(a.showFileCounter){var s=S(".upload-filename").length;e.fileCounter=s+1,S(".upload-filename").each(function(e,r){var t=S(this).html().split(a.fileCounterStyle),o=(parseInt(t[0]),s+a.fileCounterStyle+t[1]);S(this).html(o),s--})}}function b(e,r){return this.statusbar=S("<div class='upload-statusbar'></div>"),this.filename=S("<div class='upload-filename'></div>").appendTo(this.statusbar),this.progressDiv=S("<div class='upload-progress'>").appendTo(this.statusbar).hide(),this.progressbar=S("<div class='upload-bar "+e.formGroup+"'></div>").appendTo(this.progressDiv),this.abort=S("<div class='upload-red "+e.formGroup+"'>"+r.abortStr+"</div>").appendTo(this.statusbar).hide(),this.cancel=S("<div class='upload-red'>"+r.cancelStr+"</div>").appendTo(this.statusbar).hide(),this.done=S("<div class='upload-green'>"+r.doneStr+"</div>").appendTo(this.statusbar).hide(),this.del=S("<div class='upload-red'>"+r.deletelStr+"</div>").appendTo(this.statusbar).hide(),e.errorLog.after(this.statusbar),this}function w(i,l,n,d,u){var e={cache:!1,contentType:!1,processData:!1,forceSync:!1,data:l.formData,formData:l.fileData,dataType:l.returnType,beforeSubmit:function(e,r,t){if(0==l.onSubmit.call(this,d))return n.statusbar.append("<div class='um-error-block'>"+l.uploadErrorStr+"</div>"),n.cancel.show(),i.remove(),n.cancel.click(function(){n.statusbar.remove()}),!1;var o=l.dynamicFormData();if(o){var a=f(o);if(a)for(var s=0;s<a.length;s++)a[s]&&(null!=l.fileData?t.formData.append(a[s][0],a[s][1]):t.data[a[s][0]]=a[s][1])}return u.tCounter+=d.length,p.afterUploadAll&&!h&&(h=!0,function e(){0!=c.sCounter&&c.sCounter+c.fCounter==c.tCounter?(p.afterUploadAll(c),h=!1):window.setTimeout(e,100)}()),!0},beforeSend:function(e,r){n.progressDiv.show(),n.cancel.hide(),n.done.hide(),l.showAbort&&(n.abort.show(),n.abort.click(function(){e.abort(),u.selectedFiles-=d.length})),C.formdata?n.progressbar.width("1%"):n.progressbar.width("5%")},uploadProgress:function(e,r,t,o){98<o&&(o=98);var a=o+"%";1<o&&n.progressbar.width(a),l.showProgress&&(n.progressbar.html(a),n.progressbar.css("text-align","center"))},success:function(e,r,t){u.responses.push(e),n.progressbar.width("100%"),l.showProgress&&(n.progressbar.html("100%"),n.progressbar.css("text-align","center")),n.abort.hide(),l.onSuccess.call(this,d,e,t),l.showStatusAfterSuccess?(l.showDone?(n.done.show(),n.done.click(function(){n.statusbar.hide("slow"),n.statusbar.remove()})):n.done.hide(),l.showDelete?(n.del.show(),n.del.click(function(){n.statusbar.hide().remove(),l.deleteCallback&&l.deleteCallback.call(this,e,n),u.selectedFiles-=d.length,g(l,u)})):n.del.hide()):(n.statusbar.hide("slow"),n.statusbar.remove()),i.remove(),u.sCounter+=d.length},error:function(e,r,t){n.abort.hide(),"abort"==e.statusText?(n.statusbar.hide("slow").remove(),g(l,u)):(l.onError.call(this,d,r,t),l.showStatusAfterError?(n.progressDiv.hide(),n.statusbar.append("<span class='um-error-block'>ERROR: "+t+"</span>")):(n.statusbar.hide(),n.statusbar.remove()),u.selectedFiles-=d.length),i.remove(),u.fCounter+=d.length}};l.autoSubmit?i.ajaxSubmit(e):(l.showCancel&&(n.cancel.show(),n.cancel.click(function(){i.remove(),n.statusbar.remove(),u.selectedFiles-=d.length,g(l,u)})),i.ajaxForm(e))}return this}}(jQuery);
 
includes/admin/class-admin.php CHANGED
@@ -1,1956 +1,1956 @@
1
- <?php
2
- namespace um\admin;
3
-
4
- // Exit if accessed directly.
5
- if ( ! defined( 'ABSPATH' ) ) {
6
- exit;
7
- }
8
-
9
- if ( ! class_exists( 'um\admin\Admin' ) ) {
10
-
11
-
12
- /**
13
- * Class Admin
14
- * @package um\admin
15
- */
16
- class Admin extends Admin_Functions {
17
-
18
-
19
- /**
20
- * @var string
21
- */
22
- public $templates_path;
23
-
24
-
25
- /**
26
- * @var array
27
- */
28
- public $role_meta;
29
-
30
-
31
- /**
32
- * @var array
33
- */
34
- public $restriction_term_meta;
35
-
36
-
37
- /**
38
- * @var array
39
- */
40
- public $member_directory_meta;
41
-
42
-
43
- /**
44
- * @var array
45
- */
46
- public $form_meta;
47
-
48
-
49
- /**
50
- * @var array
51
- */
52
- public $builder_input;
53
-
54
-
55
- /**
56
- * @var array
57
- */
58
- public $restriction_post_meta;
59
-
60
-
61
- /**
62
- * Admin constructor.
63
- */
64
- public function __construct() {
65
- parent::__construct();
66
-
67
- $this->templates_path = um_path . 'includes/admin/templates/';
68
-
69
- $this->role_meta = apply_filters(
70
- 'um_role_meta_map',
71
- array(
72
- '_um_priority' => array(
73
- 'sanitize' => 'int',
74
- ),
75
- '_um_can_access_wpadmin' => array(
76
- 'sanitize' => 'bool',
77
- ),
78
- '_um_can_not_see_adminbar' => array(
79
- 'sanitize' => 'bool',
80
- ),
81
- '_um_can_edit_everyone' => array(
82
- 'sanitize' => 'bool',
83
- ),
84
- '_um_can_edit_roles' => array(
85
- 'sanitize' => array( $this, 'sanitize_existed_role' ),
86
- ),
87
- '_um_can_delete_everyone' => array(
88
- 'sanitize' => 'bool',
89
- ),
90
- '_um_can_delete_roles' => array(
91
- 'sanitize' => array( $this, 'sanitize_existed_role' ),
92
- ),
93
- '_um_can_edit_profile' => array(
94
- 'sanitize' => 'bool',
95
- ),
96
- '_um_can_delete_profile' => array(
97
- 'sanitize' => 'bool',
98
- ),
99
- '_um_can_view_all' => array(
100
- 'sanitize' => 'bool',
101
- ),
102
- '_um_can_view_roles' => array(
103
- 'sanitize' => array( $this, 'sanitize_existed_role' ),
104
- ),
105
- '_um_can_make_private_profile' => array(
106
- 'sanitize' => 'bool',
107
- ),
108
- '_um_can_access_private_profile' => array(
109
- 'sanitize' => 'bool',
110
- ),
111
- '_um_profile_noindex' => array(
112
- 'sanitize' => array( $this, 'sanitize_profile_noindex' ),
113
- ),
114
- '_um_default_homepage' => array(
115
- 'sanitize' => 'bool',
116
- ),
117
- '_um_redirect_homepage' => array(
118
- 'sanitize' => 'url',
119
- ),
120
- '_um_status' => array(
121
- 'sanitize' => 'sanitize_array_key',
122
- 'default' => 'approved',
123
- 'array' => array( 'approved', 'checkmail', 'pending' ),
124
- ),
125
- '_um_auto_approve_act' => array(
126
- 'sanitize' => 'sanitize_array_key',
127
- 'default' => 'redirect_profile',
128
- 'array' => array( 'redirect_profile', 'redirect_url' ),
129
- ),
130
- '_um_auto_approve_url' => array(
131
- 'sanitize' => 'url',
132
- ),
133
- '_um_login_email_activate' => array(
134
- 'sanitize' => 'bool',
135
- ),
136
- '_um_checkmail_action' => array(
137
- 'sanitize' => 'sanitize_array_key',
138
- 'default' => 'show_message',
139
- 'array' => array( 'show_message', 'redirect_url' ),
140
- ),
141
- '_um_checkmail_message' => array(
142
- 'sanitize' => 'textarea',
143
- ),
144
- '_um_checkmail_url' => array(
145
- 'sanitize' => 'url',
146
- ),
147
- '_um_url_email_activate' => array(
148
- 'sanitize' => 'url',
149
- ),
150
- '_um_pending_action' => array(
151
- 'sanitize' => 'sanitize_array_key',
152
- 'default' => 'show_message',
153
- 'array' => array( 'show_message', 'redirect_url' ),
154
- ),
155
- '_um_pending_message' => array(
156
- 'sanitize' => 'textarea',
157
- ),
158
- '_um_pending_url' => array(
159
- 'sanitize' => 'url',
160
- ),
161
- '_um_after_login' => array(
162
- 'sanitize' => 'sanitize_array_key',
163
- 'default' => 'redirect_profile',
164
- 'array' => array( 'redirect_profile', 'redirect_url', 'refresh', 'redirect_admin' ),
165
- ),
166
- '_um_login_redirect_url' => array(
167
- 'sanitize' => 'url',
168
- ),
169
- '_um_after_logout' => array(
170
- 'sanitize' => 'sanitize_array_key',
171
- 'default' => 'redirect_home',
172
- 'array' => array( 'redirect_home', 'redirect_url' ),
173
- ),
174
- '_um_logout_redirect_url' => array(
175
- 'sanitize' => 'url',
176
- ),
177
- '_um_after_delete' => array(
178
- 'sanitize' => 'sanitize_array_key',
179
- 'default' => 'redirect_home',
180
- 'array' => array( 'redirect_home', 'redirect_url' ),
181
- ),
182
- '_um_delete_redirect_url' => array(
183
- 'sanitize' => 'url',
184
- ),
185
- 'wp_capabilities' => array(
186
- 'sanitize' => array( $this, 'sanitize_wp_capabilities' ),
187
- ),
188
- )
189
- );
190
-
191
- $this->restriction_post_meta = apply_filters(
192
- 'um_restriction_post_meta_map',
193
- array(
194
- '_um_custom_access_settings' => array(
195
- 'sanitize' => 'bool',
196
- ),
197
- '_um_accessible' => array(
198
- 'sanitize' => 'int',
199
- ),
200
- '_um_access_roles' => array(
201
- 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
202
- ),
203
- '_um_noaccess_action' => array(
204
- 'sanitize' => 'int',
205
- ),
206
- '_um_restrict_by_custom_message' => array(
207
- 'sanitize' => 'int',
208
- ),
209
- '_um_restrict_custom_message' => array(
210
- 'sanitize' => 'textarea',
211
- ),
212
- '_um_access_redirect' => array(
213
- 'sanitize' => 'int',
214
- ),
215
- '_um_access_redirect_url' => array(
216
- 'sanitize' => 'url',
217
- ),
218
- '_um_access_hide_from_queries' => array(
219
- 'sanitize' => 'bool',
220
- ),
221
- )
222
- );
223
-
224
- $this->restriction_term_meta = apply_filters(
225
- 'um_restriction_term_meta_map',
226
- array(
227
- '_um_custom_access_settings' => array(
228
- 'sanitize' => 'bool',
229
- ),
230
- '_um_accessible' => array(
231
- 'sanitize' => 'int',
232
- ),
233
- '_um_access_roles' => array(
234
- 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
235
- ),
236
- '_um_noaccess_action' => array(
237
- 'sanitize' => 'int',
238
- ),
239
- '_um_restrict_by_custom_message' => array(
240
- 'sanitize' => 'int',
241
- ),
242
- '_um_restrict_custom_message' => array(
243
- 'sanitize' => 'textarea',
244
- ),
245
- '_um_access_redirect' => array(
246
- 'sanitize' => 'int',
247
- ),
248
- '_um_access_redirect_url' => array(
249
- 'sanitize' => 'url',
250
- ),
251
- '_um_access_hide_from_queries' => array(
252
- 'sanitize' => 'bool',
253
- ),
254
- )
255
- );
256
-
257
- $this->member_directory_meta = apply_filters(
258
- 'um_member_directory_meta_map',
259
- array(
260
- '_um_directory_template' => array(
261
- 'sanitize' => 'text',
262
- ),
263
- '_um_mode' => array(
264
- 'sanitize' => 'key',
265
- ),
266
- '_um_view_types' => array(
267
- 'sanitize' => array( $this, 'sanitize_md_view_types' ),
268
- ),
269
- '_um_default_view' => array(
270
- 'sanitize' => 'key',
271
- ),
272
- '_um_roles' => array(
273
- 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
274
- ),
275
- '_um_has_profile_photo' => array(
276
- 'sanitize' => 'bool',
277
- ),
278
- '_um_show_these_users' => array(
279
- 'sanitize' => 'textarea',
280
- ),
281
- '_um_exclude_these_users' => array(
282
- 'sanitize' => 'textarea',
283
- ),
284
- '_um_must_search' => array(
285
- 'sanitize' => 'bool',
286
- ),
287
- '_um_max_users' => array(
288
- 'sanitize' => 'absint',
289
- ),
290
- '_um_profiles_per_page' => array(
291
- 'sanitize' => 'absint',
292
- ),
293
- '_um_profiles_per_page_mobile' => array(
294
- 'sanitize' => 'absint',
295
- ),
296
- '_um_directory_header' => array(
297
- 'sanitize' => 'text',
298
- ),
299
- '_um_directory_header_single' => array(
300
- 'sanitize' => 'text',
301
- ),
302
- '_um_directory_no_users' => array(
303
- 'sanitize' => 'text',
304
- ),
305
- '_um_profile_photo' => array(
306
- 'sanitize' => 'bool',
307
- ),
308
- '_um_cover_photos' => array(
309
- 'sanitize' => 'bool',
310
- ),
311
- '_um_show_name' => array(
312
- 'sanitize' => 'bool',
313
- ),
314
- '_um_show_tagline' => array(
315
- 'sanitize' => 'bool',
316
- ),
317
- '_um_tagline_fields' => array(
318
- 'sanitize' => array( $this, 'sanitize_user_field' ),
319
- ),
320
- '_um_show_userinfo' => array(
321
- 'sanitize' => 'bool',
322
- ),
323
- '_um_reveal_fields' => array(
324
- 'sanitize' => array( $this, 'sanitize_user_field' ),
325
- ),
326
- '_um_show_social' => array(
327
- 'sanitize' => 'bool',
328
- ),
329
- '_um_userinfo_animate' => array(
330
- 'sanitize' => 'bool',
331
- ),
332
- '_um_search' => array(
333
- 'sanitize' => 'bool',
334
- ),
335
- '_um_roles_can_search' => array(
336
- 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
337
- ),
338
- '_um_filters' => array(
339
- 'sanitize' => 'bool',
340
- ),
341
- '_um_roles_can_filter' => array(
342
- 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
343
- ),
344
- '_um_search_fields' => array(
345
- 'sanitize' => array( $this, 'sanitize_filter_fields' ),
346
- ),
347
- '_um_filters_expanded' => array(
348
- 'sanitize' => 'bool',
349
- ),
350
- '_um_filters_is_collapsible' => array(
351
- 'sanitize' => 'bool',
352
- ),
353
- '_um_search_filters' => array(
354
- 'sanitize' => array( $this, 'sanitize_filter_fields' ),
355
- ),
356
- '_um_sortby' => array(
357
- 'sanitize' => 'text',
358
- ),
359
- '_um_sortby_custom' => array(
360
- 'sanitize' => 'text',
361
- ),
362
- '_um_sortby_custom_label' => array(
363
- 'sanitize' => 'text',
364
- ),
365
- '_um_enable_sorting' => array(
366
- 'sanitize' => 'bool',
367
- ),
368
- '_um_sorting_fields' => array(
369
- 'sanitize' => array( $this, 'sanitize_md_sorting_fields' ),
370
- ),
371
- )
372
- );
373
-
374
- $this->form_meta = apply_filters(
375
- 'um_form_meta_map',
376
- array(
377
- '_um_mode' => array(
378
- 'sanitize' => 'key',
379
- ),
380
- '_um_register_use_gdpr' => array(
381
- 'sanitize' => 'bool',
382
- ),
383
- '_um_register_use_gdpr_content_id' => array(
384
- 'sanitize' => 'absint',
385
- ),
386
- '_um_register_use_gdpr_toggle_show' => array(
387
- 'sanitize' => 'text',
388
- ),
389
- '_um_register_use_gdpr_toggle_hide' => array(
390
- 'sanitize' => 'text',
391
- ),
392
- '_um_register_use_gdpr_agreement' => array(
393
- 'sanitize' => 'text',
394
- ),
395
- '_um_register_use_gdpr_error_text' => array(
396
- 'sanitize' => 'text',
397
- ),
398
- '_um_register_use_custom_settings' => array(
399
- 'sanitize' => 'bool',
400
- ),
401
- '_um_register_role' => array(
402
- 'sanitize' => 'key',
403
- ),
404
- '_um_register_template' => array(
405
- 'sanitize' => 'text',
406
- ),
407
- '_um_register_max_width' => array(
408
- 'sanitize' => 'absint',
409
- ),
410
- '_um_register_icons' => array(
411
- 'sanitize' => 'key',
412
- ),
413
- '_um_register_primary_btn_word' => array(
414
- 'sanitize' => 'text',
415
- ),
416
- '_um_register_secondary_btn' => array(
417
- 'sanitize' => 'bool',
418
- ),
419
- '_um_register_secondary_btn_word' => array(
420
- 'sanitize' => 'text',
421
- ),
422
- '_um_login_after_login' => array(
423
- 'sanitize' => 'key',
424
- ),
425
- '_um_login_redirect_url' => array(
426
- 'sanitize' => 'url',
427
- ),
428
- '_um_login_use_custom_settings' => array(
429
- 'sanitize' => 'bool',
430
- ),
431
- '_um_login_template' => array(
432
- 'sanitize' => 'text',
433
- ),
434
- '_um_login_max_width' => array(
435
- 'sanitize' => 'absint',
436
- ),
437
- '_um_login_icons' => array(
438
- 'sanitize' => 'key',
439
- ),
440
- '_um_login_primary_btn_word' => array(
441
- 'sanitize' => 'text',
442
- ),
443
- '_um_login_secondary_btn' => array(
444
- 'sanitize' => 'bool',
445
- ),
446
- '_um_login_secondary_btn_word' => array(
447
- 'sanitize' => 'text',
448
- ),
449
- '_um_login_forgot_pass_link' => array(
450
- 'sanitize' => 'bool',
451
- ),
452
- '_um_login_show_rememberme' => array(
453
- 'sanitize' => 'bool',
454
- ),
455
- '_um_profile_metafields' => array(
456
- 'sanitize' => array( $this, 'sanitize_user_field' ),
457
- ),
458
- '_um_profile_use_custom_settings' => array(
459
- 'sanitize' => 'bool',
460
- ),
461
- '_um_profile_role' => array(
462
- 'sanitize' => array( $this, 'sanitize_existed_role' ),
463
- ),
464
- '_um_profile_template' => array(
465
- 'sanitize' => 'text',
466
- ),
467
- '_um_profile_max_width' => array(
468
- 'sanitize' => 'absint',
469
- ),
470
- '_um_profile_area_max_width' => array(
471
- 'sanitize' => 'absint',
472
- ),
473
- '_um_profile_icons' => array(
474
- 'sanitize' => 'key',
475
- ),
476
- '_um_profile_primary_btn_word' => array(
477
- 'sanitize' => 'text',
478
- ),
479
- '_um_profile_secondary_btn' => array(
480
- 'sanitize' => 'bool',
481
- ),
482
- '_um_profile_secondary_btn_word' => array(
483
- 'sanitize' => 'text',
484
- ),
485
- '_um_profile_cover_enabled' => array(
486
- 'sanitize' => 'bool',
487
- ),
488
- '_um_profile_coversize' => array(
489
- 'sanitize' => 'absint',
490
- ),
491
- '_um_profile_cover_ratio' => array(
492
- 'sanitize' => 'text',
493
- ),
494
- '_um_profile_disable_photo_upload' => array(
495
- 'sanitize' => 'bool',
496
- ),
497
- '_um_profile_photosize' => array(
498
- 'sanitize' => array( $this, 'sanitize_photosize' ),
499
- ),
500
- '_um_profile_photo_required' => array(
501
- 'sanitize' => 'bool',
502
- ),
503
- '_um_profile_show_name' => array(
504
- 'sanitize' => 'bool',
505
- ),
506
- '_um_profile_show_social_links' => array(
507
- 'sanitize' => 'bool',
508
- ),
509
- '_um_profile_show_bio' => array(
510
- 'sanitize' => 'bool',
511
- ),
512
-
513
- )
514
- );
515
-
516
- $this->builder_input = apply_filters(
517
- 'um_builder_input_map',
518
- array(
519
- '_in_row' => array(
520
- 'sanitize' => 'key',
521
- ),
522
- '_in_sub_row' => array(
523
- 'sanitize' => 'absint',
524
- ),
525
- '_in_column' => array(
526
- 'sanitize' => 'absint',
527
- ),
528
- '_in_group' => array(
529
- 'sanitize' => 'absint',
530
- ),
531
- '_visibility' => array(
532
- 'sanitize' => 'key',
533
- ),
534
- '_conditional_action' => array(
535
- 'sanitize' => 'key',
536
- ),
537
- '_conditional_action1' => array(
538
- 'sanitize' => 'key',
539
- ),
540
- '_conditional_action2' => array(
541
- 'sanitize' => 'key',
542
- ),
543
- '_conditional_action3' => array(
544
- 'sanitize' => 'key',
545
- ),
546
- '_conditional_action4' => array(
547
- 'sanitize' => 'key',
548
- ),
549
- '_conditional_field' => array(
550
- 'sanitize' => 'text',
551
- ),
552
- '_conditional_field1' => array(
553
- 'sanitize' => 'text',
554
- ),
555
- '_conditional_field2' => array(
556
- 'sanitize' => 'text',
557
- ),
558
- '_conditional_field3' => array(
559
- 'sanitize' => 'text',
560
- ),
561
- '_conditional_field4' => array(
562
- 'sanitize' => 'text',
563
- ),
564
- '_conditional_operator' => array(
565
- 'sanitize' => 'text',
566
- ),
567
- '_conditional_operator1' => array(
568
- 'sanitize' => 'text',
569
- ),
570
- '_conditional_operator2' => array(
571
- 'sanitize' => 'text',
572
- ),
573
- '_conditional_operator3' => array(
574
- 'sanitize' => 'text',
575
- ),
576
- '_conditional_operator4' => array(
577
- 'sanitize' => 'text',
578
- ),
579
- '_conditional_value' => array(
580
- 'sanitize' => 'text',
581
- ),
582
- '_conditional_value1' => array(
583
- 'sanitize' => 'text',
584
- ),
585
- '_conditional_value2' => array(
586
- 'sanitize' => 'text',
587
- ),
588
- '_conditional_value3' => array(
589
- 'sanitize' => 'text',
590
- ),
591
- '_conditional_value4' => array(
592
- 'sanitize' => 'text',
593
- ),
594
- '_validate' => array(
595
- 'sanitize' => 'key',
596
- ),
597
- '_custom_validate' => array(
598
- 'sanitize' => 'text',
599
- ),
600
- '_icon' => array(
601
- 'sanitize' => 'key',
602
- ),
603
- '_css_class' => array(
604
- 'sanitize' => 'text',
605
- ),
606
- '_width' => array(
607
- 'sanitize' => 'absint',
608
- ),
609
- '_divider_text' => array(
610
- 'sanitize' => 'text',
611
- ),
612
- '_padding' => array(
613
- 'sanitize' => 'text',
614
- ),
615
- '_margin' => array(
616
- 'sanitize' => 'text',
617
- ),
618
- '_border' => array(
619
- 'sanitize' => 'text',
620
- ),
621
- '_borderstyle' => array(
622
- 'sanitize' => 'key',
623
- ),
624
- '_borderradius' => array(
625
- 'sanitize' => 'text',
626
- ),
627
- '_bordercolor' => array(
628
- 'sanitize' => 'text',
629
- ),
630
- '_heading' => array(
631
- 'sanitize' => 'bool',
632
- ),
633
- '_heading_text' => array(
634
- 'sanitize' => 'text',
635
- ),
636
- '_background' => array(
637
- 'sanitize' => 'text',
638
- ),
639
- '_heading_background_color' => array(
640
- 'sanitize' => 'text',
641
- ),
642
- '_heading_text_color' => array(
643
- 'sanitize' => 'text',
644
- ),
645
- '_text_color' => array(
646
- 'sanitize' => 'text',
647
- ),
648
- '_icon_color' => array(
649
- 'sanitize' => 'text',
650
- ),
651
- '_color' => array(
652
- 'sanitize' => 'text',
653
- ),
654
- '_url_text' => array(
655
- 'sanitize' => 'text',
656
- ),
657
- '_url_target' => array(
658
- 'sanitize' => 'key',
659
- ),
660
- '_url_rel' => array(
661
- 'sanitize' => 'key',
662
- ),
663
- '_force_good_pass' => array(
664
- 'sanitize' => 'bool',
665
- ),
666
- '_force_confirm_pass' => array(
667
- 'sanitize' => 'bool',
668
- ),
669
- '_style' => array(
670
- 'sanitize' => 'key',
671
- ),
672
- '_intervals' => array(
673
- 'sanitize' => 'absint',
674
- ),
675
- '_format' => array(
676
- 'sanitize' => 'text',
677
- ),
678
- '_format_custom' => array(
679
- 'sanitize' => 'text',
680
- ),
681
- '_pretty_format' => array(
682
- 'sanitize' => 'bool',
683
- ),
684
- '_disabled_weekdays' => array(
685
- 'sanitize' => 'absint',
686
- ),
687
- '_years' => array(
688
- 'sanitize' => 'absint',
689
- ),
690
- '_years_x' => array(
691
- 'sanitize' => 'key',
692
- ),
693
- '_range_start' => array(
694
- 'sanitize' => 'text',
695
- ),
696
- '_range_end' => array(
697
- 'sanitize' => 'text',
698
- ),
699
- '_range' => array(
700
- 'sanitize' => 'key',
701
- ),
702
- '_content' => array(
703
- 'sanitize' => 'textarea',
704
- ),
705
- '_crop' => array(
706
- 'sanitize' => 'int',
707
- ),
708
- '_allowed_types' => array(
709
- 'sanitize' => 'key',
710
- ),
711
- '_upload_text' => array(
712
- 'sanitize' => 'text',
713
- ),
714
- '_upload_help_text' => array(
715
- 'sanitize' => 'text',
716
- ),
717
- '_button_text' => array(
718
- 'sanitize' => 'text',
719
- ),
720
- '_max_size' => array(
721
- 'sanitize' => 'absint',
722
- ),
723
- '_height' => array(
724
- 'sanitize' => 'text',
725
- ),
726
- '_spacing' => array(
727
- 'sanitize' => 'text',
728
- ),
729
- '_is_multi' => array(
730
- 'sanitize' => 'bool',
731
- ),
732
- '_max_selections' => array(
733
- 'sanitize' => 'absint',
734
- ),
735
- '_min_selections' => array(
736
- 'sanitize' => 'absint',
737
- ),
738
- '_max_entries' => array(
739
- 'sanitize' => 'absint',
740
- ),
741
- '_max_words' => array(
742
- 'sanitize' => 'absint',
743
- ),
744
- '_min' => array(
745
- 'sanitize' => 'absint',
746
- ),
747
- '_max' => array(
748
- 'sanitize' => 'absint',
749
- ),
750
- '_min_chars' => array(
751
- 'sanitize' => 'absint',
752
- ),
753
- '_max_chars' => array(
754
- 'sanitize' => 'absint',
755
- ),
756
- '_html' => array(
757
- 'sanitize' => 'bool',
758
- ),
759
- '_options' => array(
760
- 'sanitize' => 'textarea',
761
- ),
762
- '_title' => array(
763
- 'sanitize' => 'text',
764
- ),
765
- '_id' => array(
766
- 'sanitize' => 'text',
767
- ),
768
- '_metakey' => array(
769
- 'sanitize' => 'text',
770
- ),
771
- '_help' => array(
772
- 'sanitize' => 'text',
773
- ),
774
- '_default' => array(
775
- 'sanitize' => 'text',
776
- ),
777
- '_label' => array(
778
- 'sanitize' => 'text',
779
- ),
780
- '_label_confirm_pass' => array(
781
- 'sanitize' => 'text',
782
- ),
783
- '_placeholder' => array(
784
- 'sanitize' => 'text',
785
- ),
786
- '_public' => array(
787
- 'sanitize' => 'text',
788
- ),
789
- '_roles' => array(
790
- 'sanitize' => array( $this, 'sanitize_existed_role' ),
791
- ),
792
- '_required' => array(
793
- 'sanitize' => 'bool',
794
- ),
795
- '_editable' => array(
796
- 'sanitize' => 'bool',
797
- ),
798
- '_number' => array(
799
- 'sanitize' => 'absint',
800
- ),
801
- '_custom_dropdown_options_source' => array(
802
- 'sanitize' => 'text',
803
- ),
804
- '_parent_dropdown_relationship' => array(
805
- 'sanitize' => 'text',
806
- ),
807
- )
808
- );
809
-
810
- add_action( 'admin_init', array( &$this, 'admin_init' ), 0 );
811
-
812
- $prefix = is_network_admin() ? 'network_admin_' : '';
813
- add_filter( "{$prefix}plugin_action_links_" . um_plugin, array( &$this, 'plugin_links' ) );
814
-
815
- add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) );
816
- add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) );
817
- add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) );
818
- add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) );
819
- add_action( 'um_admin_do_action__um_hide_locale_notice', array( &$this, 'um_hide_notice' ) );
820
- add_action( 'um_admin_do_action__um_can_register_notice', array( &$this, 'um_hide_notice' ) );
821
- add_action( 'um_admin_do_action__um_hide_exif_notice', array( &$this, 'um_hide_notice' ) );
822
- add_action( 'um_admin_do_action__user_action', array( &$this, 'user_action' ) );
823
-
824
- add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) );
825
-
826
- add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ), 999 );
827
-
828
- add_action( 'parent_file', array( &$this, 'parent_file' ), 9 );
829
- add_filter( 'gettext', array( &$this, 'gettext' ), 10, 4 );
830
- add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
831
- }
832
-
833
-
834
- /**
835
- * @param array|string $value
836
- *
837
- * @return array|string
838
- */
839
- public function sanitize_md_sorting_fields( $value ) {
840
- $filter_fields = array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) );
841
- $filter_fields = array_keys( $filter_fields );
842
-
843
- if ( '' !== $value ) {
844
- $value = array_filter(
845
- $value,
846
- function( $v, $k ) use ( $filter_fields ) {
847
- if ( 'other_data' === $k ) {
848
- return true;
849
- } else {
850
- return in_array( sanitize_text_field( $v ), $filter_fields, true );
851
- }
852
- },
853
- ARRAY_FILTER_USE_BOTH
854
- );
855
-
856
- $value = array_map(
857
- function( $item ) {
858
- if ( is_array( $item ) ) {
859
- if ( isset( $item['meta_key'] ) ) {
860
- $item['meta_key'] = sanitize_text_field( $item['meta_key'] );
861
- }
862
- if ( isset( $item['label'] ) ) {
863
- $item['label'] = sanitize_text_field( $item['label'] );
864
- }
865
-
866
- return $item;
867
- } else {
868
- return sanitize_text_field( $item );
869
- }
870
- },
871
- $value
872
- );
873
- }
874
-
875
- return $value;
876
- }
877
-
878
-
879
- /**
880
- * @param array|string $value
881
- *
882
- * @return array|string
883
- */
884
- public function sanitize_filter_fields( $value ) {
885
- $filter_fields = array_keys( UM()->member_directory()->filter_fields );
886
-
887
- if ( '' !== $value ) {
888
- $value = array_filter(
889
- $value,
890
- function( $v, $k ) use ( $filter_fields ) {
891
- return in_array( sanitize_text_field( $v ), $filter_fields, true );
892
- },
893
- ARRAY_FILTER_USE_BOTH
894
- );
895
-
896
- $value = array_map( 'sanitize_text_field', $value );
897
- }
898
-
899
- return $value;
900
- }
901
-
902
-
903
- /**
904
- * @param array|string $value
905
- *
906
- * @return array|string
907
- */
908
- public function sanitize_user_field( $value ) {
909
- $user_fields = array_keys( UM()->builtin()->all_user_fields() );
910
-
911
- if ( '' !== $value ) {
912
- $value = array_filter(
913
- $value,
914
- function( $v, $k ) use ( $user_fields ) {
915
- return in_array( sanitize_text_field( $v ), $user_fields, true );
916
- },
917
- ARRAY_FILTER_USE_BOTH
918
- );
919
-
920
- $value = array_map( 'sanitize_text_field', $value );
921
- }
922
-
923
- return $value;
924
- }
925
-
926
-
927
- /**
928
- * @param array|string $value
929
- *
930
- * @return array|string
931
- */
932
- public function sanitize_md_view_types( $value ) {
933
- $view_types = array_map(
934
- function ( $item ) {
935
- return $item['title'];
936
- },
937
- UM()->member_directory()->view_types
938
- );
939
- $view_types = array_keys( $view_types );
940
-
941
- if ( '' !== $value ) {
942
- $value = array_filter(
943
- $value,
944
- function( $v, $k ) use ( $view_types ) {
945
- return in_array( sanitize_key( $k ), $view_types, true ) && 1 === (int) $v;
946
- },
947
- ARRAY_FILTER_USE_BOTH
948
- );
949
-
950
- $value = array_map( 'sanitize_key', $value );
951
- }
952
-
953
- return $value;
954
- }
955
-
956
-
957
- /**
958
- * @param array|string $value
959
- *
960
- * @return array|string
961
- */
962
- public function sanitize_photosize( $value ) {
963
- $sizes = UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' );
964
- $sizes = array_keys( $sizes );
965
-
966
- if ( '' !== $value ) {
967
- $value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
968
- }
969
-
970
- return $value;
971
- }
972
-
973
-
974
- /**
975
- * @param array|string $value
976
- *
977
- * @return array|string
978
- */
979
- public function sanitize_cover_photosize( $value ) {
980
- $sizes = UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' );
981
- $sizes = array_keys( $sizes );
982
-
983
- if ( '' !== $value ) {
984
- $value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
985
- }
986
-
987
- return $value;
988
- }
989
-
990
-
991
- /**
992
- * @param array|string $value
993
- *
994
- * @return array|string
995
- */
996
- public function sanitize_restriction_existed_role( $value ) {
997
- $all_roles = array_keys( UM()->roles()->get_roles() );
998
-
999
- if ( '' !== $value ) {
1000
- $value = array_filter(
1001
- $value,
1002
- function( $v, $k ) use ( $all_roles ) {
1003
- return in_array( sanitize_key( $k ), $all_roles, true ) && 1 === (int) $v;
1004
- },
1005
- ARRAY_FILTER_USE_BOTH
1006
- );
1007
-
1008
- $value = array_map( 'sanitize_key', $value );
1009
- }
1010
-
1011
- return $value;
1012
- }
1013
-
1014
-
1015
- /**
1016
- * @param array|string $value
1017
- *
1018
- * @return array|string
1019
- */
1020
- public function sanitize_existed_role( $value ) {
1021
- $all_roles = array_keys( UM()->roles()->get_roles() );
1022
-
1023
- if ( '' !== $value ) {
1024
- $value = array_filter(
1025
- $value,
1026
- function( $v, $k ) use ( $all_roles ) {
1027
- return in_array( sanitize_key( $v ), $all_roles, true );
1028
- },
1029
- ARRAY_FILTER_USE_BOTH
1030
- );
1031
-
1032
- $value = array_map( 'sanitize_key', $value );
1033
- }
1034
-
1035
- return $value;
1036
- }
1037
-
1038
-
1039
- /**
1040
- * @param array|string $value
1041
- *
1042
- * @return array|string
1043
- */
1044
- public function sanitize_tabs_privacy( $value ) {
1045
- $all_privacy = array_keys( UM()->profile()->tabs_privacy() );
1046
-
1047
- if ( '' !== $value ) {
1048
- $value = in_array( absint( $value ), $all_privacy, true ) ? absint( $value ) : '';
1049
- }
1050
-
1051
- return $value;
1052
- }
1053
-
1054
-
1055
- /**
1056
- * @param $value
1057
- *
1058
- * @return bool|string
1059
- */
1060
- public function sanitize_profile_noindex( $value ) {
1061
- $value = '' !== $value ? (bool) $value : $value;
1062
- return $value;
1063
- }
1064
-
1065
-
1066
- /**
1067
- * @param $value
1068
- *
1069
- * @return array
1070
- */
1071
- public function sanitize_wp_capabilities( $value ) {
1072
- $value = array_map( 'boolval', array_filter( $value ) );
1073
- return $value;
1074
- }
1075
-
1076
-
1077
- /**
1078
- * Sanitize role meta fields when wp-admin form has been submitted
1079
- *
1080
- * @param array $data
1081
- *
1082
- * @return array
1083
- */
1084
- public function sanitize_role_meta( $data ) {
1085
- $sanitized = array();
1086
- foreach ( $data as $k => $v ) {
1087
- if ( ! array_key_exists( $k, $this->role_meta ) ) {
1088
- // @todo remove since 2.2.x and leave only continue
1089
- $sanitized[ $k ] = $v;
1090
- continue;
1091
- }
1092
-
1093
- if ( ! array_key_exists( 'sanitize', $this->role_meta[ $k ] ) ) {
1094
- // @todo remove since 2.2.x and leave only continue
1095
- $sanitized[ $k ] = $v;
1096
- continue;
1097
- }
1098
-
1099
- if ( is_callable( $this->role_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1100
- add_filter( 'um_role_meta_sanitize_' . $k, $this->role_meta[ $k ]['sanitize'], 10, 1 );
1101
- }
1102
-
1103
- switch ( $this->role_meta[ $k ]['sanitize'] ) {
1104
- default:
1105
- $sanitized[ $k ] = apply_filters( 'um_role_meta_sanitize_' . $k, $data[ $k ] );
1106
- break;
1107
- case 'int':
1108
- $sanitized[ $k ] = (int) $v;
1109
- break;
1110
- case 'bool':
1111
- $sanitized[ $k ] = (bool) $v;
1112
- break;
1113
- case 'url':
1114
- $sanitized[ $k ] = esc_url_raw( $v );
1115
- break;
1116
- case 'textarea':
1117
- $sanitized[ $k ] = sanitize_textarea_field( $v );
1118
- break;
1119
- case 'sanitize_array_key':
1120
- if ( ! array_key_exists( 'default', $this->role_meta[ $k ] ) || ! array_key_exists( 'array', $this->role_meta[ $k ] ) ) {
1121
- continue 2;
1122
- }
1123
-
1124
- $sanitized[ $k ] = ! in_array( sanitize_key( $v ), $this->role_meta[ $k ]['array'], true ) ? $this->role_meta[ $k ]['default'] : sanitize_key( $v );
1125
- break;
1126
- }
1127
- }
1128
-
1129
- $data = $sanitized;
1130
-
1131
- $data = apply_filters( 'um_save_role_meta_sanitize', $data );
1132
-
1133
- return $data;
1134
- }
1135
-
1136
-
1137
- /**
1138
- * Sanitize post restriction meta fields when wp-admin form has been submitted
1139
- *
1140
- * @param array $data
1141
- *
1142
- * @return array
1143
- */
1144
- public function sanitize_post_restriction_meta( $data ) {
1145
- $sanitized = array();
1146
- foreach ( $data as $k => $v ) {
1147
- if ( ! array_key_exists( $k, $this->restriction_post_meta ) ) {
1148
- // @todo remove since 2.2.x and leave only continue
1149
- $sanitized[ $k ] = $v;
1150
- continue;
1151
- }
1152
-
1153
- if ( ! array_key_exists( 'sanitize', $this->restriction_post_meta[ $k ] ) ) {
1154
- // @todo remove since 2.2.x and leave only continue
1155
- $sanitized[ $k ] = $v;
1156
- continue;
1157
- }
1158
-
1159
- if ( is_callable( $this->restriction_post_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1160
- add_filter( 'um_restriction_post_meta_sanitize_' . $k, $this->restriction_post_meta[ $k ]['sanitize'], 10, 1 );
1161
- }
1162
-
1163
- switch ( $this->restriction_post_meta[ $k ]['sanitize'] ) {
1164
- default:
1165
- $sanitized[ $k ] = apply_filters( 'um_restriction_post_meta_sanitize_' . $k, $data[ $k ] );
1166
- break;
1167
- case 'int':
1168
- $sanitized[ $k ] = (int) $v;
1169
- break;
1170
- case 'bool':
1171
- $sanitized[ $k ] = (bool) $v;
1172
- break;
1173
- case 'url':
1174
- $sanitized[ $k ] = esc_url_raw( $v );
1175
- break;
1176
- case 'textarea':
1177
- $sanitized[ $k ] = sanitize_textarea_field( $v );
1178
- break;
1179
- }
1180
- }
1181
-
1182
- $data = $sanitized;
1183
-
1184
- $data = apply_filters( 'um_save_restriction_post_meta_sanitize', $data );
1185
-
1186
- return $data;
1187
- }
1188
-
1189
-
1190
- /**
1191
- * Sanitize term restriction meta fields when wp-admin form has been submitted
1192
- *
1193
- * @param array $data
1194
- *
1195
- * @return array
1196
- */
1197
- public function sanitize_term_restriction_meta( $data ) {
1198
- $sanitized = array();
1199
- foreach ( $data as $k => $v ) {
1200
- if ( ! array_key_exists( $k, $this->restriction_term_meta ) ) {
1201
- // @todo remove since 2.2.x and leave only continue
1202
- $sanitized[ $k ] = $v;
1203
- continue;
1204
- }
1205
-
1206
- if ( ! array_key_exists( 'sanitize', $this->restriction_term_meta[ $k ] ) ) {
1207
- // @todo remove since 2.2.x and leave only continue
1208
- $sanitized[ $k ] = $v;
1209
- continue;
1210
- }
1211
-
1212
- if ( is_callable( $this->restriction_term_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1213
- add_filter( 'um_restriction_term_meta_sanitize_' . $k, $this->restriction_term_meta[ $k ]['sanitize'], 10, 1 );
1214
- }
1215
-
1216
- switch ( $this->restriction_term_meta[ $k ]['sanitize'] ) {
1217
- default:
1218
- $sanitized[ $k ] = apply_filters( 'um_restriction_term_meta_sanitize_' . $k, $data[ $k ] );
1219
- break;
1220
- case 'int':
1221
- $sanitized[ $k ] = (int) $v;
1222
- break;
1223
- case 'bool':
1224
- $sanitized[ $k ] = (bool) $v;
1225
- break;
1226
- case 'url':
1227
- $sanitized[ $k ] = esc_url_raw( $v );
1228
- break;
1229
- case 'textarea':
1230
- $sanitized[ $k ] = sanitize_textarea_field( $v );
1231
- break;
1232
- }
1233
- }
1234
-
1235
- $data = $sanitized;
1236
-
1237
- $data = apply_filters( 'um_save_restriction_term_meta_sanitize', $data );
1238
-
1239
- return $data;
1240
- }
1241
-
1242
-
1243
- /**
1244
- * Sanitize member directory meta when wp-admin form has been submitted
1245
- *
1246
- * @todo checking all sanitize types
1247
- *
1248
- * @param array $data
1249
- *
1250
- * @return array
1251
- */
1252
- public function sanitize_member_directory_meta( $data ) {
1253
- $sanitized = array();
1254
- foreach ( $data as $k => $v ) {
1255
- if ( ! array_key_exists( $k, $this->member_directory_meta ) ) {
1256
- // @todo remove since 2.2.x and leave only continue
1257
- $sanitized[ $k ] = $v;
1258
- continue;
1259
- }
1260
-
1261
- if ( ! array_key_exists( 'sanitize', $this->member_directory_meta[ $k ] ) ) {
1262
- // @todo remove since 2.2.x and leave only continue
1263
- $sanitized[ $k ] = $v;
1264
- continue;
1265
- }
1266
-
1267
- if ( is_callable( $this->member_directory_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1268
- add_filter( 'um_member_directory_meta_sanitize_' . $k, $this->member_directory_meta[ $k ]['sanitize'], 10, 1 );
1269
- }
1270
-
1271
- switch ( $this->member_directory_meta[ $k ]['sanitize'] ) {
1272
- default:
1273
- $sanitized[ $k ] = apply_filters( 'um_member_directory_meta_sanitize_' . $k, $data[ $k ] );
1274
- break;
1275
- case 'int':
1276
- $sanitized[ $k ] = (int) $v;
1277
- break;
1278
- case 'bool':
1279
- $sanitized[ $k ] = (bool) $v;
1280
- break;
1281
- case 'url':
1282
- if ( is_array( $v ) ) {
1283
- $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1284
- } else {
1285
- $sanitized[ $k ] = esc_url_raw( $v );
1286
- }
1287
- break;
1288
- case 'text':
1289
- $sanitized[ $k ] = sanitize_text_field( $v );
1290
- break;
1291
- case 'textarea':
1292
- $sanitized[ $k ] = sanitize_textarea_field( $v );
1293
- break;
1294
- case 'key':
1295
- if ( is_array( $v ) ) {
1296
- $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1297
- } else {
1298
- $sanitized[ $k ] = sanitize_key( $v );
1299
- }
1300
- break;
1301
- case 'absint':
1302
- if ( is_array( $v ) ) {
1303
- $sanitized[ $k ] = array_map( 'absint', $v );
1304
- } else {
1305
- $sanitized[ $k ] = absint( $v );
1306
- }
1307
- break;
1308
- }
1309
- }
1310
-
1311
- $data = $sanitized;
1312
-
1313
- $data = apply_filters( 'um_save_member_directory_meta_sanitize', $data );
1314
-
1315
- return $data;
1316
- }
1317
-
1318
-
1319
- /**
1320
- * Sanitize builder field meta when wp-admin form has been submitted
1321
- *
1322
- * @todo checking all sanitize types
1323
- *
1324
- * @param array $data
1325
- *
1326
- * @return array
1327
- */
1328
- public function sanitize_builder_field_meta( $data ) {
1329
- $sanitized = array();
1330
- foreach ( $data as $k => $v ) {
1331
- if ( ! array_key_exists( $k, $this->builder_input ) ) {
1332
- // @todo remove since 2.2.x and leave only continue
1333
- $sanitized[ $k ] = $v;
1334
- continue;
1335
- }
1336
-
1337
- if ( ! array_key_exists( 'sanitize', $this->builder_input[ $k ] ) ) {
1338
- // @todo remove since 2.2.x and leave only continue
1339
- $sanitized[ $k ] = $v;
1340
- continue;
1341
- }
1342
-
1343
- if ( is_callable( $this->builder_input[ $k ]['sanitize'], true, $callable_name ) ) {
1344
- add_filter( 'um_builder_input_sanitize_' . $k, $this->builder_input[ $k ]['sanitize'], 10, 1 );
1345
- }
1346
-
1347
- switch ( $this->builder_input[ $k ]['sanitize'] ) {
1348
- default:
1349
- $sanitized[ $k ] = apply_filters( 'um_builder_input_sanitize_' . $k, $data[ $k ] );
1350
- break;
1351
- case 'int':
1352
- $sanitized[ $k ] = (int) $v;
1353
- break;
1354
- case 'bool':
1355
- $sanitized[ $k ] = (bool) $v;
1356
- break;
1357
- case 'url':
1358
- if ( is_array( $v ) ) {
1359
- $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1360
- } else {
1361
- $sanitized[ $k ] = esc_url_raw( $v );
1362
- }
1363
- break;
1364
- case 'text':
1365
- $sanitized[ $k ] = sanitize_text_field( $v );
1366
- break;
1367
- case 'textarea':
1368
- $sanitized[ $k ] = sanitize_textarea_field( $v );
1369
- break;
1370
- case 'key':
1371
- if ( is_array( $v ) ) {
1372
- $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1373
- } else {
1374
- $sanitized[ $k ] = sanitize_key( $v );
1375
- }
1376
- break;
1377
- case 'absint':
1378
- if ( is_array( $v ) ) {
1379
- $sanitized[ $k ] = array_map( 'absint', $v );
1380
- } else {
1381
- $sanitized[ $k ] = absint( $v );
1382
- }
1383
- break;
1384
- }
1385
- }
1386
-
1387
- $data = $sanitized;
1388
-
1389
- $data = apply_filters( 'um_save_builder_input_sanitize', $data );
1390
-
1391
- return $data;
1392
- }
1393
-
1394
-
1395
- /**
1396
- * Sanitize form meta when wp-admin form has been submitted
1397
- *
1398
- * @todo checking all sanitize types
1399
- *
1400
- * @param array $data
1401
- *
1402
- * @return array
1403
- */
1404
- public function sanitize_form_meta( $data ) {
1405
- $sanitized = array();
1406
- foreach ( $data as $k => $v ) {
1407
- if ( ! array_key_exists( $k, $this->form_meta ) ) {
1408
- // @todo remove since 2.2.x and leave only continue
1409
- $sanitized[ $k ] = $v;
1410
- continue;
1411
- }
1412
-
1413
- if ( ! array_key_exists( 'sanitize', $this->form_meta[ $k ] ) ) {
1414
- // @todo remove since 2.2.x and leave only continue
1415
- $sanitized[ $k ] = $v;
1416
- continue;
1417
- }
1418
-
1419
- if ( is_callable( $this->form_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1420
- add_filter( 'um_form_meta_sanitize_' . $k, $this->form_meta[ $k ]['sanitize'], 10, 1 );
1421
- }
1422
-
1423
- switch ( $this->form_meta[ $k ]['sanitize'] ) {
1424
- default:
1425
- $sanitized[ $k ] = apply_filters( 'um_form_meta_sanitize_' . $k, $data[ $k ] );
1426
- break;
1427
- case 'int':
1428
- $sanitized[ $k ] = (int) $v;
1429
- break;
1430
- case 'bool':
1431
- $sanitized[ $k ] = (bool) $v;
1432
- break;
1433
- case 'url':
1434
- if ( is_array( $v ) ) {
1435
- $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1436
- } else {
1437
- $sanitized[ $k ] = esc_url_raw( $v );
1438
- }
1439
- break;
1440
- case 'text':
1441
- $sanitized[ $k ] = sanitize_text_field( $v );
1442
- break;
1443
- case 'textarea':
1444
- $sanitized[ $k ] = sanitize_textarea_field( $v );
1445
- break;
1446
- case 'key':
1447
- if ( is_array( $v ) ) {
1448
- $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1449
- } else {
1450
- $sanitized[ $k ] = sanitize_key( $v );
1451
- }
1452
- break;
1453
- case 'absint':
1454
- if ( is_array( $v ) ) {
1455
- $sanitized[ $k ] = array_map( 'absint', $v );
1456
- } else {
1457
- $sanitized[ $k ] = absint( $v );
1458
- }
1459
- break;
1460
- }
1461
- }
1462
-
1463
- $data = $sanitized;
1464
-
1465
- $data = apply_filters( 'um_save_form_meta_sanitize', $data );
1466
-
1467
- return $data;
1468
- }
1469
-
1470
-
1471
- /**
1472
- * Sanitize options when wp-admin form has been submitted
1473
- *
1474
- * @todo checking all sanitize types
1475
- *
1476
- * @param array $data
1477
- *
1478
- * @return array
1479
- */
1480
- public function sanitize_options( $data ) {
1481
- $sanitized = array();
1482
- foreach ( $data as $k => $v ) {
1483
- if ( ! array_key_exists( $k, UM()->admin_settings()->settings_map ) ) {
1484
- // @todo remove since 2.2.x and leave only continue
1485
- $sanitized[ $k ] = $v;
1486
- continue;
1487
- }
1488
-
1489
- if ( ! array_key_exists( 'sanitize', UM()->admin_settings()->settings_map[ $k ] ) ) {
1490
- // @todo remove since 2.2.x and leave only continue
1491
- $sanitized[ $k ] = $v;
1492
- continue;
1493
- }
1494
-
1495
- if ( is_callable( UM()->admin_settings()->settings_map[ $k ]['sanitize'], true, $callable_name ) ) {
1496
- add_filter( 'um_settings_sanitize_' . $k, UM()->admin_settings()->settings_map[ $k ]['sanitize'], 10, 1 );
1497
- }
1498
-
1499
- switch ( UM()->admin_settings()->settings_map[ $k ]['sanitize'] ) {
1500
- default:
1501
- $sanitized[ $k ] = apply_filters( 'um_settings_sanitize_' . $k, $v );
1502
- break;
1503
- case 'int':
1504
- $sanitized[ $k ] = (int) $v;
1505
- break;
1506
- case 'absint':
1507
- if ( is_array( $v ) ) {
1508
- $sanitized[ $k ] = array_map( 'absint', $v );
1509
- } else {
1510
- $sanitized[ $k ] = absint( $v );
1511
- }
1512
- break;
1513
- case 'key':
1514
- if ( is_array( $v ) ) {
1515
- $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1516
- } else {
1517
- $sanitized[ $k ] = sanitize_key( $v );
1518
- }
1519
- break;
1520
- case 'bool':
1521
- $sanitized[ $k ] = (bool) $v;
1522
- break;
1523
- case 'url':
1524
- if ( is_array( $v ) ) {
1525
- $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1526
- } else {
1527
- $sanitized[ $k ] = esc_url_raw( $v );
1528
- }
1529
- break;
1530
- case 'wp_kses':
1531
- $sanitized[ $k ] = wp_kses_post( $v );
1532
- break;
1533
- case 'textarea':
1534
- $sanitized[ $k ] = sanitize_textarea_field( $v );
1535
- break;
1536
- case 'text':
1537
- $sanitized[ $k ] = sanitize_text_field( $v );
1538
- break;
1539
- }
1540
- }
1541
-
1542
- $data = $sanitized;
1543
-
1544
- $data = apply_filters( 'um_save_settings_sanitize', $data );
1545
-
1546
- return $data;
1547
- }
1548
-
1549
-
1550
- /**
1551
- * Adds class to our admin pages
1552
- *
1553
- * @param $classes
1554
- *
1555
- * @return string
1556
- */
1557
- public function admin_body_class( $classes ) {
1558
- if ( $this->is_um_screen() ) {
1559
- return "$classes um-admin";
1560
- }
1561
- return $classes;
1562
- }
1563
-
1564
-
1565
- /**
1566
- *
1567
- */
1568
- public function manual_upgrades_request() {
1569
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1570
- die();
1571
- }
1572
-
1573
- $last_request = get_option( 'um_last_manual_upgrades_request', false );
1574
-
1575
- if ( empty( $last_request ) || time() > $last_request + DAY_IN_SECONDS ) {
1576
-
1577
- if ( is_multisite() ) {
1578
- $blogs_ids = get_sites();
1579
- foreach( $blogs_ids as $b ) {
1580
- switch_to_blog( $b->blog_id );
1581
- wp_clean_update_cache();
1582
-
1583
- UM()->plugin_updater()->um_checklicenses();
1584
-
1585
- update_option( 'um_last_manual_upgrades_request', time() );
1586
- restore_current_blog();
1587
- }
1588
- } else {
1589
- wp_clean_update_cache();
1590
-
1591
- UM()->plugin_updater()->um_checklicenses();
1592
-
1593
- update_option( 'um_last_manual_upgrades_request', time() );
1594
- }
1595
-
1596
- $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'got_updates' ), admin_url( 'admin.php' ) );
1597
- } else {
1598
- $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'often_updates' ), admin_url( 'admin.php' ) );
1599
- }
1600
- exit( wp_redirect( $url ) );
1601
- }
1602
-
1603
-
1604
- /**
1605
- * Core pages installation
1606
- */
1607
- function install_core_pages() {
1608
- if ( ! is_admin() ) {
1609
- die();
1610
- }
1611
-
1612
- UM()->setup()->install_default_pages();
1613
-
1614
- //check empty pages in settings
1615
- $empty_pages = array();
1616
-
1617
- $pages = UM()->config()->permalinks;
1618
- if ( $pages && is_array( $pages ) ) {
1619
- foreach ( $pages as $slug => $page_id ) {
1620
- $page = get_post( $page_id );
1621
-
1622
- if ( ! isset( $page->ID ) && in_array( $slug, array_keys( UM()->config()->core_pages ) ) ) {
1623
- $empty_pages[] = $slug;
1624
- }
1625
- }
1626
- }
1627
-
1628
- //if there aren't empty pages - then hide pages notice
1629
- if ( empty( $empty_pages ) ) {
1630
- $hidden_notices = get_option( 'um_hidden_admin_notices', array() );
1631
- $hidden_notices[] = 'wrong_pages';
1632
-
1633
- update_option( 'um_hidden_admin_notices', $hidden_notices );
1634
- }
1635
-
1636
- $url = add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) );
1637
- exit( wp_redirect( $url ) );
1638
- }
1639
-
1640
-
1641
- /**
1642
- * Clear all users cache
1643
- *
1644
- * @param $action
1645
- */
1646
- function user_cache( $action ) {
1647
- global $wpdb;
1648
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1649
- die();
1650
- }
1651
-
1652
- $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
1653
-
1654
- $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) );
1655
- exit( wp_redirect( $url ) );
1656
- }
1657
-
1658
-
1659
- /**
1660
- * Purge temp uploads dir
1661
- * @param $action
1662
- */
1663
- function purge_temp( $action ) {
1664
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1665
- die();
1666
- }
1667
-
1668
- UM()->files()->remove_dir( UM()->files()->upload_temp );
1669
-
1670
- $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'purged_temp' ), admin_url( 'admin.php' ) );
1671
- exit( wp_redirect( $url ) );
1672
- }
1673
-
1674
-
1675
- /**
1676
- * Duplicate form
1677
- *
1678
- * @param $action
1679
- */
1680
- function duplicate_form( $action ) {
1681
- if ( ! is_admin() || ! current_user_can('manage_options') ) {
1682
- die();
1683
- }
1684
- if ( ! isset( $_REQUEST['post_id'] ) || ! is_numeric( $_REQUEST['post_id'] ) ) {
1685
- die();
1686
- }
1687
-
1688
- $post_id = absint( $_REQUEST['post_id'] );
1689
-
1690
- $n = array(
1691
- 'post_type' => 'um_form',
1692
- 'post_title' => sprintf( __( 'Duplicate of %s', 'ultimate-member' ), get_the_title( $post_id ) ),
1693
- 'post_status' => 'publish',
1694
- 'post_author' => get_current_user_id(),
1695
- );
1696
-
1697
- $n_id = wp_insert_post( $n );
1698
-
1699
- $n_fields = get_post_custom( $post_id );
1700
- foreach ( $n_fields as $key => $value ) {
1701
-
1702
- if ( $key == '_um_custom_fields' ) {
1703
- $the_value = unserialize( $value[0] );
1704
- } else {
1705
- $the_value = $value[0];
1706
- }
1707
-
1708
- update_post_meta( $n_id, $key, $the_value );
1709
-
1710
- }
1711
-
1712
- delete_post_meta( $n_id, '_um_core' );
1713
-
1714
- $url = admin_url( 'edit.php?post_type=um_form' );
1715
- $url = add_query_arg( 'update', 'form_duplicated', $url );
1716
-
1717
- exit( wp_redirect( $url ) );
1718
-
1719
- }
1720
-
1721
-
1722
- /**
1723
- * Action to hide notices in admin
1724
- *
1725
- * @param $action
1726
- */
1727
- function um_hide_notice( $action ) {
1728
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1729
- die();
1730
- }
1731
-
1732
- update_option( $action, 1 );
1733
- exit( wp_redirect( remove_query_arg( 'um_adm_action' ) ) );
1734
- }
1735
-
1736
-
1737
- /**
1738
- * Various user actions
1739
- *
1740
- * @param $action
1741
- */
1742
- function user_action( $action ) {
1743
- if ( ! is_admin() || ! current_user_can( 'edit_users' ) ) {
1744
- die();
1745
- }
1746
- if ( ! isset( $_REQUEST['sub'] ) ) {
1747
- die();
1748
- }
1749
- if ( ! isset( $_REQUEST['user_id'] ) ) {
1750
- die();
1751
- }
1752
-
1753
- um_fetch_user( absint( $_REQUEST['user_id'] ) );
1754
-
1755
- $subaction = sanitize_key( $_REQUEST['sub'] );
1756
-
1757
- /**
1758
- * UM hook
1759
- *
1760
- * @type action
1761
- * @title um_admin_user_action_hook
1762
- * @description Action on bulk user subaction
1763
- * @input_vars
1764
- * [{"var":"$subaction","type":"string","desc":"Bulk Subaction"}]
1765
- * @change_log
1766
- * ["Since: 2.0"]
1767
- * @usage add_action( 'um_admin_user_action_hook', 'function_name', 10, 1 );
1768
- * @example
1769
- * <?php
1770
- * add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
1771
- * function my_admin_user_action( $subaction ) {
1772
- * // your code here
1773
- * }
1774
- * ?>
1775
- */
1776
- do_action( 'um_admin_user_action_hook', $subaction );
1777
- /**
1778
- * UM hook
1779
- *
1780
- * @type action
1781
- * @title um_admin_user_action_{$subaction}_hook
1782
- * @description Action on bulk user subaction
1783
- * @change_log
1784
- * ["Since: 2.0"]
1785
- * @usage add_action( 'um_admin_user_action_{$subaction}_hook', 'function_name', 10 );
1786
- * @example
1787
- * <?php
1788
- * add_action( 'um_admin_user_action_{$subaction}_hook', 'my_admin_user_action', 10 );
1789
- * function my_admin_user_action() {
1790
- * // your code here
1791
- * }
1792
- * ?>
1793
- */
1794
- do_action( "um_admin_user_action_{$subaction}_hook" );
1795
-
1796
- um_reset_user();
1797
-
1798
- wp_redirect( add_query_arg( 'update', 'user_updated', admin_url( '?page=ultimatemember' ) ) );
1799
- exit;
1800
-
1801
- }
1802
-
1803
-
1804
- /**
1805
- * Add any custom links to plugin page
1806
- *
1807
- * @param array $links
1808
- *
1809
- * @return array
1810
- */
1811
- function plugin_links( $links ) {
1812
- $more_links[] = '<a href="http://docs.ultimatemember.com/">' . __( 'Docs', 'ultimate-member' ) . '</a>';
1813
- $more_links[] = '<a href="'.admin_url().'admin.php?page=um_options">' . __( 'Settings', 'ultimate-member' ) . '</a>';
1814
-
1815
- $links = $more_links + $links;
1816
- return $links;
1817
- }
1818
-
1819
-
1820
- /**
1821
- * Init admin action/filters + request handlers
1822
- */
1823
- function admin_init() {
1824
- if ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_REQUEST['um_adm_action'] ) ) {
1825
- $action = sanitize_key( $_REQUEST['um_adm_action'] );
1826
-
1827
- /**
1828
- * UM hook
1829
- *
1830
- * @type action
1831
- * @title um_admin_do_action__
1832
- * @description Make some action on custom admin action
1833
- * @input_vars
1834
- * [{"var":"$action","type":"string","desc":"Admin Action"}]
1835
- * @change_log
1836
- * ["Since: 2.0"]
1837
- * @usage add_action( 'um_admin_do_action__', 'function_name', 10, 1 );
1838
- * @example
1839
- * <?php
1840
- * add_action( 'um_admin_do_action__', 'my_admin_do_action', 10, 1 );
1841
- * function my_admin_do_action( $action ) {
1842
- * // your code here
1843
- * }
1844
- * ?>
1845
- */
1846
- do_action( 'um_admin_do_action__', $action );
1847
- /**
1848
- * UM hook
1849
- *
1850
- * @type action
1851
- * @title um_admin_do_action__{$action}
1852
- * @description Make some action on custom admin $action
1853
- * @input_vars
1854
- * [{"var":"$action","type":"string","desc":"Admin Action"}]
1855
- * @change_log
1856
- * ["Since: 2.0"]
1857
- * @usage add_action( 'um_admin_do_action__{$action}', 'function_name', 10, 1 );
1858
- * @example
1859
- * <?php
1860
- * add_action( 'um_admin_do_action__{$action}', 'my_admin_do_action', 10, 1 );
1861
- * function my_admin_do_action( $action ) {
1862
- * // your code here
1863
- * }
1864
- * ?>
1865
- */
1866
- do_action( "um_admin_do_action__{$action}", $action );
1867
- }
1868
- }
1869
-
1870
-
1871
- /**
1872
- * Updated post messages
1873
- *
1874
- * @param array $messages
1875
- *
1876
- * @return array
1877
- */
1878
- function post_updated_messages( $messages ) {
1879
- global $post_ID;
1880
-
1881
- $post_type = get_post_type( $post_ID );
1882
-
1883
- if ( $post_type == 'um_form' ) {
1884
- $messages['um_form'] = array(
1885
- 0 => '',
1886
- 1 => __( 'Form updated.', 'ultimate-member' ),
1887
- 2 => __( 'Custom field updated.', 'ultimate-member' ),
1888
- 3 => __( 'Custom field deleted.', 'ultimate-member' ),
1889
- 4 => __( 'Form updated.', 'ultimate-member' ),
1890
- 5 => isset( $_GET['revision'] ) ? __( 'Form restored to revision.', 'ultimate-member' ) : false,
1891
- 6 => __( 'Form created.', 'ultimate-member' ),
1892
- 7 => __( 'Form saved.', 'ultimate-member' ),
1893
- 8 => __( 'Form submitted.', 'ultimate-member' ),
1894
- 9 => __( 'Form scheduled.', 'ultimate-member' ),
1895
- 10 => __( 'Form draft updated.', 'ultimate-member' ),
1896
- );
1897
- }
1898
-
1899
- return $messages;
1900
- }
1901
-
1902
-
1903
- /**
1904
- * Gettext filters
1905
- *
1906
- * @param $translation
1907
- * @param $text
1908
- * @param $domain
1909
- *
1910
- * @return string
1911
- */
1912
- function gettext( $translation, $text, $domain ) {
1913
- global $post;
1914
- if ( isset( $post->post_type ) && $this->is_plugin_post_type() ) {
1915
- $translations = get_translations_for_domain( $domain );
1916
- if ( $text == 'Publish' ) {
1917
- return $translations->translate( 'Create' );
1918
- } elseif ( $text == 'Move to Trash' ) {
1919
- return $translations->translate( 'Delete' );
1920
- }
1921
- }
1922
-
1923
- return $translation;
1924
- }
1925
-
1926
-
1927
- /**
1928
- * Fix parent file for correct highlighting
1929
- *
1930
- * @param $parent_file
1931
- *
1932
- * @return string
1933
- */
1934
- function parent_file( $parent_file ) {
1935
- global $current_screen;
1936
- $screen_id = $current_screen->id;
1937
- if ( strstr( $screen_id, 'um_' ) ) {
1938
- $parent_file = 'ultimatemember';
1939
- }
1940
- return $parent_file;
1941
- }
1942
-
1943
-
1944
- /**
1945
- * @since 2.0
1946
- *
1947
- * @return core\Admin_Notices()
1948
- */
1949
- function notices() {
1950
- if ( empty( UM()->classes['admin_notices'] ) ) {
1951
- UM()->classes['admin_notices'] = new core\Admin_Notices();
1952
- }
1953
- return UM()->classes['admin_notices'];
1954
- }
1955
- }
1956
- }
1
+ <?php
2
+ namespace um\admin;
3
+
4
+ // Exit if accessed directly.
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ if ( ! class_exists( 'um\admin\Admin' ) ) {
10
+
11
+
12
+ /**
13
+ * Class Admin
14
+ * @package um\admin
15
+ */
16
+ class Admin extends Admin_Functions {
17
+
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ public $templates_path;
23
+
24
+
25
+ /**
26
+ * @var array
27
+ */
28
+ public $role_meta;
29
+
30
+
31
+ /**
32
+ * @var array
33
+ */
34
+ public $restriction_term_meta;
35
+
36
+
37
+ /**
38
+ * @var array
39
+ */
40
+ public $member_directory_meta;
41
+
42
+
43
+ /**
44
+ * @var array
45
+ */
46
+ public $form_meta;
47
+
48
+
49
+ /**
50
+ * @var array
51
+ */
52
+ public $builder_input;
53
+
54
+
55
+ /**
56
+ * @var array
57
+ */
58
+ public $restriction_post_meta;
59
+
60
+
61
+ /**
62
+ * Admin constructor.
63
+ */
64
+ public function __construct() {
65
+ parent::__construct();
66
+
67
+ $this->templates_path = um_path . 'includes/admin/templates/';
68
+
69
+ $this->role_meta = apply_filters(
70
+ 'um_role_meta_map',
71
+ array(
72
+ '_um_priority' => array(
73
+ 'sanitize' => 'int',
74
+ ),
75
+ '_um_can_access_wpadmin' => array(
76
+ 'sanitize' => 'bool',
77
+ ),
78
+ '_um_can_not_see_adminbar' => array(
79
+ 'sanitize' => 'bool',
80
+ ),
81
+ '_um_can_edit_everyone' => array(
82
+ 'sanitize' => 'bool',
83
+ ),
84
+ '_um_can_edit_roles' => array(
85
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
86
+ ),
87
+ '_um_can_delete_everyone' => array(
88
+ 'sanitize' => 'bool',
89
+ ),
90
+ '_um_can_delete_roles' => array(
91
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
92
+ ),
93
+ '_um_can_edit_profile' => array(
94
+ 'sanitize' => 'bool',
95
+ ),
96
+ '_um_can_delete_profile' => array(
97
+ 'sanitize' => 'bool',
98
+ ),
99
+ '_um_can_view_all' => array(
100
+ 'sanitize' => 'bool',
101
+ ),
102
+ '_um_can_view_roles' => array(
103
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
104
+ ),
105
+ '_um_can_make_private_profile' => array(
106
+ 'sanitize' => 'bool',
107
+ ),
108
+ '_um_can_access_private_profile' => array(
109
+ 'sanitize' => 'bool',
110
+ ),
111
+ '_um_profile_noindex' => array(
112
+ 'sanitize' => array( $this, 'sanitize_profile_noindex' ),
113
+ ),
114
+ '_um_default_homepage' => array(
115
+ 'sanitize' => 'bool',
116
+ ),
117
+ '_um_redirect_homepage' => array(
118
+ 'sanitize' => 'url',
119
+ ),
120
+ '_um_status' => array(
121
+ 'sanitize' => 'sanitize_array_key',
122
+ 'default' => 'approved',
123
+ 'array' => array( 'approved', 'checkmail', 'pending' ),
124
+ ),
125
+ '_um_auto_approve_act' => array(
126
+ 'sanitize' => 'sanitize_array_key',
127
+ 'default' => 'redirect_profile',
128
+ 'array' => array( 'redirect_profile', 'redirect_url' ),
129
+ ),
130
+ '_um_auto_approve_url' => array(
131
+ 'sanitize' => 'url',
132
+ ),
133
+ '_um_login_email_activate' => array(
134
+ 'sanitize' => 'bool',
135
+ ),
136
+ '_um_checkmail_action' => array(
137
+ 'sanitize' => 'sanitize_array_key',
138
+ 'default' => 'show_message',
139
+ 'array' => array( 'show_message', 'redirect_url' ),
140
+ ),
141
+ '_um_checkmail_message' => array(
142
+ 'sanitize' => 'textarea',
143
+ ),
144
+ '_um_checkmail_url' => array(
145
+ 'sanitize' => 'url',
146
+ ),
147
+ '_um_url_email_activate' => array(
148
+ 'sanitize' => 'url',
149
+ ),
150
+ '_um_pending_action' => array(
151
+ 'sanitize' => 'sanitize_array_key',
152
+ 'default' => 'show_message',
153
+ 'array' => array( 'show_message', 'redirect_url' ),
154
+ ),
155
+ '_um_pending_message' => array(
156
+ 'sanitize' => 'textarea',
157
+ ),
158
+ '_um_pending_url' => array(
159
+ 'sanitize' => 'url',
160
+ ),
161
+ '_um_after_login' => array(
162
+ 'sanitize' => 'sanitize_array_key',
163
+ 'default' => 'redirect_profile',
164
+ 'array' => array( 'redirect_profile', 'redirect_url', 'refresh', 'redirect_admin' ),
165
+ ),
166
+ '_um_login_redirect_url' => array(
167
+ 'sanitize' => 'url',
168
+ ),
169
+ '_um_after_logout' => array(
170
+ 'sanitize' => 'sanitize_array_key',
171
+ 'default' => 'redirect_home',
172
+ 'array' => array( 'redirect_home', 'redirect_url' ),
173
+ ),
174
+ '_um_logout_redirect_url' => array(
175
+ 'sanitize' => 'url',
176
+ ),
177
+ '_um_after_delete' => array(
178
+ 'sanitize' => 'sanitize_array_key',
179
+ 'default' => 'redirect_home',
180
+ 'array' => array( 'redirect_home', 'redirect_url' ),
181
+ ),
182
+ '_um_delete_redirect_url' => array(
183
+ 'sanitize' => 'url',
184
+ ),
185
+ 'wp_capabilities' => array(
186
+ 'sanitize' => array( $this, 'sanitize_wp_capabilities' ),
187
+ ),
188
+ )
189
+ );
190
+
191
+ $this->restriction_post_meta = apply_filters(
192
+ 'um_restriction_post_meta_map',
193
+ array(
194
+ '_um_custom_access_settings' => array(
195
+ 'sanitize' => 'bool',
196
+ ),
197
+ '_um_accessible' => array(
198
+ 'sanitize' => 'int',
199
+ ),
200
+ '_um_access_roles' => array(
201
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
202
+ ),
203
+ '_um_noaccess_action' => array(
204
+ 'sanitize' => 'int',
205
+ ),
206
+ '_um_restrict_by_custom_message' => array(
207
+ 'sanitize' => 'int',
208
+ ),
209
+ '_um_restrict_custom_message' => array(
210
+ 'sanitize' => 'textarea',
211
+ ),
212
+ '_um_access_redirect' => array(
213
+ 'sanitize' => 'int',
214
+ ),
215
+ '_um_access_redirect_url' => array(
216
+ 'sanitize' => 'url',
217
+ ),
218
+ '_um_access_hide_from_queries' => array(
219
+ 'sanitize' => 'bool',
220
+ ),
221
+ )
222
+ );
223
+
224
+ $this->restriction_term_meta = apply_filters(
225
+ 'um_restriction_term_meta_map',
226
+ array(
227
+ '_um_custom_access_settings' => array(
228
+ 'sanitize' => 'bool',
229
+ ),
230
+ '_um_accessible' => array(
231
+ 'sanitize' => 'int',
232
+ ),
233
+ '_um_access_roles' => array(
234
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
235
+ ),
236
+ '_um_noaccess_action' => array(
237
+ 'sanitize' => 'int',
238
+ ),
239
+ '_um_restrict_by_custom_message' => array(
240
+ 'sanitize' => 'int',
241
+ ),
242
+ '_um_restrict_custom_message' => array(
243
+ 'sanitize' => 'textarea',
244
+ ),
245
+ '_um_access_redirect' => array(
246
+ 'sanitize' => 'int',
247
+ ),
248
+ '_um_access_redirect_url' => array(
249
+ 'sanitize' => 'url',
250
+ ),
251
+ '_um_access_hide_from_queries' => array(
252
+ 'sanitize' => 'bool',
253
+ ),
254
+ )
255
+ );
256
+
257
+ $this->member_directory_meta = apply_filters(
258
+ 'um_member_directory_meta_map',
259
+ array(
260
+ '_um_directory_template' => array(
261
+ 'sanitize' => 'text',
262
+ ),
263
+ '_um_mode' => array(
264
+ 'sanitize' => 'key',
265
+ ),
266
+ '_um_view_types' => array(
267
+ 'sanitize' => array( $this, 'sanitize_md_view_types' ),
268
+ ),
269
+ '_um_default_view' => array(
270
+ 'sanitize' => 'key',
271
+ ),
272
+ '_um_roles' => array(
273
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
274
+ ),
275
+ '_um_has_profile_photo' => array(
276
+ 'sanitize' => 'bool',
277
+ ),
278
+ '_um_show_these_users' => array(
279
+ 'sanitize' => 'textarea',
280
+ ),
281
+ '_um_exclude_these_users' => array(
282
+ 'sanitize' => 'textarea',
283
+ ),
284
+ '_um_must_search' => array(
285
+ 'sanitize' => 'bool',
286
+ ),
287
+ '_um_max_users' => array(
288
+ 'sanitize' => 'absint',
289
+ ),
290
+ '_um_profiles_per_page' => array(
291
+ 'sanitize' => 'absint',
292
+ ),
293
+ '_um_profiles_per_page_mobile' => array(
294
+ 'sanitize' => 'absint',
295
+ ),
296
+ '_um_directory_header' => array(
297
+ 'sanitize' => 'text',
298
+ ),
299
+ '_um_directory_header_single' => array(
300
+ 'sanitize' => 'text',
301
+ ),
302
+ '_um_directory_no_users' => array(
303
+ 'sanitize' => 'text',
304
+ ),
305
+ '_um_profile_photo' => array(
306
+ 'sanitize' => 'bool',
307
+ ),
308
+ '_um_cover_photos' => array(
309
+ 'sanitize' => 'bool',
310
+ ),
311
+ '_um_show_name' => array(
312
+ 'sanitize' => 'bool',
313
+ ),
314
+ '_um_show_tagline' => array(
315
+ 'sanitize' => 'bool',
316
+ ),
317
+ '_um_tagline_fields' => array(
318
+ 'sanitize' => array( $this, 'sanitize_user_field' ),
319
+ ),
320
+ '_um_show_userinfo' => array(
321
+ 'sanitize' => 'bool',
322
+ ),
323
+ '_um_reveal_fields' => array(
324
+ 'sanitize' => array( $this, 'sanitize_user_field' ),
325
+ ),
326
+ '_um_show_social' => array(
327
+ 'sanitize' => 'bool',
328
+ ),
329
+ '_um_userinfo_animate' => array(
330
+ 'sanitize' => 'bool',
331
+ ),
332
+ '_um_search' => array(
333
+ 'sanitize' => 'bool',
334
+ ),
335
+ '_um_roles_can_search' => array(
336
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
337
+ ),
338
+ '_um_filters' => array(
339
+ 'sanitize' => 'bool',
340
+ ),
341
+ '_um_roles_can_filter' => array(
342
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
343
+ ),
344
+ '_um_search_fields' => array(
345
+ 'sanitize' => array( $this, 'sanitize_filter_fields' ),
346
+ ),
347
+ '_um_filters_expanded' => array(
348
+ 'sanitize' => 'bool',
349
+ ),
350
+ '_um_filters_is_collapsible' => array(
351
+ 'sanitize' => 'bool',
352
+ ),
353
+ '_um_search_filters' => array(
354
+ 'sanitize' => array( $this, 'sanitize_filter_fields' ),
355
+ ),
356
+ '_um_sortby' => array(
357
+ 'sanitize' => 'text',
358
+ ),
359
+ '_um_sortby_custom' => array(
360
+ 'sanitize' => 'text',
361
+ ),
362
+ '_um_sortby_custom_label' => array(
363
+ 'sanitize' => 'text',
364
+ ),
365
+ '_um_enable_sorting' => array(
366
+ 'sanitize' => 'bool',
367
+ ),
368
+ '_um_sorting_fields' => array(
369
+ 'sanitize' => array( $this, 'sanitize_md_sorting_fields' ),
370
+ ),
371
+ )
372
+ );
373
+
374
+ $this->form_meta = apply_filters(
375
+ 'um_form_meta_map',
376
+ array(
377
+ '_um_mode' => array(
378
+ 'sanitize' => 'key',
379
+ ),
380
+ '_um_register_use_gdpr' => array(
381
+ 'sanitize' => 'bool',
382
+ ),
383
+ '_um_register_use_gdpr_content_id' => array(
384
+ 'sanitize' => 'absint',
385
+ ),
386
+ '_um_register_use_gdpr_toggle_show' => array(
387
+ 'sanitize' => 'text',
388
+ ),
389
+ '_um_register_use_gdpr_toggle_hide' => array(
390
+ 'sanitize' => 'text',
391
+ ),
392
+ '_um_register_use_gdpr_agreement' => array(
393
+ 'sanitize' => 'text',
394
+ ),
395
+ '_um_register_use_gdpr_error_text' => array(
396
+ 'sanitize' => 'text',
397
+ ),
398
+ '_um_register_use_custom_settings' => array(
399
+ 'sanitize' => 'bool',
400
+ ),
401
+ '_um_register_role' => array(
402
+ 'sanitize' => 'key',
403
+ ),
404
+ '_um_register_template' => array(
405
+ 'sanitize' => 'text',
406
+ ),
407
+ '_um_register_max_width' => array(
408
+ 'sanitize' => 'absint',
409
+ ),
410
+ '_um_register_icons' => array(
411
+ 'sanitize' => 'key',
412
+ ),
413
+ '_um_register_primary_btn_word' => array(
414
+ 'sanitize' => 'text',
415
+ ),
416
+ '_um_register_secondary_btn' => array(
417
+ 'sanitize' => 'bool',
418
+ ),
419
+ '_um_register_secondary_btn_word' => array(
420
+ 'sanitize' => 'text',
421
+ ),
422
+ '_um_login_after_login' => array(
423
+ 'sanitize' => 'key',
424
+ ),
425
+ '_um_login_redirect_url' => array(
426
+ 'sanitize' => 'url',
427
+ ),
428
+ '_um_login_use_custom_settings' => array(
429
+ 'sanitize' => 'bool',
430
+ ),
431
+ '_um_login_template' => array(
432
+ 'sanitize' => 'text',
433
+ ),
434
+ '_um_login_max_width' => array(
435
+ 'sanitize' => 'absint',
436
+ ),
437
+ '_um_login_icons' => array(
438
+ 'sanitize' => 'key',
439
+ ),
440
+ '_um_login_primary_btn_word' => array(
441
+ 'sanitize' => 'text',
442
+ ),
443
+ '_um_login_secondary_btn' => array(
444
+ 'sanitize' => 'bool',
445
+ ),
446
+ '_um_login_secondary_btn_word' => array(
447
+ 'sanitize' => 'text',
448
+ ),
449
+ '_um_login_forgot_pass_link' => array(
450
+ 'sanitize' => 'bool',
451
+ ),
452
+ '_um_login_show_rememberme' => array(
453
+ 'sanitize' => 'bool',
454
+ ),
455
+ '_um_profile_metafields' => array(
456
+ 'sanitize' => array( $this, 'sanitize_user_field' ),
457
+ ),
458
+ '_um_profile_use_custom_settings' => array(
459
+ 'sanitize' => 'bool',
460
+ ),
461
+ '_um_profile_role' => array(
462
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
463
+ ),
464
+ '_um_profile_template' => array(
465
+ 'sanitize' => 'text',
466
+ ),
467
+ '_um_profile_max_width' => array(
468
+ 'sanitize' => 'absint',
469
+ ),
470
+ '_um_profile_area_max_width' => array(
471
+ 'sanitize' => 'absint',
472
+ ),
473
+ '_um_profile_icons' => array(
474
+ 'sanitize' => 'key',
475
+ ),
476
+ '_um_profile_primary_btn_word' => array(
477
+ 'sanitize' => 'text',
478
+ ),
479
+ '_um_profile_secondary_btn' => array(
480
+ 'sanitize' => 'bool',
481
+ ),
482
+ '_um_profile_secondary_btn_word' => array(
483
+ 'sanitize' => 'text',
484
+ ),
485
+ '_um_profile_cover_enabled' => array(
486
+ 'sanitize' => 'bool',
487
+ ),
488
+ '_um_profile_coversize' => array(
489
+ 'sanitize' => 'absint',
490
+ ),
491
+ '_um_profile_cover_ratio' => array(
492
+ 'sanitize' => 'text',
493
+ ),
494
+ '_um_profile_disable_photo_upload' => array(
495
+ 'sanitize' => 'bool',
496
+ ),
497
+ '_um_profile_photosize' => array(
498
+ 'sanitize' => array( $this, 'sanitize_photosize' ),
499
+ ),
500
+ '_um_profile_photo_required' => array(
501
+ 'sanitize' => 'bool',
502
+ ),
503
+ '_um_profile_show_name' => array(
504
+ 'sanitize' => 'bool',
505
+ ),
506
+ '_um_profile_show_social_links' => array(
507
+ 'sanitize' => 'bool',
508
+ ),
509
+ '_um_profile_show_bio' => array(
510
+ 'sanitize' => 'bool',
511
+ ),
512
+
513
+ )
514
+ );
515
+
516
+ $this->builder_input = apply_filters(
517
+ 'um_builder_input_map',
518
+ array(
519
+ '_in_row' => array(
520
+ 'sanitize' => 'key',
521
+ ),
522
+ '_in_sub_row' => array(
523
+ 'sanitize' => 'absint',
524
+ ),
525
+ '_in_column' => array(
526
+ 'sanitize' => 'absint',
527
+ ),
528
+ '_in_group' => array(
529
+ 'sanitize' => 'absint',
530
+ ),
531
+ '_visibility' => array(
532
+ 'sanitize' => 'key',
533
+ ),
534
+ '_conditional_action' => array(
535
+ 'sanitize' => 'key',
536
+ ),
537
+ '_conditional_action1' => array(
538
+ 'sanitize' => 'key',
539
+ ),
540
+ '_conditional_action2' => array(
541
+ 'sanitize' => 'key',
542
+ ),
543
+ '_conditional_action3' => array(
544
+ 'sanitize' => 'key',
545
+ ),
546
+ '_conditional_action4' => array(
547
+ 'sanitize' => 'key',
548
+ ),
549
+ '_conditional_field' => array(
550
+ 'sanitize' => 'text',
551
+ ),
552
+ '_conditional_field1' => array(
553
+ 'sanitize' => 'text',
554
+ ),
555
+ '_conditional_field2' => array(
556
+ 'sanitize' => 'text',
557
+ ),
558
+ '_conditional_field3' => array(
559
+ 'sanitize' => 'text',
560
+ ),
561
+ '_conditional_field4' => array(
562
+ 'sanitize' => 'text',
563
+ ),
564
+ '_conditional_operator' => array(
565
+ 'sanitize' => 'text',
566
+ ),
567
+ '_conditional_operator1' => array(
568
+ 'sanitize' => 'text',
569
+ ),
570
+ '_conditional_operator2' => array(
571
+ 'sanitize' => 'text',
572
+ ),
573
+ '_conditional_operator3' => array(
574
+ 'sanitize' => 'text',
575
+ ),
576
+ '_conditional_operator4' => array(
577
+ 'sanitize' => 'text',
578
+ ),
579
+ '_conditional_value' => array(
580
+ 'sanitize' => 'text',
581
+ ),
582
+ '_conditional_value1' => array(
583
+ 'sanitize' => 'text',
584
+ ),
585
+ '_conditional_value2' => array(
586
+ 'sanitize' => 'text',
587
+ ),
588
+ '_conditional_value3' => array(
589
+ 'sanitize' => 'text',
590
+ ),
591
+ '_conditional_value4' => array(
592
+ 'sanitize' => 'text',
593
+ ),
594
+ '_validate' => array(
595
+ 'sanitize' => 'key',
596
+ ),
597
+ '_custom_validate' => array(
598
+ 'sanitize' => 'text',
599
+ ),
600
+ '_icon' => array(
601
+ 'sanitize' => 'key',
602
+ ),
603
+ '_css_class' => array(
604
+ 'sanitize' => 'text',
605
+ ),
606
+ '_width' => array(
607
+ 'sanitize' => 'absint',
608
+ ),
609
+ '_divider_text' => array(
610
+ 'sanitize' => 'text',
611
+ ),
612
+ '_padding' => array(
613
+ 'sanitize' => 'text',
614
+ ),
615
+ '_margin' => array(
616
+ 'sanitize' => 'text',
617
+ ),
618
+ '_border' => array(
619
+ 'sanitize' => 'text',
620
+ ),
621
+ '_borderstyle' => array(
622
+ 'sanitize' => 'key',
623
+ ),
624
+ '_borderradius' => array(
625
+ 'sanitize' => 'text',
626
+ ),
627
+ '_bordercolor' => array(
628
+ 'sanitize' => 'text',
629
+ ),
630
+ '_heading' => array(
631
+ 'sanitize' => 'bool',
632
+ ),
633
+ '_heading_text' => array(
634
+ 'sanitize' => 'text',
635
+ ),
636
+ '_background' => array(
637
+ 'sanitize' => 'text',
638
+ ),
639
+ '_heading_background_color' => array(
640
+ 'sanitize' => 'text',
641
+ ),
642
+ '_heading_text_color' => array(
643
+ 'sanitize' => 'text',
644
+ ),
645
+ '_text_color' => array(
646
+ 'sanitize' => 'text',
647
+ ),
648
+ '_icon_color' => array(
649
+ 'sanitize' => 'text',
650
+ ),
651
+ '_color' => array(
652
+ 'sanitize' => 'text',
653
+ ),
654
+ '_url_text' => array(
655
+ 'sanitize' => 'text',
656
+ ),
657
+ '_url_target' => array(
658
+ 'sanitize' => 'key',
659
+ ),
660
+ '_url_rel' => array(
661
+ 'sanitize' => 'key',
662
+ ),
663
+ '_force_good_pass' => array(
664
+ 'sanitize' => 'bool',
665
+ ),
666
+ '_force_confirm_pass' => array(
667
+ 'sanitize' => 'bool',
668
+ ),
669
+ '_style' => array(
670
+ 'sanitize' => 'key',
671
+ ),
672
+ '_intervals' => array(
673
+ 'sanitize' => 'absint',
674
+ ),
675
+ '_format' => array(
676
+ 'sanitize' => 'text',
677
+ ),
678
+ '_format_custom' => array(
679
+ 'sanitize' => 'text',
680
+ ),
681
+ '_pretty_format' => array(
682
+ 'sanitize' => 'bool',
683
+ ),
684
+ '_disabled_weekdays' => array(
685
+ 'sanitize' => 'absint',
686
+ ),
687
+ '_years' => array(
688
+ 'sanitize' => 'absint',
689
+ ),
690
+ '_years_x' => array(
691
+ 'sanitize' => 'key',
692
+ ),
693
+ '_range_start' => array(
694
+ 'sanitize' => 'text',
695
+ ),
696
+ '_range_end' => array(
697
+ 'sanitize' => 'text',
698
+ ),
699
+ '_range' => array(
700
+ 'sanitize' => 'key',
701
+ ),
702
+ '_content' => array(
703
+ 'sanitize' => 'textarea',
704
+ ),
705
+ '_crop' => array(
706
+ 'sanitize' => 'int',
707
+ ),
708
+ '_allowed_types' => array(
709
+ 'sanitize' => 'key',
710
+ ),
711
+ '_upload_text' => array(
712
+ 'sanitize' => 'text',
713
+ ),
714
+ '_upload_help_text' => array(
715
+ 'sanitize' => 'text',
716
+ ),
717
+ '_button_text' => array(
718
+ 'sanitize' => 'text',
719
+ ),
720
+ '_max_size' => array(
721
+ 'sanitize' => 'absint',
722
+ ),
723
+ '_height' => array(
724
+ 'sanitize' => 'text',
725
+ ),
726
+ '_spacing' => array(
727
+ 'sanitize' => 'text',
728
+ ),
729
+ '_is_multi' => array(
730
+ 'sanitize' => 'bool',
731
+ ),
732
+ '_max_selections' => array(
733
+ 'sanitize' => 'absint',
734
+ ),
735
+ '_min_selections' => array(
736
+ 'sanitize' => 'absint',
737
+ ),
738
+ '_max_entries' => array(
739
+ 'sanitize' => 'absint',
740
+ ),
741
+ '_max_words' => array(
742
+ 'sanitize' => 'absint',
743
+ ),
744
+ '_min' => array(
745
+ 'sanitize' => 'absint',
746
+ ),
747
+ '_max' => array(
748
+ 'sanitize' => 'absint',
749
+ ),
750
+ '_min_chars' => array(
751
+ 'sanitize' => 'absint',
752
+ ),
753
+ '_max_chars' => array(
754
+ 'sanitize' => 'absint',
755
+ ),
756
+ '_html' => array(
757
+ 'sanitize' => 'bool',
758
+ ),
759
+ '_options' => array(
760
+ 'sanitize' => 'textarea',
761
+ ),
762
+ '_title' => array(
763
+ 'sanitize' => 'text',
764
+ ),
765
+ '_id' => array(
766
+ 'sanitize' => 'text',
767
+ ),
768
+ '_metakey' => array(
769
+ 'sanitize' => 'text',
770
+ ),
771
+ '_help' => array(
772
+ 'sanitize' => 'text',
773
+ ),
774
+ '_default' => array(
775
+ 'sanitize' => 'text',
776
+ ),
777
+ '_label' => array(
778
+ 'sanitize' => 'text',
779
+ ),
780
+ '_label_confirm_pass' => array(
781
+ 'sanitize' => 'text',
782
+ ),
783
+ '_placeholder' => array(
784
+ 'sanitize' => 'text',
785
+ ),
786
+ '_public' => array(
787
+ 'sanitize' => 'text',
788
+ ),
789
+ '_roles' => array(
790
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
791
+ ),
792
+ '_required' => array(
793
+ 'sanitize' => 'bool',
794
+ ),
795
+ '_editable' => array(
796
+ 'sanitize' => 'bool',
797
+ ),
798
+ '_number' => array(
799
+ 'sanitize' => 'absint',
800
+ ),
801
+ '_custom_dropdown_options_source' => array(
802
+ 'sanitize' => 'text',
803
+ ),
804
+ '_parent_dropdown_relationship' => array(
805
+ 'sanitize' => 'text',
806
+ ),
807
+ )
808
+ );
809
+
810
+ add_action( 'admin_init', array( &$this, 'admin_init' ), 0 );
811
+
812
+ $prefix = is_network_admin() ? 'network_admin_' : '';
813
+ add_filter( "{$prefix}plugin_action_links_" . um_plugin, array( &$this, 'plugin_links' ) );
814
+
815
+ add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) );
816
+ add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) );
817
+ add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) );
818
+ add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) );
819
+ add_action( 'um_admin_do_action__um_hide_locale_notice', array( &$this, 'um_hide_notice' ) );
820
+ add_action( 'um_admin_do_action__um_can_register_notice', array( &$this, 'um_hide_notice' ) );
821