Version Description
Download this release
Release Info
Developer | nsinelnikov |
Plugin | 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 +8 -8
- assets/js/um-fileupload.min.js +0 -1
- includes/admin/class-admin.php +1956 -1956
- includes/admin/core/class-admin-builder.php +1228 -1223
- includes/admin/core/class-admin-enqueue.php +2 -2
- includes/core/class-builtin.php +1915 -1915
- includes/core/class-enqueue.php +442 -442
- includes/core/class-fields.php +5 -1
- includes/core/class-form.php +749 -749
- includes/um-short-functions.php +5 -4
- includes/widgets/class-um-search-widget.php +7 -0
- readme.txt +12 -2
- ultimate-member.php +24 -24
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 & 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)
|
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 & 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 & 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 |
+
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 |
+
}
|
includes/admin/core/class-admin-builder.php
CHANGED
@@ -1,1223 +1,1228 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\admin\core;
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Admin_Builder
|
13 |
-
* @package um\admin\core
|
14 |
-
*/
|
15 |
-
class Admin_Builder {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var
|
20 |
-
*/
|
21 |
-
var $form_id;
|
22 |
-
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Admin_Builder constructor.
|
26 |
-
*/
|
27 |
-
function __construct() {
|
28 |
-
add_action( 'um_admin_field_modal_header', array( &$this, 'add_message_handlers' ) );
|
29 |
-
add_action( 'um_admin_field_modal_footer', array( &$this, 'add_conditional_support' ), 10, 4 );
|
30 |
-
add_filter( 'um_admin_builder_skip_field_validation', array( &$this, 'skip_field_validation' ), 10, 3 );
|
31 |
-
add_filter( 'um_admin_pre_save_field_to_form', array( &$this, 'um_admin_pre_save_field_to_form' ), 1 );
|
32 |
-
add_filter( 'um_admin_pre_save_fields_hook', array( &$this, 'um_admin_pre_save_fields_hook' ), 1 );
|
33 |
-
add_filter( 'um_admin_field_update_error_handling', array( &$this, 'um_admin_field_update_error_handling' ), 1, 2 );
|
34 |
-
}
|
35 |
-
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Apply a filter to handle errors for field updating in backend
|
39 |
-
*
|
40 |
-
* @param $errors
|
41 |
-
* @param $array
|
42 |
-
*
|
43 |
-
* @return mixed
|
44 |
-
*/
|
45 |
-
function um_admin_field_update_error_handling( $errors, $array ) {
|
46 |
-
/**
|
47 |
-
* @var $field_type
|
48 |
-
*/
|
49 |
-
extract( $array );
|
50 |
-
|
51 |
-
$field_attr = UM()->builtin()->get_core_field_attrs( $field_type );
|
52 |
-
|
53 |
-
if ( isset( $field_attr['validate'] ) ) {
|
54 |
-
|
55 |
-
$validate = $field_attr['validate'];
|
56 |
-
foreach ( $validate as $post_input => $arr ) {
|
57 |
-
|
58 |
-
$skip = apply_filters( 'um_admin_builder_skip_field_validation', false, $post_input, $array );
|
59 |
-
if ( $skip ) {
|
60 |
-
continue;
|
61 |
-
}
|
62 |
-
|
63 |
-
$mode = $arr['mode'];
|
64 |
-
|
65 |
-
switch ( $mode ) {
|
66 |
-
|
67 |
-
case 'numeric':
|
68 |
-
if ( ! empty( $array['post'][ $post_input ] ) && ! is_numeric( $array['post'][ $post_input ] ) ){
|
69 |
-
$errors[ $post_input ] = $validate[ $post_input ]['error'];
|
70 |
-
}
|
71 |
-
break;
|
72 |
-
|
73 |
-
case 'unique':
|
74 |
-
if ( ! isset( $array['post']['edit_mode'] ) ) {
|
75 |
-
if ( UM()->builtin()->unique_field_err( $array['post'][ $post_input ] ) ) {
|
76 |
-
$errors[ $post_input ] = UM()->builtin()->unique_field_err( $array['post'][ $post_input ] );
|
77 |
-
}
|
78 |
-
}
|
79 |
-
break;
|
80 |
-
|
81 |
-
case 'required':
|
82 |
-
if ( $array['post'][ $post_input ] == '' ) {
|
83 |
-
$errors[ $post_input ] = $validate[ $post_input ]['error'];
|
84 |
-
}
|
85 |
-
break;
|
86 |
-
|
87 |
-
case 'range-start':
|
88 |
-
if ( UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] ) && $array['post']['_range'] == 'date_range' ) {
|
89 |
-
$errors[ $post_input ] = UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] );
|
90 |
-
}
|
91 |
-
break;
|
92 |
-
|
93 |
-
case 'range-end':
|
94 |
-
if ( UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] ) && $array['post']['_range'] == 'date_range' ) {
|
95 |
-
$errors[ $post_input ] = UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] );
|
96 |
-
}
|
97 |
-
break;
|
98 |
-
|
99 |
-
}
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
}
|
104 |
-
|
105 |
-
return $errors;
|
106 |
-
|
107 |
-
}
|
108 |
-
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Some fields may require extra fields before saving
|
112 |
-
*
|
113 |
-
* @param $array
|
114 |
-
*
|
115 |
-
* @return mixed
|
116 |
-
*/
|
117 |
-
function um_admin_pre_save_fields_hook( $array ) {
|
118 |
-
/**
|
119 |
-
* @var $form_id
|
120 |
-
* @var $field_type
|
121 |
-
*/
|
122 |
-
extract( $array );
|
123 |
-
|
124 |
-
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
125 |
-
|
126 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
127 |
-
$count = 1;
|
128 |
-
if ( ! empty( $fields ) ) {
|
129 |
-
$count = count( $fields ) + 1;
|
130 |
-
}
|
131 |
-
|
132 |
-
// set unique meta key
|
133 |
-
if ( in_array( $field_type, $fields_without_metakey ) && ! isset( $array['post']['_metakey'] ) ) {
|
134 |
-
$array['post']['_metakey'] = "um_{$field_type}_{$form_id}_{$count}";
|
135 |
-
}
|
136 |
-
|
137 |
-
// set position
|
138 |
-
if ( ! isset( $array['post']['_position'] ) ) {
|
139 |
-
$array['post']['_position'] = $count;
|
140 |
-
}
|
141 |
-
|
142 |
-
return $array;
|
143 |
-
}
|
144 |
-
|
145 |
-
|
146 |
-
/**
|
147 |
-
* Modify field args just before it is saved into form
|
148 |
-
*
|
149 |
-
* @param $array
|
150 |
-
*
|
151 |
-
* @return mixed
|
152 |
-
*/
|
153 |
-
function um_admin_pre_save_field_to_form( $array ){
|
154 |
-
unset( $array['conditions'] );
|
155 |
-
if ( isset($array['conditional_field']) && ! empty( $array['conditional_action'] ) && ! empty( $array['conditional_operator'] ) ) {
|
156 |
-
$array['conditional_value'] = isset( $array['conditional_value'] ) ? $array['conditional_value'] : '';
|
157 |
-
$array['conditions'][] = array( $array['conditional_action'], $array['conditional_field'], $array['conditional_operator'], $array['conditional_value'] );
|
158 |
-
}
|
159 |
-
|
160 |
-
if ( isset( $array['conditional_field1'] ) && ! empty( $array['conditional_action1'] ) && ! empty( $array['conditional_operator1'] ) ) {
|
161 |
-
$array['conditional_value1'] = isset( $array['conditional_value1'] ) ? $array['conditional_value1'] : '';
|
162 |
-
$array['conditions'][] = array( $array['conditional_action1'], $array['conditional_field1'], $array['conditional_operator1'], $array['conditional_value1'] );
|
163 |
-
}
|
164 |
-
|
165 |
-
if ( isset( $array['conditional_field2'] ) && ! empty( $array['conditional_action2'] ) && ! empty( $array['conditional_operator2'] ) ) {
|
166 |
-
$array['conditional_value2'] = isset( $array['conditional_value2'] ) ? $array['conditional_value2'] : '';
|
167 |
-
$array['conditions'][] = array( $array['conditional_action2'], $array['conditional_field2'], $array['conditional_operator2'], $array['conditional_value2'] );
|
168 |
-
}
|
169 |
-
|
170 |
-
if ( isset( $array['conditional_field3'] ) && ! empty( $array['conditional_action3'] ) && ! empty( $array['conditional_operator3'] ) ) {
|
171 |
-
$array['conditional_value3'] = isset( $array['conditional_value3'] ) ? $array['conditional_value3'] : '';
|
172 |
-
$array['conditions'][] = array( $array['conditional_action3'], $array['conditional_field3'], $array['conditional_operator3'], $array['conditional_value3'] );
|
173 |
-
}
|
174 |
-
|
175 |
-
if ( isset( $array['conditional_field4'] ) && ! empty( $array['conditional_action4'] ) && ! empty( $array['conditional_operator4'] ) ) {
|
176 |
-
$array['conditional_value4'] = isset( $array['conditional_value4'] ) ? $array['conditional_value4'] : '';
|
177 |
-
$array['conditions'][] = array( $array['conditional_action4'], $array['conditional_field4'], $array['conditional_operator4'], $array['conditional_value4'] );
|
178 |
-
}
|
179 |
-
|
180 |
-
return $array;
|
181 |
-
}
|
182 |
-
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Put status handler in modal
|
186 |
-
*/
|
187 |
-
function add_message_handlers() {
|
188 |
-
?>
|
189 |
-
<div class="um-admin-error-block"></div>
|
190 |
-
<div class="um-admin-success-block"></div>
|
191 |
-
<?php
|
192 |
-
}
|
193 |
-
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Footer of modal
|
197 |
-
*
|
198 |
-
* @param $form_id
|
199 |
-
* @param $field_args
|
200 |
-
* @param $in_edit
|
201 |
-
* @param $edit_array
|
202 |
-
*/
|
203 |
-
function add_conditional_support( $form_id, $field_args, $in_edit, $edit_array ) {
|
204 |
-
$metabox = UM()->metabox();
|
205 |
-
|
206 |
-
if ( isset( $field_args['conditional_support'] ) && $field_args['conditional_support'] == 0 ) {
|
207 |
-
return;
|
208 |
-
} ?>
|
209 |
-
|
210 |
-
<div class="um-admin-btn-toggle">
|
211 |
-
|
212 |
-
<?php if ( $in_edit ) { $metabox->in_edit = true; $metabox->edit_array = $edit_array; ?>
|
213 |
-
<a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Manage conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
|
214 |
-
<?php } else { ?>
|
215 |
-
<a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Add conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
|
216 |
-
<?php } ?>
|
217 |
-
|
218 |
-
<div class="um-admin-btn-content">
|
219 |
-
<div class="um-admin-cur-condition-template">
|
220 |
-
|
221 |
-
<?php $metabox->field_input( '_conditional_action', $form_id ); ?>
|
222 |
-
<?php $metabox->field_input( '_conditional_field', $form_id ); ?>
|
223 |
-
<?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
|
224 |
-
<?php $metabox->field_input( '_conditional_value', $form_id ); ?>
|
225 |
-
|
226 |
-
<p><a href="javascript:void(0);" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
|
227 |
-
|
228 |
-
<div class="um-admin-clear"></div>
|
229 |
-
</div>
|
230 |
-
<p class="um-admin-conditions-notice">
|
231 |
-
<small>
|
232 |
-
<?php _e( 'Use the condition operator `equals to` or `not equals` if the parent field has a single option.', 'ultimate-member' ); ?>
|
233 |
-
<br><?php _e( 'Use the condition operator `greater than` or `less than` if the parent field is a number.', 'ultimate-member' ); ?>
|
234 |
-
<br><?php _e( 'Use the condition operator `contains` if the parent field has multiple options.', 'ultimate-member' ); ?>
|
235 |
-
</small>
|
236 |
-
</p>
|
237 |
-
<p><a href="javascript:void(0);" class="um-admin-new-condition button button-primary um-admin-tipsy-n" title="Add new condition"><?php _e( 'Add new rule', 'ultimate-member' ); ?></a></p>
|
238 |
-
<p class="um-admin-reset-conditions"><a href="javascript:void(0);" class="button"><?php _e( 'Reset all rules', 'ultimate-member' ); ?></a></p>
|
239 |
-
|
240 |
-
<div class="um-admin-clear"></div>
|
241 |
-
|
242 |
-
<?php if ( isset( $edit_array['conditions'] ) && count( $edit_array['conditions'] ) != 0 ) {
|
243 |
-
|
244 |
-
foreach ( $edit_array['conditions'] as $k => $arr ) {
|
245 |
-
|
246 |
-
if ( $k == 0 ) $k = ''; ?>
|
247 |
-
|
248 |
-
<div class="um-admin-cur-condition">
|
249 |
-
|
250 |
-
<?php $metabox->field_input( '_conditional_action' . $k, $form_id ); ?>
|
251 |
-
<?php $metabox->field_input( '_conditional_field' . $k , $form_id ); ?>
|
252 |
-
<?php $metabox->field_input( '_conditional_operator' . $k, $form_id ); ?>
|
253 |
-
<?php $metabox->field_input( '_conditional_value' . $k, $form_id ); ?>
|
254 |
-
|
255 |
-
<p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
|
256 |
-
|
257 |
-
<div class="um-admin-clear"></div>
|
258 |
-
</div>
|
259 |
-
|
260 |
-
<?php
|
261 |
-
}
|
262 |
-
|
263 |
-
} else { ?>
|
264 |
-
|
265 |
-
<div class="um-admin-cur-condition">
|
266 |
-
|
267 |
-
<?php $metabox->field_input( '_conditional_action', $form_id ); ?>
|
268 |
-
<?php $metabox->field_input( '_conditional_field', $form_id ); ?>
|
269 |
-
<?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
|
270 |
-
<?php $metabox->field_input( '_conditional_value', $form_id ); ?>
|
271 |
-
|
272 |
-
<p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
|
273 |
-
|
274 |
-
<div class="um-admin-clear"></div>
|
275 |
-
</div>
|
276 |
-
|
277 |
-
<?php } ?>
|
278 |
-
</div>
|
279 |
-
</div>
|
280 |
-
|
281 |
-
<?php
|
282 |
-
}
|
283 |
-
|
284 |
-
|
285 |
-
/**
|
286 |
-
* Update the builder area
|
287 |
-
*/
|
288 |
-
function update_builder() {
|
289 |
-
UM()->admin()->check_ajax_nonce();
|
290 |
-
|
291 |
-
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
292 |
-
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
293 |
-
}
|
294 |
-
|
295 |
-
ob_start();
|
296 |
-
|
297 |
-
$this->form_id = absint( $_POST['form_id'] );
|
298 |
-
|
299 |
-
$this->show_builder();
|
300 |
-
|
301 |
-
$output = ob_get_clean();
|
302 |
-
|
303 |
-
if ( is_array( $output ) ) {
|
304 |
-
print_r( $output );
|
305 |
-
} else {
|
306 |
-
echo $output;
|
307 |
-
}
|
308 |
-
die;
|
309 |
-
}
|
310 |
-
|
311 |
-
|
312 |
-
/**
|
313 |
-
* Sort array function
|
314 |
-
*
|
315 |
-
* @param array $arr
|
316 |
-
* @param string $col
|
317 |
-
* @param int $dir
|
318 |
-
*
|
319 |
-
* @return array
|
320 |
-
*/
|
321 |
-
function array_sort_by_column( $arr, $col, $dir = SORT_ASC ) {
|
322 |
-
$sort_col = array();
|
323 |
-
|
324 |
-
foreach ( $arr as $key => $row ) {
|
325 |
-
if ( ! empty( $row[ $col ] ) ) {
|
326 |
-
$sort_col[ $key ] = $row[ $col ];
|
327 |
-
}
|
328 |
-
}
|
329 |
-
|
330 |
-
if ( ! empty( $sort_col ) ) {
|
331 |
-
array_multisort( $sort_col, $dir, $arr );
|
332 |
-
}
|
333 |
-
|
334 |
-
return $arr;
|
335 |
-
}
|
336 |
-
|
337 |
-
|
338 |
-
/**
|
339 |
-
* Get fields in row
|
340 |
-
*
|
341 |
-
* @param $row_id
|
342 |
-
*
|
343 |
-
* @return string
|
344 |
-
*/
|
345 |
-
function get_fields_by_row( $row_id ) {
|
346 |
-
|
347 |
-
if ( empty( $this->global_fields ) || ! is_array( $this->global_fields ) ) {
|
348 |
-
$this->global_fields = array();
|
349 |
-
}
|
350 |
-
|
351 |
-
foreach ( $this->global_fields as $key => $array ) {
|
352 |
-
if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
|
353 |
-
$results[ $key ] = $array;
|
354 |
-
unset( $this->global_fields[ $key ] );
|
355 |
-
}
|
356 |
-
}
|
357 |
-
|
358 |
-
return ( isset ( $results ) ) ? $results : '';
|
359 |
-
}
|
360 |
-
|
361 |
-
|
362 |
-
/**
|
363 |
-
* Get fields by sub row
|
364 |
-
*
|
365 |
-
* @param $row_fields
|
366 |
-
* @param $subrow_id
|
367 |
-
*
|
368 |
-
* @return string
|
369 |
-
*/
|
370 |
-
function get_fields_in_subrow( $row_fields, $subrow_id ) {
|
371 |
-
if ( ! is_array( $row_fields ) ) {
|
372 |
-
return '';
|
373 |
-
}
|
374 |
-
|
375 |
-
foreach( $row_fields as $key => $array ) {
|
376 |
-
if ( ! isset( $array['in_sub_row'] ) || ( isset( $array['in_sub_row'] ) && $array['in_sub_row'] == $subrow_id ) ) {
|
377 |
-
$results[ $key ] = $array;
|
378 |
-
unset( $this->global_fields[ $key ] );
|
379 |
-
}
|
380 |
-
}
|
381 |
-
|
382 |
-
return ( isset ( $results ) ) ? $results : '';
|
383 |
-
}
|
384 |
-
|
385 |
-
|
386 |
-
/**
|
387 |
-
* Display the builder
|
388 |
-
*/
|
389 |
-
function show_builder() {
|
390 |
-
|
391 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $this->form_id );
|
392 |
-
|
393 |
-
if ( !isset( $fields ) || empty( $fields ) ) { ?>
|
394 |
-
|
395 |
-
<div class="um-admin-drag-row">
|
396 |
-
|
397 |
-
<!-- Master Row Actions -->
|
398 |
-
<div class="um-admin-drag-row-icons">
|
399 |
-
<a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
|
400 |
-
<a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member' ); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="_um_row_1"><i class="um-faicon-pencil"></i></a>
|
401 |
-
<span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
|
402 |
-
</div>
|
403 |
-
<div class="um-admin-clear"></div>
|
404 |
-
|
405 |
-
<div class="um-admin-drag-rowsubs">
|
406 |
-
<div class="um-admin-drag-rowsub">
|
407 |
-
|
408 |
-
<!-- Column Layout -->
|
409 |
-
<div class="um-admin-drag-ctrls columns">
|
410 |
-
<a href="javascript:void(0);" class="active" data-cols="1"></a>
|
411 |
-
<a href="javascript:void(0);" data-cols="2"></a>
|
412 |
-
<a href="javascript:void(0);" data-cols="3"></a>
|
413 |
-
</div>
|
414 |
-
|
415 |
-
<!-- Sub Row Actions -->
|
416 |
-
<div class="um-admin-drag-rowsub-icons">
|
417 |
-
<span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
|
418 |
-
</div><div class="um-admin-clear"></div>
|
419 |
-
|
420 |
-
<!-- Columns -->
|
421 |
-
<div class="um-admin-drag-col">
|
422 |
-
|
423 |
-
</div>
|
424 |
-
|
425 |
-
<div class="um-admin-drag-col-dynamic"></div>
|
426 |
-
|
427 |
-
<div class="um-admin-clear"></div>
|
428 |
-
|
429 |
-
</div>
|
430 |
-
</div>
|
431 |
-
|
432 |
-
</div>
|
433 |
-
|
434 |
-
<?php
|
435 |
-
|
436 |
-
} else {
|
437 |
-
|
438 |
-
if ( empty( $fields ) || ! is_array( $fields ) ) {
|
439 |
-
$this->global_fields = array();
|
440 |
-
} else {
|
441 |
-
$this->global_fields = $fields;
|
442 |
-
}
|
443 |
-
|
444 |
-
foreach ( $this->global_fields as $key => $array ) {
|
445 |
-
if ( $array['type'] == 'row' ) {
|
446 |
-
$rows[ $key ] = $array;
|
447 |
-
unset( $this->global_fields[ $key ] ); // not needed now
|
448 |
-
}
|
449 |
-
|
450 |
-
}
|
451 |
-
|
452 |
-
if ( ! isset( $rows ) ) {
|
453 |
-
$rows = array(
|
454 |
-
'_um_row_1' => array(
|
455 |
-
'type' => 'row',
|
456 |
-
'id' => '_um_row_1',
|
457 |
-
'sub_rows' => 1,
|
458 |
-
'cols' => 1
|
459 |
-
),
|
460 |
-
);
|
461 |
-
}
|
462 |
-
|
463 |
-
foreach ( $rows as $row_id => $array ) { ?>
|
464 |
-
|
465 |
-
<div class="um-admin-drag-row" data-original="<?php echo esc_attr( $row_id ); ?>">
|
466 |
-
|
467 |
-
<!-- Master Row Actions -->
|
468 |
-
<div class="um-admin-drag-row-icons">
|
469 |
-
<a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
|
470 |
-
<a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member'); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="<?php echo esc_attr( $row_id ); ?>"><i class="um-faicon-pencil"></i></a>
|
471 |
-
<span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
|
472 |
-
<?php if ( $row_id != '_um_row_1' ) {?>
|
473 |
-
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-row"><i class="um-faicon-trash-o"></i></a>
|
474 |
-
<?php } ?>
|
475 |
-
</div><div class="um-admin-clear"></div>
|
476 |
-
|
477 |
-
<div class="um-admin-drag-rowsubs">
|
478 |
-
|
479 |
-
<?php $row_fields = $this->get_fields_by_row( $row_id );
|
480 |
-
|
481 |
-
$sub_rows = ( isset( $array['sub_rows'] ) ) ? $array['sub_rows'] : 1;
|
482 |
-
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
483 |
-
|
484 |
-
$subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
|
485 |
-
|
486 |
-
?>
|
487 |
-
|
488 |
-
<div class="um-admin-drag-rowsub">
|
489 |
-
|
490 |
-
<!-- Column Layout -->
|
491 |
-
<div class="um-admin-drag-ctrls columns">
|
492 |
-
|
493 |
-
<?php
|
494 |
-
|
495 |
-
if ( !isset( $array['cols'] ) ){
|
496 |
-
$col_num = 1;
|
497 |
-
} else {
|
498 |
-
|
499 |
-
$col_split = explode(':', $array['cols'] );
|
500 |
-
$col_num = $col_split[$c];
|
501 |
-
|
502 |
-
}
|
503 |
-
|
504 |
-
for ( $i = 1; $i <= 3; $i++ ) {
|
505 |
-
echo '<a href="javascript:void(0);" data-cols="'.$i.'" ';
|
506 |
-
if ( $col_num == $i ) echo 'class="active"';
|
507 |
-
echo '></a>';
|
508 |
-
}
|
509 |
-
|
510 |
-
?>
|
511 |
-
|
512 |
-
</div>
|
513 |
-
|
514 |
-
<!-- Sub Row Actions -->
|
515 |
-
<div class="um-admin-drag-rowsub-icons">
|
516 |
-
<span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
|
517 |
-
<?php if ( $c > 0 ) { ?><a href="javascript:void(0);" class="um-admin-tipsy-n" title="Delete Row" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a><?php } ?>
|
518 |
-
</div>
|
519 |
-
<div class="um-admin-clear"></div>
|
520 |
-
|
521 |
-
<!-- Columns -->
|
522 |
-
<div class="um-admin-drag-col">
|
523 |
-
|
524 |
-
<?php
|
525 |
-
|
526 |
-
if ( is_array( $subrow_fields ) ) {
|
527 |
-
|
528 |
-
$subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position');
|
529 |
-
|
530 |
-
foreach( $subrow_fields as $key => $keyarray ) {
|
531 |
-
/**
|
532 |
-
* @var $type
|
533 |
-
* @var $title
|
534 |
-
*/
|
535 |
-
extract( $keyarray );
|
536 |
-
|
537 |
-
?>
|
538 |
-
|
539 |
-
<div class="um-admin-drag-fld um-admin-delete-area um-field-type-<?php echo $type; ?> <?php echo $key; ?>" data-group="<?php echo (isset($keyarray['in_group'])) ? $keyarray['in_group'] : ''; ?>" data-key="<?php echo $key; ?>" data-column="<?php echo ( isset($keyarray['in_column']) ) ? $keyarray['in_column'] : 1; ?>">
|
540 |
-
|
541 |
-
<div class="um-admin-drag-fld-title um-field-type-<?php echo $type; ?>">
|
542 |
-
<?php if ( $type == 'group' ) { ?>
|
543 |
-
<i class="um-icon-plus"></i>
|
544 |
-
<?php } else if ( isset($keyarray['icon']) && !empty( $keyarray['icon'] ) ) { ?>
|
545 |
-
<i class="<?php echo $keyarray['icon']; ?>"></i>
|
546 |
-
<?php } ?><?php echo ! empty( $keyarray['title'] ) ? $keyarray['title'] : __( '(no title)', 'ultimate-member' ); ?></div>
|
547 |
-
<?php $field_name = isset( UM()->builtin()->core_fields[$type]['name'] ) ? UM()->builtin()->core_fields[$type]['name'] : ''; ?>
|
548 |
-
<div class="um-admin-drag-fld-type um-field-type-<?php echo $type; ?>"><?php echo $field_name; ?></div>
|
549 |
-
<div class="um-admin-drag-fld-icons um-field-type-<?php echo $type; ?>">
|
550 |
-
|
551 |
-
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit', 'ultimate-member' ) ?>" data-modal="UM_edit_field" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="<?php echo $type; ?>" data-arg2="<?php echo $this->form_id; ?>" data-arg3="<?php echo $key; ?>"><i class="um-faicon-pencil"></i></a>
|
552 |
-
|
553 |
-
<a href="javascript:void(0);" class="um-admin-tipsy-n um_admin_duplicate_field" title="<?php esc_attr_e( 'Duplicate', 'ultimate-member' ) ?>" data-silent_action="um_admin_duplicate_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-files-o"></i></a>
|
554 |
-
|
555 |
-
<?php if ( $type == 'group' ) { ?>
|
556 |
-
|
557 |
-
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Group', 'ultimate-member' ) ?>" data-remove_element="um-admin-drag-fld.um-field-type-group" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
|
558 |
-
<?php } else { ?>
|
559 |
-
|
560 |
-
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete', 'ultimate-member' ) ?>" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
|
561 |
-
|
562 |
-
<?php } ?>
|
563 |
-
|
564 |
-
</div><div class="um-admin-clear"></div>
|
565 |
-
|
566 |
-
<?php if ( $type == 'group' ) { ?>
|
567 |
-
<div class="um-admin-drag-group">
|
568 |
-
|
569 |
-
</div>
|
570 |
-
<?php } ?>
|
571 |
-
|
572 |
-
</div>
|
573 |
-
|
574 |
-
<?php
|
575 |
-
|
576 |
-
} // end foreach
|
577 |
-
|
578 |
-
} // end if
|
579 |
-
|
580 |
-
?>
|
581 |
-
|
582 |
-
</div>
|
583 |
-
|
584 |
-
<div class="um-admin-drag-col-dynamic"></div>
|
585 |
-
|
586 |
-
<div class="um-admin-clear"></div>
|
587 |
-
|
588 |
-
</div>
|
589 |
-
|
590 |
-
<?php } ?>
|
591 |
-
|
592 |
-
</div>
|
593 |
-
|
594 |
-
</div>
|
595 |
-
|
596 |
-
<?php
|
597 |
-
|
598 |
-
} // rows loop
|
599 |
-
|
600 |
-
} // if fields exist
|
601 |
-
|
602 |
-
}
|
603 |
-
|
604 |
-
|
605 |
-
/**
|
606 |
-
*
|
607 |
-
*/
|
608 |
-
function update_field() {
|
609 |
-
UM()->admin()->check_ajax_nonce();
|
610 |
-
|
611 |
-
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
612 |
-
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
613 |
-
}
|
614 |
-
|
615 |
-
$output['error'] = null;
|
616 |
-
|
617 |
-
$array = array(
|
618 |
-
'field_type' => sanitize_key( $_POST['_type'] ),
|
619 |
-
'form_id' => absint( $_POST['post_id'] ),
|
620 |
-
'args' => UM()->builtin()->get_core_field_attrs( sanitize_key( $_POST['_type'] ) ),
|
621 |
-
'post' => UM()->admin()->sanitize_builder_field_meta( $_POST ),
|
622 |
-
);
|
623 |
-
|
624 |
-
/**
|
625 |
-
* UM hook
|
626 |
-
*
|
627 |
-
* @type filter
|
628 |
-
* @title um_admin_pre_save_fields_hook
|
629 |
-
* @description Filter field data before save
|
630 |
-
* @input_vars
|
631 |
-
* [{"var":"$array","type":"array","desc":"Save Field data"}]
|
632 |
-
* @change_log
|
633 |
-
* ["Since: 2.0"]
|
634 |
-
* @usage add_filter( 'um_admin_pre_save_fields_hook', 'function_name', 10, 1 );
|
635 |
-
* @example
|
636 |
-
* <?php
|
637 |
-
* add_filter( 'um_admin_pre_save_fields_hook', 'my_admin_pre_save_fields', 10, 1 );
|
638 |
-
* function my_admin_pre_save_fields( $array ) {
|
639 |
-
* // your code here
|
640 |
-
* return $array;
|
641 |
-
* }
|
642 |
-
* ?>
|
643 |
-
*/
|
644 |
-
$array = apply_filters( 'um_admin_pre_save_fields_hook', $array );
|
645 |
-
|
646 |
-
/**
|
647 |
-
* UM hook
|
648 |
-
*
|
649 |
-
* @type filter
|
650 |
-
* @title um_admin_field_update_error_handling
|
651 |
-
* @description Change error string on save field
|
652 |
-
* @input_vars
|
653 |
-
* [{"var":"$error","type":"string","desc":"Error String"},
|
654 |
-
* {"var":"$array","type":"array","desc":"Save Field data"}]
|
655 |
-
* @change_log
|
656 |
-
* ["Since: 2.0"]
|
657 |
-
* @usage add_filter( 'um_admin_field_update_error_handling', 'function_name', 10, 2 );
|
658 |
-
* @example
|
659 |
-
* <?php
|
660 |
-
* add_filter( 'um_admin_field_update_error_handling', 'my_admin_field_update_error', 10, 2 );
|
661 |
-
* function my_admin_field_update_error( $error, $array ) {
|
662 |
-
* // your code here
|
663 |
-
* return $error;
|
664 |
-
* }
|
665 |
-
* ?>
|
666 |
-
*/
|
667 |
-
$output['error'] = apply_filters( 'um_admin_field_update_error_handling', $output['error'], $array );
|
668 |
-
|
669 |
-
/**
|
670 |
-
* @var $_metakey
|
671 |
-
* @var $post_id
|
672 |
-
*/
|
673 |
-
extract( $array['post'] );
|
674 |
-
|
675 |
-
if ( empty( $output['error'] ) ) {
|
676 |
-
|
677 |
-
$save = array();
|
678 |
-
$save[ $_metakey ] = null;
|
679 |
-
foreach ( $array['post'] as $key => $val ) {
|
680 |
-
|
681 |
-
if ( substr( $key, 0, 1 ) === '_' && $val
|
682 |
-
$new_key = ltrim ($key,'_');
|
683 |
-
|
684 |
-
if ( $new_key == 'options' ) {
|
685 |
-
//$save[ $_metakey ][$new_key] = explode(PHP_EOL, $val);
|
686 |
-
$save[ $_metakey ][ $new_key ] = preg_split( '/[\r\n]+/', $val, -1, PREG_SPLIT_NO_EMPTY );
|
687 |
-
} else {
|
688 |
-
$save[ $_metakey ][ $new_key ] = $val;
|
689 |
-
}
|
690 |
-
|
691 |
-
} elseif ( strstr( $key, 'um_editor' ) ) {
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
*
|
707 |
-
*
|
708 |
-
* @
|
709 |
-
*
|
710 |
-
* @
|
711 |
-
* @
|
712 |
-
*
|
713 |
-
*
|
714 |
-
*
|
715 |
-
*
|
716 |
-
*
|
717 |
-
*
|
718 |
-
*
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
*
|
731 |
-
*
|
732 |
-
* @
|
733 |
-
*
|
734 |
-
* @
|
735 |
-
* @
|
736 |
-
*
|
737 |
-
*
|
738 |
-
*
|
739 |
-
*
|
740 |
-
*
|
741 |
-
*
|
742 |
-
*
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
}
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
*
|
809 |
-
*
|
810 |
-
* @
|
811 |
-
*
|
812 |
-
* @
|
813 |
-
* @
|
814 |
-
*
|
815 |
-
*
|
816 |
-
*
|
817 |
-
*
|
818 |
-
*
|
819 |
-
*
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
*
|
824 |
-
*
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
*
|
829 |
-
*
|
830 |
-
* @
|
831 |
-
* @
|
832 |
-
*
|
833 |
-
*
|
834 |
-
*
|
835 |
-
*
|
836 |
-
*
|
837 |
-
*
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
$
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
<?php
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
*
|
1129 |
-
*
|
1130 |
-
* @
|
1131 |
-
* @
|
1132 |
-
*
|
1133 |
-
*
|
1134 |
-
*
|
1135 |
-
*
|
1136 |
-
*
|
1137 |
-
*
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
*
|
1158 |
-
*
|
1159 |
-
*
|
1160 |
-
*
|
1161 |
-
*
|
1162 |
-
* @
|
1163 |
-
* ["
|
1164 |
-
*
|
1165 |
-
*
|
1166 |
-
*
|
1167 |
-
*
|
1168 |
-
*
|
1169 |
-
*
|
1170 |
-
*
|
1171 |
-
*
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
*
|
1184 |
-
*
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
$arr_options['
|
1217 |
-
}
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace um\admin\core;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Admin_Builder
|
13 |
+
* @package um\admin\core
|
14 |
+
*/
|
15 |
+
class Admin_Builder {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var
|
20 |
+
*/
|
21 |
+
var $form_id;
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Admin_Builder constructor.
|
26 |
+
*/
|
27 |
+
function __construct() {
|
28 |
+
add_action( 'um_admin_field_modal_header', array( &$this, 'add_message_handlers' ) );
|
29 |
+
add_action( 'um_admin_field_modal_footer', array( &$this, 'add_conditional_support' ), 10, 4 );
|
30 |
+
add_filter( 'um_admin_builder_skip_field_validation', array( &$this, 'skip_field_validation' ), 10, 3 );
|
31 |
+
add_filter( 'um_admin_pre_save_field_to_form', array( &$this, 'um_admin_pre_save_field_to_form' ), 1 );
|
32 |
+
add_filter( 'um_admin_pre_save_fields_hook', array( &$this, 'um_admin_pre_save_fields_hook' ), 1 );
|
33 |
+
add_filter( 'um_admin_field_update_error_handling', array( &$this, 'um_admin_field_update_error_handling' ), 1, 2 );
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Apply a filter to handle errors for field updating in backend
|
39 |
+
*
|
40 |
+
* @param $errors
|
41 |
+
* @param $array
|
42 |
+
*
|
43 |
+
* @return mixed
|
44 |
+
*/
|
45 |
+
function um_admin_field_update_error_handling( $errors, $array ) {
|
46 |
+
/**
|
47 |
+
* @var $field_type
|
48 |
+
*/
|
49 |
+
extract( $array );
|
50 |
+
|
51 |
+
$field_attr = UM()->builtin()->get_core_field_attrs( $field_type );
|
52 |
+
|
53 |
+
if ( isset( $field_attr['validate'] ) ) {
|
54 |
+
|
55 |
+
$validate = $field_attr['validate'];
|
56 |
+
foreach ( $validate as $post_input => $arr ) {
|
57 |
+
|
58 |
+
$skip = apply_filters( 'um_admin_builder_skip_field_validation', false, $post_input, $array );
|
59 |
+
if ( $skip ) {
|
60 |
+
continue;
|
61 |
+
}
|
62 |
+
|
63 |
+
$mode = $arr['mode'];
|
64 |
+
|
65 |
+
switch ( $mode ) {
|
66 |
+
|
67 |
+
case 'numeric':
|
68 |
+
if ( ! empty( $array['post'][ $post_input ] ) && ! is_numeric( $array['post'][ $post_input ] ) ){
|
69 |
+
$errors[ $post_input ] = $validate[ $post_input ]['error'];
|
70 |
+
}
|
71 |
+
break;
|
72 |
+
|
73 |
+
case 'unique':
|
74 |
+
if ( ! isset( $array['post']['edit_mode'] ) ) {
|
75 |
+
if ( UM()->builtin()->unique_field_err( $array['post'][ $post_input ] ) ) {
|
76 |
+
$errors[ $post_input ] = UM()->builtin()->unique_field_err( $array['post'][ $post_input ] );
|
77 |
+
}
|
78 |
+
}
|
79 |
+
break;
|
80 |
+
|
81 |
+
case 'required':
|
82 |
+
if ( $array['post'][ $post_input ] == '' ) {
|
83 |
+
$errors[ $post_input ] = $validate[ $post_input ]['error'];
|
84 |
+
}
|
85 |
+
break;
|
86 |
+
|
87 |
+
case 'range-start':
|
88 |
+
if ( UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] ) && $array['post']['_range'] == 'date_range' ) {
|
89 |
+
$errors[ $post_input ] = UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] );
|
90 |
+
}
|
91 |
+
break;
|
92 |
+
|
93 |
+
case 'range-end':
|
94 |
+
if ( UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] ) && $array['post']['_range'] == 'date_range' ) {
|
95 |
+
$errors[ $post_input ] = UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] );
|
96 |
+
}
|
97 |
+
break;
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
return $errors;
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Some fields may require extra fields before saving
|
112 |
+
*
|
113 |
+
* @param $array
|
114 |
+
*
|
115 |
+
* @return mixed
|
116 |
+
*/
|
117 |
+
function um_admin_pre_save_fields_hook( $array ) {
|
118 |
+
/**
|
119 |
+
* @var $form_id
|
120 |
+
* @var $field_type
|
121 |
+
*/
|
122 |
+
extract( $array );
|
123 |
+
|
124 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
125 |
+
|
126 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
127 |
+
$count = 1;
|
128 |
+
if ( ! empty( $fields ) ) {
|
129 |
+
$count = count( $fields ) + 1;
|
130 |
+
}
|
131 |
+
|
132 |
+
// set unique meta key
|
133 |
+
if ( in_array( $field_type, $fields_without_metakey ) && ! isset( $array['post']['_metakey'] ) ) {
|
134 |
+
$array['post']['_metakey'] = "um_{$field_type}_{$form_id}_{$count}";
|
135 |
+
}
|
136 |
+
|
137 |
+
// set position
|
138 |
+
if ( ! isset( $array['post']['_position'] ) ) {
|
139 |
+
$array['post']['_position'] = $count;
|
140 |
+
}
|
141 |
+
|
142 |
+
return $array;
|
143 |
+
}
|
144 |
+
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Modify field args just before it is saved into form
|
148 |
+
*
|
149 |
+
* @param $array
|
150 |
+
*
|
151 |
+
* @return mixed
|
152 |
+
*/
|
153 |
+
function um_admin_pre_save_field_to_form( $array ){
|
154 |
+
unset( $array['conditions'] );
|
155 |
+
if ( isset($array['conditional_field']) && ! empty( $array['conditional_action'] ) && ! empty( $array['conditional_operator'] ) ) {
|
156 |
+
$array['conditional_value'] = isset( $array['conditional_value'] ) ? $array['conditional_value'] : '';
|
157 |
+
$array['conditions'][] = array( $array['conditional_action'], $array['conditional_field'], $array['conditional_operator'], $array['conditional_value'] );
|
158 |
+
}
|
159 |
+
|
160 |
+
if ( isset( $array['conditional_field1'] ) && ! empty( $array['conditional_action1'] ) && ! empty( $array['conditional_operator1'] ) ) {
|
161 |
+
$array['conditional_value1'] = isset( $array['conditional_value1'] ) ? $array['conditional_value1'] : '';
|
162 |
+
$array['conditions'][] = array( $array['conditional_action1'], $array['conditional_field1'], $array['conditional_operator1'], $array['conditional_value1'] );
|
163 |
+
}
|
164 |
+
|
165 |
+
if ( isset( $array['conditional_field2'] ) && ! empty( $array['conditional_action2'] ) && ! empty( $array['conditional_operator2'] ) ) {
|
166 |
+
$array['conditional_value2'] = isset( $array['conditional_value2'] ) ? $array['conditional_value2'] : '';
|
167 |
+
$array['conditions'][] = array( $array['conditional_action2'], $array['conditional_field2'], $array['conditional_operator2'], $array['conditional_value2'] );
|
168 |
+
}
|
169 |
+
|
170 |
+
if ( isset( $array['conditional_field3'] ) && ! empty( $array['conditional_action3'] ) && ! empty( $array['conditional_operator3'] ) ) {
|
171 |
+
$array['conditional_value3'] = isset( $array['conditional_value3'] ) ? $array['conditional_value3'] : '';
|
172 |
+
$array['conditions'][] = array( $array['conditional_action3'], $array['conditional_field3'], $array['conditional_operator3'], $array['conditional_value3'] );
|
173 |
+
}
|
174 |
+
|
175 |
+
if ( isset( $array['conditional_field4'] ) && ! empty( $array['conditional_action4'] ) && ! empty( $array['conditional_operator4'] ) ) {
|
176 |
+
$array['conditional_value4'] = isset( $array['conditional_value4'] ) ? $array['conditional_value4'] : '';
|
177 |
+
$array['conditions'][] = array( $array['conditional_action4'], $array['conditional_field4'], $array['conditional_operator4'], $array['conditional_value4'] );
|
178 |
+
}
|
179 |
+
|
180 |
+
return $array;
|
181 |
+
}
|
182 |
+
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Put status handler in modal
|
186 |
+
*/
|
187 |
+
function add_message_handlers() {
|
188 |
+
?>
|
189 |
+
<div class="um-admin-error-block"></div>
|
190 |
+
<div class="um-admin-success-block"></div>
|
191 |
+
<?php
|
192 |
+
}
|
193 |
+
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Footer of modal
|
197 |
+
*
|
198 |
+
* @param $form_id
|
199 |
+
* @param $field_args
|
200 |
+
* @param $in_edit
|
201 |
+
* @param $edit_array
|
202 |
+
*/
|
203 |
+
function add_conditional_support( $form_id, $field_args, $in_edit, $edit_array ) {
|
204 |
+
$metabox = UM()->metabox();
|
205 |
+
|
206 |
+
if ( isset( $field_args['conditional_support'] ) && $field_args['conditional_support'] == 0 ) {
|
207 |
+
return;
|
208 |
+
} ?>
|
209 |
+
|
210 |
+
<div class="um-admin-btn-toggle">
|
211 |
+
|
212 |
+
<?php if ( $in_edit ) { $metabox->in_edit = true; $metabox->edit_array = $edit_array; ?>
|
213 |
+
<a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Manage conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
|
214 |
+
<?php } else { ?>
|
215 |
+
<a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Add conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
|
216 |
+
<?php } ?>
|
217 |
+
|
218 |
+
<div class="um-admin-btn-content">
|
219 |
+
<div class="um-admin-cur-condition-template">
|
220 |
+
|
221 |
+
<?php $metabox->field_input( '_conditional_action', $form_id ); ?>
|
222 |
+
<?php $metabox->field_input( '_conditional_field', $form_id ); ?>
|
223 |
+
<?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
|
224 |
+
<?php $metabox->field_input( '_conditional_value', $form_id ); ?>
|
225 |
+
|
226 |
+
<p><a href="javascript:void(0);" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
|
227 |
+
|
228 |
+
<div class="um-admin-clear"></div>
|
229 |
+
</div>
|
230 |
+
<p class="um-admin-conditions-notice">
|
231 |
+
<small>
|
232 |
+
<?php _e( 'Use the condition operator `equals to` or `not equals` if the parent field has a single option.', 'ultimate-member' ); ?>
|
233 |
+
<br><?php _e( 'Use the condition operator `greater than` or `less than` if the parent field is a number.', 'ultimate-member' ); ?>
|
234 |
+
<br><?php _e( 'Use the condition operator `contains` if the parent field has multiple options.', 'ultimate-member' ); ?>
|
235 |
+
</small>
|
236 |
+
</p>
|
237 |
+
<p><a href="javascript:void(0);" class="um-admin-new-condition button button-primary um-admin-tipsy-n" title="Add new condition"><?php _e( 'Add new rule', 'ultimate-member' ); ?></a></p>
|
238 |
+
<p class="um-admin-reset-conditions"><a href="javascript:void(0);" class="button"><?php _e( 'Reset all rules', 'ultimate-member' ); ?></a></p>
|
239 |
+
|
240 |
+
<div class="um-admin-clear"></div>
|
241 |
+
|
242 |
+
<?php if ( isset( $edit_array['conditions'] ) && count( $edit_array['conditions'] ) != 0 ) {
|
243 |
+
|
244 |
+
foreach ( $edit_array['conditions'] as $k => $arr ) {
|
245 |
+
|
246 |
+
if ( $k == 0 ) $k = ''; ?>
|
247 |
+
|
248 |
+
<div class="um-admin-cur-condition">
|
249 |
+
|
250 |
+
<?php $metabox->field_input( '_conditional_action' . $k, $form_id ); ?>
|
251 |
+
<?php $metabox->field_input( '_conditional_field' . $k , $form_id ); ?>
|
252 |
+
<?php $metabox->field_input( '_conditional_operator' . $k, $form_id ); ?>
|
253 |
+
<?php $metabox->field_input( '_conditional_value' . $k, $form_id ); ?>
|
254 |
+
|
255 |
+
<p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
|
256 |
+
|
257 |
+
<div class="um-admin-clear"></div>
|
258 |
+
</div>
|
259 |
+
|
260 |
+
<?php
|
261 |
+
}
|
262 |
+
|
263 |
+
} else { ?>
|
264 |
+
|
265 |
+
<div class="um-admin-cur-condition">
|
266 |
+
|
267 |
+
<?php $metabox->field_input( '_conditional_action', $form_id ); ?>
|
268 |
+
<?php $metabox->field_input( '_conditional_field', $form_id ); ?>
|
269 |
+
<?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
|
270 |
+
<?php $metabox->field_input( '_conditional_value', $form_id ); ?>
|
271 |
+
|
272 |
+
<p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
|
273 |
+
|
274 |
+
<div class="um-admin-clear"></div>
|
275 |
+
</div>
|
276 |
+
|
277 |
+
<?php } ?>
|
278 |
+
</div>
|
279 |
+
</div>
|
280 |
+
|
281 |
+
<?php
|
282 |
+
}
|
283 |
+
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Update the builder area
|
287 |
+
*/
|
288 |
+
function update_builder() {
|
289 |
+
UM()->admin()->check_ajax_nonce();
|
290 |
+
|
291 |
+
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
292 |
+
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
293 |
+
}
|
294 |
+
|
295 |
+
ob_start();
|
296 |
+
|
297 |
+
$this->form_id = absint( $_POST['form_id'] );
|
298 |
+
|
299 |
+
$this->show_builder();
|
300 |
+
|
301 |
+
$output = ob_get_clean();
|
302 |
+
|
303 |
+
if ( is_array( $output ) ) {
|
304 |
+
print_r( $output );
|
305 |
+
} else {
|
306 |
+
echo $output;
|
307 |
+
}
|
308 |
+
die;
|
309 |
+
}
|
310 |
+
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Sort array function
|
314 |
+
*
|
315 |
+
* @param array $arr
|
316 |
+
* @param string $col
|
317 |
+
* @param int $dir
|
318 |
+
*
|
319 |
+
* @return array
|
320 |
+
*/
|
321 |
+
function array_sort_by_column( $arr, $col, $dir = SORT_ASC ) {
|
322 |
+
$sort_col = array();
|
323 |
+
|
324 |
+
foreach ( $arr as $key => $row ) {
|
325 |
+
if ( ! empty( $row[ $col ] ) ) {
|
326 |
+
$sort_col[ $key ] = $row[ $col ];
|
327 |
+
}
|
328 |
+
}
|
329 |
+
|
330 |
+
if ( ! empty( $sort_col ) ) {
|
331 |
+
array_multisort( $sort_col, $dir, $arr );
|
332 |
+
}
|
333 |
+
|
334 |
+
return $arr;
|
335 |
+
}
|
336 |
+
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Get fields in row
|
340 |
+
*
|
341 |
+
* @param $row_id
|
342 |
+
*
|
343 |
+
* @return string
|
344 |
+
*/
|
345 |
+
function get_fields_by_row( $row_id ) {
|
346 |
+
|
347 |
+
if ( empty( $this->global_fields ) || ! is_array( $this->global_fields ) ) {
|
348 |
+
$this->global_fields = array();
|
349 |
+
}
|
350 |
+
|
351 |
+
foreach ( $this->global_fields as $key => $array ) {
|
352 |
+
if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
|
353 |
+
$results[ $key ] = $array;
|
354 |
+
unset( $this->global_fields[ $key ] );
|
355 |
+
}
|
356 |
+
}
|
357 |
+
|
358 |
+
return ( isset ( $results ) ) ? $results : '';
|
359 |
+
}
|
360 |
+
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Get fields by sub row
|
364 |
+
*
|
365 |
+
* @param $row_fields
|
366 |
+
* @param $subrow_id
|
367 |
+
*
|
368 |
+
* @return string
|
369 |
+
*/
|
370 |
+
function get_fields_in_subrow( $row_fields, $subrow_id ) {
|
371 |
+
if ( ! is_array( $row_fields ) ) {
|
372 |
+
return '';
|
373 |
+
}
|
374 |
+
|
375 |
+
foreach( $row_fields as $key => $array ) {
|
376 |
+
if ( ! isset( $array['in_sub_row'] ) || ( isset( $array['in_sub_row'] ) && $array['in_sub_row'] == $subrow_id ) ) {
|
377 |
+
$results[ $key ] = $array;
|
378 |
+
unset( $this->global_fields[ $key ] );
|
379 |
+
}
|
380 |
+
}
|
381 |
+
|
382 |
+
return ( isset ( $results ) ) ? $results : '';
|
383 |
+
}
|
384 |
+
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Display the builder
|
388 |
+
*/
|
389 |
+
function show_builder() {
|
390 |
+
|
391 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $this->form_id );
|
392 |
+
|
393 |
+
if ( !isset( $fields ) || empty( $fields ) ) { ?>
|
394 |
+
|
395 |
+
<div class="um-admin-drag-row">
|
396 |
+
|
397 |
+
<!-- Master Row Actions -->
|
398 |
+
<div class="um-admin-drag-row-icons">
|
399 |
+
<a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
|
400 |
+
<a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member' ); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="_um_row_1"><i class="um-faicon-pencil"></i></a>
|
401 |
+
<span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
|
402 |
+
</div>
|
403 |
+
<div class="um-admin-clear"></div>
|
404 |
+
|
405 |
+
<div class="um-admin-drag-rowsubs">
|
406 |
+
<div class="um-admin-drag-rowsub">
|
407 |
+
|
408 |
+
<!-- Column Layout -->
|
409 |
+
<div class="um-admin-drag-ctrls columns">
|
410 |
+
<a href="javascript:void(0);" class="active" data-cols="1"></a>
|
411 |
+
<a href="javascript:void(0);" data-cols="2"></a>
|
412 |
+
<a href="javascript:void(0);" data-cols="3"></a>
|
413 |
+
</div>
|
414 |
+
|
415 |
+
<!-- Sub Row Actions -->
|
416 |
+
<div class="um-admin-drag-rowsub-icons">
|
417 |
+
<span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
|
418 |
+
</div><div class="um-admin-clear"></div>
|
419 |
+
|
420 |
+
<!-- Columns -->
|
421 |
+
<div class="um-admin-drag-col">
|
422 |
+
|
423 |
+
</div>
|
424 |
+
|
425 |
+
<div class="um-admin-drag-col-dynamic"></div>
|
426 |
+
|
427 |
+
<div class="um-admin-clear"></div>
|
428 |
+
|
429 |
+
</div>
|
430 |
+
</div>
|
431 |
+
|
432 |
+
</div>
|
433 |
+
|
434 |
+
<?php
|
435 |
+
|
436 |
+
} else {
|
437 |
+
|
438 |
+
if ( empty( $fields ) || ! is_array( $fields ) ) {
|
439 |
+
$this->global_fields = array();
|
440 |
+
} else {
|
441 |
+
$this->global_fields = $fields;
|
442 |
+
}
|
443 |
+
|
444 |
+
foreach ( $this->global_fields as $key => $array ) {
|
445 |
+
if ( $array['type'] == 'row' ) {
|
446 |
+
$rows[ $key ] = $array;
|
447 |
+
unset( $this->global_fields[ $key ] ); // not needed now
|
448 |
+
}
|
449 |
+
|
450 |
+
}
|
451 |
+
|
452 |
+
if ( ! isset( $rows ) ) {
|
453 |
+
$rows = array(
|
454 |
+
'_um_row_1' => array(
|
455 |
+
'type' => 'row',
|
456 |
+
'id' => '_um_row_1',
|
457 |
+
'sub_rows' => 1,
|
458 |
+
'cols' => 1
|
459 |
+
),
|
460 |
+
);
|
461 |
+
}
|
462 |
+
|
463 |
+
foreach ( $rows as $row_id => $array ) { ?>
|
464 |
+
|
465 |
+
<div class="um-admin-drag-row" data-original="<?php echo esc_attr( $row_id ); ?>">
|
466 |
+
|
467 |
+
<!-- Master Row Actions -->
|
468 |
+
<div class="um-admin-drag-row-icons">
|
469 |
+
<a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
|
470 |
+
<a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member'); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="<?php echo esc_attr( $row_id ); ?>"><i class="um-faicon-pencil"></i></a>
|
471 |
+
<span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
|
472 |
+
<?php if ( $row_id != '_um_row_1' ) {?>
|
473 |
+
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-row"><i class="um-faicon-trash-o"></i></a>
|
474 |
+
<?php } ?>
|
475 |
+
</div><div class="um-admin-clear"></div>
|
476 |
+
|
477 |
+
<div class="um-admin-drag-rowsubs">
|
478 |
+
|
479 |
+
<?php $row_fields = $this->get_fields_by_row( $row_id );
|
480 |
+
|
481 |
+
$sub_rows = ( isset( $array['sub_rows'] ) ) ? $array['sub_rows'] : 1;
|
482 |
+
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
483 |
+
|
484 |
+
$subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
|
485 |
+
|
486 |
+
?>
|
487 |
+
|
488 |
+
<div class="um-admin-drag-rowsub">
|
489 |
+
|
490 |
+
<!-- Column Layout -->
|
491 |
+
<div class="um-admin-drag-ctrls columns">
|
492 |
+
|
493 |
+
<?php
|
494 |
+
|
495 |
+
if ( !isset( $array['cols'] ) ){
|
496 |
+
$col_num = 1;
|
497 |
+
} else {
|
498 |
+
|
499 |
+
$col_split = explode(':', $array['cols'] );
|
500 |
+
$col_num = $col_split[$c];
|
501 |
+
|
502 |
+
}
|
503 |
+
|
504 |
+
for ( $i = 1; $i <= 3; $i++ ) {
|
505 |
+
echo '<a href="javascript:void(0);" data-cols="'.$i.'" ';
|
506 |
+
if ( $col_num == $i ) echo 'class="active"';
|
507 |
+
echo '></a>';
|
508 |
+
}
|
509 |
+
|
510 |
+
?>
|
511 |
+
|
512 |
+
</div>
|
513 |
+
|
514 |
+
<!-- Sub Row Actions -->
|
515 |
+
<div class="um-admin-drag-rowsub-icons">
|
516 |
+
<span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
|
517 |
+
<?php if ( $c > 0 ) { ?><a href="javascript:void(0);" class="um-admin-tipsy-n" title="Delete Row" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a><?php } ?>
|
518 |
+
</div>
|
519 |
+
<div class="um-admin-clear"></div>
|
520 |
+
|
521 |
+
<!-- Columns -->
|
522 |
+
<div class="um-admin-drag-col">
|
523 |
+
|
524 |
+
<?php
|
525 |
+
|
526 |
+
if ( is_array( $subrow_fields ) ) {
|
527 |
+
|
528 |
+
$subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position');
|
529 |
+
|
530 |
+
foreach( $subrow_fields as $key => $keyarray ) {
|
531 |
+
/**
|
532 |
+
* @var $type
|
533 |
+
* @var $title
|
534 |
+
*/
|
535 |
+
extract( $keyarray );
|
536 |
+
|
537 |
+
?>
|
538 |
+
|
539 |
+
<div class="um-admin-drag-fld um-admin-delete-area um-field-type-<?php echo $type; ?> <?php echo $key; ?>" data-group="<?php echo (isset($keyarray['in_group'])) ? $keyarray['in_group'] : ''; ?>" data-key="<?php echo $key; ?>" data-column="<?php echo ( isset($keyarray['in_column']) ) ? $keyarray['in_column'] : 1; ?>">
|
540 |
+
|
541 |
+
<div class="um-admin-drag-fld-title um-field-type-<?php echo $type; ?>">
|
542 |
+
<?php if ( $type == 'group' ) { ?>
|
543 |
+
<i class="um-icon-plus"></i>
|
544 |
+
<?php } else if ( isset($keyarray['icon']) && !empty( $keyarray['icon'] ) ) { ?>
|
545 |
+
<i class="<?php echo $keyarray['icon']; ?>"></i>
|
546 |
+
<?php } ?><?php echo ! empty( $keyarray['title'] ) ? $keyarray['title'] : __( '(no title)', 'ultimate-member' ); ?></div>
|
547 |
+
<?php $field_name = isset( UM()->builtin()->core_fields[$type]['name'] ) ? UM()->builtin()->core_fields[$type]['name'] : ''; ?>
|
548 |
+
<div class="um-admin-drag-fld-type um-field-type-<?php echo $type; ?>"><?php echo $field_name; ?></div>
|
549 |
+
<div class="um-admin-drag-fld-icons um-field-type-<?php echo $type; ?>">
|
550 |
+
|
551 |
+
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit', 'ultimate-member' ) ?>" data-modal="UM_edit_field" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="<?php echo $type; ?>" data-arg2="<?php echo $this->form_id; ?>" data-arg3="<?php echo $key; ?>"><i class="um-faicon-pencil"></i></a>
|
552 |
+
|
553 |
+
<a href="javascript:void(0);" class="um-admin-tipsy-n um_admin_duplicate_field" title="<?php esc_attr_e( 'Duplicate', 'ultimate-member' ) ?>" data-silent_action="um_admin_duplicate_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-files-o"></i></a>
|
554 |
+
|
555 |
+
<?php if ( $type == 'group' ) { ?>
|
556 |
+
|
557 |
+
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Group', 'ultimate-member' ) ?>" data-remove_element="um-admin-drag-fld.um-field-type-group" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
|
558 |
+
<?php } else { ?>
|
559 |
+
|
560 |
+
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete', 'ultimate-member' ) ?>" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
|
561 |
+
|
562 |
+
<?php } ?>
|
563 |
+
|
564 |
+
</div><div class="um-admin-clear"></div>
|
565 |
+
|
566 |
+
<?php if ( $type == 'group' ) { ?>
|
567 |
+
<div class="um-admin-drag-group">
|
568 |
+
|
569 |
+
</div>
|
570 |
+
<?php } ?>
|
571 |
+
|
572 |
+
</div>
|
573 |
+
|
574 |
+
<?php
|
575 |
+
|
576 |
+
} // end foreach
|
577 |
+
|
578 |
+
} // end if
|
579 |
+
|
580 |
+
?>
|
581 |
+
|
582 |
+
</div>
|
583 |
+
|
584 |
+
<div class="um-admin-drag-col-dynamic"></div>
|
585 |
+
|
586 |
+
<div class="um-admin-clear"></div>
|
587 |
+
|
588 |
+
</div>
|
589 |
+
|
590 |
+
<?php } ?>
|
591 |
+
|
592 |
+
</div>
|
593 |
+
|
594 |
+
</div>
|
595 |
+
|
596 |
+
<?php
|
597 |
+
|
598 |
+
} // rows loop
|
599 |
+
|
600 |
+
} // if fields exist
|
601 |
+
|
602 |
+
}
|
603 |
+
|
604 |
+
|
605 |
+
/**
|
606 |
+
*
|
607 |
+
*/
|
608 |
+
function update_field() {
|
609 |
+
UM()->admin()->check_ajax_nonce();
|
610 |
+
|
611 |
+
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
612 |
+
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
613 |
+
}
|
614 |
+
|
615 |
+
$output['error'] = null;
|
616 |
+
|
617 |
+
$array = array(
|
618 |
+
'field_type' => sanitize_key( $_POST['_type'] ),
|
619 |
+
'form_id' => absint( $_POST['post_id'] ),
|
620 |
+
'args' => UM()->builtin()->get_core_field_attrs( sanitize_key( $_POST['_type'] ) ),
|
621 |
+
'post' => UM()->admin()->sanitize_builder_field_meta( $_POST ),
|
622 |
+
);
|
623 |
+
|
624 |
+
/**
|
625 |
+
* UM hook
|
626 |
+
*
|
627 |
+
* @type filter
|
628 |
+
* @title um_admin_pre_save_fields_hook
|
629 |
+
* @description Filter field data before save
|
630 |
+
* @input_vars
|
631 |
+
* [{"var":"$array","type":"array","desc":"Save Field data"}]
|
632 |
+
* @change_log
|
633 |
+
* ["Since: 2.0"]
|
634 |
+
* @usage add_filter( 'um_admin_pre_save_fields_hook', 'function_name', 10, 1 );
|
635 |
+
* @example
|
636 |
+
* <?php
|
637 |
+
* add_filter( 'um_admin_pre_save_fields_hook', 'my_admin_pre_save_fields', 10, 1 );
|
638 |
+
* function my_admin_pre_save_fields( $array ) {
|
639 |
+
* // your code here
|
640 |
+
* return $array;
|
641 |
+
* }
|
642 |
+
* ?>
|
643 |
+
*/
|
644 |
+
$array = apply_filters( 'um_admin_pre_save_fields_hook', $array );
|
645 |
+
|
646 |
+
/**
|
647 |
+
* UM hook
|
648 |
+
*
|
649 |
+
* @type filter
|
650 |
+
* @title um_admin_field_update_error_handling
|
651 |
+
* @description Change error string on save field
|
652 |
+
* @input_vars
|
653 |
+
* [{"var":"$error","type":"string","desc":"Error String"},
|
654 |
+
* {"var":"$array","type":"array","desc":"Save Field data"}]
|
655 |
+
* @change_log
|
656 |
+
* ["Since: 2.0"]
|
657 |
+
* @usage add_filter( 'um_admin_field_update_error_handling', 'function_name', 10, 2 );
|
658 |
+
* @example
|
659 |
+
* <?php
|
660 |
+
* add_filter( 'um_admin_field_update_error_handling', 'my_admin_field_update_error', 10, 2 );
|
661 |
+
* function my_admin_field_update_error( $error, $array ) {
|
662 |
+
* // your code here
|
663 |
+
* return $error;
|
664 |
+
* }
|
665 |
+
* ?>
|
666 |
+
*/
|
667 |
+
$output['error'] = apply_filters( 'um_admin_field_update_error_handling', $output['error'], $array );
|
668 |
+
|
669 |
+
/**
|
670 |
+
* @var $_metakey
|
671 |
+
* @var $post_id
|
672 |
+
*/
|
673 |
+
extract( $array['post'] );
|
674 |
+
|
675 |
+
if ( empty( $output['error'] ) ) {
|
676 |
+
|
677 |
+
$save = array();
|
678 |
+
$save[ $_metakey ] = null;
|
679 |
+
foreach ( $array['post'] as $key => $val ) {
|
680 |
+
|
681 |
+
if ( substr( $key, 0, 1 ) === '_' && $val !== '' ) { // field attribute
|
682 |
+
$new_key = ltrim ( $key, '_' );
|
683 |
+
|
684 |
+
if ( $new_key == 'options' ) {
|
685 |
+
//$save[ $_metakey ][$new_key] = explode(PHP_EOL, $val);
|
686 |
+
$save[ $_metakey ][ $new_key ] = preg_split( '/[\r\n]+/', $val, -1, PREG_SPLIT_NO_EMPTY );
|
687 |
+
} else {
|
688 |
+
$save[ $_metakey ][ $new_key ] = $val;
|
689 |
+
}
|
690 |
+
|
691 |
+
} elseif ( strstr( $key, 'um_editor' ) ) {
|
692 |
+
|
693 |
+
if ( 'block' === $array['post']['_type'] ) {
|
694 |
+
$save[ $_metakey ]['content'] = wp_kses_post( $val );
|
695 |
+
} else {
|
696 |
+
$save[ $_metakey ]['content'] = sanitize_textarea_field( $val );
|
697 |
+
}
|
698 |
+
}
|
699 |
+
|
700 |
+
}
|
701 |
+
|
702 |
+
$field_ID = $_metakey;
|
703 |
+
$field_args = $save[ $_metakey ];
|
704 |
+
|
705 |
+
/**
|
706 |
+
* UM hook
|
707 |
+
*
|
708 |
+
* @type filter
|
709 |
+
* @title um_admin_pre_save_field_to_form
|
710 |
+
* @description Change field options before save to form
|
711 |
+
* @input_vars
|
712 |
+
* [{"var":"$field_args","type":"array","desc":"Field Options"}]
|
713 |
+
* @change_log
|
714 |
+
* ["Since: 2.0"]
|
715 |
+
* @usage add_filter( 'um_admin_pre_save_field_to_form', 'function_name', 10, 1 );
|
716 |
+
* @example
|
717 |
+
* <?php
|
718 |
+
* add_filter( 'um_admin_pre_save_field_to_form', 'my_admin_pre_save_field_to_form', 10, 1 );
|
719 |
+
* function my_admin_pre_save_field_to_form( $field_args ) {
|
720 |
+
* // your code here
|
721 |
+
* return $field_args;
|
722 |
+
* }
|
723 |
+
* ?>
|
724 |
+
*/
|
725 |
+
$field_args = apply_filters( 'um_admin_pre_save_field_to_form', $field_args );
|
726 |
+
|
727 |
+
UM()->fields()->update_field( $field_ID, $field_args, $post_id );
|
728 |
+
|
729 |
+
/**
|
730 |
+
* UM hook
|
731 |
+
*
|
732 |
+
* @type filter
|
733 |
+
* @title um_admin_pre_save_field_to_db
|
734 |
+
* @description Change field options before save to DB
|
735 |
+
* @input_vars
|
736 |
+
* [{"var":"$field_args","type":"array","desc":"Field Options"}]
|
737 |
+
* @change_log
|
738 |
+
* ["Since: 2.0"]
|
739 |
+
* @usage add_filter( 'um_admin_pre_save_field_to_db', 'function_name', 10, 1 );
|
740 |
+
* @example
|
741 |
+
* <?php
|
742 |
+
* add_filter( 'um_admin_pre_save_field_to_db', 'my_admin_pre_save_field_to_db', 10, 1 );
|
743 |
+
* function my_admin_pre_save_field_to_form( $field_args ) {
|
744 |
+
* // your code here
|
745 |
+
* return $field_args;
|
746 |
+
* }
|
747 |
+
* ?>
|
748 |
+
*/
|
749 |
+
$field_args = apply_filters( 'um_admin_pre_save_field_to_db', $field_args );
|
750 |
+
|
751 |
+
if ( ! isset( $array['args']['form_only'] ) ) {
|
752 |
+
if ( ! isset( UM()->builtin()->predefined_fields[ $field_ID ] ) ) {
|
753 |
+
UM()->fields()->globally_update_field( $field_ID, $field_args );
|
754 |
+
}
|
755 |
+
}
|
756 |
+
|
757 |
+
}
|
758 |
+
|
759 |
+
$output = json_encode( $output );
|
760 |
+
if ( is_array( $output ) ) {
|
761 |
+
print_r( $output );
|
762 |
+
} else {
|
763 |
+
echo $output;
|
764 |
+
}
|
765 |
+
die;
|
766 |
+
}
|
767 |
+
|
768 |
+
|
769 |
+
/**
|
770 |
+
*
|
771 |
+
*/
|
772 |
+
function dynamic_modal_content() {
|
773 |
+
UM()->admin()->check_ajax_nonce();
|
774 |
+
|
775 |
+
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
776 |
+
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
777 |
+
}
|
778 |
+
|
779 |
+
$metabox = UM()->metabox();
|
780 |
+
|
781 |
+
/**
|
782 |
+
* @var $act_id
|
783 |
+
* @var $arg1
|
784 |
+
* @var $arg2
|
785 |
+
* @var $arg3
|
786 |
+
*/
|
787 |
+
extract( $_POST );
|
788 |
+
|
789 |
+
if ( isset( $arg1 ) ) {
|
790 |
+
$arg1 = sanitize_text_field( $arg1 );
|
791 |
+
}
|
792 |
+
|
793 |
+
if ( isset( $arg2 ) ) {
|
794 |
+
$arg2 = sanitize_text_field( $arg2 );
|
795 |
+
}
|
796 |
+
|
797 |
+
if ( isset( $arg3 ) ) {
|
798 |
+
$arg3 = sanitize_text_field( $arg3 );
|
799 |
+
}
|
800 |
+
|
801 |
+
switch ( sanitize_key( $act_id ) ) {
|
802 |
+
|
803 |
+
default:
|
804 |
+
|
805 |
+
ob_start();
|
806 |
+
|
807 |
+
/**
|
808 |
+
* UM hook
|
809 |
+
*
|
810 |
+
* @type action
|
811 |
+
* @title um_admin_ajax_modal_content__hook
|
812 |
+
* @description Integration hook on ajax popup admin builder modal content
|
813 |
+
* @input_vars
|
814 |
+
* [{"var":"$act_id","type":"string","desc":"Ajax Action"}]
|
815 |
+
* @change_log
|
816 |
+
* ["Since: 2.0"]
|
817 |
+
* @usage add_action( 'um_admin_ajax_modal_content__hook', 'function_name', 10, 1 );
|
818 |
+
* @example
|
819 |
+
* <?php
|
820 |
+
* add_action( 'um_admin_ajax_modal_content__hook', 'my_admin_custom_hook', 10, 1 );
|
821 |
+
* function um_admin_ajax_modal_content__hook( $act_id ) {
|
822 |
+
* // your code here
|
823 |
+
* }
|
824 |
+
* ?>
|
825 |
+
*/
|
826 |
+
do_action( 'um_admin_ajax_modal_content__hook', sanitize_key( $act_id ) );
|
827 |
+
/**
|
828 |
+
* UM hook
|
829 |
+
*
|
830 |
+
* @type action
|
831 |
+
* @title um_admin_ajax_modal_content__hook_{$act_id}
|
832 |
+
* @description Integration hook on ajax popup admin builder modal content
|
833 |
+
* @change_log
|
834 |
+
* ["Since: 2.0"]
|
835 |
+
* @usage add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'function_name', 10 );
|
836 |
+
* @example
|
837 |
+
* <?php
|
838 |
+
* add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'my_admin_ajax_modal_content', 10 );
|
839 |
+
* function my_admin_ajax_modal_content() {
|
840 |
+
* // your code here
|
841 |
+
* }
|
842 |
+
* ?>
|
843 |
+
*/
|
844 |
+
do_action( "um_admin_ajax_modal_content__hook_" . sanitize_key( $act_id ) );
|
845 |
+
|
846 |
+
$output = ob_get_clean();
|
847 |
+
break;
|
848 |
+
|
849 |
+
case 'um_admin_fonticon_selector':
|
850 |
+
|
851 |
+
ob_start(); ?>
|
852 |
+
|
853 |
+
<div class="um-admin-metabox">
|
854 |
+
<p class="_icon_search"><input type="text" name="_icon_search" id="_icon_search" value="" placeholder="<?php esc_attr_e('Search Icons...', 'ultimate-member' ); ?>" /></p>
|
855 |
+
</div>
|
856 |
+
|
857 |
+
<div class="um-admin-icons">
|
858 |
+
<?php foreach( UM()->fonticons()->all as $icon ) { ?>
|
859 |
+
<span data-code="<?php echo esc_attr( $icon ); ?>" title="<?php echo esc_attr( $icon ); ?>" class="um-admin-tipsy-n"><i class="<?php echo $icon; ?>"></i></span>
|
860 |
+
<?php } ?>
|
861 |
+
</div><div class="um-admin-clear"></div>
|
862 |
+
|
863 |
+
<?php $output = ob_get_clean();
|
864 |
+
break;
|
865 |
+
|
866 |
+
case 'um_admin_show_fields':
|
867 |
+
|
868 |
+
ob_start();
|
869 |
+
$form_fields = UM()->query()->get_attr( 'custom_fields', $arg2 );
|
870 |
+
$form_fields = array_values( array_filter( array_keys( $form_fields ) ) );
|
871 |
+
//$form_fields = array_keys( $form_fields );
|
872 |
+
?>
|
873 |
+
|
874 |
+
<h4><?php _e('Setup New Field','ultimate-member'); ?></h4>
|
875 |
+
<div class="um-admin-btns">
|
876 |
+
|
877 |
+
<?php if ( UM()->builtin()->core_fields ) {
|
878 |
+
foreach ( UM()->builtin()->core_fields as $field_type => $array ) {
|
879 |
+
|
880 |
+
if ( isset( $array['in_fields'] ) && $array['in_fields'] == false ) {
|
881 |
+
continue;
|
882 |
+
} ?>
|
883 |
+
|
884 |
+
<a href="javascript:void(0);" class="button" data-modal="UM_add_field" data-modal-size="normal" data-dynamic-content="um_admin_new_field_popup" data-arg1="<?php echo esc_attr( $field_type ); ?>" data-arg2="<?php echo esc_attr( $arg2 ) ?>"><?php echo esc_html( $array['name'] ); ?></a>
|
885 |
+
|
886 |
+
<?php }
|
887 |
+
} ?>
|
888 |
+
|
889 |
+
</div>
|
890 |
+
|
891 |
+
<h4><?php _e('Predefined Fields','ultimate-member'); ?></h4>
|
892 |
+
<div class="um-admin-btns">
|
893 |
+
|
894 |
+
<?php if ( UM()->builtin()->predefined_fields ) {
|
895 |
+
foreach ( UM()->builtin()->predefined_fields as $field_key => $array ) {
|
896 |
+
if ( ! isset( $array['account_only'] ) && ! isset( $array['private_use'] ) ) { ?>
|
897 |
+
|
898 |
+
<a href="javascript:void(0);" class="button" <?php disabled( in_array( $field_key, $form_fields, true ) ) ?> data-silent_action="um_admin_add_field_from_predefined" data-arg1="<?php echo esc_attr( $field_key ); ?>" data-arg2="<?php echo esc_attr( $arg2 ); ?>"><?php echo um_trim_string( stripslashes( $array['title'] ), 20 ); ?></a>
|
899 |
+
|
900 |
+
<?php }
|
901 |
+
}
|
902 |
+
} else {
|
903 |
+
echo '<p>' . __( 'None', 'ultimate-member' ) . '</p>';
|
904 |
+
} ?>
|
905 |
+
|
906 |
+
</div>
|
907 |
+
|
908 |
+
<h4><?php _e( 'Custom Fields', 'ultimate-member' ); ?></h4>
|
909 |
+
<div class="um-admin-btns">
|
910 |
+
|
911 |
+
<?php
|
912 |
+
if ( UM()->builtin()->custom_fields ) {
|
913 |
+
foreach ( UM()->builtin()->custom_fields as $field_key => $array ) {
|
914 |
+
if ( empty( $array['title'] ) || empty( $array['type'] ) ) {
|
915 |
+
continue;
|
916 |
+
} ?>
|
917 |
+
|
918 |
+
<a href="javascript:void(0);" class="button with-icon" <?php disabled( in_array( $field_key, $form_fields, true ) ) ?> data-silent_action="um_admin_add_field_from_list" data-arg1="<?php echo esc_attr( $field_key ); ?>" data-arg2="<?php echo esc_attr( $arg2 ); ?>" title="<?php echo __( 'Meta Key', 'ultimate-member' ) . ' - ' . esc_attr( $field_key ); ?>"><?php echo um_trim_string( stripslashes( $array['title'] ), 20 ); ?> <small>(<?php echo ucfirst( $array['type'] ); ?>)</small><span class="remove"></span></a>
|
919 |
+
|
920 |
+
<?php }
|
921 |
+
} else {
|
922 |
+
echo '<p>' . __( 'You did not create any custom fields', 'ultimate-member' ) . '</p>';
|
923 |
+
} ?>
|
924 |
+
|
925 |
+
</div>
|
926 |
+
|
927 |
+
<?php $output = ob_get_clean();
|
928 |
+
break;
|
929 |
+
|
930 |
+
case 'um_admin_edit_field_popup':
|
931 |
+
|
932 |
+
ob_start();
|
933 |
+
|
934 |
+
$args = UM()->builtin()->get_core_field_attrs( $arg1 );
|
935 |
+
|
936 |
+
$form_fields = UM()->query()->get_attr( 'custom_fields', $arg2 );
|
937 |
+
|
938 |
+
$metabox->set_field_type = $arg1;
|
939 |
+
$metabox->in_edit = true;
|
940 |
+
$metabox->edit_array = $form_fields[ $arg3 ];
|
941 |
+
|
942 |
+
if ( !isset( $metabox->edit_array['metakey'] ) ){
|
943 |
+
$metabox->edit_array['metakey'] = $metabox->edit_array['id'];
|
944 |
+
}
|
945 |
+
|
946 |
+
if ( !isset( $metabox->edit_array['position'] ) ){
|
947 |
+
$metabox->edit_array['position'] = $metabox->edit_array['id'];
|
948 |
+
}
|
949 |
+
|
950 |
+
extract( $args );
|
951 |
+
|
952 |
+
if ( ! isset( $col1 ) ) {
|
953 |
+
|
954 |
+
echo '<p>'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '</p>';
|
955 |
+
|
956 |
+
} else {
|
957 |
+
|
958 |
+
?>
|
959 |
+
|
960 |
+
<?php if ( isset( $metabox->edit_array['in_group'] ) ) { ?>
|
961 |
+
<input type="hidden" name="_in_row" id="_in_row" value="<?php echo $metabox->edit_array['in_row']; ?>" />
|
962 |
+
<input type="hidden" name="_in_sub_row" id="_in_sub_row" value="<?php echo $metabox->edit_array['in_sub_row']; ?>" />
|
963 |
+
<input type="hidden" name="_in_column" id="_in_column" value="<?php echo $metabox->edit_array['in_column']; ?>" />
|
964 |
+
<input type="hidden" name="_in_group" id="_in_group" value="<?php echo $metabox->edit_array['in_group']; ?>" />
|
965 |
+
<?php } ?>
|
966 |
+
|
967 |
+
<input type="hidden" name="_type" id="_type" value="<?php echo $arg1; ?>" />
|
968 |
+
|
969 |
+
<input type="hidden" name="post_id" id="post_id" value="<?php echo $arg2; ?>" />
|
970 |
+
|
971 |
+
<input type="hidden" name="edit_mode" id="edit_mode" value="true" />
|
972 |
+
|
973 |
+
<input type="hidden" name="_metakey" id="_metakey" value="<?php echo $metabox->edit_array['metakey']; ?>" />
|
974 |
+
|
975 |
+
<input type="hidden" name="_position" id="_position" value="<?php echo $metabox->edit_array['position']; ?>" />
|
976 |
+
|
977 |
+
<?php if ( isset( $args['mce_content'] ) ) { ?>
|
978 |
+
<div class="dynamic-mce-content"><?php echo ! empty( $metabox->edit_array['content'] ) ? $metabox->edit_array['content'] : ''; ?></div>
|
979 |
+
<?php } ?>
|
980 |
+
|
981 |
+
<?php $this->modal_header(); ?>
|
982 |
+
|
983 |
+
<div class="um-admin-half">
|
984 |
+
|
985 |
+
<?php if ( isset( $col1 ) ) { foreach( $col1 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
|
986 |
+
|
987 |
+
</div>
|
988 |
+
|
989 |
+
<div class="um-admin-half um-admin-right">
|
990 |
+
|
991 |
+
<?php if ( isset( $col2 ) ) { foreach( $col2 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
|
992 |
+
|
993 |
+
</div><div class="um-admin-clear"></div>
|
994 |
+
|
995 |
+
<?php if ( isset( $col3 ) ) { foreach( $col3 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
|
996 |
+
|
997 |
+
<div class="um-admin-clear"></div>
|
998 |
+
|
999 |
+
<?php if ( isset( $col_full ) ) {foreach( $col_full as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
|
1000 |
+
|
1001 |
+
<?php $this->modal_footer( $arg2, $args, $metabox ); ?>
|
1002 |
+
|
1003 |
+
<?php
|
1004 |
+
|
1005 |
+
}
|
1006 |
+
|
1007 |
+
$output = ob_get_clean();
|
1008 |
+
break;
|
1009 |
+
|
1010 |
+
case 'um_admin_new_field_popup':
|
1011 |
+
|
1012 |
+
ob_start();
|
1013 |
+
|
1014 |
+
$args = UM()->builtin()->get_core_field_attrs( $arg1 );
|
1015 |
+
|
1016 |
+
$metabox->set_field_type = $arg1;
|
1017 |
+
|
1018 |
+
/**
|
1019 |
+
* @var $in_row
|
1020 |
+
* @var $in_sub_row
|
1021 |
+
* @var $in_column
|
1022 |
+
* @var $in_group
|
1023 |
+
*/
|
1024 |
+
extract( $args );
|
1025 |
+
|
1026 |
+
if ( ! isset( $col1 ) ) {
|
1027 |
+
|
1028 |
+
echo '<p>'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '</p>';
|
1029 |
+
|
1030 |
+
} else {
|
1031 |
+
|
1032 |
+
if ( $in_column ) { ?>
|
1033 |
+
<input type="hidden" name="_in_row" id="_in_row" value="_um_row_<?php echo $in_row + 1; ?>" />
|
1034 |
+
<input type="hidden" name="_in_sub_row" id="_in_sub_row" value="<?php echo $in_sub_row; ?>" />
|
1035 |
+
<input type="hidden" name="_in_column" id="_in_column" value="<?php echo $in_column; ?>" />
|
1036 |
+
<input type="hidden" name="_in_group" id="_in_group" value="<?php echo $in_group; ?>" />
|
1037 |
+
<?php } ?>
|
1038 |
+
|
1039 |
+
<input type="hidden" name="_type" id="_type" value="<?php echo $arg1; ?>" />
|
1040 |
+
|
1041 |
+
<input type="hidden" name="post_id" id="post_id" value="<?php echo $arg2; ?>" />
|
1042 |
+
|
1043 |
+
<?php $this->modal_header(); ?>
|
1044 |
+
|
1045 |
+
<div class="um-admin-half">
|
1046 |
+
|
1047 |
+
<?php if ( isset( $col1 ) ) { foreach( $col1 as $opt ) $metabox->field_input ( $opt ); } ?>
|
1048 |
+
|
1049 |
+
</div>
|
1050 |
+
|
1051 |
+
<div class="um-admin-half um-admin-right">
|
1052 |
+
|
1053 |
+
<?php if ( isset( $col2 ) ) { foreach( $col2 as $opt ) $metabox->field_input ( $opt ); } ?>
|
1054 |
+
|
1055 |
+
</div><div class="um-admin-clear"></div>
|
1056 |
+
|
1057 |
+
<?php if ( isset( $col3 ) ) { foreach( $col3 as $opt ) $metabox->field_input ( $opt ); } ?>
|
1058 |
+
|
1059 |
+
<div class="um-admin-clear"></div>
|
1060 |
+
|
1061 |
+
<?php if ( isset( $col_full ) ) { foreach( $col_full as $opt ) $metabox->field_input ( $opt ); } ?>
|
1062 |
+
|
1063 |
+
<?php $this->modal_footer( $arg2, $args, $metabox ); ?>
|
1064 |
+
|
1065 |
+
<?php
|
1066 |
+
|
1067 |
+
}
|
1068 |
+
|
1069 |
+
$output = ob_get_clean();
|
1070 |
+
break;
|
1071 |
+
|
1072 |
+
case 'um_admin_preview_form':
|
1073 |
+
|
1074 |
+
UM()->user()->preview = true;
|
1075 |
+
|
1076 |
+
$mode = UM()->query()->get_attr('mode', $arg1 );
|
1077 |
+
|
1078 |
+
if ( $mode == 'profile' ) {
|
1079 |
+
UM()->fields()->editing = true;
|
1080 |
+
}
|
1081 |
+
|
1082 |
+
$output = '<div class="um-admin-preview-overlay"></div>';
|
1083 |
+
|
1084 |
+
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
|
1085 |
+
$output .= do_shortcode('[ultimatemember form_id="' . $arg1 . '" /]');
|
1086 |
+
} else {
|
1087 |
+
$output .= apply_shortcodes('[ultimatemember form_id="' . $arg1 . '" /]');
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
break;
|
1091 |
+
|
1092 |
+
case 'um_admin_review_registration':
|
1093 |
+
//$user_id = $arg1;
|
1094 |
+
|
1095 |
+
if ( ! current_user_can( 'administrator' ) ) {
|
1096 |
+
if ( ! um_can_view_profile( $arg1 ) ) {
|
1097 |
+
$output = '';
|
1098 |
+
break;
|
1099 |
+
}
|
1100 |
+
}
|
1101 |
+
|
1102 |
+
um_fetch_user( $arg1 );
|
1103 |
+
|
1104 |
+
UM()->user()->preview = true;
|
1105 |
+
|
1106 |
+
$output = um_user_submitted_registration_formatted( true );
|
1107 |
+
|
1108 |
+
um_reset_user();
|
1109 |
+
|
1110 |
+
break;
|
1111 |
+
|
1112 |
+
}
|
1113 |
+
|
1114 |
+
if ( is_array( $output ) ) {
|
1115 |
+
print_r( $output );
|
1116 |
+
} else {
|
1117 |
+
echo $output;
|
1118 |
+
}
|
1119 |
+
die;
|
1120 |
+
}
|
1121 |
+
|
1122 |
+
|
1123 |
+
/**
|
1124 |
+
*
|
1125 |
+
*/
|
1126 |
+
function modal_header() {
|
1127 |
+
/**
|
1128 |
+
* UM hook
|
1129 |
+
*
|
1130 |
+
* @type action
|
1131 |
+
* @title um_admin_field_modal_header
|
1132 |
+
* @description Modal Window Header
|
1133 |
+
* @change_log
|
1134 |
+
* ["Since: 2.0"]
|
1135 |
+
* @usage add_action( 'um_admin_field_modal_header', 'function_name', 10 );
|
1136 |
+
* @example
|
1137 |
+
* <?php
|
1138 |
+
* add_action( 'um_admin_field_modal_header', 'my_admin_field_modal_header', 10 );
|
1139 |
+
* function my_admin_field_modal_header() {
|
1140 |
+
* // your code here
|
1141 |
+
* }
|
1142 |
+
* ?>
|
1143 |
+
*/
|
1144 |
+
do_action( 'um_admin_field_modal_header' );
|
1145 |
+
}
|
1146 |
+
|
1147 |
+
|
1148 |
+
/**
|
1149 |
+
* Modal Footer loading
|
1150 |
+
*
|
1151 |
+
* @param $arg2
|
1152 |
+
* @param $args
|
1153 |
+
* @param $metabox
|
1154 |
+
*/
|
1155 |
+
function modal_footer( $arg2, $args, $metabox ) {
|
1156 |
+
/**
|
1157 |
+
* UM hook
|
1158 |
+
*
|
1159 |
+
* @type action
|
1160 |
+
* @title um_admin_field_modal_footer
|
1161 |
+
* @description Modal Window Footer
|
1162 |
+
* @input_vars
|
1163 |
+
* [{"var":"$arg2","type":"string","desc":"Ajax Action"},
|
1164 |
+
* {"var":"$args","type":"array","desc":"Modal window arguments"},
|
1165 |
+
* {"var":"$in_edit","type":"bool","desc":"Is edit mode?"},
|
1166 |
+
* {"var":"$edit_array","type":"array","desc":"Edit Array"}]
|
1167 |
+
* @change_log
|
1168 |
+
* ["Since: 2.0"]
|
1169 |
+
* @usage add_action( 'um_admin_field_modal_footer', 'function_name', 10, 4 );
|
1170 |
+
* @example
|
1171 |
+
* <?php
|
1172 |
+
* add_action( 'um_admin_field_modal_footer', 'my_admin_field_modal_footer', 10, 4 );
|
1173 |
+
* function my_admin_field_modal_footer( $arg2, $args, $in_edit, $edit_array ) {
|
1174 |
+
* // your code here
|
1175 |
+
* }
|
1176 |
+
* ?>
|
1177 |
+
*/
|
1178 |
+
do_action( 'um_admin_field_modal_footer', $arg2, $args, $metabox->in_edit, ( isset( $metabox->edit_array ) ) ? $metabox->edit_array : '' );
|
1179 |
+
}
|
1180 |
+
|
1181 |
+
|
1182 |
+
/**
|
1183 |
+
* Skip field validation for:
|
1184 |
+
* - '_options' if Choices Callback specified
|
1185 |
+
*
|
1186 |
+
* @param boolean $skip
|
1187 |
+
* @param string $post_input
|
1188 |
+
* @param array $array
|
1189 |
+
* @return boolean
|
1190 |
+
*/
|
1191 |
+
public function skip_field_validation( $skip, $post_input, $array ) {
|
1192 |
+
if ( $post_input === '_options' && isset( $array['post']['_custom_dropdown_options_source'] ) ) {
|
1193 |
+
$skip = function_exists( $array['post']['_custom_dropdown_options_source'] );
|
1194 |
+
}
|
1195 |
+
|
1196 |
+
return $skip;
|
1197 |
+
}
|
1198 |
+
|
1199 |
+
|
1200 |
+
/**
|
1201 |
+
* Retrieves dropdown/multi-select options from a callback function
|
1202 |
+
*/
|
1203 |
+
function populate_dropdown_options() {
|
1204 |
+
UM()->admin()->check_ajax_nonce();
|
1205 |
+
|
1206 |
+
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
1207 |
+
wp_send_json_error( __( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
1208 |
+
}
|
1209 |
+
|
1210 |
+
$arr_options = array();
|
1211 |
+
|
1212 |
+
$um_callback_func = sanitize_key( $_POST['um_option_callback'] );
|
1213 |
+
if ( empty( $um_callback_func ) ) {
|
1214 |
+
$arr_options['status'] = 'empty';
|
1215 |
+
$arr_options['function_name'] = $um_callback_func;
|
1216 |
+
$arr_options['function_exists'] = function_exists( $um_callback_func );
|
1217 |
+
}
|
1218 |
+
|
1219 |
+
$arr_options['data'] = array();
|
1220 |
+
if ( function_exists( $um_callback_func ) ) {
|
1221 |
+
$arr_options['data'] = call_user_func( $um_callback_func );
|
1222 |
+
}
|
1223 |
+
|
1224 |
+
wp_send_json( $arr_options );
|
1225 |
+
}
|
1226 |
+
|
1227 |
+
}
|
1228 |
+
}
|
includes/admin/core/class-admin-enqueue.php
CHANGED
@@ -84,7 +84,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
|
|
84 |
add_action( 'load-post.php', array( &$this, 'enqueue_cpt_scripts' ) );
|
85 |
|
86 |
global $wp_version;
|
87 |
-
if ( version_compare( $wp_version, '5.8
|
88 |
add_filter( 'block_categories_all', array( &$this, 'blocks_category' ), 10, 2 );
|
89 |
} else {
|
90 |
add_filter( 'block_categories', array( &$this, 'blocks_category' ), 10, 2 );
|
@@ -127,7 +127,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
|
|
127 |
|
128 |
wp_register_script( 'select2', $this->front_js_baseurl . 'select2/select2.full' . $this->suffix . '.js', array( 'jquery', 'jquery-masonry' ), '4.0.13', true );
|
129 |
wp_register_script( 'um_jquery_form', $this->front_js_baseurl . 'um-jquery-form' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
130 |
-
wp_register_script( 'um_fileupload', $this->front_js_baseurl . 'um-fileupload
|
131 |
wp_register_script( 'um_crop', $this->front_js_baseurl . 'um-crop' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
132 |
wp_register_script( 'um_tipsy', $this->front_js_baseurl . 'um-tipsy' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
133 |
wp_register_script( 'um_functions', $this->front_js_baseurl . 'um-functions' . $this->suffix . '.js', array( 'jquery', 'um_tipsy', 'um_scrollbar' ), ultimatemember_version, true );
|
84 |
add_action( 'load-post.php', array( &$this, 'enqueue_cpt_scripts' ) );
|
85 |
|
86 |
global $wp_version;
|
87 |
+
if ( version_compare( $wp_version, '5.8', '>=' ) ) {
|
88 |
add_filter( 'block_categories_all', array( &$this, 'blocks_category' ), 10, 2 );
|
89 |
} else {
|
90 |
add_filter( 'block_categories', array( &$this, 'blocks_category' ), 10, 2 );
|
127 |
|
128 |
wp_register_script( 'select2', $this->front_js_baseurl . 'select2/select2.full' . $this->suffix . '.js', array( 'jquery', 'jquery-masonry' ), '4.0.13', true );
|
129 |
wp_register_script( 'um_jquery_form', $this->front_js_baseurl . 'um-jquery-form' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
130 |
+
wp_register_script( 'um_fileupload', $this->front_js_baseurl . 'um-fileupload.js', array( 'jquery' ), ultimatemember_version, true );
|
131 |
wp_register_script( 'um_crop', $this->front_js_baseurl . 'um-crop' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
132 |
wp_register_script( 'um_tipsy', $this->front_js_baseurl . 'um-tipsy' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
133 |
wp_register_script( 'um_functions', $this->front_js_baseurl . 'um-functions' . $this->suffix . '.js', array( 'jquery', 'um_tipsy', 'um_scrollbar' ), ultimatemember_version, true );
|
includes/core/class-builtin.php
CHANGED
@@ -1,1915 +1,1915 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
// Exit if accessed directly
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
if ( ! class_exists( 'um\core\Builtin' ) ) {
|
8 |
-
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class Builtin
|
12 |
-
* @package um\core
|
13 |
-
*/
|
14 |
-
class Builtin {
|
15 |
-
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @var array
|
19 |
-
*/
|
20 |
-
public $predefined_fields = array();
|
21 |
-
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @var array
|
25 |
-
*/
|
26 |
-
var $all_user_fields = array();
|
27 |
-
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @var array
|
31 |
-
*/
|
32 |
-
var $core_fields = array();
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Builtin constructor.
|
37 |
-
*/
|
38 |
-
function __construct() {
|
39 |
-
add_action( 'init', array( &$this, 'set_core_fields' ), 1 );
|
40 |
-
add_action( 'init', array( &$this, 'set_predefined_fields' ), 1 );
|
41 |
-
add_action( 'init', array( &$this, 'set_custom_fields' ), 1 );
|
42 |
-
$this->saved_fields = get_option( 'um_fields' );
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
/**
|
47 |
-
* @return array
|
48 |
-
*/
|
49 |
-
function get_all_user_fields() {
|
50 |
-
return apply_filters( 'um_builtin_all_user_fields', $this->all_user_fields );
|
51 |
-
}
|
52 |
-
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Regular or multi-select/options
|
56 |
-
*
|
57 |
-
* @param $field
|
58 |
-
* @param $attrs
|
59 |
-
*
|
60 |
-
* @return bool
|
61 |
-
*/
|
62 |
-
function is_dropdown_field( $field, $attrs ) {
|
63 |
-
|
64 |
-
if ( isset( $attrs['options'] ) ) {
|
65 |
-
return true;
|
66 |
-
}
|
67 |
-
|
68 |
-
$fields = $this->all_user_fields;
|
69 |
-
|
70 |
-
if ( isset( $fields[$field]['options'] ) || ! empty( $fields[$field]['custom_dropdown_options_source'] ) ) {
|
71 |
-
return true;
|
72 |
-
}
|
73 |
-
|
74 |
-
return false;
|
75 |
-
}
|
76 |
-
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Get a field
|
80 |
-
*
|
81 |
-
* @param $field
|
82 |
-
*
|
83 |
-
* @return mixed|string
|
84 |
-
*/
|
85 |
-
function get_a_field( $field ) {
|
86 |
-
$fields = $this->all_user_fields;
|
87 |
-
if ( isset( $fields[ $field ] ) ) {
|
88 |
-
return $fields[ $field ];
|
89 |
-
}
|
90 |
-
return '';
|
91 |
-
}
|
92 |
-
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Get specific fields
|
96 |
-
*
|
97 |
-
* @param $fields
|
98 |
-
*
|
99 |
-
* @return array
|
100 |
-
*/
|
101 |
-
function get_specific_fields( $fields ) {
|
102 |
-
$fields = explode( ',', $fields );
|
103 |
-
$array = array();
|
104 |
-
foreach ( $fields as $field ) {
|
105 |
-
if ( isset( $this->predefined_fields[ $field ] ) ) {
|
106 |
-
$array[ $field ] = $this->predefined_fields[ $field ];
|
107 |
-
}
|
108 |
-
}
|
109 |
-
return $array;
|
110 |
-
}
|
111 |
-
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Get specific field
|
115 |
-
*
|
116 |
-
* @param $fields
|
117 |
-
*
|
118 |
-
* @return array|mixed
|
119 |
-
*/
|
120 |
-
function get_specific_field( $fields ) {
|
121 |
-
$fields = explode( ',', $fields );
|
122 |
-
$array = array();
|
123 |
-
foreach ( $fields as $field ) {
|
124 |
-
if ( isset( $this->predefined_fields[ $field ] ) ) {
|
125 |
-
$array = $this->predefined_fields[ $field ];
|
126 |
-
} elseif ( isset( $this->saved_fields[ $field ] ) ) {
|
127 |
-
$array = $this->saved_fields[ $field ];
|
128 |
-
}
|
129 |
-
}
|
130 |
-
return $array;
|
131 |
-
}
|
132 |
-
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Checks for a unique field error
|
136 |
-
*
|
137 |
-
* @param $key
|
138 |
-
*
|
139 |
-
* @return int|string
|
140 |
-
*/
|
141 |
-
function unique_field_err( $key ) {
|
142 |
-
if ( empty( $key ) ) {
|
143 |
-
return __( 'Please provide a meta key', 'ultimate-member' );
|
144 |
-
}
|
145 |
-
if ( isset( $this->core_fields[ $key ] ) ) {
|
146 |
-
return __( 'Your meta key is a reserved core field and cannot be used', 'ultimate-member' );
|
147 |
-
}
|
148 |
-
if ( isset( $this->predefined_fields[ $key ] ) ) {
|
149 |
-
return __( 'Your meta key is a predefined reserved key and cannot be used', 'ultimate-member' );
|
150 |
-
}
|
151 |
-
if ( isset( $this->saved_fields[ $key ] ) ) {
|
152 |
-
return __( 'Your meta key already exists in your fields list', 'ultimate-member' );
|
153 |
-
}
|
154 |
-
if ( ! UM()->validation()->safe_string( $key ) ) {
|
155 |
-
return __( 'Your meta key contains illegal characters. Please correct it.', 'ultimate-member' );
|
156 |
-
}
|
157 |
-
|
158 |
-
return 0;
|
159 |
-
}
|
160 |
-
|
161 |
-
|
162 |
-
/**
|
163 |
-
* Check date range errors (start date)
|
164 |
-
*
|
165 |
-
* @param $date
|
166 |
-
*
|
167 |
-
* @return int|string
|
168 |
-
*/
|
169 |
-
function date_range_start_err( $date ) {
|
170 |
-
if ( empty( $date ) ) {
|
171 |
-
return __( 'Please provide a date range beginning', 'ultimate-member' );
|
172 |
-
}
|
173 |
-
if ( ! UM()->validation()->validate_date( $date ) ) {
|
174 |
-
return __( 'Please enter a valid start date in the date range', 'ultimate-member' );
|
175 |
-
}
|
176 |
-
|
177 |
-
return 0;
|
178 |
-
}
|
179 |
-
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Check date range errors (end date)
|
183 |
-
*
|
184 |
-
* @param $date
|
185 |
-
* @param $start_date
|
186 |
-
*
|
187 |
-
* @return int|string
|
188 |
-
*/
|
189 |
-
function date_range_end_err( $date, $start_date ) {
|
190 |
-
if ( empty( $date ) ) {
|
191 |
-
return __( 'Please provide a date range end', 'ultimate-member' );
|
192 |
-
}
|
193 |
-
if ( ! UM()->validation()->validate_date( $date ) ) {
|
194 |
-
return __( 'Please enter a valid end date in the date range', 'ultimate-member' );
|
195 |
-
}
|
196 |
-
if ( strtotime( $date ) <= strtotime( $start_date ) ) {
|
197 |
-
return __( 'The end of date range must be greater than the start of date range', 'ultimate-member' );
|
198 |
-
}
|
199 |
-
return 0;
|
200 |
-
}
|
201 |
-
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Get a core field attrs
|
205 |
-
*
|
206 |
-
* @param $type
|
207 |
-
*
|
208 |
-
* @return array|mixed
|
209 |
-
*/
|
210 |
-
function get_core_field_attrs( $type ) {
|
211 |
-
return ( isset( $this->core_fields[ $type ] ) ) ? $this->core_fields[ $type ] : array('');
|
212 |
-
}
|
213 |
-
|
214 |
-
|
215 |
-
/**
|
216 |
-
* Core Fields
|
217 |
-
*/
|
218 |
-
function set_core_fields() {
|
219 |
-
|
220 |
-
$this->core_fields = array(
|
221 |
-
|
222 |
-
'row' => array(
|
223 |
-
'name' => 'Row',
|
224 |
-
'in_fields' => false,
|
225 |
-
'form_only' => true,
|
226 |
-
'conditional_support' => 0,
|
227 |
-
'icon' => 'um-faicon-pencil',
|
228 |
-
'col1' => array('_id','_background','_text_color','_padding','_margin','_border','_borderradius','_borderstyle','_bordercolor'),
|
229 |
-
'col2' => array('_heading','_heading_text','_heading_background_color','_heading_text_color','_icon','_icon_color','_css_class'),
|
230 |
-
),
|
231 |
-
|
232 |
-
'text' => array(
|
233 |
-
'name' => 'Text Box',
|
234 |
-
'col1' => array('_title','_metakey','_help','_default','_min_chars','_visibility'),
|
235 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max_chars'),
|
236 |
-
'col3' => array('_required','_editable','_icon'),
|
237 |
-
'validate' => array(
|
238 |
-
'_title' => array(
|
239 |
-
'mode' => 'required',
|
240 |
-
'error' => __('You must provide a title','ultimate-member')
|
241 |
-
),
|
242 |
-
'_metakey' => array(
|
243 |
-
'mode' => 'unique',
|
244 |
-
),
|
245 |
-
)
|
246 |
-
),
|
247 |
-
|
248 |
-
'number' => array(
|
249 |
-
'name' => __('Number','ultimate-member'),
|
250 |
-
'col1' => array('_title','_metakey','_help','_default','_min','_visibility'),
|
251 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max'),
|
252 |
-
'col3' => array('_required','_editable','_icon'),
|
253 |
-
'validate' => array(
|
254 |
-
'_title' => array(
|
255 |
-
'mode' => 'required',
|
256 |
-
'error' => __('You must provide a title','ultimate-member')
|
257 |
-
),
|
258 |
-
'_metakey' => array(
|
259 |
-
'mode' => 'unique',
|
260 |
-
),
|
261 |
-
)
|
262 |
-
),
|
263 |
-
|
264 |
-
'textarea' => array(
|
265 |
-
'name' => 'Textarea',
|
266 |
-
'col1' => array('_title','_metakey','_help','_height','_max_chars','_max_words','_visibility'),
|
267 |
-
'col2' => array('_label','_placeholder','_public','_roles','_default','_html'),
|
268 |
-
'col3' => array('_required','_editable','_icon'),
|
269 |
-
'validate' => array(
|
270 |
-
'_title' => array(
|
271 |
-
'mode' => 'required',
|
272 |
-
'error' => __('You must provide a title','ultimate-member')
|
273 |
-
),
|
274 |
-
'_metakey' => array(
|
275 |
-
'mode' => 'unique',
|
276 |
-
),
|
277 |
-
)
|
278 |
-
),
|
279 |
-
|
280 |
-
'select' => array(
|
281 |
-
'name' => 'Dropdown',
|
282 |
-
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
283 |
-
'col2' => array('_label','_placeholder','_public','_roles','_custom_dropdown_options_source','_parent_dropdown_relationship'),
|
284 |
-
'col3' => array('_required','_editable','_icon'),
|
285 |
-
'validate' => array(
|
286 |
-
'_title' => array(
|
287 |
-
'mode' => 'required',
|
288 |
-
'error' => __('You must provide a title','ultimate-member')
|
289 |
-
),
|
290 |
-
'_metakey' => array(
|
291 |
-
'mode' => 'unique',
|
292 |
-
),
|
293 |
-
'_options' => array(
|
294 |
-
'mode' => 'required',
|
295 |
-
'error' => __('You have not added any choices yet.','ultimate-member')
|
296 |
-
),
|
297 |
-
)
|
298 |
-
),
|
299 |
-
|
300 |
-
'multiselect' => array(
|
301 |
-
'name' => 'Multi-Select',
|
302 |
-
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
303 |
-
'col2' => array('_label','_placeholder','_public','_roles','_min_selections','_max_selections','_custom_dropdown_options_source'),
|
304 |
-
'col3' => array('_required','_editable','_icon'),
|
305 |
-
'validate' => array(
|
306 |
-
'_title' => array(
|
307 |
-
'mode' => 'required',
|
308 |
-
'error' => __('You must provide a title','ultimate-member')
|
309 |
-
),
|
310 |
-
'_metakey' => array(
|
311 |
-
'mode' => 'unique',
|
312 |
-
),
|
313 |
-
'_options' => array(
|
314 |
-
'mode' => 'required',
|
315 |
-
'error' => __('You have not added any choices yet.','ultimate-member')
|
316 |
-
),
|
317 |
-
)
|
318 |
-
),
|
319 |
-
|
320 |
-
'radio' => array(
|
321 |
-
'name' => 'Radio',
|
322 |
-
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
323 |
-
'col2' => array('_label','_public','_roles'),
|
324 |
-
'col3' => array('_required','_editable','_icon'),
|
325 |
-
'validate' => array(
|
326 |
-
'_title' => array(
|
327 |
-
'mode' => 'required',
|
328 |
-
'error' => __('You must provide a title','ultimate-member')
|
329 |
-
),
|
330 |
-
'_metakey' => array(
|
331 |
-
'mode' => 'unique',
|
332 |
-
),
|
333 |
-
'_options' => array(
|
334 |
-
'mode' => 'required',
|
335 |
-
'error' => __('You have not added any choices yet.','ultimate-member')
|
336 |
-
),
|
337 |
-
)
|
338 |
-
),
|
339 |
-
|
340 |
-
'checkbox' => array(
|
341 |
-
'name' => 'Checkbox',
|
342 |
-
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
343 |
-
'col2' => array('_label','_public','_roles','_max_selections'),
|
344 |
-
'col3' => array('_required','_editable','_icon'),
|
345 |
-
'validate' => array(
|
346 |
-
'_title' => array(
|
347 |
-
'mode' => 'required',
|
348 |
-
'error' => __('You must provide a title','ultimate-member')
|
349 |
-
),
|
350 |
-
'_metakey' => array(
|
351 |
-
'mode' => 'unique',
|
352 |
-
),
|
353 |
-
'_options' => array(
|
354 |
-
'mode' => 'required',
|
355 |
-
'error' => __('You have not added any choices yet.','ultimate-member')
|
356 |
-
),
|
357 |
-
)
|
358 |
-
),
|
359 |
-
|
360 |
-
'url' => array(
|
361 |
-
'name' => 'URL',
|
362 |
-
'col1' => array('_title','_metakey','_help','_default','_url_text','_visibility'),
|
363 |
-
'col2' => array('_label','_placeholder','_url_target','_url_rel','_public','_roles','_validate','_custom_validate'),
|
364 |
-
'col3' => array('_required','_editable','_icon'),
|
365 |
-
'validate' => array(
|
366 |
-
'_title' => array(
|
367 |
-
'mode' => 'required',
|
368 |
-
'error' => __('You must provide a title','ultimate-member')
|
369 |
-
),
|
370 |
-
'_metakey' => array(
|
371 |
-
'mode' => 'unique',
|
372 |
-
),
|
373 |
-
)
|
374 |
-
),
|
375 |
-
|
376 |
-
'password' => array(
|
377 |
-
'name' => 'Password',
|
378 |
-
'col1' => array('_title','_metakey','_help','_min_chars','_max_chars','_visibility'),
|
379 |
-
'col2' => array('_label','_placeholder','_public','_roles','_force_good_pass','_force_confirm_pass','_label_confirm_pass'),
|
380 |
-
'col3' => array('_required','_editable','_icon'),
|
381 |
-
'validate' => array(
|
382 |
-
'_title' => array(
|
383 |
-
'mode' => 'required',
|
384 |
-
'error' => __('You must provide a title','ultimate-member')
|
385 |
-
),
|
386 |
-
'_metakey' => array(
|
387 |
-
'mode' => 'unique',
|
388 |
-
),
|
389 |
-
)
|
390 |
-
),
|
391 |
-
|
392 |
-
'image' => array(
|
393 |
-
'name' => 'Image Upload',
|
394 |
-
'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_crop','_visibility'),
|
395 |
-
'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
|
396 |
-
'col3' => array('_required','_editable','_icon'),
|
397 |
-
'validate' => array(
|
398 |
-
'_title' => array(
|
399 |
-
'mode' => 'required',
|
400 |
-
'error' => __('You must provide a title','ultimate-member')
|
401 |
-
),
|
402 |
-
'_metakey' => array(
|
403 |
-
'mode' => 'unique',
|
404 |
-
),
|
405 |
-
'_max_size' => array(
|
406 |
-
'mode' => 'numeric',
|
407 |
-
'error' => __('Please enter a valid size','ultimate-member')
|
408 |
-
),
|
409 |
-
)
|
410 |
-
),
|
411 |
-
|
412 |
-
'file' => array(
|
413 |
-
'name' => 'File Upload',
|
414 |
-
'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_visibility'),
|
415 |
-
'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
|
416 |
-
'col3' => array('_required','_editable','_icon'),
|
417 |
-
'validate' => array(
|
418 |
-
'_title' => array(
|
419 |
-
'mode' => 'required',
|
420 |
-
'error' => __('You must provide a title','ultimate-member')
|
421 |
-
),
|
422 |
-
'_metakey' => array(
|
423 |
-
'mode' => 'unique',
|
424 |
-
),
|
425 |
-
'_max_size' => array(
|
426 |
-
'mode' => 'numeric',
|
427 |
-
'error' => __( 'Please enter a valid size', 'ultimate-member' )
|
428 |
-
),
|
429 |
-
)
|
430 |
-
),
|
431 |
-
|
432 |
-
'date' => array(
|
433 |
-
'name' => 'Date Picker',
|
434 |
-
'col1' => array( '_title', '_metakey', '_help', '_default', '_range', '_years', '_years_x', '_range_start', '_range_end', '_visibility' ),
|
435 |
-
'col2' => array( '_label', '_placeholder', '_public', '_roles', '_format', '_format_custom', '_pretty_format', '_disabled_weekdays' ),
|
436 |
-
'col3' => array( '_required', '_editable', '_icon' ),
|
437 |
-
'validate' => array(
|
438 |
-
'_title' => array(
|
439 |
-
'mode' => 'required',
|
440 |
-
'error' => __( 'You must provide a title', 'ultimate-member' )
|
441 |
-
),
|
442 |
-
'_metakey' => array(
|
443 |
-
'mode' => 'unique',
|
444 |
-
),
|
445 |
-
'_years' => array(
|
446 |
-
'mode' => 'numeric',
|
447 |
-
'error' => __( 'Number of years is not valid', 'ultimate-member' )
|
448 |
-
),
|
449 |
-
'_range_start' => array(
|
450 |
-
'mode' => 'range-start',
|
451 |
-
),
|
452 |
-
'_range_end' => array(
|
453 |
-
'mode' => 'range-end',
|
454 |
-
),
|
455 |
-
)
|
456 |
-
),
|
457 |
-
|
458 |
-
'time' => array(
|
459 |
-
'name' => 'Time Picker',
|
460 |
-
'col1' => array('_title','_metakey','_help','_format','_visibility'),
|
461 |
-
'col2' => array('_label','_placeholder','_default','_public','_roles','_intervals'),
|
462 |
-
'col3' => array('_required','_editable','_icon'),
|
463 |
-
'validate' => array(
|
464 |
-
'_title' => array(
|
465 |
-
'mode' => 'required',
|
466 |
-
'error' => __( 'You must provide a title', 'ultimate-member' )
|
467 |
-
),
|
468 |
-
'_metakey' => array(
|
469 |
-
'mode' => 'unique',
|
470 |
-
),
|
471 |
-
)
|
472 |
-
),
|
473 |
-
|
474 |
-
'rating' => array(
|
475 |
-
'name' => 'Rating',
|
476 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
477 |
-
'col2' => array('_label','_public','_roles','_number','_default'),
|
478 |
-
'col3' => array('_required','_editable','_icon'),
|
479 |
-
'validate' => array(
|
480 |
-
'_title' => array(
|
481 |
-
'mode' => 'required',
|
482 |
-
'error' => __('You must provide a title','ultimate-member')
|
483 |
-
),
|
484 |
-
'_metakey' => array(
|
485 |
-
'mode' => 'unique',
|
486 |
-
),
|
487 |
-
)
|
488 |
-
),
|
489 |
-
|
490 |
-
'block' => array(
|
491 |
-
'name' => 'Content Block',
|
492 |
-
'col1' => array('_title','_visibility'),
|
493 |
-
'col2' => array('_public','_roles'),
|
494 |
-
'col_full' => array('_content'),
|
495 |
-
'mce_content' => true,
|
496 |
-
'validate' => array(
|
497 |
-
'_title' => array(
|
498 |
-
'mode' => 'required',
|
499 |
-
'error' => __('You must provide a title','ultimate-member')
|
500 |
-
),
|
501 |
-
)
|
502 |
-
),
|
503 |
-
|
504 |
-
'shortcode' => array(
|
505 |
-
'name' => 'Shortcode',
|
506 |
-
'col1' => array('_title','_visibility'),
|
507 |
-
'col2' => array('_public','_roles'),
|
508 |
-
'col_full' => array('_content'),
|
509 |
-
'validate' => array(
|
510 |
-
'_title' => array(
|
511 |
-
'mode' => 'required',
|
512 |
-
'error' => __('You must provide a title','ultimate-member')
|
513 |
-
),
|
514 |
-
'_content' => array(
|
515 |
-
'mode' => 'required',
|
516 |
-
'error' => __('You must add a shortcode to the content area','ultimate-member')
|
517 |
-
),
|
518 |
-
)
|
519 |
-
),
|
520 |
-
|
521 |
-
'spacing' => array(
|
522 |
-
'name' => 'Spacing',
|
523 |
-
'col1' => array('_title','_visibility'),
|
524 |
-
'col2' => array('_spacing'),
|
525 |
-
'form_only' => true,
|
526 |
-
'validate' => array(
|
527 |
-
'_title' => array(
|
528 |
-
'mode' => 'required',
|
529 |
-
'error' => __('You must provide a title','ultimate-member')
|
530 |
-
),
|
531 |
-
)
|
532 |
-
),
|
533 |
-
|
534 |
-
'divider' => array(
|
535 |
-
'name' => 'Divider',
|
536 |
-
'col1' => array('_title','_width','_divider_text','_visibility'),
|
537 |
-
'col2' => array('_style','_color','_public','_roles'),
|
538 |
-
'form_only' => true,
|
539 |
-
'validate' => array(
|
540 |
-
'_title' => array(
|
541 |
-
'mode' => 'required',
|
542 |
-
'error' => __('You must provide a title','ultimate-member')
|
543 |
-
),
|
544 |
-
)
|
545 |
-
),
|
546 |
-
|
547 |
-
'googlemap' => array(
|
548 |
-
'name' => 'Google Map',
|
549 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
550 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
551 |
-
'col3' => array('_required','_editable','_icon'),
|
552 |
-
'validate' => array(
|
553 |
-
'_title' => array(
|
554 |
-
'mode' => 'required',
|
555 |
-
'error' => __('You must provide a title','ultimate-member')
|
556 |
-
),
|
557 |
-
'_metakey' => array(
|
558 |
-
'mode' => 'unique',
|
559 |
-
),
|
560 |
-
)
|
561 |
-
),
|
562 |
-
|
563 |
-
'youtube_video' => array(
|
564 |
-
'name' => 'YouTube Video',
|
565 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
566 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
567 |
-
'col3' => array('_required','_editable','_icon'),
|
568 |
-
'validate' => array(
|
569 |
-
'_title' => array(
|
570 |
-
'mode' => 'required',
|
571 |
-
'error' => __('You must provide a title','ultimate-member')
|
572 |
-
),
|
573 |
-
'_metakey' => array(
|
574 |
-
'mode' => 'unique',
|
575 |
-
),
|
576 |
-
)
|
577 |
-
),
|
578 |
-
|
579 |
-
'vimeo_video' => array(
|
580 |
-
'name' => 'Vimeo Video',
|
581 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
582 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
583 |
-
'col3' => array('_required','_editable','_icon'),
|
584 |
-
'validate' => array(
|
585 |
-
'_title' => array(
|
586 |
-
'mode' => 'required',
|
587 |
-
'error' => __('You must provide a title','ultimate-member')
|
588 |
-
),
|
589 |
-
'_metakey' => array(
|
590 |
-
'mode' => 'unique',
|
591 |
-
),
|
592 |
-
)
|
593 |
-
),
|
594 |
-
|
595 |
-
'soundcloud_track' => array(
|
596 |
-
'name' => 'SoundCloud Track',
|
597 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
598 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
599 |
-
'col3' => array('_required','_editable','_icon'),
|
600 |
-
'validate' => array(
|
601 |
-
'_title' => array(
|
602 |
-
'mode' => 'required',
|
603 |
-
'error' => __('You must provide a title','ultimate-member')
|
604 |
-
),
|
605 |
-
'_metakey' => array(
|
606 |
-
'mode' => 'unique',
|
607 |
-
),
|
608 |
-
)
|
609 |
-
),
|
610 |
-
|
611 |
-
/*'group' => array(
|
612 |
-
'name' => 'Field Group',
|
613 |
-
'col1' => array('_title','_max_entries'),
|
614 |
-
'col2' => array('_label','_public','_roles'),
|
615 |
-
'form_only' => true,
|
616 |
-
'validate' => array(
|
617 |
-
'_title' => array(
|
618 |
-
'mode' => 'required',
|
619 |
-
'error' => 'You must provide a title'
|
620 |
-
),
|
621 |
-
'_label' => array(
|
622 |
-
'mode' => 'required',
|
623 |
-
'error' => 'You must provide a label'
|
624 |
-
),
|
625 |
-
)
|
626 |
-
),*/
|
627 |
-
|
628 |
-
);
|
629 |
-
|
630 |
-
/**
|
631 |
-
* UM hook
|
632 |
-
*
|
633 |
-
* @type filter
|
634 |
-
* @title um_core_fields_hook
|
635 |
-
* @description UM Core Fields
|
636 |
-
* @input_vars
|
637 |
-
* [{"var":"$core_fields","type":"array","desc":"Core Fields"}]
|
638 |
-
* @change_log
|
639 |
-
* ["Since: 2.0"]
|
640 |
-
* @usage add_filter( 'um_core_fields_hook', 'function_name', 10, 1 );
|
641 |
-
* @example
|
642 |
-
* <?php
|
643 |
-
* add_filter( 'um_core_fields_hook', 'my_core_fields', 10, 1 );
|
644 |
-
* function my_core_fields( $core_fields ) {
|
645 |
-
* // your code here
|
646 |
-
* return $core_fields;
|
647 |
-
* }
|
648 |
-
* ?>
|
649 |
-
*/
|
650 |
-
$this->core_fields = apply_filters( 'um_core_fields_hook', $this->core_fields );
|
651 |
-
}
|
652 |
-
|
653 |
-
|
654 |
-
/**
|
655 |
-
* Predefined Fields
|
656 |
-
*/
|
657 |
-
function set_predefined_fields() {
|
658 |
-
|
659 |
-
global $wp_roles;
|
660 |
-
$role_keys = get_option( 'um_roles', array() );
|
661 |
-
if ( ! empty( $role_keys ) && is_array( $role_keys ) ) {
|
662 |
-
$role_keys = array_map( function( $item ) {
|
663 |
-
return 'um_' . $item;
|
664 |
-
}, $role_keys );
|
665 |
-
} else {
|
666 |
-
$role_keys = array();
|
667 |
-
}
|
668 |
-
|
669 |
-
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
670 |
-
|
671 |
-
$um_roles = UM()->roles()->get_roles( false, $exclude_roles );
|
672 |
-
|
673 |
-
/**
|
674 |
-
* UM hook
|
675 |
-
*
|
676 |
-
* @type filter
|
677 |
-
* @title um_profile_privacy_options
|
678 |
-
* @description Profile Privacy Options
|
679 |
-
* @input_vars
|
680 |
-
* [{"var":"$privacy_options","type":"array","desc":"Privacy Options"}]
|
681 |
-
* @change_log
|
682 |
-
* ["Since: 2.0"]
|
683 |
-
* @usage add_filter( 'um_profile_privacy_options', 'function_name', 10, 1 );
|
684 |
-
* @example
|
685 |
-
* <?php
|
686 |
-
* add_filter( 'um_profile_privacy_options', 'my_profile_privacy_options', 10, 1 );
|
687 |
-
* function my_profile_privacy_options( $privacy_options ) {
|
688 |
-
* // your code here
|
689 |
-
* return $privacy_options;
|
690 |
-
* }
|
691 |
-
* ?>
|
692 |
-
*/
|
693 |
-
$profile_privacy = apply_filters( 'um_profile_privacy_options', array(
|
694 |
-
'Everyone' => __( 'Everyone', 'ultimate-member' ),
|
695 |
-
'Only me' => __( 'Only me', 'ultimate-member' )
|
696 |
-
) );
|
697 |
-
|
698 |
-
/*
|
699 |
-
* it's important create key for array equals value of 'metakey'.
|
700 |
-
*
|
701 |
-
*/
|
702 |
-
|
703 |
-
$this->predefined_fields = array(
|
704 |
-
|
705 |
-
'user_login' => array(
|
706 |
-
'title' => __('Username','ultimate-member'),
|
707 |
-
'metakey' => 'user_login',
|
708 |
-
'type' => 'text',
|
709 |
-
'label' => __('Username','ultimate-member'),
|
710 |
-
'required' => 1,
|
711 |
-
'public' => 1,
|
712 |
-
'editable' => 0,
|
713 |
-
'validate' => 'unique_username',
|
714 |
-
'min_chars' => 3,
|
715 |
-
'max_chars' => 24
|
716 |
-
),
|
717 |
-
|
718 |
-
'username' => array(
|
719 |
-
'title' => __('Username or E-mail','ultimate-member'),
|
720 |
-
'metakey' => 'username',
|
721 |
-
'type' => 'text',
|
722 |
-
'label' => __('Username or E-mail','ultimate-member'),
|
723 |
-
'required' => 1,
|
724 |
-
'public' => 1,
|
725 |
-
'editable' => 0,
|
726 |
-
'validate' => 'unique_username_or_email',
|
727 |
-
),
|
728 |
-
|
729 |
-
'user_password' => array(
|
730 |
-
'title' => __('Password','ultimate-member'),
|
731 |
-
'metakey' => 'user_password',
|
732 |
-
'type' => 'password',
|
733 |
-
'label' => __('Password','ultimate-member'),
|
734 |
-
'required' => 1,
|
735 |
-
'public' => 1,
|
736 |
-
'editable' => 1,
|
737 |
-
'min_chars' => 8,
|
738 |
-
'max_chars' => 30,
|
739 |
-
'force_good_pass' => 1,
|
740 |
-
'force_confirm_pass' => 1,
|
741 |
-
'label_confirm_pass' => __('Confirm Password','ultimate-member')
|
742 |
-
),
|
743 |
-
|
744 |
-
'first_name' => array(
|
745 |
-
'title' => __('First Name','ultimate-member'),
|
746 |
-
'metakey' => 'first_name',
|
747 |
-
'type' => 'text',
|
748 |
-
'label' => __('First Name','ultimate-member'),
|
749 |
-
'required' => 0,
|
750 |
-
'public' => 1,
|
751 |
-
'editable' => 1,
|
752 |
-
),
|
753 |
-
|
754 |
-
'last_name' => array(
|
755 |
-
'title' => __('Last Name','ultimate-member'),
|
756 |
-
'metakey' => 'last_name',
|
757 |
-
'type' => 'text',
|
758 |
-
'label' => __('Last Name','ultimate-member'),
|
759 |
-
'required' => 0,
|
760 |
-
'public' => 1,
|
761 |
-
'editable' => 1,
|
762 |
-
),
|
763 |
-
|
764 |
-
'nickname' => array(
|
765 |
-
'title' => __('Nickname','ultimate-member'),
|
766 |
-
'metakey' => 'nickname',
|
767 |
-
'type' => 'text',
|
768 |
-
'label' => __('Nickname','ultimate-member'),
|
769 |
-
'required' => 0,
|
770 |
-
'public' => 1,
|
771 |
-
'editable' => 1,
|
772 |
-
),
|
773 |
-
|
774 |
-
'user_url' => array(
|
775 |
-
'title' => __('Website URL','ultimate-member'),
|
776 |
-
'metakey' => 'user_url',
|
777 |
-
'type' => 'url',
|
778 |
-
'label' => __('Website URL','ultimate-member'),
|
779 |
-
'required' => 1,
|
780 |
-
'public' => 1,
|
781 |
-
'editable' => 1,
|
782 |
-
'validate' => 'url'
|
783 |
-
),
|
784 |
-
|
785 |
-
'user_registered' => array(
|
786 |
-
'title' => __('Registration Date','ultimate-member'),
|
787 |
-
'metakey' => 'user_registered',
|
788 |
-
'type' => 'text',
|
789 |
-
'label' => __('Registration Date','ultimate-member'),
|
790 |
-
'required' => 0,
|
791 |
-
'public' => 1,
|
792 |
-
'editable' => 1,
|
793 |
-
'edit_forbidden' => 1,
|
794 |
-
),
|
795 |
-
|
796 |
-
'_um_last_login' => array(
|
797 |
-
'title' => __('Last Login','ultimate-member'),
|
798 |
-
'metakey' => '_um_last_login',
|
799 |
-
'type' => 'text',
|
800 |
-
'label' => __('Last Login','ultimate-member'),
|
801 |
-
'required' => 0,
|
802 |
-
'public' => 1,
|
803 |
-
'editable' => 1,
|
804 |
-
'edit_forbidden' => 1,
|
805 |
-
),
|
806 |
-
|
807 |
-
'user_email' => array(
|
808 |
-
'title' => __('E-mail Address','ultimate-member'),
|
809 |
-
'metakey' => 'user_email',
|
810 |
-
'type' => 'text',
|
811 |
-
'label' => __('E-mail Address','ultimate-member'),
|
812 |
-
'required' => 0,
|
813 |
-
'public' => 1,
|
814 |
-
'validate' => 'unique_email',
|
815 |
-
'autocomplete' => 'off'
|
816 |
-
),
|
817 |
-
|
818 |
-
'secondary_user_email' => array(
|
819 |
-
'title' => __('Secondary E-mail Address','ultimate-member'),
|
820 |
-
'metakey' => 'secondary_user_email',
|
821 |
-
'type' => 'text',
|
822 |
-
'label' => __('Secondary E-mail Address','ultimate-member'),
|
823 |
-
'required' => 0,
|
824 |
-
'public' => 1,
|
825 |
-
'editable' => 1,
|
826 |
-
'validate' => 'unique_email',
|
827 |
-
'autocomplete' => 'off'
|
828 |
-
),
|
829 |
-
|
830 |
-
'description' => array(
|
831 |
-
'title' => __('Biography','ultimate-member'),
|
832 |
-
'metakey' => 'description',
|
833 |
-
'type' => 'textarea',
|
834 |
-
'label' => __('Biography','ultimate-member'),
|
835 |
-
'html' => 0,
|
836 |
-
'required' => 0,
|
837 |
-
'public' => 1,
|
838 |
-
'editable' => 1,
|
839 |
-
'max_words' => 40,
|
840 |
-
'placeholder' => __('Enter a bit about yourself...','ultimate-member'),
|
841 |
-
),
|
842 |
-
|
843 |
-
'birth_date' => array(
|
844 |
-
'title' => __('Birth Date','ultimate-member'),
|
845 |
-
'metakey' => 'birth_date',
|
846 |
-
'type' => 'date',
|
847 |
-
'label' => __('Birth Date','ultimate-member'),
|
848 |
-
'required' => 0,
|
849 |
-
'public' => 1,
|
850 |
-
'editable' => 1,
|
851 |
-
'pretty_format' => 1,
|
852 |
-
'years' => 115,
|
853 |
-
'years_x' => 'past',
|
854 |
-
'icon' => 'um-faicon-calendar'
|
855 |
-
),
|
856 |
-
|
857 |
-
'gender' => array(
|
858 |
-
'title' => __('Gender','ultimate-member'),
|
859 |
-
'metakey' => 'gender',
|
860 |
-
'type' => 'radio',
|
861 |
-
'label' => __('Gender','ultimate-member'),
|
862 |
-
'required' => 0,
|
863 |
-
'public' => 1,
|
864 |
-
'editable' => 1,
|
865 |
-
'options' => array( __('Male','ultimate-member'), __('Female','ultimate-member') )
|
866 |
-
),
|
867 |
-
|
868 |
-
'country' => array(
|
869 |
-
'title' => __('Country','ultimate-member'),
|
870 |
-
'metakey' => 'country',
|
871 |
-
'type' => 'select',
|
872 |
-
'label' => __('Country','ultimate-member'),
|
873 |
-
'placeholder' => __('Choose a Country','ultimate-member'),
|
874 |
-
'required' => 0,
|
875 |
-
'public' => 1,
|
876 |
-
'editable' => 1,
|
877 |
-
'options' => $this->get('countries')
|
878 |
-
),
|
879 |
-
|
880 |
-
'facebook' => array(
|
881 |
-
'title' => __('Facebook','ultimate-member'),
|
882 |
-
'metakey' => 'facebook',
|
883 |
-
'type' => 'url',
|
884 |
-
'label' => __('Facebook','ultimate-member'),
|
885 |
-
'required' => 0,
|
886 |
-
'public' => 1,
|
887 |
-
'editable' => 1,
|
888 |
-
'url_target' => '_blank',
|
889 |
-
'url_rel' => 'nofollow',
|
890 |
-
'icon' => 'um-faicon-facebook',
|
891 |
-
'validate' => 'facebook_url',
|
892 |
-
'url_text' => 'Facebook',
|
893 |
-
'advanced' => 'social',
|
894 |
-
'color' => '#3B5999',
|
895 |
-
'match' => 'https://facebook.com/',
|
896 |
-
),
|
897 |
-
|
898 |
-
'twitter' => array(
|
899 |
-
'title' => __('Twitter','ultimate-member'),
|
900 |
-
'metakey' => 'twitter',
|
901 |
-
'type' => 'url',
|
902 |
-
'label' => __('Twitter','ultimate-member'),
|
903 |
-
'required' => 0,
|
904 |
-
'public' => 1,
|
905 |
-
'editable' => 1,
|
906 |
-
'url_target' => '_blank',
|
907 |
-
'url_rel' => 'nofollow',
|
908 |
-
'icon' => 'um-faicon-twitter',
|
909 |
-
'validate' => 'twitter_url',
|
910 |
-
'url_text' => 'Twitter',
|
911 |
-
'advanced' => 'social',
|
912 |
-
'color' => '#4099FF',
|
913 |
-
'match' => 'https://twitter.com/',
|
914 |
-
),
|
915 |
-
|
916 |
-
'linkedin' => array(
|
917 |
-
'title' => __('LinkedIn','ultimate-member'),
|
918 |
-
'metakey' => 'linkedin',
|
919 |
-
'type' => 'url',
|
920 |
-
'label' => __('LinkedIn','ultimate-member'),
|
921 |
-
'required' => 0,
|
922 |
-
'public' => 1,
|
923 |
-
'editable' => 1,
|
924 |
-
'url_target' => '_blank',
|
925 |
-
'url_rel' => 'nofollow',
|
926 |
-
'icon' => 'um-faicon-linkedin',
|
927 |
-
'validate' => 'linkedin_url',
|
928 |
-
'url_text' => 'LinkedIn',
|
929 |
-
'advanced' => 'social',
|
930 |
-
'color' => '#0976b4',
|
931 |
-
'match' => 'https://linkedin.com/in/',
|
932 |
-
),
|
933 |
-
|
934 |
-
'googleplus' => array(
|
935 |
-
'title' => __('Google+','ultimate-member'),
|
936 |
-
'metakey' => 'googleplus',
|
937 |
-
'type' => 'url',
|
938 |
-
'label' => __('Google+','ultimate-member'),
|
939 |
-
'required' => 0,
|
940 |
-
'public' => 1,
|
941 |
-
'editable' => 1,
|
942 |
-
'url_target' => '_blank',
|
943 |
-
'url_rel' => 'nofollow',
|
944 |
-
'icon' => 'um-faicon-google-plus',
|
945 |
-
'validate' => 'google_url',
|
946 |
-
'url_text' => 'Google+',
|
947 |
-
'advanced' => 'social',
|
948 |
-
'color' => '#dd4b39',
|
949 |
-
'match' => 'https://google.com/+',
|
950 |
-
),
|
951 |
-
|
952 |
-
'instagram' => array(
|
953 |
-
'title' => __('Instagram','ultimate-member'),
|
954 |
-
'metakey' => 'instagram',
|
955 |
-
'type' => 'url',
|
956 |
-
'label' => __('Instagram','ultimate-member'),
|
957 |
-
'required' => 0,
|
958 |
-
'public' => 1,
|
959 |
-
'editable' => 1,
|
960 |
-
'url_target' => '_blank',
|
961 |
-
'url_rel' => 'nofollow',
|
962 |
-
'icon' => 'um-faicon-instagram',
|
963 |
-
'validate' => 'instagram_url',
|
964 |
-
'url_text' => 'Instagram',
|
965 |
-
'advanced' => 'social',
|
966 |
-
'color' => 'radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%,#d6249f 60%,#285AEB 90%)',
|
967 |
-
'match' => 'https://instagram.com/',
|
968 |
-
),
|
969 |
-
|
970 |
-
'skype' => array(
|
971 |
-
'title' => __('Skype ID','ultimate-member'),
|
972 |
-
'metakey' => 'skype',
|
973 |
-
'type' => 'url',
|
974 |
-
'label' => __('Skype ID','ultimate-member'),
|
975 |
-
'required' => 0,
|
976 |
-
'public' => 1,
|
977 |
-
'editable' => 1,
|
978 |
-
'url_target' => '_blank',
|
979 |
-
'url_rel' => 'nofollow',
|
980 |
-
'icon' => 'um-faicon-skype',
|
981 |
-
'validate' => 'skype',
|
982 |
-
'url_text' => 'Skype',
|
983 |
-
),
|
984 |
-
|
985 |
-
'youtube' => array(
|
986 |
-
'title' => __('YouTube','ultimate-member'),
|
987 |
-
'metakey' => 'youtube',
|
988 |
-
'type' => 'url',
|
989 |
-
'label' => __('YouTube','ultimate-member'),
|
990 |
-
'required' => 0,
|
991 |
-
'public' => 1,
|
992 |
-
'editable' => 1,
|
993 |
-
'url_target' => '_blank',
|
994 |
-
'url_rel' => 'nofollow',
|
995 |
-
'icon' => 'um-faicon-youtube',
|
996 |
-
'validate' => 'youtube_url',
|
997 |
-
'url_text' => 'YouTube',
|
998 |
-
'advanced' => 'social',
|
999 |
-
'color' => '#e52d27',
|
1000 |
-
'match' => 'https://youtube.com/',
|
1001 |
-
),
|
1002 |
-
|
1003 |
-
'soundcloud' => array(
|
1004 |
-
'title' => __('SoundCloud','ultimate-member'),
|
1005 |
-
'metakey' => 'soundcloud',
|
1006 |
-
'type' => 'url',
|
1007 |
-
'label' => __('SoundCloud','ultimate-member'),
|
1008 |
-
'required' => 0,
|
1009 |
-
'public' => 1,
|
1010 |
-
'editable' => 1,
|
1011 |
-
'url_target' => '_blank',
|
1012 |
-
'url_rel' => 'nofollow',
|
1013 |
-
'icon' => 'um-faicon-soundcloud',
|
1014 |
-
'validate' => 'soundcloud_url',
|
1015 |
-
'url_text' => 'SoundCloud',
|
1016 |
-
'advanced' => 'social',
|
1017 |
-
'color' => '#f50',
|
1018 |
-
'match' => 'https://soundcloud.com/',
|
1019 |
-
),
|
1020 |
-
|
1021 |
-
'vkontakte' => array(
|
1022 |
-
'title' => __('VKontakte','ultimate-member'),
|
1023 |
-
'metakey' => 'vkontakte',
|
1024 |
-
'type' => 'url',
|
1025 |
-
'label' => __('VKontakte','ultimate-member'),
|
1026 |
-
'required' => 0,
|
1027 |
-
'public' => 1,
|
1028 |
-
'editable' => 1,
|
1029 |
-
'url_target' => '_blank',
|
1030 |
-
'url_rel' => 'nofollow',
|
1031 |
-
'icon' => 'um-faicon-vk',
|
1032 |
-
'validate' => 'vk_url',
|
1033 |
-
'url_text' => 'VKontakte',
|
1034 |
-
'advanced' => 'social',
|
1035 |
-
'color' => '#2B587A',
|
1036 |
-
'match' => 'https://vk.com/',
|
1037 |
-
),
|
1038 |
-
|
1039 |
-
'role_select' => array(
|
1040 |
-
'title' => __('Roles (Dropdown)','ultimate-member'),
|
1041 |
-
'metakey' => 'role_select',
|
1042 |
-
'type' => 'select',
|
1043 |
-
'label' => __('Account Type','ultimate-member'),
|
1044 |
-
'placeholder' => 'Choose account type',
|
1045 |
-
'required' => 0,
|
1046 |
-
'public' => 1,
|
1047 |
-
'editable' => 1,
|
1048 |
-
'options' => $um_roles,
|
1049 |
-
),
|
1050 |
-
|
1051 |
-
'role_radio' => array(
|
1052 |
-
'title' => __('Roles (Radio)','ultimate-member'),
|
1053 |
-
'metakey' => 'role_radio',
|
1054 |
-
'type' => 'radio',
|
1055 |
-
'label' => __('Account Type','ultimate-member'),
|
1056 |
-
'required' => 0,
|
1057 |
-
'public' => 1,
|
1058 |
-
'editable' => 1,
|
1059 |
-
'options' => $um_roles,
|
1060 |
-
),
|
1061 |
-
|
1062 |
-
'languages' => array(
|
1063 |
-
'title' => __('Languages','ultimate-member'),
|
1064 |
-
'metakey' => 'languages',
|
1065 |
-
'type' => 'multiselect',
|
1066 |
-
'label' => __('Languages Spoken','ultimate-member'),
|
1067 |
-
'placeholder' => __('Select languages','ultimate-member'),
|
1068 |
-
'required' => 0,
|
1069 |
-
'public' => 1,
|
1070 |
-
'editable' => 1,
|
1071 |
-
'options' => $this->get('languages'),
|
1072 |
-
),
|
1073 |
-
|
1074 |
-
'phone_number' => array(
|
1075 |
-
'title' => __('Phone Number','ultimate-member'),
|
1076 |
-
'metakey' => 'phone_number',
|
1077 |
-
'type' => 'text',
|
1078 |
-
'label' => __('Phone Number','ultimate-member'),
|
1079 |
-
'required' => 0,
|
1080 |
-
'public' => 1,
|
1081 |
-
'editable' => 1,
|
1082 |
-
'validate' => 'phone_number',
|
1083 |
-
'icon' => 'um-faicon-phone',
|
1084 |
-
),
|
1085 |
-
|
1086 |
-
'mobile_number' => array(
|
1087 |
-
'title' => __('Mobile Number','ultimate-member'),
|
1088 |
-
'metakey' => 'mobile_number',
|
1089 |
-
'type' => 'text',
|
1090 |
-
'label' => __('Mobile Number','ultimate-member'),
|
1091 |
-
'required' => 0,
|
1092 |
-
'public' => 1,
|
1093 |
-
'editable' => 1,
|
1094 |
-
'validate' => 'phone_number',
|
1095 |
-
'icon' => 'um-faicon-mobile',
|
1096 |
-
),
|
1097 |
-
|
1098 |
-
// private use ( not public list )
|
1099 |
-
|
1100 |
-
'profile_photo' => array(
|
1101 |
-
'title' => __('Profile Photo','ultimate-member'),
|
1102 |
-
'metakey' => 'profile_photo',
|
1103 |
-
'type' => 'image',
|
1104 |
-
'label' => __('Change your profile photo','ultimate-member'),
|
1105 |
-
'upload_text' => __('Upload your photo here','ultimate-member'),
|
1106 |
-
'icon' => 'um-faicon-camera',
|
1107 |
-
'crop' => 1,
|
1108 |
-
'max_size' => ( UM()->options()->get('profile_photo_max_size') ) ? UM()->options()->get('profile_photo_max_size') : 999999999,
|
1109 |
-
'min_width' => str_replace('px','',UM()->options()->get('profile_photosize')),
|
1110 |
-
'min_height' => str_replace('px','',UM()->options()->get('profile_photosize')),
|
1111 |
-
'private_use' => true,
|
1112 |
-
),
|
1113 |
-
|
1114 |
-
'cover_photo' => array(
|
1115 |
-
'title' => __('Cover Photo','ultimate-member'),
|
1116 |
-
'metakey' => 'cover_photo',
|
1117 |
-
'type' => 'image',
|
1118 |
-
'label' => __('Change your cover photo','ultimate-member'),
|
1119 |
-
'upload_text' => __('Upload profile cover here','ultimate-member'),
|
1120 |
-
'icon' => 'um-faicon-picture-o',
|
1121 |
-
'crop' => 2,
|
1122 |
-
'max_size' => ( UM()->options()->get('cover_photo_max_size') ) ? UM()->options()->get('cover_photo_max_size') : 999999999,
|
1123 |
-
'modal_size' => 'large',
|
1124 |
-
'ratio' => str_replace(':1','',UM()->options()->get('profile_cover_ratio')),
|
1125 |
-
'min_width' => UM()->options()->get('cover_min_width'),
|
1126 |
-
'private_use' => true,
|
1127 |
-
),
|
1128 |
-
|
1129 |
-
'username_b' => array(
|
1130 |
-
'title' => __('Username or E-mail','ultimate-member'),
|
1131 |
-
'metakey' => 'username_b',
|
1132 |
-
'type' => 'text',
|
1133 |
-
'placeholder' => __('Enter your username or email','ultimate-member'),
|
1134 |
-
'required' => 1,
|
1135 |
-
'public' => 1,
|
1136 |
-
'editable' => 0,
|
1137 |
-
'private_use' => true,
|
1138 |
-
),
|
1139 |
-
|
1140 |
-
// account page use ( not public )
|
1141 |
-
|
1142 |
-
'profile_privacy' => array(
|
1143 |
-
'title' => __( 'Profile Privacy', 'ultimate-member' ),
|
1144 |
-
'metakey' => 'profile_privacy',
|
1145 |
-
'type' => 'select',
|
1146 |
-
'label' => __( 'Profile Privacy', 'ultimate-member' ),
|
1147 |
-
'help' => __( 'Who can see your public profile?', 'ultimate-member' ),
|
1148 |
-
'required' => 0,
|
1149 |
-
'public' => 1,
|
1150 |
-
'editable' => 1,
|
1151 |
-
'default' => 'Everyone',
|
1152 |
-
'options' => $profile_privacy,
|
1153 |
-
'allowclear' => 0,
|
1154 |
-
'account_only' => true,
|
1155 |
-
'required_perm' => 'can_make_private_profile',
|
1156 |
-
),
|
1157 |
-
|
1158 |
-
'profile_noindex' => array(
|
1159 |
-
'title' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
|
1160 |
-
'metakey' => 'profile_noindex',
|
1161 |
-
'type' => 'select',
|
1162 |
-
'label' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
|
1163 |
-
'help' => __( 'Hide my profile for robots?', 'ultimate-member' ),
|
1164 |
-
'required' => 0,
|
1165 |
-
'public' => 1,
|
1166 |
-
'editable' => 1,
|
1167 |
-
'default' => UM()->roles()->um_user_can( 'profile_noindex' ) ? '1' : '0',
|
1168 |
-
'options' => array(
|
1169 |
-
'0' => __( 'No', 'ultimate-member' ),
|
1170 |
-
'1' => __( 'Yes', 'ultimate-member' ),
|
1171 |
-
),
|
1172 |
-
'allowclear' => 0,
|
1173 |
-
'account_only' => true,
|
1174 |
-
'required_perm' => 'can_make_private_profile',
|
1175 |
-
),
|
1176 |
-
|
1177 |
-
'hide_in_members' => array(
|
1178 |
-
'title' => __( 'Hide my profile from directory', 'ultimate-member' ),
|
1179 |
-
'metakey' => 'hide_in_members',
|
1180 |
-
'type' => 'radio',
|
1181 |
-
'label' => __( 'Hide my profile from directory', 'ultimate-member' ),
|
1182 |
-
'help' => __( 'Here you can hide yourself from appearing in public directory', 'ultimate-member' ),
|
1183 |
-
'required' => 0,
|
1184 |
-
'public' => 1,
|
1185 |
-
'editable' => 1,
|
1186 |
-
'default' => UM()->member_directory()->get_hide_in_members_default() ? 'Yes' : 'No',
|
1187 |
-
'options' => array(
|
1188 |
-
'No' => __( 'No', 'ultimate-member' ),
|
1189 |
-
'Yes' => __( 'Yes', 'ultimate-member' ),
|
1190 |
-
),
|
1191 |
-
'account_only' => true,
|
1192 |
-
'required_opt' => array( 'members_page', 1 ),
|
1193 |
-
),
|
1194 |
-
|
1195 |
-
'delete_account' => array(
|
1196 |
-
'title' => __( 'Delete Account', 'ultimate-member' ),
|
1197 |
-
'metakey' => 'delete_account',
|
1198 |
-
'type' => 'radio',
|
1199 |
-
'label' => __( 'Delete Account', 'ultimate-member'),
|
1200 |
-
'help' => __( 'If you confirm, everything related to your profile will be deleted permanently from the site', 'ultimate-member' ),
|
1201 |
-
'required' => 0,
|
1202 |
-
'public' => 1,
|
1203 |
-
'editable' => 1,
|
1204 |
-
'default' => __( 'No', 'ultimate-member' ),
|
1205 |
-
'options' => array(
|
1206 |
-
__( 'Yes', 'ultimate-member' ),
|
1207 |
-
__( 'No', 'ultimate-member' )
|
1208 |
-
),
|
1209 |
-
'account_only' => true,
|
1210 |
-
),
|
1211 |
-
|
1212 |
-
'single_user_password' => array(
|
1213 |
-
'title' => __( 'Password', 'ultimate-member' ),
|
1214 |
-
'metakey' => 'single_user_password',
|
1215 |
-
'type' => 'password',
|
1216 |
-
'label' => __( 'Password', 'ultimate-member' ),
|
1217 |
-
'required' => 1,
|
1218 |
-
'public' => 1,
|
1219 |
-
'editable' => 1,
|
1220 |
-
'account_only' => true,
|
1221 |
-
),
|
1222 |
-
|
1223 |
-
);
|
1224 |
-
|
1225 |
-
/**
|
1226 |
-
* UM hook
|
1227 |
-
*
|
1228 |
-
* @type filter
|
1229 |
-
* @title um_predefined_fields_hook
|
1230 |
-
* @description Extend Predefined Fields
|
1231 |
-
* @input_vars
|
1232 |
-
* [{"var":"$predefined_fields","type":"array","desc":"Predefined Fields"}]
|
1233 |
-
* @change_log
|
1234 |
-
* ["Since: 2.0"]
|
1235 |
-
* @usage add_filter( 'um_predefined_fields_hook', 'function_name', 10, 1 );
|
1236 |
-
* @example
|
1237 |
-
* <?php
|
1238 |
-
* add_filter( 'um_predefined_fields_hook', 'my_predefined_fields', 10, 1 );
|
1239 |
-
* function my_predefined_fields( $predefined_fields ) {
|
1240 |
-
* // your code here
|
1241 |
-
* return $predefined_fields;
|
1242 |
-
* }
|
1243 |
-
* ?>
|
1244 |
-
*/
|
1245 |
-
$this->predefined_fields = apply_filters( 'um_predefined_fields_hook', $this->predefined_fields );
|
1246 |
-
}
|
1247 |
-
|
1248 |
-
|
1249 |
-
/**
|
1250 |
-
* Custom Fields
|
1251 |
-
*/
|
1252 |
-
function set_custom_fields() {
|
1253 |
-
|
1254 |
-
if ( is_array( $this->saved_fields ) ) {
|
1255 |
-
|
1256 |
-
$this->custom_fields = $this->saved_fields;
|
1257 |
-
|
1258 |
-
} else {
|
1259 |
-
|
1260 |
-
$this->custom_fields = '';
|
1261 |
-
|
1262 |
-
}
|
1263 |
-
|
1264 |
-
$custom = $this->custom_fields;
|
1265 |
-
$predefined = $this->predefined_fields;
|
1266 |
-
|
1267 |
-
if ( is_array( $custom ) ){
|
1268 |
-
$this->all_user_fields = array_merge( $predefined, $custom );
|
1269 |
-
} else {
|
1270 |
-
$this->all_user_fields = $predefined;
|
1271 |
-
}
|
1272 |
-
|
1273 |
-
}
|
1274 |
-
|
1275 |
-
|
1276 |
-
/**
|
1277 |
-
* Get all fields without metakeys
|
1278 |
-
*
|
1279 |
-
* @since 2.0.56
|
1280 |
-
*
|
1281 |
-
* @return array
|
1282 |
-
*/
|
1283 |
-
function get_fields_without_metakey() {
|
1284 |
-
$fields_without_metakey = array(
|
1285 |
-
'block',
|
1286 |
-
'shortcode',
|
1287 |
-
'spacing',
|
1288 |
-
'divider',
|
1289 |
-
'group'
|
1290 |
-
);
|
1291 |
-
|
1292 |
-
|
1293 |
-
/**
|
1294 |
-
* UM hook
|
1295 |
-
*
|
1296 |
-
* @type filter
|
1297 |
-
* @title um_fields_without_metakey
|
1298 |
-
* @description Field Types without meta key
|
1299 |
-
* @input_vars
|
1300 |
-
* [{"var":"$types","type":"array","desc":"Field Types"}]
|
1301 |
-
* @change_log
|
1302 |
-
* ["Since: 2.0"]
|
1303 |
-
* @usage add_filter( 'um_fields_without_metakey', 'function_name', 10, 1 );
|
1304 |
-
* @example
|
1305 |
-
* <?php
|
1306 |
-
* add_filter( 'um_fields_without_metakey', 'my_fields_without_metakey', 10, 1 );
|
1307 |
-
* function my_fields_without_metakey( $types ) {
|
1308 |
-
* // your code here
|
1309 |
-
* return $types;
|
1310 |
-
* }
|
1311 |
-
* ?>
|
1312 |
-
*/
|
1313 |
-
return apply_filters( 'um_fields_without_metakey', $fields_without_metakey );
|
1314 |
-
}
|
1315 |
-
|
1316 |
-
|
1317 |
-
/**
|
1318 |
-
* May be used to show a dropdown, or source for user meta
|
1319 |
-
*
|
1320 |
-
* @param null $exclude_types
|
1321 |
-
* @param bool $show_all
|
1322 |
-
*
|
1323 |
-
* @return array
|
1324 |
-
*/
|
1325 |
-
function all_user_fields( $exclude_types = null, $show_all = false ) {
|
1326 |
-
|
1327 |
-
$fields_without_metakey = $this->get_fields_without_metakey();
|
1328 |
-
$fields_without_metakey = apply_filters( 'um_all_user_fields_without_metakey', $fields_without_metakey );
|
1329 |
-
|
1330 |
-
if ( ! $show_all ) {
|
1331 |
-
$this->fields_dropdown = array( 'image', 'file', 'password', 'rating' );
|
1332 |
-
$this->fields_dropdown = array_merge( $this->fields_dropdown, $fields_without_metakey );
|
1333 |
-
} else {
|
1334 |
-
$this->fields_dropdown = $fields_without_metakey;
|
1335 |
-
}
|
1336 |
-
|
1337 |
-
$custom = $this->custom_fields;
|
1338 |
-
$predefined = $this->predefined_fields;
|
1339 |
-
|
1340 |
-
if ( $exclude_types ) {
|
1341 |
-
$exclude_types = explode( ',', $exclude_types );
|
1342 |
-
}
|
1343 |
-
|
1344 |
-
$all = array( 0 => '' );
|
1345 |
-
|
1346 |
-
if ( is_array( $custom ) ) {
|
1347 |
-
$all = $all + array_merge( $predefined, $custom );
|
1348 |
-
} else {
|
1349 |
-
$all = $all + $predefined;
|
1350 |
-
}
|
1351 |
-
|
1352 |
-
foreach ( $all as $k => $arr ) {
|
1353 |
-
|
1354 |
-
if ( $k == 0 ) {
|
1355 |
-
unset( $all[ $k ] );
|
1356 |
-
}
|
1357 |
-
|
1358 |
-
if ( isset( $arr['title'] ) ) {
|
1359 |
-
$all[ $k ]['title'] = stripslashes( $arr['title'] );
|
1360 |
-
}
|
1361 |
-
|
1362 |
-
if ( $exclude_types && isset( $arr['type'] ) && in_array( $arr['type'], $exclude_types ) ) {
|
1363 |
-
unset( $all[ $k ] );
|
1364 |
-
}
|
1365 |
-
if ( isset( $arr['account_only'] ) || isset( $arr['private_use'] ) ) {
|
1366 |
-
if ( ! $show_all ) {
|
1367 |
-
unset( $all[ $k ] );
|
1368 |
-
}
|
1369 |
-
}
|
1370 |
-
if ( isset( $arr['type'] ) && in_array( $arr['type'], $this->fields_dropdown ) ) {
|
1371 |
-
unset( $all[ $k ] );
|
1372 |
-
}
|
1373 |
-
}
|
1374 |
-
|
1375 |
-
$all = UM()->fields()->array_sort_by_column( $all, 'title' );
|
1376 |
-
|
1377 |
-
return $all;
|
1378 |
-
}
|
1379 |
-
|
1380 |
-
|
1381 |
-
/**
|
1382 |
-
* Possible validation types for fields
|
1383 |
-
*
|
1384 |
-
* @return mixed
|
1385 |
-
*/
|
1386 |
-
function validation_types() {
|
1387 |
-
|
1388 |
-
$array[0] = __('None','ultimate-member');
|
1389 |
-
$array['alphabetic'] = __('Alphabetic value only','ultimate-member');
|
1390 |
-
$array['alpha_numeric'] = __('Alpha-numeric value','ultimate-member');
|
1391 |
-
$array['english'] = __('English letters only','ultimate-member');
|
1392 |
-
$array['facebook_url'] = __('Facebook URL','ultimate-member');
|
1393 |
-
$array['google_url'] = __('Google+ URL','ultimate-member');
|
1394 |
-
$array['instagram_url'] = __('Instagram URL','ultimate-member');
|
1395 |
-
$array['linkedin_url'] = __('LinkedIn URL','ultimate-member');
|
1396 |
-
$array['vk_url'] = __('VKontakte URL','ultimate-member');
|
1397 |
-
$array['lowercase'] = __('Lowercase only','ultimate-member');
|
1398 |
-
$array['numeric'] = __('Numeric value only','ultimate-member');
|
1399 |
-
$array['phone_number'] = __('Phone Number','ultimate-member');
|
1400 |
-
$array['skype'] = __('Skype ID','ultimate-member');
|
1401 |
-
$array['soundcloud'] = __('SoundCloud Profile','ultimate-member');
|
1402 |
-
$array['twitter_url'] = __('Twitter URL','ultimate-member');
|
1403 |
-
$array['is_email'] = __('E-mail( Not Unique )','ultimate-member');
|
1404 |
-
$array['unique_email'] = __('Unique E-mail','ultimate-member');
|
1405 |
-
$array['unique_value'] = __('Unique Metakey value','ultimate-member');
|
1406 |
-
$array['unique_username'] = __('Unique Username','ultimate-member');
|
1407 |
-
$array['unique_username_or_email'] = __('Unique Username/E-mail','ultimate-member');
|
1408 |
-
$array['url'] = __('Website URL','ultimate-member');
|
1409 |
-
$array['youtube_url'] = __('YouTube Profile','ultimate-member');
|
1410 |
-
$array['custom'] = __('Custom Validation','ultimate-member');
|
1411 |
-
|
1412 |
-
/**
|
1413 |
-
* UM hook
|
1414 |
-
*
|
1415 |
-
* @type filter
|
1416 |
-
* @title um_admin_field_validation_hook
|
1417 |
-
* @description Extend validation types
|
1418 |
-
* @input_vars
|
1419 |
-
* [{"var":"$types","type":"array","desc":"Validation Types"}]
|
1420 |
-
* @change_log
|
1421 |
-
* ["Since: 2.0"]
|
1422 |
-
* @usage add_filter( 'um_admin_field_validation_hook', 'function_name', 10, 1 );
|
1423 |
-
* @example
|
1424 |
-
* <?php
|
1425 |
-
* add_filter( 'um_admin_field_validation_hook', 'my_admin_field_validation', 10, 1 );
|
1426 |
-
* function my_admin_field_validation( $types ) {
|
1427 |
-
* // your code here
|
1428 |
-
* return $types;
|
1429 |
-
* }
|
1430 |
-
* ?>
|
1431 |
-
*/
|
1432 |
-
$array = apply_filters( 'um_admin_field_validation_hook', $array );
|
1433 |
-
return $array;
|
1434 |
-
}
|
1435 |
-
|
1436 |
-
|
1437 |
-
/**
|
1438 |
-
* Get predefined options
|
1439 |
-
*
|
1440 |
-
* @param $data
|
1441 |
-
*
|
1442 |
-
* @return array|mixed|void
|
1443 |
-
*/
|
1444 |
-
function get( $data ) {
|
1445 |
-
switch ( $data ) {
|
1446 |
-
|
1447 |
-
case 'languages':
|
1448 |
-
$array = array(
|
1449 |
-
"aa" => __("Afar",'ultimate-member'),
|
1450 |
-
"ab" => __("Abkhazian",'ultimate-member'),
|
1451 |
-
"ae" => __("Avestan",'ultimate-member'),
|
1452 |
-
"af" => __("Afrikaans",'ultimate-member'),
|
1453 |
-
"ak" => __("Akan",'ultimate-member'),
|
1454 |
-
"am" => __("Amharic",'ultimate-member'),
|
1455 |
-
"an" => __("Aragonese",'ultimate-member'),
|
1456 |
-
"ar" => __("Arabic",'ultimate-member'),
|
1457 |
-
"as" => __("Assamese",'ultimate-member'),
|
1458 |
-
"av" => __("Avaric",'ultimate-member'),
|
1459 |
-
"ay" => __("Aymara",'ultimate-member'),
|
1460 |
-
"az" => __("Azerbaijani",'ultimate-member'),
|
1461 |
-
"ba" => __("Bashkir",'ultimate-member'),
|
1462 |
-
"be" => __("Belarusian",'ultimate-member'),
|
1463 |
-
"bg" => __("Bulgarian",'ultimate-member'),
|
1464 |
-
"bh" => __("Bihari",'ultimate-member'),
|
1465 |
-
"bi" => __("Bislama",'ultimate-member'),
|
1466 |
-
"bm" => __("Bambara",'ultimate-member'),
|
1467 |
-
"bn" => __("Bengali",'ultimate-member'),
|
1468 |
-
"bo" => __("Tibetan",'ultimate-member'),
|
1469 |
-
"br" => __("Breton",'ultimate-member'),
|
1470 |
-
"bs" => __("Bosnian",'ultimate-member'),
|
1471 |
-
"ca" => __("Catalan",'ultimate-member'),
|
1472 |
-
"ce" => __("Chechen",'ultimate-member'),
|
1473 |
-
"ch" => __("Chamorro",'ultimate-member'),
|
1474 |
-
"co" => __("Corsican",'ultimate-member'),
|
1475 |
-
"cr" => __("Cree",'ultimate-member'),
|
1476 |
-
"cs" => __("Czech",'ultimate-member'),
|
1477 |
-
"cu" => __("Church Slavic",'ultimate-member'),
|
1478 |
-
"cv" => __("Chuvash",'ultimate-member'),
|
1479 |
-
"cy" => __("Welsh",'ultimate-member'),
|
1480 |
-
"da" => __("Danish",'ultimate-member'),
|
1481 |
-
"de" => __("German",'ultimate-member'),
|
1482 |
-
"dv" => __("Divehi",'ultimate-member'),
|
1483 |
-
"dz" => __("Dzongkha",'ultimate-member'),
|
1484 |
-
"ee" => __("Ewe",'ultimate-member'),
|
1485 |
-
"el" => __("Greek",'ultimate-member'),
|
1486 |
-
"en" => __("English",'ultimate-member'),
|
1487 |
-
"eo" => __("Esperanto",'ultimate-member'),
|
1488 |
-
"es" => __("Spanish",'ultimate-member'),
|
1489 |
-
"et" => __("Estonian",'ultimate-member'),
|
1490 |
-
"eu" => __("Basque",'ultimate-member'),
|
1491 |
-
"fa" => __("Persian",'ultimate-member'),
|
1492 |
-
"ff" => __("Fulah",'ultimate-member'),
|
1493 |
-
"fi" => __("Finnish",'ultimate-member'),
|
1494 |
-
"fj" => __("Fijian",'ultimate-member'),
|
1495 |
-
"fo" => __("Faroese",'ultimate-member'),
|
1496 |
-
"fr" => __("French",'ultimate-member'),
|
1497 |
-
"fy" => __("Western Frisian",'ultimate-member'),
|
1498 |
-
"ga" => __("Irish",'ultimate-member'),
|
1499 |
-
"gd" => __("Scottish Gaelic",'ultimate-member'),
|
1500 |
-
"gl" => __("Galician",'ultimate-member'),
|
1501 |
-
"gn" => __("Guarani",'ultimate-member'),
|
1502 |
-
"gu" => __("Gujarati",'ultimate-member'),
|
1503 |
-
"gv" => __("Manx",'ultimate-member'),
|
1504 |
-
"ha" => __("Hausa",'ultimate-member'),
|
1505 |
-
"he" => __("Hebrew",'ultimate-member'),
|
1506 |
-
"hi" => __("Hindi",'ultimate-member'),
|
1507 |
-
"ho" => __("Hiri Motu",'ultimate-member'),
|
1508 |
-
"hr" => __("Croatian",'ultimate-member'),
|
1509 |
-
"ht" => __("Haitian",'ultimate-member'),
|
1510 |
-
"hu" => __("Hungarian",'ultimate-member'),
|
1511 |
-
"hy" => __("Armenian",'ultimate-member'),
|
1512 |
-
"hz" => __("Herero",'ultimate-member'),
|
1513 |
-
"ia" => __("Interlingua (International Auxiliary Language Association)",'ultimate-member'),
|
1514 |
-
"id" => __("Indonesian",'ultimate-member'),
|
1515 |
-
"ie" => __("Interlingue",'ultimate-member'),
|
1516 |
-
"ig" => __("Igbo",'ultimate-member'),
|
1517 |
-
"ii" => __("Sichuan Yi",'ultimate-member'),
|
1518 |
-
"ik" => __("Inupiaq",'ultimate-member'),
|
1519 |
-
"io" => __("Ido",'ultimate-member'),
|
1520 |
-
"is" => __("Icelandic",'ultimate-member'),
|
1521 |
-
"it" => __("Italian",'ultimate-member'),
|
1522 |
-
"iu" => __("Inuktitut",'ultimate-member'),
|
1523 |
-
"ja" => __("Japanese",'ultimate-member'),
|
1524 |
-
"jv" => __("Javanese",'ultimate-member'),
|
1525 |
-
"ka" => __("Georgian",'ultimate-member'),
|
1526 |
-
"kg" => __("Kongo",'ultimate-member'),
|
1527 |
-
"ki" => __("Kikuyu",'ultimate-member'),
|
1528 |
-
"kj" => __("Kwanyama",'ultimate-member'),
|
1529 |
-
"kk" => __("Kazakh",'ultimate-member'),
|
1530 |
-
"kl" => __("Kalaallisut",'ultimate-member'),
|
1531 |
-
"km" => __("Khmer",'ultimate-member'),
|
1532 |
-
"kn" => __("Kannada",'ultimate-member'),
|
1533 |
-
"ko" => __("Korean",'ultimate-member'),
|
1534 |
-
"kr" => __("Kanuri",'ultimate-member'),
|
1535 |
-
"ks" => __("Kashmiri",'ultimate-member'),
|
1536 |
-
"ku" => __("Kurdish",'ultimate-member'),
|
1537 |
-
"kv" => __("Komi",'ultimate-member'),
|
1538 |
-
"kw" => __("Cornish",'ultimate-member'),
|
1539 |
-
"ky" => __("Kirghiz",'ultimate-member'),
|
1540 |
-
"la" => __("Latin",'ultimate-member'),
|
1541 |
-
"lb" => __("Luxembourgish",'ultimate-member'),
|
1542 |
-
"lg" => __("Ganda",'ultimate-member'),
|
1543 |
-
"li" => __("Limburgish",'ultimate-member'),
|
1544 |
-
"ln" => __("Lingala",'ultimate-member'),
|
1545 |
-
"lo" => __("Lao",'ultimate-member'),
|
1546 |
-
"lt" => __("Lithuanian",'ultimate-member'),
|
1547 |
-
"lu" => __("Luba-Katanga",'ultimate-member'),
|
1548 |
-
"lv" => __("Latvian",'ultimate-member'),
|
1549 |
-
"mg" => __("Malagasy",'ultimate-member'),
|
1550 |
-
"mh" => __("Marshallese",'ultimate-member'),
|
1551 |
-
"mi" => __("Maori",'ultimate-member'),
|
1552 |
-
"mk" => __("Macedonian",'ultimate-member'),
|
1553 |
-
"ml" => __("Malayalam",'ultimate-member'),
|
1554 |
-
"mn" => __("Mongolian",'ultimate-member'),
|
1555 |
-
"mr" => __("Marathi",'ultimate-member'),
|
1556 |
-
"ms" => __("Malay",'ultimate-member'),
|
1557 |
-
"mt" => __("Maltese",'ultimate-member'),
|
1558 |
-
"my" => __("Burmese",'ultimate-member'),
|
1559 |
-
"na" => __("Nauru",'ultimate-member'),
|
1560 |
-
"nb" => __("Norwegian Bokmal",'ultimate-member'),
|
1561 |
-
"nd" => __("North Ndebele",'ultimate-member'),
|
1562 |
-
"ne" => __("Nepali",'ultimate-member'),
|
1563 |
-
"ng" => __("Ndonga",'ultimate-member'),
|
1564 |
-
"nl" => __("Dutch",'ultimate-member'),
|
1565 |
-
"nn" => __("Norwegian Nynorsk",'ultimate-member'),
|
1566 |
-
"no" => __("Norwegian",'ultimate-member'),
|
1567 |
-
"nr" => __("South Ndebele",'ultimate-member'),
|
1568 |
-
"nv" => __("Navajo",'ultimate-member'),
|
1569 |
-
"ny" => __("Chichewa",'ultimate-member'),
|
1570 |
-
"oc" => __("Occitan",'ultimate-member'),
|
1571 |
-
"oj" => __("Ojibwa",'ultimate-member'),
|
1572 |
-
"om" => __("Oromo",'ultimate-member'),
|
1573 |
-
"or" => __("Oriya",'ultimate-member'),
|
1574 |
-
"os" => __("Ossetian",'ultimate-member'),
|
1575 |
-
"pa" => __("Panjabi",'ultimate-member'),
|
1576 |
-
"pi" => __("Pali",'ultimate-member'),
|
1577 |
-
"pl" => __("Polish",'ultimate-member'),
|
1578 |
-
"ps" => __("Pashto",'ultimate-member'),
|
1579 |
-
"pt" => __("Portuguese",'ultimate-member'),
|
1580 |
-
"qu" => __("Quechua",'ultimate-member'),
|
1581 |
-
"rm" => __("Raeto-Romance",'ultimate-member'),
|
1582 |
-
"rn" => __("Kirundi",'ultimate-member'),
|
1583 |
-
"ro" => __("Romanian",'ultimate-member'),
|
1584 |
-
"ru" => __("Russian",'ultimate-member'),
|
1585 |
-
"rw" => __("Kinyarwanda",'ultimate-member'),
|
1586 |
-
"sa" => __("Sanskrit",'ultimate-member'),
|
1587 |
-
"sc" => __("Sardinian",'ultimate-member'),
|
1588 |
-
"sd" => __("Sindhi",'ultimate-member'),
|
1589 |
-
"se" => __("Northern Sami",'ultimate-member'),
|
1590 |
-
"sg" => __("Sango",'ultimate-member'),
|
1591 |
-
"si" => __("Sinhala",'ultimate-member'),
|
1592 |
-
"sk" => __("Slovak",'ultimate-member'),
|
1593 |
-
"sl" => __("Slovenian",'ultimate-member'),
|
1594 |
-
"sm" => __("Samoan",'ultimate-member'),
|
1595 |
-
"sn" => __("Shona",'ultimate-member'),
|
1596 |
-
"so" => __("Somali",'ultimate-member'),
|
1597 |
-
"sq" => __("Albanian",'ultimate-member'),
|
1598 |
-
"sr" => __("Serbian",'ultimate-member'),
|
1599 |
-
"ss" => __("Swati",'ultimate-member'),
|
1600 |
-
"st" => __("Southern Sotho",'ultimate-member'),
|
1601 |
-
"su" => __("Sundanese",'ultimate-member'),
|
1602 |
-
"sv" => __("Swedish",'ultimate-member'),
|
1603 |
-
"sw" => __("Swahili",'ultimate-member'),
|
1604 |
-
"ta" => __("Tamil",'ultimate-member'),
|
1605 |
-
"te" => __("Telugu",'ultimate-member'),
|
1606 |
-
"tg" => __("Tajik",'ultimate-member'),
|
1607 |
-
"th" => __("Thai",'ultimate-member'),
|
1608 |
-
"ti" => __("Tigrinya",'ultimate-member'),
|
1609 |
-
"tk" => __("Turkmen",'ultimate-member'),
|
1610 |
-
"tl" => __("Tagalog",'ultimate-member'),
|
1611 |
-
"tn" => __("Tswana",'ultimate-member'),
|
1612 |
-
"to" => __("Tonga",'ultimate-member'),
|
1613 |
-
"tr" => __("Turkish",'ultimate-member'),
|
1614 |
-
"ts" => __("Tsonga",'ultimate-member'),
|
1615 |
-
"tt" => __("Tatar",'ultimate-member'),
|
1616 |
-
"tw" => __("Twi",'ultimate-member'),
|
1617 |
-
"ty" => __("Tahitian",'ultimate-member'),
|
1618 |
-
"ug" => __("Uighur",'ultimate-member'),
|
1619 |
-
"uk" => __("Ukrainian",'ultimate-member'),
|
1620 |
-
"ur" => __("Urdu",'ultimate-member'),
|
1621 |
-
"uz" => __("Uzbek",'ultimate-member'),
|
1622 |
-
"ve" => __("Venda",'ultimate-member'),
|
1623 |
-
"vi" => __("Vietnamese",'ultimate-member'),
|
1624 |
-
"vo" => __("Volapuk",'ultimate-member'),
|
1625 |
-
"wa" => __("Walloon",'ultimate-member'),
|
1626 |
-
"wo" => __("Wolof",'ultimate-member'),
|
1627 |
-
"xh" => __("Xhosa",'ultimate-member'),
|
1628 |
-
"yi" => __("Yiddish",'ultimate-member'),
|
1629 |
-
"yo" => __("Yoruba",'ultimate-member'),
|
1630 |
-
"za" => __("Zhuang",'ultimate-member'),
|
1631 |
-
"zh" => __("Chinese",'ultimate-member'),
|
1632 |
-
"zu" => __("Zulu",'ultimate-member')
|
1633 |
-
);
|
1634 |
-
break;
|
1635 |
-
|
1636 |
-
case 'countries':
|
1637 |
-
$array = array (
|
1638 |
-
'AF' => __('Afghanistan','ultimate-member'),
|
1639 |
-
'AX' => __('Åland Islands','ultimate-member'),
|
1640 |
-
'AL' => __('Albania','ultimate-member'),
|
1641 |
-
'DZ' => __('Algeria','ultimate-member'),
|
1642 |
-
'AS' => __('American Samoa','ultimate-member'),
|
1643 |
-
'AD' => __('Andorra','ultimate-member'),
|
1644 |
-
'AO' => __('Angola','ultimate-member'),
|
1645 |
-
'AI' => __('Anguilla','ultimate-member'),
|
1646 |
-
'AQ' => __('Antarctica','ultimate-member'),
|
1647 |
-
'AG' => __('Antigua and Barbuda','ultimate-member'),
|
1648 |
-
'AR' => __('Argentina','ultimate-member'),
|
1649 |
-
'AM' => __('Armenia','ultimate-member'),
|
1650 |
-
'AW' => __('Aruba','ultimate-member'),
|
1651 |
-
'AU' => __('Australia','ultimate-member'),
|
1652 |
-
'AT' => __('Austria','ultimate-member'),
|
1653 |
-
'AZ' => __('Azerbaijan','ultimate-member'),
|
1654 |
-
'BS' => __('Bahamas','ultimate-member'),
|
1655 |
-
'BH' => __('Bahrain','ultimate-member'),
|
1656 |
-
'BD' => __('Bangladesh','ultimate-member'),
|
1657 |
-
'BB' => __('Barbados','ultimate-member'),
|
1658 |
-
'BY' => __('Belarus','ultimate-member'),
|
1659 |
-
'BE' => __('Belgium','ultimate-member'),
|
1660 |
-
'BZ' => __('Belize','ultimate-member'),
|
1661 |
-
'BJ' => __('Benin','ultimate-member'),
|
1662 |
-
'BM' => __('Bermuda','ultimate-member'),
|
1663 |
-
'BT' => __('Bhutan','ultimate-member'),
|
1664 |
-
'BO' => __('Bolivia, Plurinational State of','ultimate-member'),
|
1665 |
-
'BA' => __('Bosnia and Herzegovina','ultimate-member'),
|
1666 |
-
'BW' => __('Botswana','ultimate-member'),
|
1667 |
-
'BV' => __('Bouvet Island','ultimate-member'),
|
1668 |
-
'BR' => __('Brazil','ultimate-member'),
|
1669 |
-
'IO' => __('British Indian Ocean Territory','ultimate-member'),
|
1670 |
-
'BN' => __('Brunei Darussalam','ultimate-member'),
|
1671 |
-
'BG' => __('Bulgaria','ultimate-member'),
|
1672 |
-
'BF' => __('Burkina Faso','ultimate-member'),
|
1673 |
-
'BI' => __('Burundi','ultimate-member'),
|
1674 |
-
'KH' => __('Cambodia','ultimate-member'),
|
1675 |
-
'CM' => __('Cameroon','ultimate-member'),
|
1676 |
-
'CA' => __('Canada','ultimate-member'),
|
1677 |
-
'CV' => __('Cape Verde','ultimate-member'),
|
1678 |
-
'KY' => __('Cayman Islands','ultimate-member'),
|
1679 |
-
'CF' => __('Central African Republic','ultimate-member'),
|
1680 |
-
'TD' => __('Chad','ultimate-member'),
|
1681 |
-
'CL' => __('Chile','ultimate-member'),
|
1682 |
-
'CN' => __('China','ultimate-member'),
|
1683 |
-
'CX' => __('Christmas Island','ultimate-member'),
|
1684 |
-
'CC' => __('Cocos (Keeling) Islands','ultimate-member'),
|
1685 |
-
'CO' => __('Colombia','ultimate-member'),
|
1686 |
-
'KM' => __('Comoros','ultimate-member'),
|
1687 |
-
'CG' => __('Congo','ultimate-member'),
|
1688 |
-
'CD' => __('Congo, the Democratic Republic of the','ultimate-member'),
|
1689 |
-
'CK' => __('Cook Islands','ultimate-member'),
|
1690 |
-
'CR' => __('Costa Rica','ultimate-member'),
|
1691 |
-
'CI' => __("Côte d'Ivoire",'ultimate-member'),
|
1692 |
-
'HR' => __('Croatia','ultimate-member'),
|
1693 |
-
'CU' => __('Cuba','ultimate-member'),
|
1694 |
-
'CY' => __('Cyprus','ultimate-member'),
|
1695 |
-
'CZ' => __('Czech Republic','ultimate-member'),
|
1696 |
-
'DK' => __('Denmark','ultimate-member'),
|
1697 |
-
'DJ' => __('Djibouti','ultimate-member'),
|
1698 |
-
'DM' => __('Dominica','ultimate-member'),
|
1699 |
-
'DO' => __('Dominican Republic','ultimate-member'),
|
1700 |
-
'EC' => __('Ecuador','ultimate-member'),
|
1701 |
-
'EG' => __('Egypt','ultimate-member'),
|
1702 |
-
'SV' => __('El Salvador','ultimate-member'),
|
1703 |
-
'GQ' => __('Equatorial Guinea','ultimate-member'),
|
1704 |
-
'ER' => __('Eritrea','ultimate-member'),
|
1705 |
-
'EE' => __('Estonia','ultimate-member'),
|
1706 |
-
'ET' => __('Ethiopia','ultimate-member'),
|
1707 |
-
'FK' => __('Falkland Islands (Malvinas)','ultimate-member'),
|
1708 |
-
'FO' => __('Faroe Islands','ultimate-member'),
|
1709 |
-
'FJ' => __('Fiji','ultimate-member'),
|
1710 |
-
'FI' => __('Finland','ultimate-member'),
|
1711 |
-
'FR' => __('France','ultimate-member'),
|
1712 |
-
'GF' => __('French Guiana','ultimate-member'),
|
1713 |
-
'PF' => __('French Polynesia','ultimate-member'),
|
1714 |
-
'TF' => __('French Southern Territories','ultimate-member'),
|
1715 |
-
'GA' => __('Gabon','ultimate-member'),
|
1716 |
-
'GM' => __('Gambia','ultimate-member'),
|
1717 |
-
'GE' => __('Georgia','ultimate-member'),
|
1718 |
-
'DE' => __('Germany','ultimate-member'),
|
1719 |
-
'GH' => __('Ghana','ultimate-member'),
|
1720 |
-
'GI' => __('Gibraltar','ultimate-member'),
|
1721 |
-
'GR' => __('Greece','ultimate-member'),
|
1722 |
-
'GL' => __('Greenland','ultimate-member'),
|
1723 |
-
'GD' => __('Grenada','ultimate-member'),
|
1724 |
-
'GP' => __('Guadeloupe','ultimate-member'),
|
1725 |
-
'GU' => __('Guam','ultimate-member'),
|
1726 |
-
'GT' => __('Guatemala','ultimate-member'),
|
1727 |
-
'GG' => __('Guernsey','ultimate-member'),
|
1728 |
-
'GN' => __('Guinea','ultimate-member'),
|
1729 |
-
'GW' => __('Guinea-Bissau','ultimate-member'),
|
1730 |
-
'GY' => __('Guyana','ultimate-member'),
|
1731 |
-
'HT' => __('Haiti','ultimate-member'),
|
1732 |
-
'HM' => __('Heard Island and McDonald Islands','ultimate-member'),
|
1733 |
-
'VA' => __('Holy See (Vatican City State)','ultimate-member'),
|
1734 |
-
'HN' => __('Honduras','ultimate-member'),
|
1735 |
-
'HK' => __('Hong Kong','ultimate-member'),
|
1736 |
-
'HU' => __('Hungary','ultimate-member'),
|
1737 |
-
'IS' => __('Iceland','ultimate-member'),
|
1738 |
-
'IN' => __('India','ultimate-member'),
|
1739 |
-
'ID' => __('Indonesia','ultimate-member'),
|
1740 |
-
'IR' => __('Iran, Islamic Republic of','ultimate-member'),
|
1741 |
-
'IQ' => __('Iraq','ultimate-member'),
|
1742 |
-
'IE' => __('Ireland','ultimate-member'),
|
1743 |
-
'IM' => __('Isle of Man','ultimate-member'),
|
1744 |
-
'IL' => __('Israel','ultimate-member'),
|
1745 |
-
'IT' => __('Italy','ultimate-member'),
|
1746 |
-
'JM' => __('Jamaica','ultimate-member'),
|
1747 |
-
'JP' => __('Japan','ultimate-member'),
|
1748 |
-
'JE' => __('Jersey','ultimate-member'),
|
1749 |
-
'JO' => __('Jordan','ultimate-member'),
|
1750 |
-
'KZ' => __('Kazakhstan','ultimate-member'),
|
1751 |
-
'KE' => __('Kenya','ultimate-member'),
|
1752 |
-
'KI' => __('Kiribati','ultimate-member'),
|
1753 |
-
'KP' => __("Korea, Democratic People's Republic of",'ultimate-member'),
|
1754 |
-
'KR' => __('Korea, Republic of','ultimate-member'),
|
1755 |
-
'KW' => __('Kuwait','ultimate-member'),
|
1756 |
-
'KG' => __('Kyrgyzstan','ultimate-member'),
|
1757 |
-
'LA' => __("Lao People's Democratic Republic",'ultimate-member'),
|
1758 |
-
'LV' => __('Latvia','ultimate-member'),
|
1759 |
-
'LB' => __('Lebanon','ultimate-member'),
|
1760 |
-
'LS' => __('Lesotho','ultimate-member'),
|
1761 |
-
'LR' => __('Liberia','ultimate-member'),
|
1762 |
-
'LY' => __('Libyan Arab Jamahiriya','ultimate-member'),
|
1763 |
-
'LI' => __('Liechtenstein','ultimate-member'),
|
1764 |
-
'LT' => __('Lithuania','ultimate-member'),
|
1765 |
-
'LU' => __('Luxembourg','ultimate-member'),
|
1766 |
-
'MO' => __('Macao','ultimate-member'),
|
1767 |
-
'MK' => __('Macedonia, the former Yugoslav Republic of','ultimate-member'),
|
1768 |
-
'MG' => __('Madagascar','ultimate-member'),
|
1769 |
-
'MW' => __('Malawi','ultimate-member'),
|
1770 |
-
'MY' => __('Malaysia','ultimate-member'),
|
1771 |
-
'MV' => __('Maldives','ultimate-member'),
|
1772 |
-
'ML' => __('Mali','ultimate-member'),
|
1773 |
-
'MT' => __('Malta','ultimate-member'),
|
1774 |
-
'MH' => __('Marshall Islands','ultimate-member'),
|
1775 |
-
'MQ' => __('Martinique','ultimate-member'),
|
1776 |
-
'MR' => __('Mauritania','ultimate-member'),
|
1777 |
-
'MU' => __('Mauritius','ultimate-member'),
|
1778 |
-
'YT' => __('Mayotte','ultimate-member'),
|
1779 |
-
'MX' => __('Mexico','ultimate-member'),
|
1780 |
-
'FM' => __('Micronesia, Federated States of','ultimate-member'),
|
1781 |
-
'MD' => __('Moldova, Republic of','ultimate-member'),
|
1782 |
-
'MC' => __('Monaco','ultimate-member'),
|
1783 |
-
'MN' => __('Mongolia','ultimate-member'),
|
1784 |
-
'ME' => __('Montenegro','ultimate-member'),
|
1785 |
-
'MS' => __('Montserrat','ultimate-member'),
|
1786 |
-
'MA' => __('Morocco','ultimate-member'),
|
1787 |
-
'MZ' => __('Mozambique','ultimate-member'),
|
1788 |
-
'MM' => __('Myanmar','ultimate-member'),
|
1789 |
-
'NA' => __('Namibia','ultimate-member'),
|
1790 |
-
'NR' => __('Nauru','ultimate-member'),
|
1791 |
-
'NP' => __('Nepal','ultimate-member'),
|
1792 |
-
'NL' => __('Netherlands','ultimate-member'),
|
1793 |
-
'AN' => __('Netherlands Antilles','ultimate-member'),
|
1794 |
-
'NC' => __('New Caledonia','ultimate-member'),
|
1795 |
-
'NZ' => __('New Zealand','ultimate-member'),
|
1796 |
-
'NI' => __('Nicaragua','ultimate-member'),
|
1797 |
-
'NE' => __('Niger','ultimate-member'),
|
1798 |
-
'NG' => __('Nigeria','ultimate-member'),
|
1799 |
-
'NU' => __('Niue','ultimate-member'),
|
1800 |
-
'NF' => __('Norfolk Island','ultimate-member'),
|
1801 |
-
'MP' => __('Northern Mariana Islands','ultimate-member'),
|
1802 |
-
'NO' => __('Norway','ultimate-member'),
|
1803 |
-
'OM' => __('Oman','ultimate-member'),
|
1804 |
-
'PK' => __('Pakistan','ultimate-member'),
|
1805 |
-
'PW' => __('Palau','ultimate-member'),
|
1806 |
-
'PS' => __('Palestine','ultimate-member'),
|
1807 |
-
'PA' => __('Panama','ultimate-member'),
|
1808 |
-
'PG' => __('Papua New Guinea','ultimate-member'),
|
1809 |
-
'PY' => __('Paraguay','ultimate-member'),
|
1810 |
-
'PE' => __('Peru','ultimate-member'),
|
1811 |
-
'PH' => __('Philippines','ultimate-member'),
|
1812 |
-
'PN' => __('Pitcairn','ultimate-member'),
|
1813 |
-
'PL' => __('Poland','ultimate-member'),
|
1814 |
-
'PT' => __('Portugal','ultimate-member'),
|
1815 |
-
'PR' => __('Puerto Rico','ultimate-member'),
|
1816 |
-
'QA' => __('Qatar','ultimate-member'),
|
1817 |
-
'RE' => __('Réunion','ultimate-member'),
|
1818 |
-
'RO' => __('Romania','ultimate-member'),
|
1819 |
-
'RU' => __('Russian Federation','ultimate-member'),
|
1820 |
-
'RW' => __('Rwanda','ultimate-member'),
|
1821 |
-
'BL' => __('Saint Barthélemy','ultimate-member'),
|
1822 |
-
'SH' => __('Saint Helena','ultimate-member'),
|
1823 |
-
'KN' => __('Saint Kitts and Nevis','ultimate-member'),
|
1824 |
-
'LC' => __('Saint Lucia','ultimate-member'),
|
1825 |
-
'MF' => __('Saint Martin (French part)','ultimate-member'),
|
1826 |
-
'PM' => __('Saint Pierre and Miquelon','ultimate-member'),
|
1827 |
-
'VC' => __('Saint Vincent and the Grenadines','ultimate-member'),
|
1828 |
-
'WS' => __('Samoa','ultimate-member'),
|
1829 |
-
'SM' => __('San Marino','ultimate-member'),
|
1830 |
-
'ST' => __('Sao Tome and Principe','ultimate-member'),
|
1831 |
-
'SA' => __('Saudi Arabia','ultimate-member'),
|
1832 |
-
'SN' => __('Senegal','ultimate-member'),
|
1833 |
-
'RS' => __('Serbia','ultimate-member'),
|
1834 |
-
'SC' => __('Seychelles','ultimate-member'),
|
1835 |
-
'SL' => __('Sierra Leone','ultimate-member'),
|
1836 |
-
'SG' => __('Singapore','ultimate-member'),
|
1837 |
-
'SK' => __('Slovakia','ultimate-member'),
|
1838 |
-
'SI' => __('Slovenia','ultimate-member'),
|
1839 |
-
'SB' => __('Solomon Islands','ultimate-member'),
|
1840 |
-
'SO' => __('Somalia','ultimate-member'),
|
1841 |
-
'ZA' => __('South Africa','ultimate-member'),
|
1842 |
-
'GS' => __('South Georgia and the South Sandwich Islands','ultimate-member'),
|
1843 |
-
'SS' => __('South Sudan','ultimate-member'),
|
1844 |
-
'ES' => __('Spain','ultimate-member'),
|
1845 |
-
'LK' => __('Sri Lanka','ultimate-member'),
|
1846 |
-
'SD' => __('Sudan','ultimate-member'),
|
1847 |
-
'SR' => __('Suriname','ultimate-member'),
|
1848 |
-
'SJ' => __('Svalbard and Jan Mayen','ultimate-member'),
|
1849 |
-
'SZ' => __('Swaziland','ultimate-member'),
|
1850 |
-
'SE' => __('Sweden','ultimate-member'),
|
1851 |
-
'CH' => __('Switzerland','ultimate-member'),
|
1852 |
-
'SY' => __('Syrian Arab Republic','ultimate-member'),
|
1853 |
-
'TW' => __('Taiwan, Province of China','ultimate-member'),
|
1854 |
-
'TJ' => __('Tajikistan','ultimate-member'),
|
1855 |
-
'TZ' => __('Tanzania, United Republic of','ultimate-member'),
|
1856 |
-
'TH' => __('Thailand','ultimate-member'),
|
1857 |
-
'TL' => __('Timor-Leste','ultimate-member'),
|
1858 |
-
'TG' => __('Togo','ultimate-member'),
|
1859 |
-
'TK' => __('Tokelau','ultimate-member'),
|
1860 |
-
'TO' => __('Tonga','ultimate-member'),
|
1861 |
-
'TT' => __('Trinidad and Tobago','ultimate-member'),
|
1862 |
-
'TN' => __('Tunisia','ultimate-member'),
|
1863 |
-
'TR' => __('Turkey','ultimate-member'),
|
1864 |
-
'TM' => __('Turkmenistan','ultimate-member'),
|
1865 |
-
'TC' => __('Turks and Caicos Islands','ultimate-member'),
|
1866 |
-
'TV' => __('Tuvalu','ultimate-member'),
|
1867 |
-
'UG' => __('Uganda','ultimate-member'),
|
1868 |
-
'UA' => __('Ukraine','ultimate-member'),
|
1869 |
-
'AE' => __('United Arab Emirates','ultimate-member'),
|
1870 |
-
'GB' => __('United Kingdom','ultimate-member'),
|
1871 |
-
'US' => __('United States','ultimate-member'),
|
1872 |
-
'UM' => __('United States Minor Outlying Islands','ultimate-member'),
|
1873 |
-
'UY' => __('Uruguay','ultimate-member'),
|
1874 |
-
'UZ' => __('Uzbekistan','ultimate-member'),
|
1875 |
-
'VU' => __('Vanuatu','ultimate-member'),
|
1876 |
-
'VE' => __('Venezuela, Bolivarian Republic of','ultimate-member'),
|
1877 |
-
'VN' => __('Viet Nam','ultimate-member'),
|
1878 |
-
'VG' => __('Virgin Islands, British','ultimate-member'),
|
1879 |
-
'VI' => __('Virgin Islands, U.S.','ultimate-member'),
|
1880 |
-
'WF' => __('Wallis and Futuna','ultimate-member'),
|
1881 |
-
'EH' => __('Western Sahara','ultimate-member'),
|
1882 |
-
'YE' => __('Yemen','ultimate-member'),
|
1883 |
-
'ZM' => __('Zambia','ultimate-member'),
|
1884 |
-
'ZW' => __('Zimbabwe','ultimate-member'),
|
1885 |
-
);
|
1886 |
-
break;
|
1887 |
-
|
1888 |
-
}
|
1889 |
-
|
1890 |
-
/**
|
1891 |
-
* UM hook
|
1892 |
-
*
|
1893 |
-
* @type filter
|
1894 |
-
* @title um_{$data}_predefined_field_options
|
1895 |
-
* @description Extend Predefined Fields options. Where $data - field key.
|
1896 |
-
* @input_vars
|
1897 |
-
* [{"var":"$options","type":"array","desc":"Field's Options"}]
|
1898 |
-
* @change_log
|
1899 |
-
* ["Since: 2.0"]
|
1900 |
-
* @usage add_filter( 'um_{$data}_predefined_field_options', 'function_name', 10, 1 );
|
1901 |
-
* @example
|
1902 |
-
* <?php
|
1903 |
-
* add_filter( 'um_{$data}_predefined_field_options', 'my_predefined_field', 10, 1 );
|
1904 |
-
* function my_predefined_field( $options ) {
|
1905 |
-
* // your code here
|
1906 |
-
* return $options;
|
1907 |
-
* }
|
1908 |
-
* ?>
|
1909 |
-
*/
|
1910 |
-
$array = apply_filters( "um_{$data}_predefined_field_options", $array );
|
1911 |
-
return $array;
|
1912 |
-
}
|
1913 |
-
|
1914 |
-
}
|
1915 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
// Exit if accessed directly
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
if ( ! class_exists( 'um\core\Builtin' ) ) {
|
8 |
+
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Builtin
|
12 |
+
* @package um\core
|
13 |
+
*/
|
14 |
+
class Builtin {
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var array
|
19 |
+
*/
|
20 |
+
public $predefined_fields = array();
|
21 |
+
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
var $all_user_fields = array();
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @var array
|
31 |
+
*/
|
32 |
+
var $core_fields = array();
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Builtin constructor.
|
37 |
+
*/
|
38 |
+
function __construct() {
|
39 |
+
add_action( 'init', array( &$this, 'set_core_fields' ), 1 );
|
40 |
+
add_action( 'init', array( &$this, 'set_predefined_fields' ), 1 );
|
41 |
+
add_action( 'init', array( &$this, 'set_custom_fields' ), 1 );
|
42 |
+
$this->saved_fields = get_option( 'um_fields' );
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @return array
|
48 |
+
*/
|
49 |
+
function get_all_user_fields() {
|
50 |
+
return apply_filters( 'um_builtin_all_user_fields', $this->all_user_fields );
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Regular or multi-select/options
|
56 |
+
*
|
57 |
+
* @param $field
|
58 |
+
* @param $attrs
|
59 |
+
*
|
60 |
+
* @return bool
|
61 |
+
*/
|
62 |
+
function is_dropdown_field( $field, $attrs ) {
|
63 |
+
|
64 |
+
if ( isset( $attrs['options'] ) ) {
|
65 |
+
return true;
|
66 |
+
}
|
67 |
+
|
68 |
+
$fields = $this->all_user_fields;
|
69 |
+
|
70 |
+
if ( isset( $fields[$field]['options'] ) || ! empty( $fields[$field]['custom_dropdown_options_source'] ) ) {
|
71 |
+
return true;
|
72 |
+
}
|
73 |
+
|
74 |
+
return false;
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Get a field
|
80 |
+
*
|
81 |
+
* @param $field
|
82 |
+
*
|
83 |
+
* @return mixed|string
|
84 |
+
*/
|
85 |
+
function get_a_field( $field ) {
|
86 |
+
$fields = $this->all_user_fields;
|
87 |
+
if ( isset( $fields[ $field ] ) ) {
|
88 |
+
return $fields[ $field ];
|
89 |
+
}
|
90 |
+
return '';
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Get specific fields
|
96 |
+
*
|
97 |
+
* @param $fields
|
98 |
+
*
|
99 |
+
* @return array
|
100 |
+
*/
|
101 |
+
function get_specific_fields( $fields ) {
|
102 |
+
$fields = explode( ',', $fields );
|
103 |
+
$array = array();
|
104 |
+
foreach ( $fields as $field ) {
|
105 |
+
if ( isset( $this->predefined_fields[ $field ] ) ) {
|
106 |
+
$array[ $field ] = $this->predefined_fields[ $field ];
|
107 |
+
}
|
108 |
+
}
|
109 |
+
return $array;
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Get specific field
|
115 |
+
*
|
116 |
+
* @param $fields
|
117 |
+
*
|
118 |
+
* @return array|mixed
|
119 |
+
*/
|
120 |
+
function get_specific_field( $fields ) {
|
121 |
+
$fields = explode( ',', $fields );
|
122 |
+
$array = array();
|
123 |
+
foreach ( $fields as $field ) {
|
124 |
+
if ( isset( $this->predefined_fields[ $field ] ) ) {
|
125 |
+
$array = $this->predefined_fields[ $field ];
|
126 |
+
} elseif ( isset( $this->saved_fields[ $field ] ) ) {
|
127 |
+
$array = $this->saved_fields[ $field ];
|
128 |
+
}
|
129 |
+
}
|
130 |
+
return $array;
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Checks for a unique field error
|
136 |
+
*
|
137 |
+
* @param $key
|
138 |
+
*
|
139 |
+
* @return int|string
|
140 |
+
*/
|
141 |
+
function unique_field_err( $key ) {
|
142 |
+
if ( empty( $key ) ) {
|
143 |
+
return __( 'Please provide a meta key', 'ultimate-member' );
|
144 |
+
}
|
145 |
+
if ( isset( $this->core_fields[ $key ] ) ) {
|
146 |
+
return __( 'Your meta key is a reserved core field and cannot be used', 'ultimate-member' );
|
147 |
+
}
|
148 |
+
if ( isset( $this->predefined_fields[ $key ] ) ) {
|
149 |
+
return __( 'Your meta key is a predefined reserved key and cannot be used', 'ultimate-member' );
|
150 |
+
}
|
151 |
+
if ( isset( $this->saved_fields[ $key ] ) ) {
|
152 |
+
return __( 'Your meta key already exists in your fields list', 'ultimate-member' );
|
153 |
+
}
|
154 |
+
if ( ! UM()->validation()->safe_string( $key ) ) {
|
155 |
+
return __( 'Your meta key contains illegal characters. Please correct it.', 'ultimate-member' );
|
156 |
+
}
|
157 |
+
|
158 |
+
return 0;
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Check date range errors (start date)
|
164 |
+
*
|
165 |
+
* @param $date
|
166 |
+
*
|
167 |
+
* @return int|string
|
168 |
+
*/
|
169 |
+
function date_range_start_err( $date ) {
|
170 |
+
if ( empty( $date ) ) {
|
171 |
+
return __( 'Please provide a date range beginning', 'ultimate-member' );
|
172 |
+
}
|
173 |
+
if ( ! UM()->validation()->validate_date( $date ) ) {
|
174 |
+
return __( 'Please enter a valid start date in the date range', 'ultimate-member' );
|
175 |
+
}
|
176 |
+
|
177 |
+
return 0;
|
178 |
+
}
|
179 |
+
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Check date range errors (end date)
|
183 |
+
*
|
184 |
+
* @param $date
|
185 |
+
* @param $start_date
|
186 |
+
*
|
187 |
+
* @return int|string
|
188 |
+
*/
|
189 |
+
function date_range_end_err( $date, $start_date ) {
|
190 |
+
if ( empty( $date ) ) {
|
191 |
+
return __( 'Please provide a date range end', 'ultimate-member' );
|
192 |
+
}
|
193 |
+
if ( ! UM()->validation()->validate_date( $date ) ) {
|
194 |
+
return __( 'Please enter a valid end date in the date range', 'ultimate-member' );
|
195 |
+
}
|
196 |
+
if ( strtotime( $date ) <= strtotime( $start_date ) ) {
|
197 |
+
return __( 'The end of date range must be greater than the start of date range', 'ultimate-member' );
|
198 |
+
}
|
199 |
+
return 0;
|
200 |
+
}
|
201 |
+
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Get a core field attrs
|
205 |
+
*
|
206 |
+
* @param $type
|
207 |
+
*
|
208 |
+
* @return array|mixed
|
209 |
+
*/
|
210 |
+
function get_core_field_attrs( $type ) {
|
211 |
+
return ( isset( $this->core_fields[ $type ] ) ) ? $this->core_fields[ $type ] : array('');
|
212 |
+
}
|
213 |
+
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Core Fields
|
217 |
+
*/
|
218 |
+
function set_core_fields() {
|
219 |
+
|
220 |
+
$this->core_fields = array(
|
221 |
+
|
222 |
+
'row' => array(
|
223 |
+
'name' => 'Row',
|
224 |
+
'in_fields' => false,
|
225 |
+
'form_only' => true,
|
226 |
+
'conditional_support' => 0,
|
227 |
+
'icon' => 'um-faicon-pencil',
|
228 |
+
'col1' => array('_id','_background','_text_color','_padding','_margin','_border','_borderradius','_borderstyle','_bordercolor'),
|
229 |
+
'col2' => array('_heading','_heading_text','_heading_background_color','_heading_text_color','_icon','_icon_color','_css_class'),
|
230 |
+
),
|
231 |
+
|
232 |
+
'text' => array(
|
233 |
+
'name' => 'Text Box',
|
234 |
+
'col1' => array('_title','_metakey','_help','_default','_min_chars','_visibility'),
|
235 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max_chars'),
|
236 |
+
'col3' => array('_required','_editable','_icon'),
|
237 |
+
'validate' => array(
|
238 |
+
'_title' => array(
|
239 |
+
'mode' => 'required',
|
240 |
+
'error' => __('You must provide a title','ultimate-member')
|
241 |
+
),
|
242 |
+
'_metakey' => array(
|
243 |
+
'mode' => 'unique',
|
244 |
+
),
|
245 |
+
)
|
246 |
+
),
|
247 |
+
|
248 |
+
'number' => array(
|
249 |
+
'name' => __('Number','ultimate-member'),
|
250 |
+
'col1' => array('_title','_metakey','_help','_default','_min','_visibility'),
|
251 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max'),
|
252 |
+
'col3' => array('_required','_editable','_icon'),
|
253 |
+
'validate' => array(
|
254 |
+
'_title' => array(
|
255 |
+
'mode' => 'required',
|
256 |
+
'error' => __('You must provide a title','ultimate-member')
|
257 |
+
),
|
258 |
+
'_metakey' => array(
|
259 |
+
'mode' => 'unique',
|
260 |
+
),
|
261 |
+
)
|
262 |
+
),
|
263 |
+
|
264 |
+
'textarea' => array(
|
265 |
+
'name' => 'Textarea',
|
266 |
+
'col1' => array('_title','_metakey','_help','_height','_max_chars','_max_words','_visibility'),
|
267 |
+
'col2' => array('_label','_placeholder','_public','_roles','_default','_html'),
|
268 |
+
'col3' => array('_required','_editable','_icon'),
|
269 |
+
'validate' => array(
|
270 |
+
'_title' => array(
|
271 |
+
'mode' => 'required',
|
272 |
+
'error' => __('You must provide a title','ultimate-member')
|
273 |
+
),
|
274 |
+
'_metakey' => array(
|
275 |
+
'mode' => 'unique',
|
276 |
+
),
|
277 |
+
)
|
278 |
+
),
|
279 |
+
|
280 |
+
'select' => array(
|
281 |
+
'name' => 'Dropdown',
|
282 |
+
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
283 |
+
'col2' => array('_label','_placeholder','_public','_roles','_custom_dropdown_options_source','_parent_dropdown_relationship'),
|
284 |
+
'col3' => array('_required','_editable','_icon'),
|
285 |
+
'validate' => array(
|
286 |
+
'_title' => array(
|
287 |
+
'mode' => 'required',
|
288 |
+
'error' => __('You must provide a title','ultimate-member')
|
289 |
+
),
|
290 |
+
'_metakey' => array(
|
291 |
+
'mode' => 'unique',
|
292 |
+
),
|
293 |
+
'_options' => array(
|
294 |
+
'mode' => 'required',
|
295 |
+
'error' => __('You have not added any choices yet.','ultimate-member')
|
296 |
+
),
|
297 |
+
)
|
298 |
+
),
|
299 |
+
|
300 |
+
'multiselect' => array(
|
301 |
+
'name' => 'Multi-Select',
|
302 |
+
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
303 |
+
'col2' => array('_label','_placeholder','_public','_roles','_min_selections','_max_selections','_custom_dropdown_options_source'),
|
304 |
+
'col3' => array('_required','_editable','_icon'),
|
305 |
+
'validate' => array(
|
306 |
+
'_title' => array(
|
307 |
+
'mode' => 'required',
|
308 |
+
'error' => __('You must provide a title','ultimate-member')
|
309 |
+
),
|
310 |
+
'_metakey' => array(
|
311 |
+
'mode' => 'unique',
|
312 |
+
),
|
313 |
+
'_options' => array(
|
314 |
+
'mode' => 'required',
|
315 |
+
'error' => __('You have not added any choices yet.','ultimate-member')
|
316 |
+
),
|
317 |
+
)
|
318 |
+
),
|
319 |
+
|
320 |
+
'radio' => array(
|
321 |
+
'name' => 'Radio',
|
322 |
+
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
323 |
+
'col2' => array('_label','_public','_roles'),
|
324 |
+
'col3' => array('_required','_editable','_icon'),
|
325 |
+
'validate' => array(
|
326 |
+
'_title' => array(
|
327 |
+
'mode' => 'required',
|
328 |
+
'error' => __('You must provide a title','ultimate-member')
|
329 |
+
),
|
330 |
+
'_metakey' => array(
|
331 |
+
'mode' => 'unique',
|
332 |
+
),
|
333 |
+
'_options' => array(
|
334 |
+
'mode' => 'required',
|
335 |
+
'error' => __('You have not added any choices yet.','ultimate-member')
|
336 |
+
),
|
337 |
+
)
|
338 |
+
),
|
339 |
+
|
340 |
+
'checkbox' => array(
|
341 |
+
'name' => 'Checkbox',
|
342 |
+
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
343 |
+
'col2' => array('_label','_public','_roles','_max_selections'),
|
344 |
+
'col3' => array('_required','_editable','_icon'),
|
345 |
+
'validate' => array(
|
346 |
+
'_title' => array(
|
347 |
+
'mode' => 'required',
|
348 |
+
'error' => __('You must provide a title','ultimate-member')
|
349 |
+
),
|
350 |
+
'_metakey' => array(
|
351 |
+
'mode' => 'unique',
|
352 |
+
),
|
353 |
+
'_options' => array(
|
354 |
+
'mode' => 'required',
|
355 |
+
'error' => __('You have not added any choices yet.','ultimate-member')
|
356 |
+
),
|
357 |
+
)
|
358 |
+
),
|
359 |
+
|
360 |
+
'url' => array(
|
361 |
+
'name' => 'URL',
|
362 |
+
'col1' => array('_title','_metakey','_help','_default','_url_text','_visibility'),
|
363 |
+
'col2' => array('_label','_placeholder','_url_target','_url_rel','_public','_roles','_validate','_custom_validate'),
|
364 |
+
'col3' => array('_required','_editable','_icon'),
|
365 |
+
'validate' => array(
|
366 |
+
'_title' => array(
|
367 |
+
'mode' => 'required',
|
368 |
+
'error' => __('You must provide a title','ultimate-member')
|
369 |
+
),
|
370 |
+
'_metakey' => array(
|
371 |
+
'mode' => 'unique',
|
372 |
+
),
|
373 |
+
)
|
374 |
+
),
|
375 |
+
|
376 |
+
'password' => array(
|
377 |
+
'name' => 'Password',
|
378 |
+
'col1' => array('_title','_metakey','_help','_min_chars','_max_chars','_visibility'),
|
379 |
+
'col2' => array('_label','_placeholder','_public','_roles','_force_good_pass','_force_confirm_pass','_label_confirm_pass'),
|
380 |
+
'col3' => array('_required','_editable','_icon'),
|
381 |
+
'validate' => array(
|
382 |
+
'_title' => array(
|
383 |
+
'mode' => 'required',
|
384 |
+
'error' => __('You must provide a title','ultimate-member')
|
385 |
+
),
|
386 |
+
'_metakey' => array(
|
387 |
+
'mode' => 'unique',
|
388 |
+
),
|
389 |
+
)
|
390 |
+
),
|
391 |
+
|
392 |
+
'image' => array(
|
393 |
+
'name' => 'Image Upload',
|
394 |
+
'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_crop','_visibility'),
|
395 |
+
'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
|
396 |
+
'col3' => array('_required','_editable','_icon'),
|
397 |
+
'validate' => array(
|
398 |
+
'_title' => array(
|
399 |
+
'mode' => 'required',
|
400 |
+
'error' => __('You must provide a title','ultimate-member')
|
401 |
+
),
|
402 |
+
'_metakey' => array(
|
403 |
+
'mode' => 'unique',
|
404 |
+
),
|
405 |
+
'_max_size' => array(
|
406 |
+
'mode' => 'numeric',
|
407 |
+
'error' => __('Please enter a valid size','ultimate-member')
|
408 |
+
),
|
409 |
+
)
|
410 |
+
),
|
411 |
+
|
412 |
+
'file' => array(
|
413 |
+
'name' => 'File Upload',
|
414 |
+
'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_visibility'),
|
415 |
+
'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
|
416 |
+
'col3' => array('_required','_editable','_icon'),
|
417 |
+
'validate' => array(
|
418 |
+
'_title' => array(
|
419 |
+
'mode' => 'required',
|
420 |
+
'error' => __('You must provide a title','ultimate-member')
|
421 |
+
),
|
422 |
+
'_metakey' => array(
|
423 |
+
'mode' => 'unique',
|
424 |
+
),
|
425 |
+
'_max_size' => array(
|
426 |
+
'mode' => 'numeric',
|
427 |
+
'error' => __( 'Please enter a valid size', 'ultimate-member' )
|
428 |
+
),
|
429 |
+
)
|
430 |
+
),
|
431 |
+
|
432 |
+
'date' => array(
|
433 |
+
'name' => 'Date Picker',
|
434 |
+
'col1' => array( '_title', '_metakey', '_help', '_default', '_range', '_years', '_years_x', '_range_start', '_range_end', '_visibility' ),
|
435 |
+
'col2' => array( '_label', '_placeholder', '_public', '_roles', '_format', '_format_custom', '_pretty_format', '_disabled_weekdays' ),
|
436 |
+
'col3' => array( '_required', '_editable', '_icon' ),
|
437 |
+
'validate' => array(
|
438 |
+
'_title' => array(
|
439 |
+
'mode' => 'required',
|
440 |
+
'error' => __( 'You must provide a title', 'ultimate-member' )
|
441 |
+
),
|
442 |
+
'_metakey' => array(
|
443 |
+
'mode' => 'unique',
|
444 |
+
),
|
445 |
+
'_years' => array(
|
446 |
+
'mode' => 'numeric',
|
447 |
+
'error' => __( 'Number of years is not valid', 'ultimate-member' )
|
448 |
+
),
|
449 |
+
'_range_start' => array(
|
450 |
+
'mode' => 'range-start',
|
451 |
+
),
|
452 |
+
'_range_end' => array(
|
453 |
+
'mode' => 'range-end',
|
454 |
+
),
|
455 |
+
)
|
456 |
+
),
|
457 |
+
|
458 |
+
'time' => array(
|
459 |
+
'name' => 'Time Picker',
|
460 |
+
'col1' => array('_title','_metakey','_help','_format','_visibility'),
|
461 |
+
'col2' => array('_label','_placeholder','_default','_public','_roles','_intervals'),
|
462 |
+
'col3' => array('_required','_editable','_icon'),
|
463 |
+
'validate' => array(
|
464 |
+
'_title' => array(
|
465 |
+
'mode' => 'required',
|
466 |
+
'error' => __( 'You must provide a title', 'ultimate-member' )
|
467 |
+
),
|
468 |
+
'_metakey' => array(
|
469 |
+
'mode' => 'unique',
|
470 |
+
),
|
471 |
+
)
|
472 |
+
),
|
473 |
+
|
474 |
+
'rating' => array(
|
475 |
+
'name' => 'Rating',
|
476 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
477 |
+
'col2' => array('_label','_public','_roles','_number','_default'),
|
478 |
+
'col3' => array('_required','_editable','_icon'),
|
479 |
+
'validate' => array(
|
480 |
+
'_title' => array(
|
481 |
+
'mode' => 'required',
|
482 |
+
'error' => __('You must provide a title','ultimate-member')
|
483 |
+
),
|
484 |
+
'_metakey' => array(
|
485 |
+
'mode' => 'unique',
|
486 |
+
),
|
487 |
+
)
|
488 |
+
),
|
489 |
+
|
490 |
+
'block' => array(
|
491 |
+
'name' => 'Content Block',
|
492 |
+
'col1' => array('_title','_visibility'),
|
493 |
+
'col2' => array('_public','_roles'),
|
494 |
+
'col_full' => array('_content'),
|
495 |
+
'mce_content' => true,
|
496 |
+
'validate' => array(
|
497 |
+
'_title' => array(
|
498 |
+
'mode' => 'required',
|
499 |
+
'error' => __('You must provide a title','ultimate-member')
|
500 |
+
),
|
501 |
+
)
|
502 |
+
),
|
503 |
+
|
504 |
+
'shortcode' => array(
|
505 |
+
'name' => 'Shortcode',
|
506 |
+
'col1' => array('_title','_visibility'),
|
507 |
+
'col2' => array('_public','_roles'),
|
508 |
+
'col_full' => array('_content'),
|
509 |
+
'validate' => array(
|
510 |
+
'_title' => array(
|
511 |
+
'mode' => 'required',
|
512 |
+
'error' => __('You must provide a title','ultimate-member')
|
513 |
+
),
|
514 |
+
'_content' => array(
|
515 |
+
'mode' => 'required',
|
516 |
+
'error' => __('You must add a shortcode to the content area','ultimate-member')
|
517 |
+
),
|
518 |
+
)
|
519 |
+
),
|
520 |
+
|
521 |
+
'spacing' => array(
|
522 |
+
'name' => 'Spacing',
|
523 |
+
'col1' => array('_title','_visibility'),
|
524 |
+
'col2' => array('_spacing'),
|
525 |
+
'form_only' => true,
|
526 |
+
'validate' => array(
|
527 |
+
'_title' => array(
|
528 |
+
'mode' => 'required',
|
529 |
+
'error' => __('You must provide a title','ultimate-member')
|
530 |
+
),
|
531 |
+
)
|
532 |
+
),
|
533 |
+
|
534 |
+
'divider' => array(
|
535 |
+
'name' => 'Divider',
|
536 |
+
'col1' => array('_title','_width','_divider_text','_visibility'),
|
537 |
+
'col2' => array('_style','_color','_public','_roles'),
|
538 |
+
'form_only' => true,
|
539 |
+
'validate' => array(
|
540 |
+
'_title' => array(
|
541 |
+
'mode' => 'required',
|
542 |
+
'error' => __('You must provide a title','ultimate-member')
|
543 |
+
),
|
544 |
+
)
|
545 |
+
),
|
546 |
+
|
547 |
+
'googlemap' => array(
|
548 |
+
'name' => 'Google Map',
|
549 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
550 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
551 |
+
'col3' => array('_required','_editable','_icon'),
|
552 |
+
'validate' => array(
|
553 |
+
'_title' => array(
|
554 |
+
'mode' => 'required',
|
555 |
+
'error' => __('You must provide a title','ultimate-member')
|
556 |
+
),
|
557 |
+
'_metakey' => array(
|
558 |
+
'mode' => 'unique',
|
559 |
+
),
|
560 |
+
)
|
561 |
+
),
|
562 |
+
|
563 |
+
'youtube_video' => array(
|
564 |
+
'name' => 'YouTube Video',
|
565 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
566 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
567 |
+
'col3' => array('_required','_editable','_icon'),
|
568 |
+
'validate' => array(
|
569 |
+
'_title' => array(
|
570 |
+
'mode' => 'required',
|
571 |
+
'error' => __('You must provide a title','ultimate-member')
|
572 |
+
),
|
573 |
+
'_metakey' => array(
|
574 |
+
'mode' => 'unique',
|
575 |
+
),
|
576 |
+
)
|
577 |
+
),
|
578 |
+
|
579 |
+
'vimeo_video' => array(
|
580 |
+
'name' => 'Vimeo Video',
|
581 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
582 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
583 |
+
'col3' => array('_required','_editable','_icon'),
|
584 |
+
'validate' => array(
|
585 |
+
'_title' => array(
|
586 |
+
'mode' => 'required',
|
587 |
+
'error' => __('You must provide a title','ultimate-member')
|
588 |
+
),
|
589 |
+
'_metakey' => array(
|
590 |
+
'mode' => 'unique',
|
591 |
+
),
|
592 |
+
)
|
593 |
+
),
|
594 |
+
|
595 |
+
'soundcloud_track' => array(
|
596 |
+
'name' => 'SoundCloud Track',
|
597 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
598 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
599 |
+
'col3' => array('_required','_editable','_icon'),
|
600 |
+
'validate' => array(
|
601 |
+
'_title' => array(
|
602 |
+
'mode' => 'required',
|
603 |
+
'error' => __('You must provide a title','ultimate-member')
|
604 |
+
),
|
605 |
+
'_metakey' => array(
|
606 |
+
'mode' => 'unique',
|
607 |
+
),
|
608 |
+
)
|
609 |
+
),
|
610 |
+
|
611 |
+
/*'group' => array(
|
612 |
+
'name' => 'Field Group',
|
613 |
+
'col1' => array('_title','_max_entries'),
|
614 |
+
'col2' => array('_label','_public','_roles'),
|
615 |
+
'form_only' => true,
|
616 |
+
'validate' => array(
|
617 |
+
'_title' => array(
|
618 |
+
'mode' => 'required',
|
619 |
+
'error' => 'You must provide a title'
|
620 |
+
),
|
621 |
+
'_label' => array(
|
622 |
+
'mode' => 'required',
|
623 |
+
'error' => 'You must provide a label'
|
624 |
+
),
|
625 |
+
)
|
626 |
+
),*/
|
627 |
+
|
628 |
+
);
|
629 |
+
|
630 |
+
/**
|
631 |
+
* UM hook
|
632 |
+
*
|
633 |
+
* @type filter
|
634 |
+
* @title um_core_fields_hook
|
635 |
+
* @description UM Core Fields
|
636 |
+
* @input_vars
|
637 |
+
* [{"var":"$core_fields","type":"array","desc":"Core Fields"}]
|
638 |
+
* @change_log
|
639 |
+
* ["Since: 2.0"]
|
640 |
+
* @usage add_filter( 'um_core_fields_hook', 'function_name', 10, 1 );
|
641 |
+
* @example
|
642 |
+
* <?php
|
643 |
+
* add_filter( 'um_core_fields_hook', 'my_core_fields', 10, 1 );
|
644 |
+
* function my_core_fields( $core_fields ) {
|
645 |
+
* // your code here
|
646 |
+
* return $core_fields;
|
647 |
+
* }
|
648 |
+
* ?>
|
649 |
+
*/
|
650 |
+
$this->core_fields = apply_filters( 'um_core_fields_hook', $this->core_fields );
|
651 |
+
}
|
652 |
+
|
653 |
+
|
654 |
+
/**
|
655 |
+
* Predefined Fields
|
656 |
+
*/
|
657 |
+
function set_predefined_fields() {
|
658 |
+
|
659 |
+
global $wp_roles;
|
660 |
+
$role_keys = get_option( 'um_roles', array() );
|
661 |
+
if ( ! empty( $role_keys ) && is_array( $role_keys ) ) {
|
662 |
+
$role_keys = array_map( function( $item ) {
|
663 |
+
return 'um_' . $item;
|
664 |
+
}, $role_keys );
|
665 |
+
} else {
|
666 |
+
$role_keys = array();
|
667 |
+
}
|
668 |
+
|
669 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
670 |
+
|
671 |
+
$um_roles = UM()->roles()->get_roles( false, $exclude_roles );
|
672 |
+
|
673 |
+
/**
|
674 |
+
* UM hook
|
675 |
+
*
|
676 |
+
* @type filter
|
677 |
+
* @title um_profile_privacy_options
|
678 |
+
* @description Profile Privacy Options
|
679 |
+
* @input_vars
|
680 |
+
* [{"var":"$privacy_options","type":"array","desc":"Privacy Options"}]
|
681 |
+
* @change_log
|
682 |
+
* ["Since: 2.0"]
|
683 |
+
* @usage add_filter( 'um_profile_privacy_options', 'function_name', 10, 1 );
|
684 |
+
* @example
|
685 |
+
* <?php
|
686 |
+
* add_filter( 'um_profile_privacy_options', 'my_profile_privacy_options', 10, 1 );
|
687 |
+
* function my_profile_privacy_options( $privacy_options ) {
|
688 |
+
* // your code here
|
689 |
+
* return $privacy_options;
|
690 |
+
* }
|
691 |
+
* ?>
|
692 |
+
*/
|
693 |
+
$profile_privacy = apply_filters( 'um_profile_privacy_options', array(
|
694 |
+
'Everyone' => __( 'Everyone', 'ultimate-member' ),
|
695 |
+
'Only me' => __( 'Only me', 'ultimate-member' )
|
696 |
+
) );
|
697 |
+
|
698 |
+
/*
|
699 |
+
* it's important create key for array equals value of 'metakey'.
|
700 |
+
*
|
701 |
+
*/
|
702 |
+
|
703 |
+
$this->predefined_fields = array(
|
704 |
+
|
705 |
+
'user_login' => array(
|
706 |
+
'title' => __('Username','ultimate-member'),
|
707 |
+
'metakey' => 'user_login',
|
708 |
+
'type' => 'text',
|
709 |
+
'label' => __('Username','ultimate-member'),
|
710 |
+
'required' => 1,
|
711 |
+
'public' => 1,
|
712 |
+
'editable' => 0,
|
713 |
+
'validate' => 'unique_username',
|
714 |
+
'min_chars' => 3,
|
715 |
+
'max_chars' => 24
|
716 |
+
),
|
717 |
+
|
718 |
+
'username' => array(
|
719 |
+
'title' => __('Username or E-mail','ultimate-member'),
|
720 |
+
'metakey' => 'username',
|
721 |
+
'type' => 'text',
|
722 |
+
'label' => __('Username or E-mail','ultimate-member'),
|
723 |
+
'required' => 1,
|
724 |
+
'public' => 1,
|
725 |
+
'editable' => 0,
|
726 |
+
'validate' => 'unique_username_or_email',
|
727 |
+
),
|
728 |
+
|
729 |
+
'user_password' => array(
|
730 |
+
'title' => __('Password','ultimate-member'),
|
731 |
+
'metakey' => 'user_password',
|
732 |
+
'type' => 'password',
|
733 |
+
'label' => __('Password','ultimate-member'),
|
734 |
+
'required' => 1,
|
735 |
+
'public' => 1,
|
736 |
+
'editable' => 1,
|
737 |
+
'min_chars' => 8,
|
738 |
+
'max_chars' => 30,
|
739 |
+
'force_good_pass' => 1,
|
740 |
+
'force_confirm_pass' => 1,
|
741 |
+
'label_confirm_pass' => __('Confirm Password','ultimate-member')
|
742 |
+
),
|
743 |
+
|
744 |
+
'first_name' => array(
|
745 |
+
'title' => __('First Name','ultimate-member'),
|
746 |
+
'metakey' => 'first_name',
|
747 |
+
'type' => 'text',
|
748 |
+
'label' => __('First Name','ultimate-member'),
|
749 |
+
'required' => 0,
|
750 |
+
'public' => 1,
|
751 |
+
'editable' => 1,
|
752 |
+
),
|
753 |
+
|
754 |
+
'last_name' => array(
|
755 |
+
'title' => __('Last Name','ultimate-member'),
|
756 |
+
'metakey' => 'last_name',
|
757 |
+
'type' => 'text',
|
758 |
+
'label' => __('Last Name','ultimate-member'),
|
759 |
+
'required' => 0,
|
760 |
+
'public' => 1,
|
761 |
+
'editable' => 1,
|
762 |
+
),
|
763 |
+
|
764 |
+
'nickname' => array(
|
765 |
+
'title' => __('Nickname','ultimate-member'),
|
766 |
+
'metakey' => 'nickname',
|
767 |
+
'type' => 'text',
|
768 |
+
'label' => __('Nickname','ultimate-member'),
|
769 |
+
'required' => 0,
|
770 |
+
'public' => 1,
|
771 |
+
'editable' => 1,
|
772 |
+
),
|
773 |
+
|
774 |
+
'user_url' => array(
|
775 |
+
'title' => __('Website URL','ultimate-member'),
|
776 |
+
'metakey' => 'user_url',
|
777 |
+
'type' => 'url',
|
778 |
+
'label' => __('Website URL','ultimate-member'),
|
779 |
+
'required' => 1,
|
780 |
+
'public' => 1,
|
781 |
+
'editable' => 1,
|
782 |
+
'validate' => 'url'
|
783 |
+
),
|
784 |
+
|
785 |
+
'user_registered' => array(
|
786 |
+
'title' => __('Registration Date','ultimate-member'),
|
787 |
+
'metakey' => 'user_registered',
|
788 |
+
'type' => 'text',
|
789 |
+
'label' => __('Registration Date','ultimate-member'),
|
790 |
+
'required' => 0,
|
791 |
+
'public' => 1,
|
792 |
+
'editable' => 1,
|
793 |
+
'edit_forbidden' => 1,
|
794 |
+
),
|
795 |
+
|
796 |
+
'_um_last_login' => array(
|
797 |
+
'title' => __('Last Login','ultimate-member'),
|
798 |
+
'metakey' => '_um_last_login',
|
799 |
+
'type' => 'text',
|
800 |
+
'label' => __('Last Login','ultimate-member'),
|
801 |
+
'required' => 0,
|
802 |
+
'public' => 1,
|
803 |
+
'editable' => 1,
|
804 |
+
'edit_forbidden' => 1,
|
805 |
+
),
|
806 |
+
|
807 |
+
'user_email' => array(
|
808 |
+
'title' => __('E-mail Address','ultimate-member'),
|
809 |
+
'metakey' => 'user_email',
|
810 |
+
'type' => 'text',
|
811 |
+
'label' => __('E-mail Address','ultimate-member'),
|
812 |
+
'required' => 0,
|
813 |
+
'public' => 1,
|
814 |
+
'validate' => 'unique_email',
|
815 |
+
'autocomplete' => 'off'
|
816 |
+
),
|
817 |
+
|
818 |
+
'secondary_user_email' => array(
|
819 |
+
'title' => __('Secondary E-mail Address','ultimate-member'),
|
820 |
+
'metakey' => 'secondary_user_email',
|
821 |
+
'type' => 'text',
|
822 |
+
'label' => __('Secondary E-mail Address','ultimate-member'),
|
823 |
+
'required' => 0,
|
824 |
+
'public' => 1,
|
825 |
+
'editable' => 1,
|
826 |
+
'validate' => 'unique_email',
|
827 |
+
'autocomplete' => 'off'
|
828 |
+
),
|
829 |
+
|
830 |
+
'description' => array(
|
831 |
+
'title' => __('Biography','ultimate-member'),
|
832 |
+
'metakey' => 'description',
|
833 |
+
'type' => 'textarea',
|
834 |
+
'label' => __('Biography','ultimate-member'),
|
835 |
+
'html' => 0,
|
836 |
+
'required' => 0,
|
837 |
+
'public' => 1,
|
838 |
+
'editable' => 1,
|
839 |
+
'max_words' => 40,
|
840 |
+
'placeholder' => __('Enter a bit about yourself...','ultimate-member'),
|
841 |
+
),
|
842 |
+
|
843 |
+
'birth_date' => array(
|
844 |
+
'title' => __('Birth Date','ultimate-member'),
|
845 |
+
'metakey' => 'birth_date',
|
846 |
+
'type' => 'date',
|
847 |
+
'label' => __('Birth Date','ultimate-member'),
|
848 |
+
'required' => 0,
|
849 |
+
'public' => 1,
|
850 |
+
'editable' => 1,
|
851 |
+
'pretty_format' => 1,
|
852 |
+
'years' => 115,
|
853 |
+
'years_x' => 'past',
|
854 |
+
'icon' => 'um-faicon-calendar'
|
855 |
+
),
|
856 |
+
|
857 |
+
'gender' => array(
|
858 |
+
'title' => __('Gender','ultimate-member'),
|
859 |
+
'metakey' => 'gender',
|
860 |
+
'type' => 'radio',
|
861 |
+
'label' => __('Gender','ultimate-member'),
|
862 |
+
'required' => 0,
|
863 |
+
'public' => 1,
|
864 |
+
'editable' => 1,
|
865 |
+
'options' => array( __('Male','ultimate-member'), __('Female','ultimate-member') )
|
866 |
+
),
|
867 |
+
|
868 |
+
'country' => array(
|
869 |
+
'title' => __('Country','ultimate-member'),
|
870 |
+
'metakey' => 'country',
|
871 |
+
'type' => 'select',
|
872 |
+
'label' => __('Country','ultimate-member'),
|
873 |
+
'placeholder' => __('Choose a Country','ultimate-member'),
|
874 |
+
'required' => 0,
|
875 |
+
'public' => 1,
|
876 |
+
'editable' => 1,
|
877 |
+
'options' => $this->get('countries')
|
878 |
+
),
|
879 |
+
|
880 |
+
'facebook' => array(
|
881 |
+
'title' => __('Facebook','ultimate-member'),
|
882 |
+
'metakey' => 'facebook',
|
883 |
+
'type' => 'url',
|
884 |
+
'label' => __('Facebook','ultimate-member'),
|
885 |
+
'required' => 0,
|
886 |
+
'public' => 1,
|
887 |
+
'editable' => 1,
|
888 |
+
'url_target' => '_blank',
|
889 |
+
'url_rel' => 'nofollow',
|
890 |
+
'icon' => 'um-faicon-facebook',
|
891 |
+
'validate' => 'facebook_url',
|
892 |
+
'url_text' => 'Facebook',
|
893 |
+
'advanced' => 'social',
|
894 |
+
'color' => '#3B5999',
|
895 |
+
'match' => 'https://facebook.com/',
|
896 |
+
),
|
897 |
+
|
898 |
+
'twitter' => array(
|
899 |
+
'title' => __('Twitter','ultimate-member'),
|
900 |
+
'metakey' => 'twitter',
|
901 |
+
'type' => 'url',
|
902 |
+
'label' => __('Twitter','ultimate-member'),
|
903 |
+
'required' => 0,
|
904 |
+
'public' => 1,
|
905 |
+
'editable' => 1,
|
906 |
+
'url_target' => '_blank',
|
907 |
+
'url_rel' => 'nofollow',
|
908 |
+
'icon' => 'um-faicon-twitter',
|
909 |
+
'validate' => 'twitter_url',
|
910 |
+
'url_text' => 'Twitter',
|
911 |
+
'advanced' => 'social',
|
912 |
+
'color' => '#4099FF',
|
913 |
+
'match' => 'https://twitter.com/',
|
914 |
+
),
|
915 |
+
|
916 |
+
'linkedin' => array(
|
917 |
+
'title' => __('LinkedIn','ultimate-member'),
|
918 |
+
'metakey' => 'linkedin',
|
919 |
+
'type' => 'url',
|
920 |
+
'label' => __('LinkedIn','ultimate-member'),
|
921 |
+
'required' => 0,
|
922 |
+
'public' => 1,
|
923 |
+
'editable' => 1,
|
924 |
+
'url_target' => '_blank',
|
925 |
+
'url_rel' => 'nofollow',
|
926 |
+
'icon' => 'um-faicon-linkedin',
|
927 |
+
'validate' => 'linkedin_url',
|
928 |
+
'url_text' => 'LinkedIn',
|
929 |
+
'advanced' => 'social',
|
930 |
+
'color' => '#0976b4',
|
931 |
+
'match' => 'https://linkedin.com/in/',
|
932 |
+
),
|
933 |
+
|
934 |
+
'googleplus' => array(
|
935 |
+
'title' => __('Google+','ultimate-member'),
|
936 |
+
'metakey' => 'googleplus',
|
937 |
+
'type' => 'url',
|
938 |
+
'label' => __('Google+','ultimate-member'),
|
939 |
+
'required' => 0,
|
940 |
+
'public' => 1,
|
941 |
+
'editable' => 1,
|
942 |
+
'url_target' => '_blank',
|
943 |
+
'url_rel' => 'nofollow',
|
944 |
+
'icon' => 'um-faicon-google-plus',
|
945 |
+
'validate' => 'google_url',
|
946 |
+
'url_text' => 'Google+',
|
947 |
+
'advanced' => 'social',
|
948 |
+
'color' => '#dd4b39',
|
949 |
+
'match' => 'https://google.com/+',
|
950 |
+
),
|
951 |
+
|
952 |
+
'instagram' => array(
|
953 |
+
'title' => __('Instagram','ultimate-member'),
|
954 |
+
'metakey' => 'instagram',
|
955 |
+
'type' => 'url',
|
956 |
+
'label' => __('Instagram','ultimate-member'),
|
957 |
+
'required' => 0,
|
958 |
+
'public' => 1,
|
959 |
+
'editable' => 1,
|
960 |
+
'url_target' => '_blank',
|
961 |
+
'url_rel' => 'nofollow',
|
962 |
+
'icon' => 'um-faicon-instagram',
|
963 |
+
'validate' => 'instagram_url',
|
964 |
+
'url_text' => 'Instagram',
|
965 |
+
'advanced' => 'social',
|
966 |
+
'color' => 'radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%,#d6249f 60%,#285AEB 90%)',
|
967 |
+
'match' => 'https://instagram.com/',
|
968 |
+
),
|
969 |
+
|
970 |
+
'skype' => array(
|
971 |
+
'title' => __('Skype ID','ultimate-member'),
|
972 |
+
'metakey' => 'skype',
|
973 |
+
'type' => 'url',
|
974 |
+
'label' => __('Skype ID','ultimate-member'),
|
975 |
+
'required' => 0,
|
976 |
+
'public' => 1,
|
977 |
+
'editable' => 1,
|
978 |
+
'url_target' => '_blank',
|
979 |
+
'url_rel' => 'nofollow',
|
980 |
+
'icon' => 'um-faicon-skype',
|
981 |
+
'validate' => 'skype',
|
982 |
+
'url_text' => 'Skype',
|
983 |
+
),
|
984 |
+
|
985 |
+
'youtube' => array(
|
986 |
+
'title' => __('YouTube','ultimate-member'),
|
987 |
+
'metakey' => 'youtube',
|
988 |
+
'type' => 'url',
|
989 |
+
'label' => __('YouTube','ultimate-member'),
|
990 |
+
'required' => 0,
|
991 |
+
'public' => 1,
|
992 |
+
'editable' => 1,
|
993 |
+
'url_target' => '_blank',
|
994 |
+
'url_rel' => 'nofollow',
|
995 |
+
'icon' => 'um-faicon-youtube',
|
996 |
+
'validate' => 'youtube_url',
|
997 |
+
'url_text' => 'YouTube',
|
998 |
+
'advanced' => 'social',
|
999 |
+
'color' => '#e52d27',
|
1000 |
+
'match' => 'https://youtube.com/',
|
1001 |
+
),
|
1002 |
+
|
1003 |
+
'soundcloud' => array(
|
1004 |
+
'title' => __('SoundCloud','ultimate-member'),
|
1005 |
+
'metakey' => 'soundcloud',
|
1006 |
+
'type' => 'url',
|
1007 |
+
'label' => __('SoundCloud','ultimate-member'),
|
1008 |
+
'required' => 0,
|
1009 |
+
'public' => 1,
|
1010 |
+
'editable' => 1,
|
1011 |
+
'url_target' => '_blank',
|
1012 |
+
'url_rel' => 'nofollow',
|
1013 |
+
'icon' => 'um-faicon-soundcloud',
|
1014 |
+
'validate' => 'soundcloud_url',
|
1015 |
+
'url_text' => 'SoundCloud',
|
1016 |
+
'advanced' => 'social',
|
1017 |
+
'color' => '#f50',
|
1018 |
+
'match' => 'https://soundcloud.com/',
|
1019 |
+
),
|
1020 |
+
|
1021 |
+
'vkontakte' => array(
|
1022 |
+
'title' => __('VKontakte','ultimate-member'),
|
1023 |
+
'metakey' => 'vkontakte',
|
1024 |
+
'type' => 'url',
|
1025 |
+
'label' => __('VKontakte','ultimate-member'),
|
1026 |
+
'required' => 0,
|
1027 |
+
'public' => 1,
|
1028 |
+
'editable' => 1,
|
1029 |
+
'url_target' => '_blank',
|
1030 |
+
'url_rel' => 'nofollow',
|
1031 |
+
'icon' => 'um-faicon-vk',
|
1032 |
+
'validate' => 'vk_url',
|
1033 |
+
'url_text' => 'VKontakte',
|
1034 |
+
'advanced' => 'social',
|
1035 |
+
'color' => '#2B587A',
|
1036 |
+
'match' => 'https://vk.com/',
|
1037 |
+
),
|
1038 |
+
|
1039 |
+
'role_select' => array(
|
1040 |
+
'title' => __('Roles (Dropdown)','ultimate-member'),
|
1041 |
+
'metakey' => 'role_select',
|
1042 |
+
'type' => 'select',
|
1043 |
+
'label' => __('Account Type','ultimate-member'),
|
1044 |
+
'placeholder' => 'Choose account type',
|
1045 |
+
'required' => 0,
|
1046 |
+
'public' => 1,
|
1047 |
+
'editable' => 1,
|
1048 |
+
'options' => $um_roles,
|
1049 |
+
),
|
1050 |
+
|
1051 |
+
'role_radio' => array(
|
1052 |
+
'title' => __('Roles (Radio)','ultimate-member'),
|
1053 |
+
'metakey' => 'role_radio',
|
1054 |
+
'type' => 'radio',
|
1055 |
+
'label' => __('Account Type','ultimate-member'),
|
1056 |
+
'required' => 0,
|
1057 |
+
'public' => 1,
|
1058 |
+
'editable' => 1,
|
1059 |
+
'options' => $um_roles,
|
1060 |
+
),
|
1061 |
+
|
1062 |
+
'languages' => array(
|
1063 |
+
'title' => __('Languages','ultimate-member'),
|
1064 |
+
'metakey' => 'languages',
|
1065 |
+
'type' => 'multiselect',
|
1066 |
+
'label' => __('Languages Spoken','ultimate-member'),
|
1067 |
+
'placeholder' => __('Select languages','ultimate-member'),
|
1068 |
+
'required' => 0,
|
1069 |
+
'public' => 1,
|
1070 |
+
'editable' => 1,
|
1071 |
+
'options' => $this->get('languages'),
|
1072 |
+
),
|
1073 |
+
|
1074 |
+
'phone_number' => array(
|
1075 |
+
'title' => __('Phone Number','ultimate-member'),
|
1076 |
+
'metakey' => 'phone_number',
|
1077 |
+
'type' => 'text',
|
1078 |
+
'label' => __('Phone Number','ultimate-member'),
|
1079 |
+
'required' => 0,
|
1080 |
+
'public' => 1,
|
1081 |
+
'editable' => 1,
|
1082 |
+
'validate' => 'phone_number',
|
1083 |
+
'icon' => 'um-faicon-phone',
|
1084 |
+
),
|
1085 |
+
|
1086 |
+
'mobile_number' => array(
|
1087 |
+
'title' => __('Mobile Number','ultimate-member'),
|
1088 |
+
'metakey' => 'mobile_number',
|
1089 |
+
'type' => 'text',
|
1090 |
+
'label' => __('Mobile Number','ultimate-member'),
|
1091 |
+
'required' => 0,
|
1092 |
+
'public' => 1,
|
1093 |
+
'editable' => 1,
|
1094 |
+
'validate' => 'phone_number',
|
1095 |
+
'icon' => 'um-faicon-mobile',
|
1096 |
+
),
|
1097 |
+
|
1098 |
+
// private use ( not public list )
|
1099 |
+
|
1100 |
+
'profile_photo' => array(
|
1101 |
+
'title' => __('Profile Photo','ultimate-member'),
|
1102 |
+
'metakey' => 'profile_photo',
|
1103 |
+
'type' => 'image',
|
1104 |
+
'label' => __('Change your profile photo','ultimate-member'),
|
1105 |
+
'upload_text' => __('Upload your photo here','ultimate-member'),
|
1106 |
+
'icon' => 'um-faicon-camera',
|
1107 |
+
'crop' => 1,
|
1108 |
+
'max_size' => ( UM()->options()->get('profile_photo_max_size') ) ? UM()->options()->get('profile_photo_max_size') : 999999999,
|
1109 |
+
'min_width' => str_replace('px','',UM()->options()->get('profile_photosize')),
|
1110 |
+
'min_height' => str_replace('px','',UM()->options()->get('profile_photosize')),
|
1111 |
+
'private_use' => true,
|
1112 |
+
),
|
1113 |
+
|
1114 |
+
'cover_photo' => array(
|
1115 |
+
'title' => __('Cover Photo','ultimate-member'),
|
1116 |
+
'metakey' => 'cover_photo',
|
1117 |
+
'type' => 'image',
|
1118 |
+
'label' => __('Change your cover photo','ultimate-member'),
|
1119 |
+
'upload_text' => __('Upload profile cover here','ultimate-member'),
|
1120 |
+
'icon' => 'um-faicon-picture-o',
|
1121 |
+
'crop' => 2,
|
1122 |
+
'max_size' => ( UM()->options()->get('cover_photo_max_size') ) ? UM()->options()->get('cover_photo_max_size') : 999999999,
|
1123 |
+
'modal_size' => 'large',
|
1124 |
+
'ratio' => str_replace(':1','',UM()->options()->get('profile_cover_ratio')),
|
1125 |
+
'min_width' => UM()->options()->get('cover_min_width'),
|
1126 |
+
'private_use' => true,
|
1127 |
+
),
|
1128 |
+
|
1129 |
+
'username_b' => array(
|
1130 |
+
'title' => __('Username or E-mail','ultimate-member'),
|
1131 |
+
'metakey' => 'username_b',
|
1132 |
+
'type' => 'text',
|
1133 |
+
'placeholder' => __('Enter your username or email','ultimate-member'),
|
1134 |
+
'required' => 1,
|
1135 |
+
'public' => 1,
|
1136 |
+
'editable' => 0,
|
1137 |
+
'private_use' => true,
|
1138 |
+
),
|
1139 |
+
|
1140 |
+
// account page use ( not public )
|
1141 |
+
|
1142 |
+
'profile_privacy' => array(
|
1143 |
+
'title' => __( 'Profile Privacy', 'ultimate-member' ),
|
1144 |
+
'metakey' => 'profile_privacy',
|
1145 |
+
'type' => 'select',
|
1146 |
+
'label' => __( 'Profile Privacy', 'ultimate-member' ),
|
1147 |
+
'help' => __( 'Who can see your public profile?', 'ultimate-member' ),
|
1148 |
+
'required' => 0,
|
1149 |
+
'public' => 1,
|
1150 |
+
'editable' => 1,
|
1151 |
+
'default' => 'Everyone',
|
1152 |
+
'options' => $profile_privacy,
|
1153 |
+
'allowclear' => 0,
|
1154 |
+
'account_only' => true,
|
1155 |
+
'required_perm' => 'can_make_private_profile',
|
1156 |
+
),
|
1157 |
+
|
1158 |
+
'profile_noindex' => array(
|
1159 |
+
'title' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
|
1160 |
+
'metakey' => 'profile_noindex',
|
1161 |
+
'type' => 'select',
|
1162 |
+
'label' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
|
1163 |
+
'help' => __( 'Hide my profile for robots?', 'ultimate-member' ),
|
1164 |
+
'required' => 0,
|
1165 |
+
'public' => 1,
|
1166 |
+
'editable' => 1,
|
1167 |
+
'default' => UM()->roles()->um_user_can( 'profile_noindex' ) ? '1' : '0',
|
1168 |
+
'options' => array(
|
1169 |
+
'0' => __( 'No', 'ultimate-member' ),
|
1170 |
+
'1' => __( 'Yes', 'ultimate-member' ),
|
1171 |
+
),
|
1172 |
+
'allowclear' => 0,
|
1173 |
+
'account_only' => true,
|
1174 |
+
'required_perm' => 'can_make_private_profile',
|
1175 |
+
),
|
1176 |
+
|
1177 |
+
'hide_in_members' => array(
|
1178 |
+
'title' => __( 'Hide my profile from directory', 'ultimate-member' ),
|
1179 |
+
'metakey' => 'hide_in_members',
|
1180 |
+
'type' => 'radio',
|
1181 |
+
'label' => __( 'Hide my profile from directory', 'ultimate-member' ),
|
1182 |
+
'help' => __( 'Here you can hide yourself from appearing in public directory', 'ultimate-member' ),
|
1183 |
+
'required' => 0,
|
1184 |
+
'public' => 1,
|
1185 |
+
'editable' => 1,
|
1186 |
+
'default' => UM()->member_directory()->get_hide_in_members_default() ? 'Yes' : 'No',
|
1187 |
+
'options' => array(
|
1188 |
+
'No' => __( 'No', 'ultimate-member' ),
|
1189 |
+
'Yes' => __( 'Yes', 'ultimate-member' ),
|
1190 |
+
),
|
1191 |
+
'account_only' => true,
|
1192 |
+
'required_opt' => array( 'members_page', 1 ),
|
1193 |
+
),
|
1194 |
+
|
1195 |
+
'delete_account' => array(
|
1196 |
+
'title' => __( 'Delete Account', 'ultimate-member' ),
|
1197 |
+
'metakey' => 'delete_account',
|
1198 |
+
'type' => 'radio',
|
1199 |
+
'label' => __( 'Delete Account', 'ultimate-member'),
|
1200 |
+
'help' => __( 'If you confirm, everything related to your profile will be deleted permanently from the site', 'ultimate-member' ),
|
1201 |
+
'required' => 0,
|
1202 |
+
'public' => 1,
|
1203 |
+
'editable' => 1,
|
1204 |
+
'default' => __( 'No', 'ultimate-member' ),
|
1205 |
+
'options' => array(
|
1206 |
+
__( 'Yes', 'ultimate-member' ),
|
1207 |
+
__( 'No', 'ultimate-member' )
|
1208 |
+
),
|
1209 |
+
'account_only' => true,
|
1210 |
+
),
|
1211 |
+
|
1212 |
+
'single_user_password' => array(
|
1213 |
+
'title' => __( 'Password', 'ultimate-member' ),
|
1214 |
+
'metakey' => 'single_user_password',
|
1215 |
+
'type' => 'password',
|
1216 |
+
'label' => __( 'Password', 'ultimate-member' ),
|
1217 |
+
'required' => 1,
|
1218 |
+
'public' => 1,
|
1219 |
+
'editable' => 1,
|
1220 |
+
'account_only' => true,
|
1221 |
+
),
|
1222 |
+
|
1223 |
+
);
|
1224 |
+
|
1225 |
+
/**
|
1226 |
+
* UM hook
|
1227 |
+
*
|
1228 |
+
* @type filter
|
1229 |
+
* @title um_predefined_fields_hook
|
1230 |
+
* @description Extend Predefined Fields
|
1231 |
+
* @input_vars
|
1232 |
+
* [{"var":"$predefined_fields","type":"array","desc":"Predefined Fields"}]
|
1233 |
+
* @change_log
|
1234 |
+
* ["Since: 2.0"]
|
1235 |
+
* @usage add_filter( 'um_predefined_fields_hook', 'function_name', 10, 1 );
|
1236 |
+
* @example
|
1237 |
+
* <?php
|
1238 |
+
* add_filter( 'um_predefined_fields_hook', 'my_predefined_fields', 10, 1 );
|
1239 |
+
* function my_predefined_fields( $predefined_fields ) {
|
1240 |
+
* // your code here
|
1241 |
+
* return $predefined_fields;
|
1242 |
+
* }
|
1243 |
+
* ?>
|
1244 |
+
*/
|
1245 |
+
$this->predefined_fields = apply_filters( 'um_predefined_fields_hook', $this->predefined_fields );
|
1246 |
+
}
|
1247 |
+
|
1248 |
+
|
1249 |
+
/**
|
1250 |
+
* Custom Fields
|
1251 |
+
*/
|
1252 |
+
function set_custom_fields() {
|
1253 |
+
|
1254 |
+
if ( is_array( $this->saved_fields ) ) {
|
1255 |
+
|
1256 |
+
$this->custom_fields = $this->saved_fields;
|
1257 |
+
|
1258 |
+
} else {
|
1259 |
+
|
1260 |
+
$this->custom_fields = '';
|
1261 |
+
|
1262 |
+
}
|
1263 |
+
|
1264 |
+
$custom = $this->custom_fields;
|
1265 |
+
$predefined = $this->predefined_fields;
|
1266 |
+
|
1267 |
+
if ( is_array( $custom ) ){
|
1268 |
+
$this->all_user_fields = array_merge( $predefined, $custom );
|
1269 |
+
} else {
|
1270 |
+
$this->all_user_fields = $predefined;
|
1271 |
+
}
|
1272 |
+
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
|
1276 |
+
/**
|
1277 |
+
* Get all fields without metakeys
|
1278 |
+
*
|
1279 |
+
* @since 2.0.56
|
1280 |
+
*
|
1281 |
+
* @return array
|
1282 |
+
*/
|
1283 |
+
function get_fields_without_metakey() {
|
1284 |
+
$fields_without_metakey = array(
|
1285 |
+
'block',
|
1286 |
+
'shortcode',
|
1287 |
+
'spacing',
|
1288 |
+
'divider',
|
1289 |
+
'group'
|
1290 |
+
);
|
1291 |
+
|
1292 |
+
|
1293 |
+
/**
|
1294 |
+
* UM hook
|
1295 |
+
*
|
1296 |
+
* @type filter
|
1297 |
+
* @title um_fields_without_metakey
|
1298 |
+
* @description Field Types without meta key
|
1299 |
+
* @input_vars
|
1300 |
+
* [{"var":"$types","type":"array","desc":"Field Types"}]
|
1301 |
+
* @change_log
|
1302 |
+
* ["Since: 2.0"]
|
1303 |
+
* @usage add_filter( 'um_fields_without_metakey', 'function_name', 10, 1 );
|
1304 |
+
* @example
|
1305 |
+
* <?php
|
1306 |
+
* add_filter( 'um_fields_without_metakey', 'my_fields_without_metakey', 10, 1 );
|
1307 |
+
* function my_fields_without_metakey( $types ) {
|
1308 |
+
* // your code here
|
1309 |
+
* return $types;
|
1310 |
+
* }
|
1311 |
+
* ?>
|
1312 |
+
*/
|
1313 |
+
return apply_filters( 'um_fields_without_metakey', $fields_without_metakey );
|
1314 |
+
}
|
1315 |
+
|
1316 |
+
|
1317 |
+
/**
|
1318 |
+
* May be used to show a dropdown, or source for user meta
|
1319 |
+
*
|
1320 |
+
* @param null $exclude_types
|
1321 |
+
* @param bool $show_all
|
1322 |
+
*
|
1323 |
+
* @return array
|
1324 |
+
*/
|
1325 |
+
function all_user_fields( $exclude_types = null, $show_all = false ) {
|
1326 |
+
|
1327 |
+
$fields_without_metakey = $this->get_fields_without_metakey();
|
1328 |
+
$fields_without_metakey = apply_filters( 'um_all_user_fields_without_metakey', $fields_without_metakey );
|
1329 |
+
|
1330 |
+
if ( ! $show_all ) {
|
1331 |
+
$this->fields_dropdown = array( 'image', 'file', 'password', 'rating' );
|
1332 |
+
$this->fields_dropdown = array_merge( $this->fields_dropdown, $fields_without_metakey );
|
1333 |
+
} else {
|
1334 |
+
$this->fields_dropdown = $fields_without_metakey;
|
1335 |
+
}
|
1336 |
+
|
1337 |
+
$custom = $this->custom_fields;
|
1338 |
+
$predefined = $this->predefined_fields;
|
1339 |
+
|
1340 |
+
if ( $exclude_types ) {
|
1341 |
+
$exclude_types = explode( ',', $exclude_types );
|
1342 |
+
}
|
1343 |
+
|
1344 |
+
$all = array( 0 => '' );
|
1345 |
+
|
1346 |
+
if ( is_array( $custom ) ) {
|
1347 |
+
$all = $all + array_merge( $predefined, $custom );
|
1348 |
+
} else {
|
1349 |
+
$all = $all + $predefined;
|
1350 |
+
}
|
1351 |
+
|
1352 |
+
foreach ( $all as $k => $arr ) {
|
1353 |
+
|
1354 |
+
if ( $k == 0 ) {
|
1355 |
+
unset( $all[ $k ] );
|
1356 |
+
}
|
1357 |
+
|
1358 |
+
if ( isset( $arr['title'] ) ) {
|
1359 |
+
$all[ $k ]['title'] = stripslashes( $arr['title'] );
|
1360 |
+
}
|
1361 |
+
|
1362 |
+
if ( $exclude_types && isset( $arr['type'] ) && in_array( $arr['type'], $exclude_types ) ) {
|
1363 |
+
unset( $all[ $k ] );
|
1364 |
+
}
|
1365 |
+
if ( isset( $arr['account_only'] ) || isset( $arr['private_use'] ) ) {
|
1366 |
+
if ( ! $show_all ) {
|
1367 |
+
unset( $all[ $k ] );
|
1368 |
+
}
|
1369 |
+
}
|
1370 |
+
if ( isset( $arr['type'] ) && in_array( $arr['type'], $this->fields_dropdown ) ) {
|
1371 |
+
unset( $all[ $k ] );
|
1372 |
+
}
|
1373 |
+
}
|
1374 |
+
|
1375 |
+
$all = UM()->fields()->array_sort_by_column( $all, 'title' );
|
1376 |
+
|
1377 |
+
return $all;
|
1378 |
+
}
|
1379 |
+
|
1380 |
+
|
1381 |
+
/**
|
1382 |
+
* Possible validation types for fields
|
1383 |
+
*
|
1384 |
+
* @return mixed
|
1385 |
+
*/
|
1386 |
+
function validation_types() {
|
1387 |
+
|
1388 |
+
$array[0] = __('None','ultimate-member');
|
1389 |
+
$array['alphabetic'] = __('Alphabetic value only','ultimate-member');
|
1390 |
+
$array['alpha_numeric'] = __('Alpha-numeric value','ultimate-member');
|
1391 |
+
$array['english'] = __('English letters only','ultimate-member');
|
1392 |
+
$array['facebook_url'] = __('Facebook URL','ultimate-member');
|
1393 |
+
$array['google_url'] = __('Google+ URL','ultimate-member');
|
1394 |
+
$array['instagram_url'] = __('Instagram URL','ultimate-member');
|
1395 |
+
$array['linkedin_url'] = __('LinkedIn URL','ultimate-member');
|
1396 |
+
$array['vk_url'] = __('VKontakte URL','ultimate-member');
|
1397 |
+
$array['lowercase'] = __('Lowercase only','ultimate-member');
|
1398 |
+
$array['numeric'] = __('Numeric value only','ultimate-member');
|
1399 |
+
$array['phone_number'] = __('Phone Number','ultimate-member');
|
1400 |
+
$array['skype'] = __('Skype ID','ultimate-member');
|
1401 |
+
$array['soundcloud'] = __('SoundCloud Profile','ultimate-member');
|
1402 |
+
$array['twitter_url'] = __('Twitter URL','ultimate-member');
|
1403 |
+
$array['is_email'] = __('E-mail( Not Unique )','ultimate-member');
|
1404 |
+
$array['unique_email'] = __('Unique E-mail','ultimate-member');
|
1405 |
+
$array['unique_value'] = __('Unique Metakey value','ultimate-member');
|
1406 |
+
$array['unique_username'] = __('Unique Username','ultimate-member');
|
1407 |
+
$array['unique_username_or_email'] = __('Unique Username/E-mail','ultimate-member');
|
1408 |
+
$array['url'] = __('Website URL','ultimate-member');
|
1409 |
+
$array['youtube_url'] = __('YouTube Profile','ultimate-member');
|
1410 |
+
$array['custom'] = __('Custom Validation','ultimate-member');
|
1411 |
+
|
1412 |
+
/**
|
1413 |
+
* UM hook
|
1414 |
+
*
|
1415 |
+
* @type filter
|
1416 |
+
* @title um_admin_field_validation_hook
|
1417 |
+
* @description Extend validation types
|
1418 |
+
* @input_vars
|
1419 |
+
* [{"var":"$types","type":"array","desc":"Validation Types"}]
|
1420 |
+
* @change_log
|
1421 |
+
* ["Since: 2.0"]
|
1422 |
+
* @usage add_filter( 'um_admin_field_validation_hook', 'function_name', 10, 1 );
|
1423 |
+
* @example
|
1424 |
+
* <?php
|
1425 |
+
* add_filter( 'um_admin_field_validation_hook', 'my_admin_field_validation', 10, 1 );
|
1426 |
+
* function my_admin_field_validation( $types ) {
|
1427 |
+
* // your code here
|
1428 |
+
* return $types;
|
1429 |
+
* }
|
1430 |
+
* ?>
|
1431 |
+
*/
|
1432 |
+
$array = apply_filters( 'um_admin_field_validation_hook', $array );
|
1433 |
+
return $array;
|
1434 |
+
}
|
1435 |
+
|
1436 |
+
|
1437 |
+
/**
|
1438 |
+
* Get predefined options
|
1439 |
+
*
|
1440 |
+
* @param $data
|
1441 |
+
*
|
1442 |
+
* @return array|mixed|void
|
1443 |
+
*/
|
1444 |
+
function get( $data ) {
|
1445 |
+
switch ( $data ) {
|
1446 |
+
|
1447 |
+
case 'languages':
|
1448 |
+
$array = array(
|
1449 |
+
"aa" => __("Afar",'ultimate-member'),
|
1450 |
+
"ab" => __("Abkhazian",'ultimate-member'),
|
1451 |
+
"ae" => __("Avestan",'ultimate-member'),
|
1452 |
+
"af" => __("Afrikaans",'ultimate-member'),
|
1453 |
+
"ak" => __("Akan",'ultimate-member'),
|
1454 |
+
"am" => __("Amharic",'ultimate-member'),
|
1455 |
+
"an" => __("Aragonese",'ultimate-member'),
|
1456 |
+
"ar" => __("Arabic",'ultimate-member'),
|
1457 |
+
"as" => __("Assamese",'ultimate-member'),
|
1458 |
+
"av" => __("Avaric",'ultimate-member'),
|
1459 |
+
"ay" => __("Aymara",'ultimate-member'),
|
1460 |
+
"az" => __("Azerbaijani",'ultimate-member'),
|
1461 |
+
"ba" => __("Bashkir",'ultimate-member'),
|
1462 |
+
"be" => __("Belarusian",'ultimate-member'),
|
1463 |
+
"bg" => __("Bulgarian",'ultimate-member'),
|
1464 |
+
"bh" => __("Bihari",'ultimate-member'),
|
1465 |
+
"bi" => __("Bislama",'ultimate-member'),
|
1466 |
+
"bm" => __("Bambara",'ultimate-member'),
|
1467 |
+
"bn" => __("Bengali",'ultimate-member'),
|
1468 |
+
"bo" => __("Tibetan",'ultimate-member'),
|
1469 |
+
"br" => __("Breton",'ultimate-member'),
|
1470 |
+
"bs" => __("Bosnian",'ultimate-member'),
|
1471 |
+
"ca" => __("Catalan",'ultimate-member'),
|
1472 |
+
"ce" => __("Chechen",'ultimate-member'),
|
1473 |
+
"ch" => __("Chamorro",'ultimate-member'),
|
1474 |
+
"co" => __("Corsican",'ultimate-member'),
|
1475 |
+
"cr" => __("Cree",'ultimate-member'),
|
1476 |
+
"cs" => __("Czech",'ultimate-member'),
|
1477 |
+
"cu" => __("Church Slavic",'ultimate-member'),
|
1478 |
+
"cv" => __("Chuvash",'ultimate-member'),
|
1479 |
+
"cy" => __("Welsh",'ultimate-member'),
|
1480 |
+
"da" => __("Danish",'ultimate-member'),
|
1481 |
+
"de" => __("German",'ultimate-member'),
|
1482 |
+
"dv" => __("Divehi",'ultimate-member'),
|
1483 |
+
"dz" => __("Dzongkha",'ultimate-member'),
|
1484 |
+
"ee" => __("Ewe",'ultimate-member'),
|
1485 |
+
"el" => __("Greek",'ultimate-member'),
|
1486 |
+
"en" => __("English",'ultimate-member'),
|
1487 |
+
"eo" => __("Esperanto",'ultimate-member'),
|
1488 |
+
"es" => __("Spanish",'ultimate-member'),
|
1489 |
+
"et" => __("Estonian",'ultimate-member'),
|
1490 |
+
"eu" => __("Basque",'ultimate-member'),
|
1491 |
+
"fa" => __("Persian",'ultimate-member'),
|
1492 |
+
"ff" => __("Fulah",'ultimate-member'),
|
1493 |
+
"fi" => __("Finnish",'ultimate-member'),
|
1494 |
+
"fj" => __("Fijian",'ultimate-member'),
|
1495 |
+
"fo" => __("Faroese",'ultimate-member'),
|
1496 |
+
"fr" => __("French",'ultimate-member'),
|
1497 |
+
"fy" => __("Western Frisian",'ultimate-member'),
|
1498 |
+
"ga" => __("Irish",'ultimate-member'),
|
1499 |
+
"gd" => __("Scottish Gaelic",'ultimate-member'),
|
1500 |
+
"gl" => __("Galician",'ultimate-member'),
|
1501 |
+
"gn" => __("Guarani",'ultimate-member'),
|
1502 |
+
"gu" => __("Gujarati",'ultimate-member'),
|
1503 |
+
"gv" => __("Manx",'ultimate-member'),
|
1504 |
+
"ha" => __("Hausa",'ultimate-member'),
|
1505 |
+
"he" => __("Hebrew",'ultimate-member'),
|
1506 |
+
"hi" => __("Hindi",'ultimate-member'),
|
1507 |
+
"ho" => __("Hiri Motu",'ultimate-member'),
|
1508 |
+
"hr" => __("Croatian",'ultimate-member'),
|
1509 |
+
"ht" => __("Haitian",'ultimate-member'),
|
1510 |
+
"hu" => __("Hungarian",'ultimate-member'),
|
1511 |
+
"hy" => __("Armenian",'ultimate-member'),
|
1512 |
+
"hz" => __("Herero",'ultimate-member'),
|
1513 |
+
"ia" => __("Interlingua (International Auxiliary Language Association)",'ultimate-member'),
|
1514 |
+
"id" => __("Indonesian",'ultimate-member'),
|
1515 |
+
"ie" => __("Interlingue",'ultimate-member'),
|
1516 |
+
"ig" => __("Igbo",'ultimate-member'),
|
1517 |
+
"ii" => __("Sichuan Yi",'ultimate-member'),
|
1518 |
+
"ik" => __("Inupiaq",'ultimate-member'),
|
1519 |
+
"io" => __("Ido",'ultimate-member'),
|
1520 |
+
"is" => __("Icelandic",'ultimate-member'),
|
1521 |
+
"it" => __("Italian",'ultimate-member'),
|
1522 |
+
"iu" => __("Inuktitut",'ultimate-member'),
|
1523 |
+
"ja" => __("Japanese",'ultimate-member'),
|
1524 |
+
"jv" => __("Javanese",'ultimate-member'),
|
1525 |
+
"ka" => __("Georgian",'ultimate-member'),
|
1526 |
+
"kg" => __("Kongo",'ultimate-member'),
|
1527 |
+
"ki" => __("Kikuyu",'ultimate-member'),
|
1528 |
+
"kj" => __("Kwanyama",'ultimate-member'),
|
1529 |
+
"kk" => __("Kazakh",'ultimate-member'),
|
1530 |
+
"kl" => __("Kalaallisut",'ultimate-member'),
|
1531 |
+
"km" => __("Khmer",'ultimate-member'),
|
1532 |
+
"kn" => __("Kannada",'ultimate-member'),
|
1533 |
+
"ko" => __("Korean",'ultimate-member'),
|
1534 |
+
"kr" => __("Kanuri",'ultimate-member'),
|
1535 |
+
"ks" => __("Kashmiri",'ultimate-member'),
|
1536 |
+
"ku" => __("Kurdish",'ultimate-member'),
|
1537 |
+
"kv" => __("Komi",'ultimate-member'),
|
1538 |
+
"kw" => __("Cornish",'ultimate-member'),
|
1539 |
+
"ky" => __("Kirghiz",'ultimate-member'),
|
1540 |
+
"la" => __("Latin",'ultimate-member'),
|
1541 |
+
"lb" => __("Luxembourgish",'ultimate-member'),
|
1542 |
+
"lg" => __("Ganda",'ultimate-member'),
|
1543 |
+
"li" => __("Limburgish",'ultimate-member'),
|
1544 |
+
"ln" => __("Lingala",'ultimate-member'),
|
1545 |
+
"lo" => __("Lao",'ultimate-member'),
|
1546 |
+
"lt" => __("Lithuanian",'ultimate-member'),
|
1547 |
+
"lu" => __("Luba-Katanga",'ultimate-member'),
|
1548 |
+
"lv" => __("Latvian",'ultimate-member'),
|
1549 |
+
"mg" => __("Malagasy",'ultimate-member'),
|
1550 |
+
"mh" => __("Marshallese",'ultimate-member'),
|
1551 |
+
"mi" => __("Maori",'ultimate-member'),
|
1552 |
+
"mk" => __("Macedonian",'ultimate-member'),
|
1553 |
+
"ml" => __("Malayalam",'ultimate-member'),
|
1554 |
+
"mn" => __("Mongolian",'ultimate-member'),
|
1555 |
+
"mr" => __("Marathi",'ultimate-member'),
|
1556 |
+
"ms" => __("Malay",'ultimate-member'),
|
1557 |
+
"mt" => __("Maltese",'ultimate-member'),
|
1558 |
+
"my" => __("Burmese",'ultimate-member'),
|
1559 |
+
"na" => __("Nauru",'ultimate-member'),
|
1560 |
+
"nb" => __("Norwegian Bokmal",'ultimate-member'),
|
1561 |
+
"nd" => __("North Ndebele",'ultimate-member'),
|
1562 |
+
"ne" => __("Nepali",'ultimate-member'),
|
1563 |
+
"ng" => __("Ndonga",'ultimate-member'),
|
1564 |
+
"nl" => __("Dutch",'ultimate-member'),
|
1565 |
+
"nn" => __("Norwegian Nynorsk",'ultimate-member'),
|
1566 |
+
"no" => __("Norwegian",'ultimate-member'),
|
1567 |
+
"nr" => __("South Ndebele",'ultimate-member'),
|
1568 |
+
"nv" => __("Navajo",'ultimate-member'),
|
1569 |
+
"ny" => __("Chichewa",'ultimate-member'),
|
1570 |
+
"oc" => __("Occitan",'ultimate-member'),
|
1571 |
+
"oj" => __("Ojibwa",'ultimate-member'),
|
1572 |
+
"om" => __("Oromo",'ultimate-member'),
|
1573 |
+
"or" => __("Oriya",'ultimate-member'),
|
1574 |
+
"os" => __("Ossetian",'ultimate-member'),
|
1575 |
+
"pa" => __("Panjabi",'ultimate-member'),
|
1576 |
+
"pi" => __("Pali",'ultimate-member'),
|
1577 |
+
"pl" => __("Polish",'ultimate-member'),
|
1578 |
+
"ps" => __("Pashto",'ultimate-member'),
|
1579 |
+
"pt" => __("Portuguese",'ultimate-member'),
|
1580 |
+
"qu" => __("Quechua",'ultimate-member'),
|
1581 |
+
"rm" => __("Raeto-Romance",'ultimate-member'),
|
1582 |
+
"rn" => __("Kirundi",'ultimate-member'),
|
1583 |
+
"ro" => __("Romanian",'ultimate-member'),
|
1584 |
+
"ru" => __("Russian",'ultimate-member'),
|
1585 |
+
"rw" => __("Kinyarwanda",'ultimate-member'),
|
1586 |
+
"sa" => __("Sanskrit",'ultimate-member'),
|
1587 |
+
"sc" => __("Sardinian",'ultimate-member'),
|
1588 |
+
"sd" => __("Sindhi",'ultimate-member'),
|
1589 |
+
"se" => __("Northern Sami",'ultimate-member'),
|
1590 |
+
"sg" => __("Sango",'ultimate-member'),
|
1591 |
+
"si" => __("Sinhala",'ultimate-member'),
|
1592 |
+
"sk" => __("Slovak",'ultimate-member'),
|
1593 |
+
"sl" => __("Slovenian",'ultimate-member'),
|
1594 |
+
"sm" => __("Samoan",'ultimate-member'),
|
1595 |
+
"sn" => __("Shona",'ultimate-member'),
|
1596 |
+
"so" => __("Somali",'ultimate-member'),
|
1597 |
+
"sq" => __("Albanian",'ultimate-member'),
|
1598 |
+
"sr" => __("Serbian",'ultimate-member'),
|
1599 |
+
"ss" => __("Swati",'ultimate-member'),
|
1600 |
+
"st" => __("Southern Sotho",'ultimate-member'),
|
1601 |
+
"su" => __("Sundanese",'ultimate-member'),
|
1602 |
+
"sv" => __("Swedish",'ultimate-member'),
|
1603 |
+
"sw" => __("Swahili",'ultimate-member'),
|
1604 |
+
"ta" => __("Tamil",'ultimate-member'),
|
1605 |
+
"te" => __("Telugu",'ultimate-member'),
|
1606 |
+
"tg" => __("Tajik",'ultimate-member'),
|
1607 |
+
"th" => __("Thai",'ultimate-member'),
|
1608 |
+
"ti" => __("Tigrinya",'ultimate-member'),
|
1609 |
+
"tk" => __("Turkmen",'ultimate-member'),
|
1610 |
+
"tl" => __("Tagalog",'ultimate-member'),
|
1611 |
+
"tn" => __("Tswana",'ultimate-member'),
|
1612 |
+
"to" => __("Tonga",'ultimate-member'),
|
1613 |
+
"tr" => __("Turkish",'ultimate-member'),
|
1614 |
+
"ts" => __("Tsonga",'ultimate-member'),
|
1615 |
+
"tt" => __("Tatar",'ultimate-member'),
|
1616 |
+
"tw" => __("Twi",'ultimate-member'),
|
1617 |
+
"ty" => __("Tahitian",'ultimate-member'),
|
1618 |
+
"ug" => __("Uighur",'ultimate-member'),
|
1619 |
+
"uk" => __("Ukrainian",'ultimate-member'),
|
1620 |
+
"ur" => __("Urdu",'ultimate-member'),
|
1621 |
+
"uz" => __("Uzbek",'ultimate-member'),
|
1622 |
+
"ve" => __("Venda",'ultimate-member'),
|
1623 |
+
"vi" => __("Vietnamese",'ultimate-member'),
|
1624 |
+
"vo" => __("Volapuk",'ultimate-member'),
|
1625 |
+
"wa" => __("Walloon",'ultimate-member'),
|
1626 |
+
"wo" => __("Wolof",'ultimate-member'),
|
1627 |
+
"xh" => __("Xhosa",'ultimate-member'),
|
1628 |
+
"yi" => __("Yiddish",'ultimate-member'),
|
1629 |
+
"yo" => __("Yoruba",'ultimate-member'),
|
1630 |
+
"za" => __("Zhuang",'ultimate-member'),
|
1631 |
+
"zh" => __("Chinese",'ultimate-member'),
|
1632 |
+
"zu" => __("Zulu",'ultimate-member')
|
1633 |
+
);
|
1634 |
+
break;
|
1635 |
+
|
1636 |
+
case 'countries':
|
1637 |
+
$array = array (
|
1638 |
+
'AF' => __('Afghanistan','ultimate-member'),
|
1639 |
+
'AX' => __('Åland Islands','ultimate-member'),
|
1640 |
+
'AL' => __('Albania','ultimate-member'),
|
1641 |
+
'DZ' => __('Algeria','ultimate-member'),
|
1642 |
+
'AS' => __('American Samoa','ultimate-member'),
|
1643 |
+
'AD' => __('Andorra','ultimate-member'),
|
1644 |
+
'AO' => __('Angola','ultimate-member'),
|
1645 |
+
'AI' => __('Anguilla','ultimate-member'),
|
1646 |
+
'AQ' => __('Antarctica','ultimate-member'),
|
1647 |
+
'AG' => __('Antigua and Barbuda','ultimate-member'),
|
1648 |
+
'AR' => __('Argentina','ultimate-member'),
|
1649 |
+
'AM' => __('Armenia','ultimate-member'),
|
1650 |
+
'AW' => __('Aruba','ultimate-member'),
|
1651 |
+
'AU' => __('Australia','ultimate-member'),
|
1652 |
+
'AT' => __('Austria','ultimate-member'),
|
1653 |
+
'AZ' => __('Azerbaijan','ultimate-member'),
|
1654 |
+
'BS' => __('Bahamas','ultimate-member'),
|
1655 |
+
'BH' => __('Bahrain','ultimate-member'),
|
1656 |
+
'BD' => __('Bangladesh','ultimate-member'),
|
1657 |
+
'BB' => __('Barbados','ultimate-member'),
|
1658 |
+
'BY' => __('Belarus','ultimate-member'),
|
1659 |
+
'BE' => __('Belgium','ultimate-member'),
|
1660 |
+
'BZ' => __('Belize','ultimate-member'),
|
1661 |
+
'BJ' => __('Benin','ultimate-member'),
|
1662 |
+
'BM' => __('Bermuda','ultimate-member'),
|
1663 |
+
'BT' => __('Bhutan','ultimate-member'),
|
1664 |
+
'BO' => __('Bolivia, Plurinational State of','ultimate-member'),
|
1665 |
+
'BA' => __('Bosnia and Herzegovina','ultimate-member'),
|
1666 |
+
'BW' => __('Botswana','ultimate-member'),
|
1667 |
+
'BV' => __('Bouvet Island','ultimate-member'),
|
1668 |
+
'BR' => __('Brazil','ultimate-member'),
|
1669 |
+
'IO' => __('British Indian Ocean Territory','ultimate-member'),
|
1670 |
+
'BN' => __('Brunei Darussalam','ultimate-member'),
|
1671 |
+
'BG' => __('Bulgaria','ultimate-member'),
|
1672 |
+
'BF' => __('Burkina Faso','ultimate-member'),
|
1673 |
+
'BI' => __('Burundi','ultimate-member'),
|
1674 |
+
'KH' => __('Cambodia','ultimate-member'),
|
1675 |
+
'CM' => __('Cameroon','ultimate-member'),
|
1676 |
+
'CA' => __('Canada','ultimate-member'),
|
1677 |
+
'CV' => __('Cape Verde','ultimate-member'),
|
1678 |
+
'KY' => __('Cayman Islands','ultimate-member'),
|
1679 |
+
'CF' => __('Central African Republic','ultimate-member'),
|
1680 |
+
'TD' => __('Chad','ultimate-member'),
|
1681 |
+
'CL' => __('Chile','ultimate-member'),
|
1682 |
+
'CN' => __('China','ultimate-member'),
|
1683 |
+
'CX' => __('Christmas Island','ultimate-member'),
|
1684 |
+
'CC' => __('Cocos (Keeling) Islands','ultimate-member'),
|
1685 |
+
'CO' => __('Colombia','ultimate-member'),
|
1686 |
+
'KM' => __('Comoros','ultimate-member'),
|
1687 |
+
'CG' => __('Congo','ultimate-member'),
|
1688 |
+
'CD' => __('Congo, the Democratic Republic of the','ultimate-member'),
|
1689 |
+
'CK' => __('Cook Islands','ultimate-member'),
|
1690 |
+
'CR' => __('Costa Rica','ultimate-member'),
|
1691 |
+
'CI' => __("Côte d'Ivoire",'ultimate-member'),
|
1692 |
+
'HR' => __('Croatia','ultimate-member'),
|
1693 |
+
'CU' => __('Cuba','ultimate-member'),
|
1694 |
+
'CY' => __('Cyprus','ultimate-member'),
|
1695 |
+
'CZ' => __('Czech Republic','ultimate-member'),
|
1696 |
+
'DK' => __('Denmark','ultimate-member'),
|
1697 |
+
'DJ' => __('Djibouti','ultimate-member'),
|
1698 |
+
'DM' => __('Dominica','ultimate-member'),
|
1699 |
+
'DO' => __('Dominican Republic','ultimate-member'),
|
1700 |
+
'EC' => __('Ecuador','ultimate-member'),
|
1701 |
+
'EG' => __('Egypt','ultimate-member'),
|
1702 |
+
'SV' => __('El Salvador','ultimate-member'),
|
1703 |
+
'GQ' => __('Equatorial Guinea','ultimate-member'),
|
1704 |
+
'ER' => __('Eritrea','ultimate-member'),
|
1705 |
+
'EE' => __('Estonia','ultimate-member'),
|
1706 |
+
'ET' => __('Ethiopia','ultimate-member'),
|
1707 |
+
'FK' => __('Falkland Islands (Malvinas)','ultimate-member'),
|
1708 |
+
'FO' => __('Faroe Islands','ultimate-member'),
|
1709 |
+
'FJ' => __('Fiji','ultimate-member'),
|
1710 |
+
'FI' => __('Finland','ultimate-member'),
|
1711 |
+
'FR' => __('France','ultimate-member'),
|
1712 |
+
'GF' => __('French Guiana','ultimate-member'),
|
1713 |
+
'PF' => __('French Polynesia','ultimate-member'),
|
1714 |
+
'TF' => __('French Southern Territories','ultimate-member'),
|
1715 |
+
'GA' => __('Gabon','ultimate-member'),
|
1716 |
+
'GM' => __('Gambia','ultimate-member'),
|
1717 |
+
'GE' => __('Georgia','ultimate-member'),
|
1718 |
+
'DE' => __('Germany','ultimate-member'),
|
1719 |
+
'GH' => __('Ghana','ultimate-member'),
|
1720 |
+
'GI' => __('Gibraltar','ultimate-member'),
|
1721 |
+
'GR' => __('Greece','ultimate-member'),
|
1722 |
+
'GL' => __('Greenland','ultimate-member'),
|
1723 |
+
'GD' => __('Grenada','ultimate-member'),
|
1724 |
+
'GP' => __('Guadeloupe','ultimate-member'),
|
1725 |
+
'GU' => __('Guam','ultimate-member'),
|
1726 |
+
'GT' => __('Guatemala','ultimate-member'),
|
1727 |
+
'GG' => __('Guernsey','ultimate-member'),
|
1728 |
+
'GN' => __('Guinea','ultimate-member'),
|
1729 |
+
'GW' => __('Guinea-Bissau','ultimate-member'),
|
1730 |
+
'GY' => __('Guyana','ultimate-member'),
|
1731 |
+
'HT' => __('Haiti','ultimate-member'),
|
1732 |
+
'HM' => __('Heard Island and McDonald Islands','ultimate-member'),
|
1733 |
+
'VA' => __('Holy See (Vatican City State)','ultimate-member'),
|
1734 |
+
'HN' => __('Honduras','ultimate-member'),
|
1735 |
+
'HK' => __('Hong Kong','ultimate-member'),
|
1736 |
+
'HU' => __('Hungary','ultimate-member'),
|
1737 |
+
'IS' => __('Iceland','ultimate-member'),
|
1738 |
+
'IN' => __('India','ultimate-member'),
|
1739 |
+
'ID' => __('Indonesia','ultimate-member'),
|
1740 |
+
'IR' => __('Iran, Islamic Republic of','ultimate-member'),
|
1741 |
+
'IQ' => __('Iraq','ultimate-member'),
|
1742 |
+
'IE' => __('Ireland','ultimate-member'),
|
1743 |
+
'IM' => __('Isle of Man','ultimate-member'),
|
1744 |
+
'IL' => __('Israel','ultimate-member'),
|
1745 |
+
'IT' => __('Italy','ultimate-member'),
|
1746 |
+
'JM' => __('Jamaica','ultimate-member'),
|
1747 |
+
'JP' => __('Japan','ultimate-member'),
|
1748 |
+
'JE' => __('Jersey','ultimate-member'),
|
1749 |
+
'JO' => __('Jordan','ultimate-member'),
|
1750 |
+
'KZ' => __('Kazakhstan','ultimate-member'),
|
1751 |
+
'KE' => __('Kenya','ultimate-member'),
|
1752 |
+
'KI' => __('Kiribati','ultimate-member'),
|
1753 |
+
'KP' => __("Korea, Democratic People's Republic of",'ultimate-member'),
|
1754 |
+
'KR' => __('Korea, Republic of','ultimate-member'),
|
1755 |
+
'KW' => __('Kuwait','ultimate-member'),
|
1756 |
+
'KG' => __('Kyrgyzstan','ultimate-member'),
|
1757 |
+
'LA' => __("Lao People's Democratic Republic",'ultimate-member'),
|
1758 |
+
'LV' => __('Latvia','ultimate-member'),
|
1759 |
+
'LB' => __('Lebanon','ultimate-member'),
|
1760 |
+
'LS' => __('Lesotho','ultimate-member'),
|
1761 |
+
'LR' => __('Liberia','ultimate-member'),
|
1762 |
+
'LY' => __('Libyan Arab Jamahiriya','ultimate-member'),
|
1763 |
+
'LI' => __('Liechtenstein','ultimate-member'),
|
1764 |
+
'LT' => __('Lithuania','ultimate-member'),
|
1765 |
+
'LU' => __('Luxembourg','ultimate-member'),
|
1766 |
+
'MO' => __('Macao','ultimate-member'),
|
1767 |
+
'MK' => __('Macedonia, the former Yugoslav Republic of','ultimate-member'),
|
1768 |
+
'MG' => __('Madagascar','ultimate-member'),
|
1769 |
+
'MW' => __('Malawi','ultimate-member'),
|
1770 |
+
'MY' => __('Malaysia','ultimate-member'),
|
1771 |
+
'MV' => __('Maldives','ultimate-member'),
|
1772 |
+
'ML' => __('Mali','ultimate-member'),
|
1773 |
+
'MT' => __('Malta','ultimate-member'),
|
1774 |
+
'MH' => __('Marshall Islands','ultimate-member'),
|
1775 |
+
'MQ' => __('Martinique','ultimate-member'),
|
1776 |
+
'MR' => __('Mauritania','ultimate-member'),
|
1777 |
+
'MU' => __('Mauritius','ultimate-member'),
|
1778 |
+
'YT' => __('Mayotte','ultimate-member'),
|
1779 |
+
'MX' => __('Mexico','ultimate-member'),
|
1780 |
+
'FM' => __('Micronesia, Federated States of','ultimate-member'),
|
1781 |
+
'MD' => __('Moldova, Republic of','ultimate-member'),
|
1782 |
+
'MC' => __('Monaco','ultimate-member'),
|
1783 |
+
'MN' => __('Mongolia','ultimate-member'),
|
1784 |
+
'ME' => __('Montenegro','ultimate-member'),
|
1785 |
+
'MS' => __('Montserrat','ultimate-member'),
|
1786 |
+
'MA' => __('Morocco','ultimate-member'),
|
1787 |
+
'MZ' => __('Mozambique','ultimate-member'),
|
1788 |
+
'MM' => __('Myanmar','ultimate-member'),
|
1789 |
+
'NA' => __('Namibia','ultimate-member'),
|
1790 |
+
'NR' => __('Nauru','ultimate-member'),
|
1791 |
+
'NP' => __('Nepal','ultimate-member'),
|
1792 |
+
'NL' => __('Netherlands','ultimate-member'),
|
1793 |
+
'AN' => __('Netherlands Antilles','ultimate-member'),
|
1794 |
+
'NC' => __('New Caledonia','ultimate-member'),
|
1795 |
+
'NZ' => __('New Zealand','ultimate-member'),
|
1796 |
+
'NI' => __('Nicaragua','ultimate-member'),
|
1797 |
+
'NE' => __('Niger','ultimate-member'),
|
1798 |
+
'NG' => __('Nigeria','ultimate-member'),
|
1799 |
+
'NU' => __('Niue','ultimate-member'),
|
1800 |
+
'NF' => __('Norfolk Island','ultimate-member'),
|
1801 |
+
'MP' => __('Northern Mariana Islands','ultimate-member'),
|
1802 |
+
'NO' => __('Norway','ultimate-member'),
|
1803 |
+
'OM' => __('Oman','ultimate-member'),
|
1804 |
+
'PK' => __('Pakistan','ultimate-member'),
|
1805 |
+
'PW' => __('Palau','ultimate-member'),
|
1806 |
+
'PS' => __('Palestine','ultimate-member'),
|
1807 |
+
'PA' => __('Panama','ultimate-member'),
|
1808 |
+
'PG' => __('Papua New Guinea','ultimate-member'),
|
1809 |
+
'PY' => __('Paraguay','ultimate-member'),
|
1810 |
+
'PE' => __('Peru','ultimate-member'),
|
1811 |
+
'PH' => __('Philippines','ultimate-member'),
|
1812 |
+
'PN' => __('Pitcairn','ultimate-member'),
|
1813 |
+
'PL' => __('Poland','ultimate-member'),
|
1814 |
+
'PT' => __('Portugal','ultimate-member'),
|
1815 |
+
'PR' => __('Puerto Rico','ultimate-member'),
|
1816 |
+
'QA' => __('Qatar','ultimate-member'),
|
1817 |
+
'RE' => __('Réunion','ultimate-member'),
|
1818 |
+
'RO' => __('Romania','ultimate-member'),
|
1819 |
+
'RU' => __('Russian Federation','ultimate-member'),
|
1820 |
+
'RW' => __('Rwanda','ultimate-member'),
|
1821 |
+
'BL' => __('Saint Barthélemy','ultimate-member'),
|
1822 |
+
'SH' => __('Saint Helena','ultimate-member'),
|
1823 |
+
'KN' => __('Saint Kitts and Nevis','ultimate-member'),
|
1824 |
+
'LC' => __('Saint Lucia','ultimate-member'),
|
1825 |
+
'MF' => __('Saint Martin (French part)','ultimate-member'),
|
1826 |
+
'PM' => __('Saint Pierre and Miquelon','ultimate-member'),
|
1827 |
+
'VC' => __('Saint Vincent and the Grenadines','ultimate-member'),
|
1828 |
+
'WS' => __('Samoa','ultimate-member'),
|
1829 |
+
'SM' => __('San Marino','ultimate-member'),
|
1830 |
+
'ST' => __('Sao Tome and Principe','ultimate-member'),
|
1831 |
+
'SA' => __('Saudi Arabia','ultimate-member'),
|
1832 |
+
'SN' => __('Senegal','ultimate-member'),
|
1833 |
+
'RS' => __('Serbia','ultimate-member'),
|
1834 |
+
'SC' => __('Seychelles','ultimate-member'),
|
1835 |
+
'SL' => __('Sierra Leone','ultimate-member'),
|
1836 |
+
'SG' => __('Singapore','ultimate-member'),
|
1837 |
+
'SK' => __('Slovakia','ultimate-member'),
|
1838 |
+
'SI' => __('Slovenia','ultimate-member'),
|
1839 |
+
'SB' => __('Solomon Islands','ultimate-member'),
|
1840 |
+
'SO' => __('Somalia','ultimate-member'),
|
1841 |
+
'ZA' => __('South Africa','ultimate-member'),
|
1842 |
+
'GS' => __('South Georgia and the South Sandwich Islands','ultimate-member'),
|
1843 |
+
'SS' => __('South Sudan','ultimate-member'),
|
1844 |
+
'ES' => __('Spain','ultimate-member'),
|
1845 |
+
'LK' => __('Sri Lanka','ultimate-member'),
|
1846 |
+
'SD' => __('Sudan','ultimate-member'),
|
1847 |
+
'SR' => __('Suriname','ultimate-member'),
|
1848 |
+
'SJ' => __('Svalbard and Jan Mayen','ultimate-member'),
|
1849 |
+
'SZ' => __('Swaziland','ultimate-member'),
|
1850 |
+
'SE' => __('Sweden','ultimate-member'),
|
1851 |
+
'CH' => __('Switzerland','ultimate-member'),
|
1852 |
+
'SY' => __('Syrian Arab Republic','ultimate-member'),
|
1853 |
+
'TW' => __('Taiwan, Province of China','ultimate-member'),
|
1854 |
+
'TJ' => __('Tajikistan','ultimate-member'),
|
1855 |
+
'TZ' => __('Tanzania, United Republic of','ultimate-member'),
|
1856 |
+
'TH' => __('Thailand','ultimate-member'),
|
1857 |
+
'TL' => __('Timor-Leste','ultimate-member'),
|
1858 |
+
'TG' => __('Togo','ultimate-member'),
|
1859 |
+
'TK' => __('Tokelau','ultimate-member'),
|
1860 |
+
'TO' => __('Tonga','ultimate-member'),
|
1861 |
+
'TT' => __('Trinidad and Tobago','ultimate-member'),
|
1862 |
+
'TN' => __('Tunisia','ultimate-member'),
|
1863 |
+
'TR' => __('Turkey','ultimate-member'),
|
1864 |
+
'TM' => __('Turkmenistan','ultimate-member'),
|
1865 |
+
'TC' => __('Turks and Caicos Islands','ultimate-member'),
|
1866 |
+
'TV' => __('Tuvalu','ultimate-member'),
|
1867 |
+
'UG' => __('Uganda','ultimate-member'),
|
1868 |
+
'UA' => __('Ukraine','ultimate-member'),
|
1869 |
+
'AE' => __('United Arab Emirates','ultimate-member'),
|
1870 |
+
'GB' => __('United Kingdom','ultimate-member'),
|
1871 |
+
'US' => __('United States','ultimate-member'),
|
1872 |
+
'UM' => __('United States Minor Outlying Islands','ultimate-member'),
|
1873 |
+
'UY' => __('Uruguay','ultimate-member'),
|
1874 |
+
'UZ' => __('Uzbekistan','ultimate-member'),
|
1875 |
+
'VU' => __('Vanuatu','ultimate-member'),
|
1876 |
+
'VE' => __('Venezuela, Bolivarian Republic of','ultimate-member'),
|
1877 |
+
'VN' => __('Viet Nam','ultimate-member'),
|
1878 |
+
'VG' => __('Virgin Islands, British','ultimate-member'),
|
1879 |
+
'VI' => __('Virgin Islands, U.S.','ultimate-member'),
|
1880 |
+
'WF' => __('Wallis and Futuna','ultimate-member'),
|
1881 |
+
'EH' => __('Western Sahara','ultimate-member'),
|
1882 |
+
'YE' => __('Yemen','ultimate-member'),
|
1883 |
+
'ZM' => __('Zambia','ultimate-member'),
|
1884 |
+
'ZW' => __('Zimbabwe','ultimate-member'),
|
1885 |
+
);
|
1886 |
+
break;
|
1887 |
+
|
1888 |
+
}
|
1889 |
+
|
1890 |
+
/**
|
1891 |
+
* UM hook
|
1892 |
+
*
|
1893 |
+
* @type filter
|
1894 |
+
* @title um_{$data}_predefined_field_options
|
1895 |
+
* @description Extend Predefined Fields options. Where $data - field key.
|
1896 |
+
* @input_vars
|
1897 |
+
* [{"var":"$options","type":"array","desc":"Field's Options"}]
|
1898 |
+
* @change_log
|
1899 |
+
* ["Since: 2.0"]
|
1900 |
+
* @usage add_filter( 'um_{$data}_predefined_field_options', 'function_name', 10, 1 );
|
1901 |
+
* @example
|
1902 |
+
* <?php
|
1903 |
+
* add_filter( 'um_{$data}_predefined_field_options', 'my_predefined_field', 10, 1 );
|
1904 |
+
* function my_predefined_field( $options ) {
|
1905 |
+
* // your code here
|
1906 |
+
* return $options;
|
1907 |
+
* }
|
1908 |
+
* ?>
|
1909 |
+
*/
|
1910 |
+
$array = apply_filters( "um_{$data}_predefined_field_options", $array );
|
1911 |
+
return $array;
|
1912 |
+
}
|
1913 |
+
|
1914 |
+
}
|
1915 |
+
}
|
includes/core/class-enqueue.php
CHANGED
@@ -1,442 +1,442 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
|
5 |
-
// Exit if accessed directly
|
6 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
7 |
-
|
8 |
-
|
9 |
-
if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
10 |
-
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class Enqueue
|
14 |
-
* @package um\core
|
15 |
-
*/
|
16 |
-
class Enqueue {
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @var string
|
21 |
-
*/
|
22 |
-
var $suffix = '';
|
23 |
-
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @var string
|
27 |
-
*/
|
28 |
-
var $js_baseurl = '';
|
29 |
-
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @var string
|
33 |
-
*/
|
34 |
-
var $css_baseurl = '';
|
35 |
-
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Enqueue constructor.
|
39 |
-
*/
|
40 |
-
function __construct() {
|
41 |
-
$this->suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'UM_SCRIPT_DEBUG' ) ) ? '' : '.min';
|
42 |
-
|
43 |
-
$this->js_baseurl = um_url . 'assets/js/';
|
44 |
-
$this->css_baseurl = um_url . 'assets/css/';
|
45 |
-
|
46 |
-
add_action( 'init', array( &$this, 'scripts_enqueue_priority' ) );
|
47 |
-
}
|
48 |
-
|
49 |
-
|
50 |
-
/**
|
51 |
-
*
|
52 |
-
*/
|
53 |
-
function scripts_enqueue_priority() {
|
54 |
-
add_action( 'wp_enqueue_scripts', array( &$this, 'wp_enqueue_scripts' ), $this->get_priority() );
|
55 |
-
}
|
56 |
-
|
57 |
-
|
58 |
-
/**
|
59 |
-
* @return int
|
60 |
-
*/
|
61 |
-
function get_priority() {
|
62 |
-
/**
|
63 |
-
* UM hook
|
64 |
-
*
|
65 |
-
* @type filter
|
66 |
-
* @title um_core_enqueue_priority
|
67 |
-
* @description Change Enqueue scripts priority
|
68 |
-
* @input_vars
|
69 |
-
* [{"var":"$priority","type":"int","desc":"Priority"}]
|
70 |
-
* @change_log
|
71 |
-
* ["Since: 2.0"]
|
72 |
-
* @usage add_filter( 'um_core_enqueue_priority', 'function_name', 10, 1 );
|
73 |
-
* @example
|
74 |
-
* <?php
|
75 |
-
* add_filter( 'um_core_enqueue_priority', 'my_core_enqueue_priority', 10, 1 );
|
76 |
-
* function my_core_enqueue_priority( $priority ) {
|
77 |
-
* // your code here
|
78 |
-
* return $priority;
|
79 |
-
* }
|
80 |
-
* ?>
|
81 |
-
*/
|
82 |
-
return apply_filters( 'um_core_enqueue_priority', 100 );
|
83 |
-
}
|
84 |
-
|
85 |
-
|
86 |
-
/**
|
87 |
-
*
|
88 |
-
*/
|
89 |
-
function register_scripts() {
|
90 |
-
$dequeue_select2 = apply_filters( 'um_dequeue_select2_scripts', false );
|
91 |
-
if ( class_exists( 'WooCommerce' ) || $dequeue_select2 ) {
|
92 |
-
wp_dequeue_style( 'select2' );
|
93 |
-
wp_deregister_style( 'select2' );
|
94 |
-
|
95 |
-
wp_dequeue_script( 'select2');
|
96 |
-
wp_deregister_script('select2');
|
97 |
-
}
|
98 |
-
wp_register_script( 'select2', $this->js_baseurl . 'select2/select2.full' . $this->suffix . '.js', array( 'jquery' ), '4.0.13', true );
|
99 |
-
|
100 |
-
wp_register_script( 'um_scrollbar', $this->js_baseurl . 'simplebar' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
101 |
-
|
102 |
-
wp_register_script( 'um_jquery_form', $this->js_baseurl . 'um-jquery-form' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
103 |
-
wp_register_script( 'um_fileupload', $this->js_baseurl . 'um-fileupload
|
104 |
-
|
105 |
-
|
106 |
-
wp_register_script( 'um_datetime', $this->js_baseurl . 'pickadate/picker.js', array( 'jquery' ), ultimatemember_version, true );
|
107 |
-
wp_register_script( 'um_datetime_date', $this->js_baseurl . 'pickadate/picker.date.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
108 |
-
wp_register_script( 'um_datetime_time', $this->js_baseurl . 'pickadate/picker.time.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
109 |
-
// wp_register_script( 'um_datetime_legacy', $this->js_baseurl . 'pickadate/legacy.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
110 |
-
// load a localized version for date/time
|
111 |
-
$locale = get_locale();
|
112 |
-
if ( $locale ) {
|
113 |
-
if ( file_exists( WP_LANG_DIR . '/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js' ) ) {
|
114 |
-
wp_register_script('um_datetime_locale', content_url() . '/languages/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
115 |
-
} elseif ( file_exists( um_path . 'assets/js/pickadate/translations/' . $locale . '.js' ) ) {
|
116 |
-
wp_register_script('um_datetime_locale', um_url . 'assets/js/pickadate/translations/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
117 |
-
}
|
118 |
-
}
|
119 |
-
|
120 |
-
wp_register_script( 'um_tipsy', $this->js_baseurl . 'um-tipsy' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
121 |
-
wp_register_script( 'um_raty', $this->js_baseurl . 'um-raty' . $this->suffix . '.js', array( 'jquery', 'wp-i18n' ), ultimatemember_version, true );
|
122 |
-
wp_register_script( 'um_crop', $this->js_baseurl . 'um-crop' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
123 |
-
|
124 |
-
wp_register_script( 'um_modal', $this->js_baseurl . 'um-modal' . $this->suffix . '.js', array( 'jquery', 'wp-util', 'um_crop' ), ultimatemember_version, true );
|
125 |
-
|
126 |
-
wp_register_script('um_functions', $this->js_baseurl . 'um-functions' . $this->suffix . '.js', array( 'jquery', 'jquery-masonry', 'wp-util', 'um_scrollbar' ), ultimatemember_version, true );
|
127 |
-
wp_register_script( 'um_responsive', $this->js_baseurl . 'um-responsive' . $this->suffix . '.js', array( 'jquery', 'um_functions', 'um_crop' ), ultimatemember_version, true );
|
128 |
-
|
129 |
-
wp_register_script( 'um-gdpr', $this->js_baseurl . 'um-gdpr' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, false );
|
130 |
-
wp_register_script('um_conditional', $this->js_baseurl . 'um-conditional' . $this->suffix . '.js', array( 'jquery', 'wp-hooks' ), ultimatemember_version, true );
|
131 |
-
wp_register_script('um_scripts', $this->js_baseurl . 'um-scripts' . $this->suffix . '.js', array( 'jquery', 'wp-util', 'um_conditional', 'um_datetime', 'um_datetime_date', 'um_datetime_time', /*'um_datetime_legacy',*/ 'select2' ), ultimatemember_version, true );
|
132 |
-
/**
|
133 |
-
* UM hook
|
134 |
-
*
|
135 |
-
* @type filter
|
136 |
-
* @title um_enqueue_localize_data
|
137 |
-
* @description Extend UM localized data
|
138 |
-
* @input_vars
|
139 |
-
* [{"var":"$data","type":"array","desc":"Localize Array"}]
|
140 |
-
* @change_log
|
141 |
-
* ["Since: 2.0"]
|
142 |
-
* @usage add_filter( 'um_enqueue_localize_data', 'function_name', 10, 1 );
|
143 |
-
* @example
|
144 |
-
* <?php
|
145 |
-
* add_filter( 'um_enqueue_localize_data', 'my_enqueue_localize_data', 10, 1 );
|
146 |
-
* function my_enqueue_localize_data( $data ) {
|
147 |
-
* // your code here
|
148 |
-
* return $data;
|
149 |
-
* }
|
150 |
-
* ?>
|
151 |
-
*/
|
152 |
-
|
153 |
-
|
154 |
-
$max_upload_size = wp_max_upload_size();
|
155 |
-
if ( ! $max_upload_size ) {
|
156 |
-
$max_upload_size = 0;
|
157 |
-
}
|
158 |
-
|
159 |
-
$localize_data = apply_filters( 'um_enqueue_localize_data', array(
|
160 |
-
'max_upload_size' => $max_upload_size,
|
161 |
-
'nonce' => wp_create_nonce( "um-frontend-nonce" ),
|
162 |
-
) );
|
163 |
-
wp_localize_script( 'um_scripts', 'um_scripts', $localize_data );
|
164 |
-
|
165 |
-
wp_register_script('um_dropdown', $this->js_baseurl . 'dropdown' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
166 |
-
|
167 |
-
wp_register_script('um_members', $this->js_baseurl . 'um-members' . $this->suffix . '.js', array( 'jquery', 'wp-util', 'jquery-ui-slider', 'um_dropdown', 'wp-hooks', 'jquery-masonry', 'um_scripts' ), ultimatemember_version, true );
|
168 |
-
wp_register_script('um_profile', $this->js_baseurl . 'um-profile' . $this->suffix . '.js', array( 'jquery', 'wp-util', 'wp-i18n' ), ultimatemember_version, true );
|
169 |
-
|
170 |
-
$account_deps = apply_filters( 'um_account_scripts_dependencies', array( 'jquery', 'wp-hooks' ) );
|
171 |
-
wp_register_script('um_account', $this->js_baseurl . 'um-account' . $this->suffix . '.js', $account_deps, ultimatemember_version, true );
|
172 |
-
|
173 |
-
wp_register_script( 'um_gchart', 'https://www.google.com/jsapi', array(), ultimatemember_version, true );
|
174 |
-
}
|
175 |
-
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Register styles
|
179 |
-
*/
|
180 |
-
function register_styles() {
|
181 |
-
|
182 |
-
//FontAwesome and FontIcons styles
|
183 |
-
wp_register_style( 'um_fonticons_ii', $this->css_baseurl . 'um-fonticons-ii.css', array(), ultimatemember_version );
|
184 |
-
wp_register_style( 'um_fonticons_fa', $this->css_baseurl . 'um-fonticons-fa.css', array(), ultimatemember_version );
|
185 |
-
wp_register_style( 'um_crop', $this->css_baseurl . 'um-crop.css', array(), ultimatemember_version );
|
186 |
-
wp_register_style( 'um_tipsy', $this->css_baseurl . 'um-tipsy.css', array(), ultimatemember_version );
|
187 |
-
wp_register_style( 'um_raty', $this->css_baseurl . 'um-raty.css', array(), ultimatemember_version );
|
188 |
-
wp_register_style( 'select2', $this->css_baseurl . 'select2/select2.min.css', array(), '4.0.13' );
|
189 |
-
wp_register_style( 'um_fileupload', $this->css_baseurl . 'um-fileupload.css', array(), ultimatemember_version );
|
190 |
-
wp_register_style( 'um_datetime', $this->css_baseurl . 'pickadate/default.css', array(), ultimatemember_version );
|
191 |
-
wp_register_style( 'um_datetime_date', $this->css_baseurl . 'pickadate/default.date.css', array( 'um_datetime' ), ultimatemember_version );
|
192 |
-
wp_register_style( 'um_datetime_time', $this->css_baseurl . 'pickadate/default.time.css', array( 'um_datetime' ), ultimatemember_version );
|
193 |
-
wp_register_style( 'um_scrollbar', $this->css_baseurl . 'simplebar.css', array(), ultimatemember_version );
|
194 |
-
|
195 |
-
wp_register_style( 'um_rtl', $this->css_baseurl . 'um.rtl.css', array(), ultimatemember_version );
|
196 |
-
wp_register_style( 'um_default_css', $this->css_baseurl . 'um-old-default.css', array(), ultimatemember_version );
|
197 |
-
wp_register_style( 'um_modal', $this->css_baseurl . 'um-modal.css', array( 'um_crop' ), ultimatemember_version );
|
198 |
-
wp_register_style( 'um_responsive', $this->css_baseurl . 'um-responsive.css', array( 'um_profile', 'um_crop' ), ultimatemember_version );
|
199 |
-
|
200 |
-
wp_register_style( 'um_styles', $this->css_baseurl . 'um-styles.css', array(), ultimatemember_version );
|
201 |
-
|
202 |
-
wp_register_style( 'um_ui', $this->css_baseurl . 'jquery-ui.css', array(), ultimatemember_version );
|
203 |
-
|
204 |
-
wp_register_style( 'um_members', $this->css_baseurl . 'um-members.css', array( 'um_ui' ), ultimatemember_version );
|
205 |
-
if ( is_rtl() ) {
|
206 |
-
wp_register_style( 'um_members_rtl', $this->css_baseurl . 'um-members-rtl.css', array( 'um_members' ), ultimatemember_version );
|
207 |
-
}
|
208 |
-
|
209 |
-
wp_register_style( 'um_profile', $this->css_baseurl . 'um-profile.css', array(), ultimatemember_version );
|
210 |
-
wp_register_style( 'um_account', $this->css_baseurl . 'um-account.css', array(), ultimatemember_version );
|
211 |
-
wp_register_style( 'um_misc', $this->css_baseurl . 'um-misc.css', array(), ultimatemember_version );
|
212 |
-
|
213 |
-
}
|
214 |
-
|
215 |
-
|
216 |
-
/**
|
217 |
-
* Enqueue scripts and styles
|
218 |
-
*/
|
219 |
-
function wp_enqueue_scripts() {
|
220 |
-
|
221 |
-
$this->register_scripts();
|
222 |
-
$this->register_styles();
|
223 |
-
|
224 |
-
$this->load_original();
|
225 |
-
|
226 |
-
// rtl style
|
227 |
-
if ( is_rtl() ) {
|
228 |
-
wp_enqueue_style( 'um_rtl' );
|
229 |
-
}
|
230 |
-
|
231 |
-
global $post;
|
232 |
-
if ( is_object( $post ) && has_shortcode( $post->post_content,'ultimatemember' ) ) {
|
233 |
-
wp_dequeue_script( 'jquery-form' );
|
234 |
-
}
|
235 |
-
|
236 |
-
//old settings before UM 2.0 CSS
|
237 |
-
wp_enqueue_style( 'um_default_css' );
|
238 |
-
|
239 |
-
$this->old_css_settings();
|
240 |
-
}
|
241 |
-
|
242 |
-
|
243 |
-
/**
|
244 |
-
*
|
245 |
-
*/
|
246 |
-
function old_css_settings() {
|
247 |
-
$uploads = wp_upload_dir();
|
248 |
-
$upload_dir = $uploads['basedir'] . DIRECTORY_SEPARATOR . 'ultimatemember' . DIRECTORY_SEPARATOR;
|
249 |
-
if ( file_exists( $upload_dir . 'um_old_settings.css' ) ) {
|
250 |
-
wp_register_style( 'um_old_css', um_url . '../../uploads/ultimatemember/um_old_settings.css' );
|
251 |
-
wp_enqueue_style( 'um_old_css' );
|
252 |
-
}
|
253 |
-
}
|
254 |
-
|
255 |
-
|
256 |
-
/**
|
257 |
-
* This will load original files (not minified)
|
258 |
-
*/
|
259 |
-
function load_original() {
|
260 |
-
|
261 |
-
//maybe deprecated
|
262 |
-
//$this->load_google_charts();
|
263 |
-
|
264 |
-
$this->load_fonticons();
|
265 |
-
|
266 |
-
$this->load_selectjs();
|
267 |
-
|
268 |
-
$this->load_modal();
|
269 |
-
|
270 |
-
$this->load_css();
|
271 |
-
|
272 |
-
$this->load_fileupload();
|
273 |
-
|
274 |
-
$this->load_datetimepicker();
|
275 |
-
|
276 |
-
$this->load_raty();
|
277 |
-
|
278 |
-
//$this->load_scrollto();
|
279 |
-
|
280 |
-
$this->load_scrollbar();
|
281 |
-
|
282 |
-
$this->load_imagecrop();
|
283 |
-
|
284 |
-
$this->load_tipsy();
|
285 |
-
|
286 |
-
$this->load_functions();
|
287 |
-
|
288 |
-
$this->load_responsive();
|
289 |
-
|
290 |
-
$this->load_customjs();
|
291 |
-
|
292 |
-
}
|
293 |
-
|
294 |
-
|
295 |
-
/**
|
296 |
-
* Include Google charts
|
297 |
-
*/
|
298 |
-
function load_google_charts() {
|
299 |
-
wp_enqueue_script( 'um_gchart' );
|
300 |
-
}
|
301 |
-
|
302 |
-
|
303 |
-
/**
|
304 |
-
* Load plugin css
|
305 |
-
*/
|
306 |
-
function load_css() {
|
307 |
-
wp_enqueue_style( 'um_styles' );
|
308 |
-
/*if ( is_rtl() ) {
|
309 |
-
wp_enqueue_style( 'um_members_rtl' );
|
310 |
-
} else {
|
311 |
-
wp_enqueue_style( 'um_members' );
|
312 |
-
}*/
|
313 |
-
|
314 |
-
wp_enqueue_style( 'um_profile' );
|
315 |
-
wp_enqueue_style( 'um_account' );
|
316 |
-
wp_enqueue_style( 'um_misc' );
|
317 |
-
}
|
318 |
-
|
319 |
-
|
320 |
-
/**
|
321 |
-
* Load select-dropdowns JS
|
322 |
-
*/
|
323 |
-
function load_selectjs() {
|
324 |
-
wp_enqueue_script( 'select2' );
|
325 |
-
wp_enqueue_style( 'select2' );
|
326 |
-
}
|
327 |
-
|
328 |
-
|
329 |
-
/**
|
330 |
-
* Load Fonticons
|
331 |
-
*/
|
332 |
-
function load_fonticons() {
|
333 |
-
wp_enqueue_style( 'um_fonticons_ii' );
|
334 |
-
wp_enqueue_style( 'um_fonticons_fa' );
|
335 |
-
}
|
336 |
-
|
337 |
-
|
338 |
-
/**
|
339 |
-
* Load fileupload JS
|
340 |
-
*/
|
341 |
-
function load_fileupload() {
|
342 |
-
wp_enqueue_script( 'um_fileupload' );
|
343 |
-
wp_enqueue_style( 'um_fileupload' );
|
344 |
-
}
|
345 |
-
|
346 |
-
|
347 |
-
/**
|
348 |
-
* Load JS functions
|
349 |
-
*/
|
350 |
-
function load_functions() {
|
351 |
-
wp_enqueue_script('um_functions' );
|
352 |
-
wp_enqueue_script( 'um-gdpr' );
|
353 |
-
}
|
354 |
-
|
355 |
-
|
356 |
-
/**
|
357 |
-
* Load custom JS
|
358 |
-
*/
|
359 |
-
function load_customjs() {
|
360 |
-
wp_enqueue_script('um_conditional');
|
361 |
-
wp_enqueue_script('um_scripts');
|
362 |
-
//wp_enqueue_script('um_members');
|
363 |
-
wp_enqueue_script('um_profile');
|
364 |
-
wp_enqueue_script('um_account');
|
365 |
-
}
|
366 |
-
|
367 |
-
|
368 |
-
/**
|
369 |
-
* Load date & time picker
|
370 |
-
*/
|
371 |
-
function load_datetimepicker() {
|
372 |
-
wp_enqueue_script( 'um_datetime' );
|
373 |
-
wp_enqueue_script( 'um_datetime_date' );
|
374 |
-
wp_enqueue_script( 'um_datetime_time' );
|
375 |
-
//wp_enqueue_script( 'um_datetime_legacy' );
|
376 |
-
|
377 |
-
// load a localized version for date/time
|
378 |
-
$locale = get_locale();
|
379 |
-
if ( $locale && ( file_exists( WP_LANG_DIR . '/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js' ) || file_exists( um_path . 'assets/js/pickadate/translations/' . $locale . '.js' ) ) ) {
|
380 |
-
wp_enqueue_script('um_datetime_locale' );
|
381 |
-
}
|
382 |
-
|
383 |
-
wp_enqueue_style( 'um_datetime' );
|
384 |
-
wp_enqueue_style( 'um_datetime_date' );
|
385 |
-
wp_enqueue_style( 'um_datetime_time' );
|
386 |
-
}
|
387 |
-
|
388 |
-
|
389 |
-
/**
|
390 |
-
* Load scrollbar
|
391 |
-
*/
|
392 |
-
function load_scrollbar(){
|
393 |
-
wp_enqueue_style('um_scrollbar');
|
394 |
-
}
|
395 |
-
|
396 |
-
|
397 |
-
/**
|
398 |
-
* Load rating
|
399 |
-
*/
|
400 |
-
function load_raty() {
|
401 |
-
wp_enqueue_script('um_raty');
|
402 |
-
wp_enqueue_style('um_raty');
|
403 |
-
}
|
404 |
-
|
405 |
-
|
406 |
-
/**
|
407 |
-
* Load crop script
|
408 |
-
*/
|
409 |
-
function load_imagecrop() {
|
410 |
-
wp_enqueue_script( 'um_crop' );
|
411 |
-
wp_enqueue_style( 'um_crop' );
|
412 |
-
}
|
413 |
-
|
414 |
-
|
415 |
-
/**
|
416 |
-
* Load tipsy
|
417 |
-
*/
|
418 |
-
function load_tipsy() {
|
419 |
-
wp_enqueue_script( 'um_tipsy' );
|
420 |
-
wp_enqueue_style( 'um_tipsy' );
|
421 |
-
}
|
422 |
-
|
423 |
-
|
424 |
-
/**
|
425 |
-
* Load modal
|
426 |
-
*/
|
427 |
-
function load_modal() {
|
428 |
-
wp_enqueue_script( 'um_modal' );
|
429 |
-
wp_enqueue_style( 'um_modal' );
|
430 |
-
}
|
431 |
-
|
432 |
-
|
433 |
-
/**
|
434 |
-
* Load responsive styles
|
435 |
-
*/
|
436 |
-
function load_responsive() {
|
437 |
-
wp_enqueue_script( 'um_responsive' );
|
438 |
-
wp_enqueue_style( 'um_responsive' );
|
439 |
-
}
|
440 |
-
|
441 |
-
}
|
442 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
|
5 |
+
// Exit if accessed directly
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
7 |
+
|
8 |
+
|
9 |
+
if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class Enqueue
|
14 |
+
* @package um\core
|
15 |
+
*/
|
16 |
+
class Enqueue {
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
var $suffix = '';
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var string
|
27 |
+
*/
|
28 |
+
var $js_baseurl = '';
|
29 |
+
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @var string
|
33 |
+
*/
|
34 |
+
var $css_baseurl = '';
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Enqueue constructor.
|
39 |
+
*/
|
40 |
+
function __construct() {
|
41 |
+
$this->suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'UM_SCRIPT_DEBUG' ) ) ? '' : '.min';
|
42 |
+
|
43 |
+
$this->js_baseurl = um_url . 'assets/js/';
|
44 |
+
$this->css_baseurl = um_url . 'assets/css/';
|
45 |
+
|
46 |
+
add_action( 'init', array( &$this, 'scripts_enqueue_priority' ) );
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
*
|
52 |
+
*/
|
53 |
+
function scripts_enqueue_priority() {
|
54 |
+
add_action( 'wp_enqueue_scripts', array( &$this, 'wp_enqueue_scripts' ), $this->get_priority() );
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @return int
|
60 |
+
*/
|
61 |
+
function get_priority() {
|
62 |
+
/**
|
63 |
+
* UM hook
|
64 |
+
*
|
65 |
+
* @type filter
|
66 |
+
* @title um_core_enqueue_priority
|
67 |
+
* @description Change Enqueue scripts priority
|
68 |
+
* @input_vars
|
69 |
+
* [{"var":"$priority","type":"int","desc":"Priority"}]
|
70 |
+
* @change_log
|
71 |
+
* ["Since: 2.0"]
|
72 |
+
* @usage add_filter( 'um_core_enqueue_priority', 'function_name', 10, 1 );
|
73 |
+
* @example
|
74 |
+
* <?php
|
75 |
+
* add_filter( 'um_core_enqueue_priority', 'my_core_enqueue_priority', 10, 1 );
|
76 |
+
* function my_core_enqueue_priority( $priority ) {
|
77 |
+
* // your code here
|
78 |
+
* return $priority;
|
79 |
+
* }
|
80 |
+
* ?>
|
81 |
+
*/
|
82 |
+
return apply_filters( 'um_core_enqueue_priority', 100 );
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
/**
|
87 |
+
*
|
88 |
+
*/
|
89 |
+
function register_scripts() {
|
90 |
+
$dequeue_select2 = apply_filters( 'um_dequeue_select2_scripts', false );
|
91 |
+
if ( class_exists( 'WooCommerce' ) || $dequeue_select2 ) {
|
92 |
+
wp_dequeue_style( 'select2' );
|
93 |
+
wp_deregister_style( 'select2' );
|
94 |
+
|
95 |
+
wp_dequeue_script( 'select2');
|
96 |
+
wp_deregister_script('select2');
|
97 |
+
}
|
98 |
+
wp_register_script( 'select2', $this->js_baseurl . 'select2/select2.full' . $this->suffix . '.js', array( 'jquery' ), '4.0.13', true );
|
99 |
+
|
100 |
+
wp_register_script( 'um_scrollbar', $this->js_baseurl . 'simplebar' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
101 |
+
|
102 |
+
wp_register_script( 'um_jquery_form', $this->js_baseurl . 'um-jquery-form' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
103 |
+
wp_register_script( 'um_fileupload', $this->js_baseurl . 'um-fileupload.js', array( 'jquery', 'um_jquery_form' ), ultimatemember_version, true );
|
104 |
+
|
105 |
+
|
106 |
+
wp_register_script( 'um_datetime', $this->js_baseurl . 'pickadate/picker.js', array( 'jquery' ), ultimatemember_version, true );
|
107 |
+
wp_register_script( 'um_datetime_date', $this->js_baseurl . 'pickadate/picker.date.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
108 |
+
wp_register_script( 'um_datetime_time', $this->js_baseurl . 'pickadate/picker.time.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
109 |
+
// wp_register_script( 'um_datetime_legacy', $this->js_baseurl . 'pickadate/legacy.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
110 |
+
// load a localized version for date/time
|
111 |
+
$locale = get_locale();
|
112 |
+
if ( $locale ) {
|
113 |
+
if ( file_exists( WP_LANG_DIR . '/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js' ) ) {
|
114 |
+
wp_register_script('um_datetime_locale', content_url() . '/languages/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
115 |
+
} elseif ( file_exists( um_path . 'assets/js/pickadate/translations/' . $locale . '.js' ) ) {
|
116 |
+
wp_register_script('um_datetime_locale', um_url . 'assets/js/pickadate/translations/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
wp_register_script( 'um_tipsy', $this->js_baseurl . 'um-tipsy' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
121 |
+
wp_register_script( 'um_raty', $this->js_baseurl . 'um-raty' . $this->suffix . '.js', array( 'jquery', 'wp-i18n' ), ultimatemember_version, true );
|
122 |
+
wp_register_script( 'um_crop', $this->js_baseurl . 'um-crop' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
123 |
+
|
124 |
+
wp_register_script( 'um_modal', $this->js_baseurl . 'um-modal' . $this->suffix . '.js', array( 'jquery', 'wp-util', 'um_crop' ), ultimatemember_version, true );
|
125 |
+
|
126 |
+
wp_register_script('um_functions', $this->js_baseurl . 'um-functions' . $this->suffix . '.js', array( 'jquery', 'jquery-masonry', 'wp-util', 'um_scrollbar' ), ultimatemember_version, true );
|
127 |
+
wp_register_script( 'um_responsive', $this->js_baseurl . 'um-responsive' . $this->suffix . '.js', array( 'jquery', 'um_functions', 'um_crop' ), ultimatemember_version, true );
|
128 |
+
|
129 |
+
wp_register_script( 'um-gdpr', $this->js_baseurl . 'um-gdpr' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, false );
|
130 |
+
wp_register_script('um_conditional', $this->js_baseurl . 'um-conditional' . $this->suffix . '.js', array( 'jquery', 'wp-hooks' ), ultimatemember_version, true );
|
131 |
+
wp_register_script('um_scripts', $this->js_baseurl . 'um-scripts' . $this->suffix . '.js', array( 'jquery', 'wp-util', 'um_conditional', 'um_datetime', 'um_datetime_date', 'um_datetime_time', /*'um_datetime_legacy',*/ 'select2' ), ultimatemember_version, true );
|
132 |
+
/**
|
133 |
+
* UM hook
|
134 |
+
*
|
135 |
+
* @type filter
|
136 |
+
* @title um_enqueue_localize_data
|
137 |
+
* @description Extend UM localized data
|
138 |
+
* @input_vars
|
139 |
+
* [{"var":"$data","type":"array","desc":"Localize Array"}]
|
140 |
+
* @change_log
|
141 |
+
* ["Since: 2.0"]
|
142 |
+
* @usage add_filter( 'um_enqueue_localize_data', 'function_name', 10, 1 );
|
143 |
+
* @example
|
144 |
+
* <?php
|
145 |
+
* add_filter( 'um_enqueue_localize_data', 'my_enqueue_localize_data', 10, 1 );
|
146 |
+
* function my_enqueue_localize_data( $data ) {
|
147 |
+
* // your code here
|
148 |
+
* return $data;
|
149 |
+
* }
|
150 |
+
* ?>
|
151 |
+
*/
|
152 |
+
|
153 |
+
|
154 |
+
$max_upload_size = wp_max_upload_size();
|
155 |
+
if ( ! $max_upload_size ) {
|
156 |
+
$max_upload_size = 0;
|
157 |
+
}
|
158 |
+
|
159 |
+
$localize_data = apply_filters( 'um_enqueue_localize_data', array(
|
160 |
+
'max_upload_size' => $max_upload_size,
|
161 |
+
'nonce' => wp_create_nonce( "um-frontend-nonce" ),
|
162 |
+
) );
|
163 |
+
wp_localize_script( 'um_scripts', 'um_scripts', $localize_data );
|
164 |
+
|
165 |
+
wp_register_script('um_dropdown', $this->js_baseurl . 'dropdown' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
166 |
+
|
167 |
+
wp_register_script('um_members', $this->js_baseurl . 'um-members' . $this->suffix . '.js', array( 'jquery', 'wp-util', 'jquery-ui-slider', 'um_dropdown', 'wp-hooks', 'jquery-masonry', 'um_scripts' ), ultimatemember_version, true );
|
168 |
+
wp_register_script('um_profile', $this->js_baseurl . 'um-profile' . $this->suffix . '.js', array( 'jquery', 'wp-util', 'wp-i18n' ), ultimatemember_version, true );
|
169 |
+
|
170 |
+
$account_deps = apply_filters( 'um_account_scripts_dependencies', array( 'jquery', 'wp-hooks' ) );
|
171 |
+
wp_register_script('um_account', $this->js_baseurl . 'um-account' . $this->suffix . '.js', $account_deps, ultimatemember_version, true );
|
172 |
+
|
173 |
+
wp_register_script( 'um_gchart', 'https://www.google.com/jsapi', array(), ultimatemember_version, true );
|
174 |
+
}
|
175 |
+
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Register styles
|
179 |
+
*/
|
180 |
+
function register_styles() {
|
181 |
+
|
182 |
+
//FontAwesome and FontIcons styles
|
183 |
+
wp_register_style( 'um_fonticons_ii', $this->css_baseurl . 'um-fonticons-ii.css', array(), ultimatemember_version );
|
184 |
+
wp_register_style( 'um_fonticons_fa', $this->css_baseurl . 'um-fonticons-fa.css', array(), ultimatemember_version );
|
185 |
+
wp_register_style( 'um_crop', $this->css_baseurl . 'um-crop.css', array(), ultimatemember_version );
|
186 |
+
wp_register_style( 'um_tipsy', $this->css_baseurl . 'um-tipsy.css', array(), ultimatemember_version );
|
187 |
+
wp_register_style( 'um_raty', $this->css_baseurl . 'um-raty.css', array(), ultimatemember_version );
|
188 |
+
wp_register_style( 'select2', $this->css_baseurl . 'select2/select2.min.css', array(), '4.0.13' );
|
189 |
+
wp_register_style( 'um_fileupload', $this->css_baseurl . 'um-fileupload.css', array(), ultimatemember_version );
|
190 |
+
wp_register_style( 'um_datetime', $this->css_baseurl . 'pickadate/default.css', array(), ultimatemember_version );
|
191 |
+
wp_register_style( 'um_datetime_date', $this->css_baseurl . 'pickadate/default.date.css', array( 'um_datetime' ), ultimatemember_version );
|
192 |
+
wp_register_style( 'um_datetime_time', $this->css_baseurl . 'pickadate/default.time.css', array( 'um_datetime' ), ultimatemember_version );
|
193 |
+
wp_register_style( 'um_scrollbar', $this->css_baseurl . 'simplebar.css', array(), ultimatemember_version );
|
194 |
+
|
195 |
+
wp_register_style( 'um_rtl', $this->css_baseurl . 'um.rtl.css', array(), ultimatemember_version );
|
196 |
+
wp_register_style( 'um_default_css', $this->css_baseurl . 'um-old-default.css', array(), ultimatemember_version );
|
197 |
+
wp_register_style( 'um_modal', $this->css_baseurl . 'um-modal.css', array( 'um_crop' ), ultimatemember_version );
|
198 |
+
wp_register_style( 'um_responsive', $this->css_baseurl . 'um-responsive.css', array( 'um_profile', 'um_crop' ), ultimatemember_version );
|
199 |
+
|
200 |
+
wp_register_style( 'um_styles', $this->css_baseurl . 'um-styles.css', array(), ultimatemember_version );
|
201 |
+
|
202 |
+
wp_register_style( 'um_ui', $this->css_baseurl . 'jquery-ui.css', array(), ultimatemember_version );
|
203 |
+
|
204 |
+
wp_register_style( 'um_members', $this->css_baseurl . 'um-members.css', array( 'um_ui' ), ultimatemember_version );
|
205 |
+
if ( is_rtl() ) {
|
206 |
+
wp_register_style( 'um_members_rtl', $this->css_baseurl . 'um-members-rtl.css', array( 'um_members' ), ultimatemember_version );
|
207 |
+
}
|
208 |
+
|
209 |
+
wp_register_style( 'um_profile', $this->css_baseurl . 'um-profile.css', array(), ultimatemember_version );
|
210 |
+
wp_register_style( 'um_account', $this->css_baseurl . 'um-account.css', array(), ultimatemember_version );
|
211 |
+
wp_register_style( 'um_misc', $this->css_baseurl . 'um-misc.css', array(), ultimatemember_version );
|
212 |
+
|
213 |
+
}
|
214 |
+
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Enqueue scripts and styles
|
218 |
+
*/
|
219 |
+
function wp_enqueue_scripts() {
|
220 |
+
|
221 |
+
$this->register_scripts();
|
222 |
+
$this->register_styles();
|
223 |
+
|
224 |
+
$this->load_original();
|
225 |
+
|
226 |
+
// rtl style
|
227 |
+
if ( is_rtl() ) {
|
228 |
+
wp_enqueue_style( 'um_rtl' );
|
229 |
+
}
|
230 |
+
|
231 |
+
global $post;
|
232 |
+
if ( is_object( $post ) && has_shortcode( $post->post_content,'ultimatemember' ) ) {
|
233 |
+
wp_dequeue_script( 'jquery-form' );
|
234 |
+
}
|
235 |
+
|
236 |
+
//old settings before UM 2.0 CSS
|
237 |
+
wp_enqueue_style( 'um_default_css' );
|
238 |
+
|
239 |
+
$this->old_css_settings();
|
240 |
+
}
|
241 |
+
|
242 |
+
|
243 |
+
/**
|
244 |
+
*
|
245 |
+
*/
|
246 |
+
function old_css_settings() {
|
247 |
+
$uploads = wp_upload_dir();
|
248 |
+
$upload_dir = $uploads['basedir'] . DIRECTORY_SEPARATOR . 'ultimatemember' . DIRECTORY_SEPARATOR;
|
249 |
+
if ( file_exists( $upload_dir . 'um_old_settings.css' ) ) {
|
250 |
+
wp_register_style( 'um_old_css', um_url . '../../uploads/ultimatemember/um_old_settings.css' );
|
251 |
+
wp_enqueue_style( 'um_old_css' );
|
252 |
+
}
|
253 |
+
}
|
254 |
+
|
255 |
+
|
256 |
+
/**
|
257 |
+
* This will load original files (not minified)
|
258 |
+
*/
|
259 |
+
function load_original() {
|
260 |
+
|
261 |
+
//maybe deprecated
|
262 |
+
//$this->load_google_charts();
|
263 |
+
|
264 |
+
$this->load_fonticons();
|
265 |
+
|
266 |
+
$this->load_selectjs();
|
267 |
+
|
268 |
+
$this->load_modal();
|
269 |
+
|
270 |
+
$this->load_css();
|
271 |
+
|
272 |
+
$this->load_fileupload();
|
273 |
+
|
274 |
+
$this->load_datetimepicker();
|
275 |
+
|
276 |
+
$this->load_raty();
|
277 |
+
|
278 |
+
//$this->load_scrollto();
|
279 |
+
|
280 |
+
$this->load_scrollbar();
|
281 |
+
|
282 |
+
$this->load_imagecrop();
|
283 |
+
|
284 |
+
$this->load_tipsy();
|
285 |
+
|
286 |
+
$this->load_functions();
|
287 |
+
|
288 |
+
$this->load_responsive();
|
289 |
+
|
290 |
+
$this->load_customjs();
|
291 |
+
|
292 |
+
}
|
293 |
+
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Include Google charts
|
297 |
+
*/
|
298 |
+
function load_google_charts() {
|
299 |
+
wp_enqueue_script( 'um_gchart' );
|
300 |
+
}
|
301 |
+
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Load plugin css
|
305 |
+
*/
|
306 |
+
function load_css() {
|
307 |
+
wp_enqueue_style( 'um_styles' );
|
308 |
+
/*if ( is_rtl() ) {
|
309 |
+
wp_enqueue_style( 'um_members_rtl' );
|
310 |
+
} else {
|
311 |
+
wp_enqueue_style( 'um_members' );
|
312 |
+
}*/
|
313 |
+
|
314 |
+
wp_enqueue_style( 'um_profile' );
|
315 |
+
wp_enqueue_style( 'um_account' );
|
316 |
+
wp_enqueue_style( 'um_misc' );
|
317 |
+
}
|
318 |
+
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Load select-dropdowns JS
|
322 |
+
*/
|
323 |
+
function load_selectjs() {
|
324 |
+
wp_enqueue_script( 'select2' );
|
325 |
+
wp_enqueue_style( 'select2' );
|
326 |
+
}
|
327 |
+
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Load Fonticons
|
331 |
+
*/
|
332 |
+
function load_fonticons() {
|
333 |
+
wp_enqueue_style( 'um_fonticons_ii' );
|
334 |
+
wp_enqueue_style( 'um_fonticons_fa' );
|
335 |
+
}
|
336 |
+
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Load fileupload JS
|
340 |
+
*/
|
341 |
+
function load_fileupload() {
|
342 |
+
wp_enqueue_script( 'um_fileupload' );
|
343 |
+
wp_enqueue_style( 'um_fileupload' );
|
344 |
+
}
|
345 |
+
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Load JS functions
|
349 |
+
*/
|
350 |
+
function load_functions() {
|
351 |
+
wp_enqueue_script('um_functions' );
|
352 |
+
wp_enqueue_script( 'um-gdpr' );
|
353 |
+
}
|
354 |
+
|
355 |
+
|
356 |
+
/**
|
357 |
+
* Load custom JS
|
358 |
+
*/
|
359 |
+
function load_customjs() {
|
360 |
+
wp_enqueue_script('um_conditional');
|
361 |
+
wp_enqueue_script('um_scripts');
|
362 |
+
//wp_enqueue_script('um_members');
|
363 |
+
wp_enqueue_script('um_profile');
|
364 |
+
wp_enqueue_script('um_account');
|
365 |
+
}
|
366 |
+
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Load date & time picker
|
370 |
+
*/
|
371 |
+
function load_datetimepicker() {
|
372 |
+
wp_enqueue_script( 'um_datetime' );
|
373 |
+
wp_enqueue_script( 'um_datetime_date' );
|
374 |
+
wp_enqueue_script( 'um_datetime_time' );
|
375 |
+
//wp_enqueue_script( 'um_datetime_legacy' );
|
376 |
+
|
377 |
+
// load a localized version for date/time
|
378 |
+
$locale = get_locale();
|
379 |
+
if ( $locale && ( file_exists( WP_LANG_DIR . '/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js' ) || file_exists( um_path . 'assets/js/pickadate/translations/' . $locale . '.js' ) ) ) {
|
380 |
+
wp_enqueue_script('um_datetime_locale' );
|
381 |
+
}
|
382 |
+
|
383 |
+
wp_enqueue_style( 'um_datetime' );
|
384 |
+
wp_enqueue_style( 'um_datetime_date' );
|
385 |
+
wp_enqueue_style( 'um_datetime_time' );
|
386 |
+
}
|
387 |
+
|
388 |
+
|
389 |
+
/**
|
390 |
+
* Load scrollbar
|
391 |
+
*/
|
392 |
+
function load_scrollbar(){
|
393 |
+
wp_enqueue_style('um_scrollbar');
|
394 |
+
}
|
395 |
+
|
396 |
+
|
397 |
+
/**
|
398 |
+
* Load rating
|
399 |
+
*/
|
400 |
+
function load_raty() {
|
401 |
+
wp_enqueue_script('um_raty');
|
402 |
+
wp_enqueue_style('um_raty');
|
403 |
+
}
|
404 |
+
|
405 |
+
|
406 |
+
/**
|
407 |
+
* Load crop script
|
408 |
+
*/
|
409 |
+
function load_imagecrop() {
|
410 |
+
wp_enqueue_script( 'um_crop' );
|
411 |
+
wp_enqueue_style( 'um_crop' );
|
412 |
+
}
|
413 |
+
|
414 |
+
|
415 |
+
/**
|
416 |
+
* Load tipsy
|
417 |
+
*/
|
418 |
+
function load_tipsy() {
|
419 |
+
wp_enqueue_script( 'um_tipsy' );
|
420 |
+
wp_enqueue_style( 'um_tipsy' );
|
421 |
+
}
|
422 |
+
|
423 |
+
|
424 |
+
/**
|
425 |
+
* Load modal
|
426 |
+
*/
|
427 |
+
function load_modal() {
|
428 |
+
wp_enqueue_script( 'um_modal' );
|
429 |
+
wp_enqueue_style( 'um_modal' );
|
430 |
+
}
|
431 |
+
|
432 |
+
|
433 |
+
/**
|
434 |
+
* Load responsive styles
|
435 |
+
*/
|
436 |
+
function load_responsive() {
|
437 |
+
wp_enqueue_script( 'um_responsive' );
|
438 |
+
wp_enqueue_style( 'um_responsive' );
|
439 |
+
}
|
440 |
+
|
441 |
+
}
|
442 |
+
}
|
includes/core/class-fields.php
CHANGED
@@ -3783,11 +3783,15 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
|
3783 |
/**
|
3784 |
* Get fields in row
|
3785 |
*
|
3786 |
-
* @param
|
3787 |
*
|
3788 |
* @return string
|
3789 |
*/
|
3790 |
function get_fields_by_row( $row_id ) {
|
|
|
|
|
|
|
|
|
3791 |
foreach ( $this->get_fields as $key => $array ) {
|
3792 |
if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
|
3793 |
$results[ $key ] = $array;
|
3783 |
/**
|
3784 |
* Get fields in row
|
3785 |
*
|
3786 |
+
* @param int $row_id
|
3787 |
*
|
3788 |
* @return string
|
3789 |
*/
|
3790 |
function get_fields_by_row( $row_id ) {
|
3791 |
+
if ( ! isset( $this->get_fields ) ) {
|
3792 |
+
return '';
|
3793 |
+
}
|
3794 |
+
|
3795 |
foreach ( $this->get_fields as $key => $array ) {
|
3796 |
if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
|
3797 |
$results[ $key ] = $array;
|
includes/core/class-form.php
CHANGED
@@ -1,749 +1,749 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
// Exit if accessed directly
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
if ( ! class_exists( 'um\core\Form' ) ) {
|
8 |
-
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class Form
|
12 |
-
* @package um\core
|
13 |
-
*/
|
14 |
-
class Form {
|
15 |
-
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @var null
|
19 |
-
*/
|
20 |
-
public $form_suffix;
|
21 |
-
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @var
|
25 |
-
*/
|
26 |
-
var $form_id;
|
27 |
-
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @var null
|
31 |
-
*/
|
32 |
-
var $post_form = null;
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Form constructor.
|
37 |
-
*/
|
38 |
-
function __construct() {
|
39 |
-
|
40 |
-
$this->form_suffix = null;
|
41 |
-
|
42 |
-
$this->errors = null;
|
43 |
-
|
44 |
-
$this->processing = null;
|
45 |
-
|
46 |
-
add_action( 'template_redirect', array( &$this, 'form_init' ), 2 );
|
47 |
-
|
48 |
-
add_action( 'init', array( &$this, 'field_declare' ), 10 );
|
49 |
-
|
50 |
-
}
|
51 |
-
|
52 |
-
|
53 |
-
/**
|
54 |
-
*
|
55 |
-
*/
|
56 |
-
public function ajax_muted_action() {
|
57 |
-
UM()->check_ajax_nonce();
|
58 |
-
|
59 |
-
/**
|
60 |
-
* @var $user_id
|
61 |
-
* @var $hook
|
62 |
-
*/
|
63 |
-
extract( $_REQUEST );
|
64 |
-
|
65 |
-
if ( isset( $user_id ) ) {
|
66 |
-
$user_id = absint( $user_id );
|
67 |
-
}
|
68 |
-
|
69 |
-
if ( isset( $hook ) ) {
|
70 |
-
$hook = sanitize_key( $hook );
|
71 |
-
}
|
72 |
-
|
73 |
-
if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
74 |
-
die( esc_html__( 'You can not edit this user', 'ultimate-member' ) );
|
75 |
-
}
|
76 |
-
|
77 |
-
switch ( $hook ) {
|
78 |
-
default:
|
79 |
-
/**
|
80 |
-
* UM hook
|
81 |
-
*
|
82 |
-
* @type action
|
83 |
-
* @title um_run_ajax_function__{$hook}
|
84 |
-
* @description Action on AJAX muted action
|
85 |
-
* @input_vars
|
86 |
-
* [{"var":"$request","type":"int","desc":"Request"}]
|
87 |
-
* @change_log
|
88 |
-
* ["Since: 2.0"]
|
89 |
-
* @usage add_action( 'um_run_ajax_function__{$hook}', 'function_name', 10, 1 );
|
90 |
-
* @example
|
91 |
-
* <?php
|
92 |
-
* add_action( 'um_run_ajax_function__{$hook}', 'my_run_ajax_function', 10, 1 );
|
93 |
-
* function my_run_ajax_function( $request ) {
|
94 |
-
* // your code here
|
95 |
-
* }
|
96 |
-
* ?>
|
97 |
-
*/
|
98 |
-
do_action( "um_run_ajax_function__{$hook}", $_REQUEST );
|
99 |
-
break;
|
100 |
-
}
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
/**
|
105 |
-
*
|
106 |
-
*/
|
107 |
-
public function ajax_select_options() {
|
108 |
-
UM()->check_ajax_nonce();
|
109 |
-
|
110 |
-
$arr_options = array();
|
111 |
-
$arr_options['status'] = 'success';
|
112 |
-
$arr_options['post'] = $_POST;
|
113 |
-
|
114 |
-
UM()->fields()->set_id = absint( $_POST['form_id'] );
|
115 |
-
UM()->fields()->set_mode = 'profile';
|
116 |
-
$form_fields = UM()->fields()->get_fields();
|
117 |
-
$arr_options['fields'] = $form_fields;
|
118 |
-
|
119 |
-
if ( isset( $arr_options['post']['members_directory'] ) && 'yes' === $arr_options['post']['members_directory'] ) {
|
120 |
-
$ajax_source_func = $_POST['child_callback'];
|
121 |
-
if ( function_exists( $ajax_source_func ) ) {
|
122 |
-
$arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
|
123 |
-
|
124 |
-
global $wpdb;
|
125 |
-
|
126 |
-
$values_array = $wpdb->get_col(
|
127 |
-
$wpdb->prepare(
|
128 |
-
"SELECT DISTINCT meta_value
|
129 |
-
FROM $wpdb->usermeta
|
130 |
-
WHERE meta_key = %s AND
|
131 |
-
meta_value != ''",
|
132 |
-
$arr_options['post']['child_name']
|
133 |
-
)
|
134 |
-
);
|
135 |
-
|
136 |
-
if ( ! empty( $values_array ) ) {
|
137 |
-
$arr_options['items'] = array_intersect( $arr_options['items'], $values_array );
|
138 |
-
} else {
|
139 |
-
$arr_options['items'] = array();
|
140 |
-
}
|
141 |
-
|
142 |
-
wp_send_json( $arr_options );
|
143 |
-
}
|
144 |
-
} else {
|
145 |
-
/**
|
146 |
-
* UM hook
|
147 |
-
*
|
148 |
-
* @type filter
|
149 |
-
* @title um_ajax_select_options__debug_mode
|
150 |
-
* @description Activate debug mode for AJAX select options
|
151 |
-
* @input_vars
|
152 |
-
* [{"var":"$debug_mode","type":"bool","desc":"Enable Debug mode"}]
|
153 |
-
* @change_log
|
154 |
-
* ["Since: 2.0"]
|
155 |
-
* @usage
|
156 |
-
* <?php add_filter( 'um_ajax_select_options__debug_mode', 'function_name', 10, 1 ); ?>
|
157 |
-
* @example
|
158 |
-
* <?php
|
159 |
-
* add_filter( 'um_ajax_select_options__debug_mode', 'my_ajax_select_options__debug_mode', 10, 1 );
|
160 |
-
* function my_ajax_select_options__debug_mode( $debug_mode ) {
|
161 |
-
* // your code here
|
162 |
-
* return $debug_mode;
|
163 |
-
* }
|
164 |
-
* ?>
|
165 |
-
*/
|
166 |
-
$debug = apply_filters( 'um_ajax_select_options__debug_mode', false );
|
167 |
-
if ( $debug ) {
|
168 |
-
$arr_options['debug'] = array(
|
169 |
-
$_POST,
|
170 |
-
$form_fields,
|
171 |
-
);
|
172 |
-
}
|
173 |
-
|
174 |
-
if ( ! empty( $_POST['child_callback'] ) && isset( $form_fields[ $_POST['child_name'] ] ) ) {
|
175 |
-
|
176 |
-
$ajax_source_func = $_POST['child_callback'];
|
177 |
-
|
178 |
-
// If the requested callback function is added in the form or added in the field option, execute it with call_user_func.
|
179 |
-
if ( isset( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
|
180 |
-
! empty( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
|
181 |
-
$form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] === $ajax_source_func ) {
|
182 |
-
|
183 |
-
$arr_options['field'] = $form_fields[ $_POST['child_name'] ];
|
184 |
-
|
185 |
-
if ( function_exists( $ajax_source_func ) ) {
|
186 |
-
$arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
|
187 |
-
}
|
188 |
-
} else {
|
189 |
-
$arr_options['status'] = 'error';
|
190 |
-
$arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' );
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
wp_send_json( $arr_options );
|
195 |
-
}
|
196 |
-
}
|
197 |
-
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Count the form errors.
|
201 |
-
* @return integer
|
202 |
-
*/
|
203 |
-
public function count_errors() {
|
204 |
-
$errors = $this->errors;
|
205 |
-
|
206 |
-
if ( $errors && is_array( $errors ) ) {
|
207 |
-
return count( $errors );
|
208 |
-
}
|
209 |
-
|
210 |
-
return 0;
|
211 |
-
}
|
212 |
-
|
213 |
-
|
214 |
-
/**
|
215 |
-
* Appends field errors
|
216 |
-
*
|
217 |
-
* @param string $key
|
218 |
-
* @param string $error
|
219 |
-
*/
|
220 |
-
public function add_error( $key, $error ) {
|
221 |
-
if ( ! isset( $this->errors[ $key ] ) ) {
|
222 |
-
/**
|
223 |
-
* UM hook
|
224 |
-
*
|
225 |
-
* @type filter
|
226 |
-
* @title um_submit_form_error
|
227 |
-
* @description Change error text on submit form
|
228 |
-
* @input_vars
|
229 |
-
* [{"var":"$error","type":"string","desc":"Error String"},
|
230 |
-
* {"var":"$key","type":"string","desc":"Error Key"}]
|
231 |
-
* @change_log
|
232 |
-
* ["Since: 2.0"]
|
233 |
-
* @usage
|
234 |
-
* <?php add_filter( 'um_submit_form_error', 'function_name', 10, 2 ); ?>
|
235 |
-
* @example
|
236 |
-
* <?php
|
237 |
-
* add_filter( 'um_submit_form_error', 'my_submit_form_error', 10, 2 );
|
238 |
-
* function my_submit_form_error( $error, $key ) {
|
239 |
-
* // your code here
|
240 |
-
* return $error;
|
241 |
-
* }
|
242 |
-
* ?>
|
243 |
-
*/
|
244 |
-
$this->errors[ $key ] = apply_filters( 'um_submit_form_error', $error, $key );
|
245 |
-
}
|
246 |
-
}
|
247 |
-
|
248 |
-
/**
|
249 |
-
* Appends field notices
|
250 |
-
* @param string $key
|
251 |
-
* @param string $notice
|
252 |
-
*/
|
253 |
-
public function add_notice( $key, $notice ) {
|
254 |
-
if ( ! isset( $this->notices[ $key ] ) ) {
|
255 |
-
/**
|
256 |
-
* UM hook
|
257 |
-
*
|
258 |
-
* @type filter
|
259 |
-
* @title um_submit_form_notice
|
260 |
-
* @description Change notice text on submit form
|
261 |
-
* @input_vars
|
262 |
-
* [{"var":"$notice","type":"string","desc":"notice String"},
|
263 |
-
* {"var":"$key","type":"string","desc":"notice Key"}]
|
264 |
-
* @change_log
|
265 |
-
* ["Since: 2.0"]
|
266 |
-
* @usage
|
267 |
-
* <?php add_filter( 'um_submit_form_notice', 'function_name', 10, 2 ); ?>
|
268 |
-
* @example
|
269 |
-
* <?php
|
270 |
-
* add_filter( 'um_submit_form_notice', 'my_submit_form_notice', 10, 2 );
|
271 |
-
* function my_submit_form_notice( $notice, $key ) {
|
272 |
-
* // your code here
|
273 |
-
* return $notice;
|
274 |
-
* }
|
275 |
-
* ?>
|
276 |
-
*/
|
277 |
-
$this->notices[ $key ] = apply_filters( 'um_submit_form_notice', $notice, $key );
|
278 |
-
}
|
279 |
-
}
|
280 |
-
|
281 |
-
|
282 |
-
/**
|
283 |
-
* If a form has errors
|
284 |
-
*
|
285 |
-
* @param string $key
|
286 |
-
* @return boolean
|
287 |
-
*/
|
288 |
-
public function has_error( $key ) {
|
289 |
-
if ( isset( $this->errors[ $key ] ) ) {
|
290 |
-
return true;
|
291 |
-
}
|
292 |
-
return false;
|
293 |
-
}
|
294 |
-
|
295 |
-
|
296 |
-
/**
|
297 |
-
* If a form has notices/info
|
298 |
-
*
|
299 |
-
* @param string $key
|
300 |
-
* @return boolean
|
301 |
-
*/
|
302 |
-
public function has_notice( $key ) {
|
303 |
-
if ( isset( $this->notices[ $key ] ) ) {
|
304 |
-
return true;
|
305 |
-
}
|
306 |
-
return false;
|
307 |
-
}
|
308 |
-
|
309 |
-
|
310 |
-
/**
|
311 |
-
* Declare all fields
|
312 |
-
*/
|
313 |
-
public function field_declare() {
|
314 |
-
if ( isset( UM()->builtin()->custom_fields ) ) {
|
315 |
-
$this->all_fields = UM()->builtin()->custom_fields;
|
316 |
-
} else {
|
317 |
-
$this->all_fields = null;
|
318 |
-
}
|
319 |
-
}
|
320 |
-
|
321 |
-
|
322 |
-
/**
|
323 |
-
* Validate form on submit
|
324 |
-
*/
|
325 |
-
public function form_init() {
|
326 |
-
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
|
327 |
-
$http_post = ( 'POST' === $_SERVER['REQUEST_METHOD'] );
|
328 |
-
} else {
|
329 |
-
$http_post = 'POST';
|
330 |
-
}
|
331 |
-
|
332 |
-
if ( $http_post && ! is_admin() && isset( $_POST['form_id'] ) && is_numeric( $_POST['form_id'] ) ) {
|
333 |
-
|
334 |
-
$this->form_id = absint( $_POST['form_id'] );
|
335 |
-
$this->form_status = get_post_status( $this->form_id );
|
336 |
-
$this->form_data = UM()->query()->post_data( $this->form_id );
|
337 |
-
|
338 |
-
if ( 'publish' !== $this->form_status ) {
|
339 |
-
return;
|
340 |
-
}
|
341 |
-
|
342 |
-
/**
|
343 |
-
* UM hook
|
344 |
-
*
|
345 |
-
* @type action
|
346 |
-
* @title um_before_submit_form_post
|
347 |
-
* @description Before submit form
|
348 |
-
* @change_log
|
349 |
-
* ["Since: 2.0"]
|
350 |
-
* @usage add_action( 'um_before_submit_form_post', 'function_name', 10, 1 );
|
351 |
-
* @example
|
352 |
-
* <?php
|
353 |
-
* add_action( 'um_before_submit_form_post', 'my_before_submit_form_post', 10, 1 );
|
354 |
-
* function my_run_ajax_function( $post ) {
|
355 |
-
* // your code here
|
356 |
-
* }
|
357 |
-
* ?>
|
358 |
-
*/
|
359 |
-
do_action( 'um_before_submit_form_post' );
|
360 |
-
|
361 |
-
/* save entire form as global */
|
362 |
-
/**
|
363 |
-
* UM hook
|
364 |
-
*
|
365 |
-
* @type filter
|
366 |
-
* @title um_submit_post_form
|
367 |
-
* @description Change submitted data on form submit
|
368 |
-
* @input_vars
|
369 |
-
* [{"var":"$data","type":"array","desc":"Submitted data"}]
|
370 |
-
* @change_log
|
371 |
-
* ["Since: 2.0"]
|
372 |
-
* @usage
|
373 |
-
* <?php add_filter( 'um_submit_post_form', 'function_name', 10, 1 ); ?>
|
374 |
-
* @example
|
375 |
-
* <?php
|
376 |
-
* add_filter( 'um_submit_post_form', 'my_submit_post_form', 10, 1 );
|
377 |
-
* function my_submit_post_form( $data ) {
|
378 |
-
* // your code here
|
379 |
-
* return $data;
|
380 |
-
* }
|
381 |
-
* ?>
|
382 |
-
*/
|
383 |
-
$this->post_form = apply_filters( 'um_submit_post_form', $_POST );
|
384 |
-
|
385 |
-
if ( isset( $this->post_form[ UM()->honeypot ] ) && '' !== $this->post_form[ UM()->honeypot ] ) {
|
386 |
-
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
|
387 |
-
}
|
388 |
-
|
389 |
-
$this->post_form = $this->beautify( $this->post_form );
|
390 |
-
$this->post_form = $this->sanitize( $this->post_form );
|
391 |
-
$this->post_form['submitted'] = $this->post_form;
|
392 |
-
|
393 |
-
$this->post_form = array_merge( $this->form_data, $this->post_form );
|
394 |
-
|
395 |
-
// Remove role from post_form at first if role ! empty and there aren't custom fields with role name
|
396 |
-
if ( ! empty( $_POST['role'] ) ) {
|
397 |
-
if ( ! isset( $this->form_data['custom_fields'] ) || ! strstr( $this->form_data['custom_fields'], 'role_' ) ) {
|
398 |
-
unset( $this->post_form['role'] );
|
399 |
-
unset( $this->post_form['submitted']['role'] );
|
400 |
-
}
|
401 |
-
}
|
402 |
-
|
403 |
-
// Secure sanitize of the submitted data
|
404 |
-
if ( ! empty( $this->post_form ) ) {
|
405 |
-
$this->post_form = array_diff_key( $this->post_form, array_flip( UM()->user()->banned_keys ) );
|
406 |
-
}
|
407 |
-
if ( ! empty( $this->post_form['submitted'] ) ) {
|
408 |
-
$this->post_form['submitted'] = array_diff_key( $this->post_form['submitted'], array_flip( UM()->user()->banned_keys ) );
|
409 |
-
}
|
410 |
-
|
411 |
-
// set default role from settings on registration form
|
412 |
-
if ( isset( $this->post_form['mode'] ) && 'register' === $this->post_form['mode'] ) {
|
413 |
-
$role = $this->assigned_role( $this->form_id );
|
414 |
-
$this->post_form['role'] = $role;
|
415 |
-
}
|
416 |
-
|
417 |
-
if ( isset( $this->form_data['custom_fields'] ) && strstr( $this->form_data['custom_fields'], 'role_' ) ) { // Secure selected role
|
418 |
-
|
419 |
-
if ( ! empty( $_POST['role'] ) ) {
|
420 |
-
$custom_field_roles = $this->custom_field_roles( $this->form_data['custom_fields'] );
|
421 |
-
|
422 |
-
if ( ! empty( $custom_field_roles ) ) {
|
423 |
-
if ( is_array( $_POST['role'] ) ) {
|
424 |
-
$role = current( $_POST['role'] );
|
425 |
-
$role = sanitize_key( $role );
|
426 |
-
} else {
|
427 |
-
$role = sanitize_key( $_POST['role'] );
|
428 |
-
}
|
429 |
-
|
430 |
-
global $wp_roles;
|
431 |
-
$role_keys = array_map(
|
432 |
-
function( $item ) {
|
433 |
-
return 'um_' . $item;
|
434 |
-
},
|
435 |
-
get_option( 'um_roles', array() )
|
436 |
-
);
|
437 |
-
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
438 |
-
|
439 |
-
if ( ! empty( $role ) &&
|
440 |
-
( ! in_array( $role, $custom_field_roles, true ) || in_array( $role, $exclude_roles, true ) ) ) {
|
441 |
-
wp_die( esc_html__( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
442 |
-
}
|
443 |
-
|
444 |
-
$this->post_form['role'] = $role;
|
445 |
-
$this->post_form['submitted']['role'] = $role;
|
446 |
-
} else {
|
447 |
-
unset( $this->post_form['role'] );
|
448 |
-
unset( $this->post_form['submitted']['role'] );
|
449 |
-
|
450 |
-
// set default role for registration form if custom field hasn't proper value
|
451 |
-
if ( isset( $this->post_form['mode'] ) && 'register' === $this->post_form['mode'] ) {
|
452 |
-
$role = $this->assigned_role( $this->form_id );
|
453 |
-
$this->post_form['role'] = $role;
|
454 |
-
}
|
455 |
-
}
|
456 |
-
}
|
457 |
-
}
|
458 |
-
|
459 |
-
/**
|
460 |
-
* UM hook
|
461 |
-
*
|
462 |
-
* @type filter
|
463 |
-
* @title um_submit_form_data
|
464 |
-
* @description Change submitted data on form submit
|
465 |
-
* @input_vars
|
466 |
-
* [{"var":"$data","type":"array","desc":"Submitted data"},
|
467 |
-
* {"var":"$mode","type":"string","desc":"Form mode"}]
|
468 |
-
* @change_log
|
469 |
-
* ["Since: 2.0"]
|
470 |
-
* @usage
|
471 |
-
* <?php add_filter( 'um_submit_form_data', 'function_name', 10, 2 ); ?>
|
472 |
-
* @example
|
473 |
-
* <?php
|
474 |
-
* add_filter( 'um_submit_form_data', 'my_submit_form_data', 10, 2 );
|
475 |
-
* function my_submit_form_data( $data ) {
|
476 |
-
* // your code here
|
477 |
-
* return $data;
|
478 |
-
* }
|
479 |
-
* ?>
|
480 |
-
*/
|
481 |
-
$this->post_form = apply_filters( 'um_submit_form_data', $this->post_form, $this->post_form['mode'] );
|
482 |
-
|
483 |
-
/* Continue based on form mode - pre-validation */
|
484 |
-
|
485 |
-
/**
|
486 |
-
* UM hook
|
487 |
-
*
|
488 |
-
* @type action
|
489 |
-
* @title um_submit_form_errors_hook
|
490 |
-
* @description Action on submit form
|
491 |
-
* @input_vars
|
492 |
-
* [{"var":"$post","type":"int","desc":"Post data"}]
|
493 |
-
* @change_log
|
494 |
-
* ["Since: 2.0"]
|
495 |
-
* @usage add_action( 'um_submit_form_errors_hook', 'function_name', 10, 1 );
|
496 |
-
* @example
|
497 |
-
* <?php
|
498 |
-
* add_action( 'um_submit_form_errors_hook', 'my_submit_form_errors', 10, 1 );
|
499 |
-
* function my_submit_form_errors( $post ) {
|
500 |
-
* // your code here
|
501 |
-
* }
|
502 |
-
* ?>
|
503 |
-
*/
|
504 |
-
do_action( 'um_submit_form_errors_hook', $this->post_form );
|
505 |
-
/**
|
506 |
-
* UM hook
|
507 |
-
*
|
508 |
-
* @type action
|
509 |
-
* @title um_submit_form_{$mode}
|
510 |
-
* @description Action on submit form
|
511 |
-
* @input_vars
|
512 |
-
* [{"var":"$post","type":"int","desc":"Post data"}]
|
513 |
-
* @change_log
|
514 |
-
* ["Since: 2.0"]
|
515 |
-
* @usage add_action( 'um_submit_form_{$mode}', 'function_name', 10, 1 );
|
516 |
-
* @example
|
517 |
-
* <?php
|
518 |
-
* add_action( 'um_submit_form_{$mode}', 'my_submit_form', 10, 1 );
|
519 |
-
* function my_submit_form( $post ) {
|
520 |
-
* // your code here
|
521 |
-
* }
|
522 |
-
* ?>
|
523 |
-
*/
|
524 |
-
do_action( "um_submit_form_{$this->post_form['mode']}", $this->post_form );
|
525 |
-
|
526 |
-
}
|
527 |
-
}
|
528 |
-
|
529 |
-
|
530 |
-
/**
|
531 |
-
* Beautify form data
|
532 |
-
*
|
533 |
-
* @param array $form
|
534 |
-
*
|
535 |
-
* @return array $form
|
536 |
-
*/
|
537 |
-
public function beautify( $form ) {
|
538 |
-
if ( isset( $form['form_id'] ) ) {
|
539 |
-
$this->form_suffix = '-' . $form['form_id'];
|
540 |
-
$this->processing = $form['form_id'];
|
541 |
-
|
542 |
-
foreach ( $form as $key => $value ) {
|
543 |
-
if ( strstr( $key, $this->form_suffix ) ) {
|
544 |
-
$a_key = str_replace( $this->form_suffix, '', $key );
|
545 |
-
$form[ $a_key ] = $value;
|
546 |
-
unset( $form[ $key ] );
|
547 |
-
}
|
548 |
-
}
|
549 |
-
}
|
550 |
-
|
551 |
-
return $form;
|
552 |
-
}
|
553 |
-
|
554 |
-
|
555 |
-
/**
|
556 |
-
* Beautify form data
|
557 |
-
*
|
558 |
-
* @param array $form
|
559 |
-
*
|
560 |
-
* @return array $form
|
561 |
-
*/
|
562 |
-
public function sanitize( $form ) {
|
563 |
-
|
564 |
-
if ( isset( $form['form_id'] ) ) {
|
565 |
-
if ( isset( $this->form_data['custom_fields'] ) ) {
|
566 |
-
$custom_fields = maybe_unserialize( $this->form_data['custom_fields'] );
|
567 |
-
|
568 |
-
if ( is_array( $custom_fields ) ) {
|
569 |
-
foreach ( $custom_fields as $k => $field ) {
|
570 |
-
|
571 |
-
if ( isset( $field['type'] ) ) {
|
572 |
-
if ( isset( $form[ $k ] ) ) {
|
573 |
-
|
574 |
-
switch ( $field['type'] ) {
|
575 |
-
default:
|
576 |
-
$form[ $k ] = apply_filters( 'um_sanitize_form_field', $form[ $k ], $field );
|
577 |
-
break;
|
578 |
-
case 'number':
|
579 |
-
$form[ $k ] = (int) $form[ $k ];
|
580 |
-
break;
|
581 |
-
case 'textarea':
|
582 |
-
if ( ! empty( $field['html'] ) ) {
|
583 |
-
$form[ $k ] = wp_kses_post( $form[ $k ] );
|
584 |
-
} else {
|
585 |
-
$form[ $k ] = sanitize_textarea_field( $form[ $k ] );
|
586 |
-
}
|
587 |
-
break;
|
588 |
-
case 'url':
|
589 |
-
$form[ $k ] = esc_url_raw( $form[ $k ] );
|
590 |
-
break;
|
591 |
-
case 'text':
|
592 |
-
case 'select':
|
593 |
-
case 'password':
|
594 |
-
case 'image':
|
595 |
-
case 'file':
|
596 |
-
case 'date':
|
597 |
-
case 'time':
|
598 |
-
case 'rating':
|
599 |
-
case 'googlemap':
|
600 |
-
case 'youtube_video':
|
601 |
-
case 'vimeo_video':
|
602 |
-
case 'soundcloud_track':
|
603 |
-
$form[ $k ] = sanitize_text_field( $form[ $k ] );
|
604 |
-
break;
|
605 |
-
case 'multiselect':
|
606 |
-
case 'radio':
|
607 |
-
case 'checkbox':
|
608 |
-
$form[ $k ] = array_map( 'sanitize_text_field', $form[ $k ] );
|
609 |
-
break;
|
610 |
-
}
|
611 |
-
}
|
612 |
-
}
|
613 |
-
}
|
614 |
-
}
|
615 |
-
}
|
616 |
-
}
|
617 |
-
|
618 |
-
return $form;
|
619 |
-
}
|
620 |
-
|
621 |
-
|
622 |
-
/**
|
623 |
-
* Display form type as Title
|
624 |
-
* @param string $mode
|
625 |
-
* @param integer $post_id
|
626 |
-
* @return string $output
|
627 |
-
*/
|
628 |
-
public function display_form_type( $mode, $post_id ) {
|
629 |
-
$output = null;
|
630 |
-
switch ( $mode ) {
|
631 |
-
case 'login':
|
632 |
-
$output = __( 'Login', 'ultimate-member' );
|
633 |
-
break;
|
634 |
-
case 'profile':
|
635 |
-
$output = __( 'Profile', 'ultimate-member' );
|
636 |
-
break;
|
637 |
-
case 'register':
|
638 |
-
$output = __( 'Register', 'ultimate-member' );
|
639 |
-
break;
|
640 |
-
}
|
641 |
-
return $output;
|
642 |
-
}
|
643 |
-
|
644 |
-
|
645 |
-
/**
|
646 |
-
* Assigned roles to a form
|
647 |
-
* @param integer $post_id
|
648 |
-
* @return string $role
|
649 |
-
*/
|
650 |
-
public function assigned_role( $post_id ) {
|
651 |
-
|
652 |
-
$global_role = get_option( 'default_role' ); // WP Global settings
|
653 |
-
|
654 |
-
$um_global_role = UM()->options()->get( 'register_role' ); // UM Settings Global settings
|
655 |
-
if ( ! empty( $um_global_role ) ) {
|
656 |
-
$global_role = $um_global_role; // Form Global settings
|
657 |
-
}
|
658 |
-
|
659 |
-
$mode = $this->form_type( $post_id );
|
660 |
-
|
661 |
-
/**
|
662 |
-
* @todo WPML integration to get role from original if it's empty
|
663 |
-
*/
|
664 |
-
$use_custom = get_post_meta( $post_id, "_um_{$mode}_use_custom_settings", true );
|
665 |
-
if ( $use_custom ) { // Custom Form settings
|
666 |
-
$role = get_post_meta( $post_id, "_um_{$mode}_role", true );
|
667 |
-
}
|
668 |
-
|
669 |
-
if ( empty( $role ) ) { // custom role is default, return default role's slug
|
670 |
-
$role = $global_role;
|
671 |
-
}
|
672 |
-
|
673 |
-
return $role;
|
674 |
-
}
|
675 |
-
|
676 |
-
|
677 |
-
/**
|
678 |
-
* Get form type
|
679 |
-
* @param integer $post_id
|
680 |
-
* @return string
|
681 |
-
*/
|
682 |
-
public function form_type( $post_id ) {
|
683 |
-
$mode = get_post_meta( $post_id, '_um_mode', true );
|
684 |
-
return $mode;
|
685 |
-
}
|
686 |
-
|
687 |
-
|
688 |
-
/**
|
689 |
-
* Get custom field roles
|
690 |
-
*
|
691 |
-
* @param string $custom_fields serialized
|
692 |
-
* @return bool|array roles
|
693 |
-
*/
|
694 |
-
public function custom_field_roles( $custom_fields ) {
|
695 |
-
|
696 |
-
$fields = maybe_unserialize( $custom_fields );
|
697 |
-
if ( ! is_array( $fields ) ) {
|
698 |
-
return false;
|
699 |
-
}
|
700 |
-
|
701 |
-
// role field
|
702 |
-
global $wp_roles;
|
703 |
-
$role_keys = array_map(
|
704 |
-
function( $item ) {
|
705 |
-
return 'um_' . $item;
|
706 |
-
},
|
707 |
-
get_option( 'um_roles', array() )
|
708 |
-
);
|
709 |
-
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
710 |
-
|
711 |
-
$roles = UM()->roles()->get_roles( false, $exclude_roles );
|
712 |
-
$roles = array_map(
|
713 |
-
function( $item ) {
|
714 |
-
return html_entity_decode( $item, ENT_QUOTES );
|
715 |
-
},
|
716 |
-
$roles
|
717 |
-
);
|
718 |
-
|
719 |
-
foreach ( $fields as $field_key => $field_settings ) {
|
720 |
-
|
721 |
-
if ( strstr( $field_key, 'role_' ) && is_array( $field_settings['options'] ) ) {
|
722 |
-
|
723 |
-
if ( isset( $this->post_form['mode'] ) && 'profile' === $this->post_form['mode'] &&
|
724 |
-
isset( $field_settings['editable'] ) && $field_settings['editable'] == 0 ) {
|
725 |
-
continue;
|
726 |
-
}
|
727 |
-
|
728 |
-
if ( ! um_can_view_field( $field_settings ) ) {
|
729 |
-
continue;
|
730 |
-
}
|
731 |
-
|
732 |
-
$intersected_options = array();
|
733 |
-
foreach ( $field_settings['options'] as $key => $title ) {
|
734 |
-
if ( false !== $search_key = array_search( $title, $roles ) ) {
|
735 |
-
$intersected_options[ $search_key ] = $title;
|
736 |
-
} elseif ( isset( $roles[ $key ] ) ) {
|
737 |
-
$intersected_options[ $key ] = $title;
|
738 |
-
}
|
739 |
-
}
|
740 |
-
|
741 |
-
// getting roles only from the first role fields
|
742 |
-
return array_keys( $intersected_options );
|
743 |
-
}
|
744 |
-
}
|
745 |
-
|
746 |
-
return false;
|
747 |
-
}
|
748 |
-
}
|
749 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
// Exit if accessed directly
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
if ( ! class_exists( 'um\core\Form' ) ) {
|
8 |
+
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Form
|
12 |
+
* @package um\core
|
13 |
+
*/
|
14 |
+
class Form {
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var null
|
19 |
+
*/
|
20 |
+
public $form_suffix;
|
21 |
+
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var
|
25 |
+
*/
|
26 |
+
var $form_id;
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @var null
|
31 |
+
*/
|
32 |
+
var $post_form = null;
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Form constructor.
|
37 |
+
*/
|
38 |
+
function __construct() {
|
39 |
+
|
40 |
+
$this->form_suffix = null;
|
41 |
+
|
42 |
+
$this->errors = null;
|
43 |
+
|
44 |
+
$this->processing = null;
|
45 |
+
|
46 |
+
add_action( 'template_redirect', array( &$this, 'form_init' ), 2 );
|
47 |
+
|
48 |
+
add_action( 'init', array( &$this, 'field_declare' ), 10 );
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
*
|
55 |
+
*/
|
56 |
+
public function ajax_muted_action() {
|
57 |
+
UM()->check_ajax_nonce();
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @var $user_id
|
61 |
+
* @var $hook
|
62 |
+
*/
|
63 |
+
extract( $_REQUEST );
|
64 |
+
|
65 |
+
if ( isset( $user_id ) ) {
|
66 |
+
$user_id = absint( $user_id );
|
67 |
+
}
|
68 |
+
|
69 |
+
if ( isset( $hook ) ) {
|
70 |
+
$hook = sanitize_key( $hook );
|
71 |
+
}
|
72 |
+
|
73 |
+
if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
74 |
+
die( esc_html__( 'You can not edit this user', 'ultimate-member' ) );
|
75 |
+
}
|
76 |
+
|
77 |
+
switch ( $hook ) {
|
78 |
+
default:
|
79 |
+
/**
|
80 |
+
* UM hook
|
81 |
+
*
|
82 |
+
* @type action
|
83 |
+
* @title um_run_ajax_function__{$hook}
|
84 |
+
* @description Action on AJAX muted action
|
85 |
+
* @input_vars
|
86 |
+
* [{"var":"$request","type":"int","desc":"Request"}]
|
87 |
+
* @change_log
|
88 |
+
* ["Since: 2.0"]
|
89 |
+
* @usage add_action( 'um_run_ajax_function__{$hook}', 'function_name', 10, 1 );
|
90 |
+
* @example
|
91 |
+
* <?php
|
92 |
+
* add_action( 'um_run_ajax_function__{$hook}', 'my_run_ajax_function', 10, 1 );
|
93 |
+
* function my_run_ajax_function( $request ) {
|
94 |
+
* // your code here
|
95 |
+
* }
|
96 |
+
* ?>
|
97 |
+
*/
|
98 |
+
do_action( "um_run_ajax_function__{$hook}", $_REQUEST );
|
99 |
+
break;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
/**
|
105 |
+
*
|
106 |
+
*/
|
107 |
+
public function ajax_select_options() {
|
108 |
+
UM()->check_ajax_nonce();
|
109 |
+
|
110 |
+
$arr_options = array();
|
111 |
+
$arr_options['status'] = 'success';
|
112 |
+
$arr_options['post'] = $_POST;
|
113 |
+
|
114 |
+
UM()->fields()->set_id = absint( $_POST['form_id'] );
|
115 |
+
UM()->fields()->set_mode = 'profile';
|
116 |
+
$form_fields = UM()->fields()->get_fields();
|
117 |
+
$arr_options['fields'] = $form_fields;
|
118 |
+
|
119 |
+
if ( isset( $arr_options['post']['members_directory'] ) && 'yes' === $arr_options['post']['members_directory'] ) {
|
120 |
+
$ajax_source_func = $_POST['child_callback'];
|
121 |
+
if ( function_exists( $ajax_source_func ) ) {
|
122 |
+
$arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
|
123 |
+
|
124 |
+
global $wpdb;
|
125 |
+
|
126 |
+
$values_array = $wpdb->get_col(
|
127 |
+
$wpdb->prepare(
|
128 |
+
"SELECT DISTINCT meta_value
|
129 |
+
FROM $wpdb->usermeta
|
130 |
+
WHERE meta_key = %s AND
|
131 |
+
meta_value != ''",
|
132 |
+
$arr_options['post']['child_name']
|
133 |
+
)
|
134 |
+
);
|
135 |
+
|
136 |
+
if ( ! empty( $values_array ) ) {
|
137 |
+
$arr_options['items'] = array_intersect( $arr_options['items'], $values_array );
|
138 |
+
} else {
|
139 |
+
$arr_options['items'] = array();
|
140 |
+
}
|
141 |
+
|
142 |
+
wp_send_json( $arr_options );
|
143 |
+
}
|
144 |
+
} else {
|
145 |
+
/**
|
146 |
+
* UM hook
|
147 |
+
*
|
148 |
+
* @type filter
|
149 |
+
* @title um_ajax_select_options__debug_mode
|
150 |
+
* @description Activate debug mode for AJAX select options
|
151 |
+
* @input_vars
|
152 |
+
* [{"var":"$debug_mode","type":"bool","desc":"Enable Debug mode"}]
|
153 |
+
* @change_log
|
154 |
+
* ["Since: 2.0"]
|
155 |
+
* @usage
|
156 |
+
* <?php add_filter( 'um_ajax_select_options__debug_mode', 'function_name', 10, 1 ); ?>
|
157 |
+
* @example
|
158 |
+
* <?php
|
159 |
+
* add_filter( 'um_ajax_select_options__debug_mode', 'my_ajax_select_options__debug_mode', 10, 1 );
|
160 |
+
* function my_ajax_select_options__debug_mode( $debug_mode ) {
|
161 |
+
* // your code here
|
162 |
+
* return $debug_mode;
|
163 |
+
* }
|
164 |
+
* ?>
|
165 |
+
*/
|
166 |
+
$debug = apply_filters( 'um_ajax_select_options__debug_mode', false );
|
167 |
+
if ( $debug ) {
|
168 |
+
$arr_options['debug'] = array(
|
169 |
+
$_POST,
|
170 |
+
$form_fields,
|
171 |
+
);
|
172 |
+
}
|
173 |
+
|
174 |
+
if ( ! empty( $_POST['child_callback'] ) && isset( $form_fields[ $_POST['child_name'] ] ) ) {
|
175 |
+
|
176 |
+
$ajax_source_func = $_POST['child_callback'];
|
177 |
+
|
178 |
+
// If the requested callback function is added in the form or added in the field option, execute it with call_user_func.
|
179 |
+
if ( isset( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
|
180 |
+
! empty( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
|
181 |
+
$form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] === $ajax_source_func ) {
|
182 |
+
|
183 |
+
$arr_options['field'] = $form_fields[ $_POST['child_name'] ];
|
184 |
+
|
185 |
+
if ( function_exists( $ajax_source_func ) ) {
|
186 |
+
$arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
|
187 |
+
}
|
188 |
+
} else {
|
189 |
+
$arr_options['status'] = 'error';
|
190 |
+
$arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' );
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
wp_send_json( $arr_options );
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Count the form errors.
|
201 |
+
* @return integer
|
202 |
+
*/
|
203 |
+
public function count_errors() {
|
204 |
+
$errors = $this->errors;
|
205 |
+
|
206 |
+
if ( $errors && is_array( $errors ) ) {
|
207 |
+
return count( $errors );
|
208 |
+
}
|
209 |
+
|
210 |
+
return 0;
|
211 |
+
}
|
212 |
+
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Appends field errors
|
216 |
+
*
|
217 |
+
* @param string $key
|
218 |
+
* @param string $error
|
219 |
+
*/
|
220 |
+
public function add_error( $key, $error ) {
|
221 |
+
if ( ! isset( $this->errors[ $key ] ) ) {
|
222 |
+
/**
|
223 |
+
* UM hook
|
224 |
+
*
|
225 |
+
* @type filter
|
226 |
+
* @title um_submit_form_error
|
227 |
+
* @description Change error text on submit form
|
228 |
+
* @input_vars
|
229 |
+
* [{"var":"$error","type":"string","desc":"Error String"},
|
230 |
+
* {"var":"$key","type":"string","desc":"Error Key"}]
|
231 |
+
* @change_log
|
232 |
+
* ["Since: 2.0"]
|
233 |
+
* @usage
|
234 |
+
* <?php add_filter( 'um_submit_form_error', 'function_name', 10, 2 ); ?>
|
235 |
+
* @example
|
236 |
+
* <?php
|
237 |
+
* add_filter( 'um_submit_form_error', 'my_submit_form_error', 10, 2 );
|
238 |
+
* function my_submit_form_error( $error, $key ) {
|
239 |
+
* // your code here
|
240 |
+
* return $error;
|
241 |
+
* }
|
242 |
+
* ?>
|
243 |
+
*/
|
244 |
+
$this->errors[ $key ] = apply_filters( 'um_submit_form_error', $error, $key );
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Appends field notices
|
250 |
+
* @param string $key
|
251 |
+
* @param string $notice
|
252 |
+
*/
|
253 |
+
public function add_notice( $key, $notice ) {
|
254 |
+
if ( ! isset( $this->notices[ $key ] ) ) {
|
255 |
+
/**
|
256 |
+
* UM hook
|
257 |
+
*
|
258 |
+
* @type filter
|
259 |
+
* @title um_submit_form_notice
|
260 |
+
* @description Change notice text on submit form
|
261 |
+
* @input_vars
|
262 |
+
* [{"var":"$notice","type":"string","desc":"notice String"},
|
263 |
+
* {"var":"$key","type":"string","desc":"notice Key"}]
|
264 |
+
* @change_log
|
265 |
+
* ["Since: 2.0"]
|
266 |
+
* @usage
|
267 |
+
* <?php add_filter( 'um_submit_form_notice', 'function_name', 10, 2 ); ?>
|
268 |
+
* @example
|
269 |
+
* <?php
|
270 |
+
* add_filter( 'um_submit_form_notice', 'my_submit_form_notice', 10, 2 );
|
271 |
+
* function my_submit_form_notice( $notice, $key ) {
|
272 |
+
* // your code here
|
273 |
+
* return $notice;
|
274 |
+
* }
|
275 |
+
* ?>
|
276 |
+
*/
|
277 |
+
$this->notices[ $key ] = apply_filters( 'um_submit_form_notice', $notice, $key );
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
|
282 |
+
/**
|
283 |
+
* If a form has errors
|
284 |
+
*
|
285 |
+
* @param string $key
|
286 |
+
* @return boolean
|
287 |
+
*/
|
288 |
+
public function has_error( $key ) {
|
289 |
+
if ( isset( $this->errors[ $key ] ) ) {
|
290 |
+
return true;
|
291 |
+
}
|
292 |
+
return false;
|
293 |
+
}
|
294 |
+
|
295 |
+
|
296 |
+
/**
|
297 |
+
* If a form has notices/info
|
298 |
+
*
|
299 |
+
* @param string $key
|
300 |
+
* @return boolean
|
301 |
+
*/
|
302 |
+
public function has_notice( $key ) {
|
303 |
+
if ( isset( $this->notices[ $key ] ) ) {
|
304 |
+
return true;
|
305 |
+
}
|
306 |
+
return false;
|
307 |
+
}
|
308 |
+
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Declare all fields
|
312 |
+
*/
|
313 |
+
public function field_declare() {
|
314 |
+
if ( isset( UM()->builtin()->custom_fields ) ) {
|
315 |
+
$this->all_fields = UM()->builtin()->custom_fields;
|
316 |
+
} else {
|
317 |
+
$this->all_fields = null;
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Validate form on submit
|
324 |
+
*/
|
325 |
+
public function form_init() {
|
326 |
+
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
|
327 |
+
$http_post = ( 'POST' === $_SERVER['REQUEST_METHOD'] );
|
328 |
+
} else {
|
329 |
+
$http_post = 'POST';
|
330 |
+
}
|
331 |
+
|
332 |
+
if ( $http_post && ! is_admin() && isset( $_POST['form_id'] ) && is_numeric( $_POST['form_id'] ) ) {
|
333 |
+
|
334 |
+
$this->form_id = absint( $_POST['form_id'] );
|
335 |
+
$this->form_status = get_post_status( $this->form_id );
|
336 |
+
$this->form_data = UM()->query()->post_data( $this->form_id );
|
337 |
+
|
338 |
+
if ( 'publish' !== $this->form_status ) {
|
339 |
+
return;
|
340 |
+
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* UM hook
|
344 |
+
*
|
345 |
+
* @type action
|
346 |
+
* @title um_before_submit_form_post
|
347 |
+
* @description Before submit form
|
348 |
+
* @change_log
|
349 |
+
* ["Since: 2.0"]
|
350 |
+
* @usage add_action( 'um_before_submit_form_post', 'function_name', 10, 1 );
|
351 |
+
* @example
|
352 |
+
* <?php
|
353 |
+
* add_action( 'um_before_submit_form_post', 'my_before_submit_form_post', 10, 1 );
|
354 |
+
* function my_run_ajax_function( $post ) {
|
355 |
+
* // your code here
|
356 |
+
* }
|
357 |
+
* ?>
|
358 |
+
*/
|
359 |
+
do_action( 'um_before_submit_form_post' );
|
360 |
+
|
361 |
+
/* save entire form as global */
|
362 |
+
/**
|
363 |
+
* UM hook
|
364 |
+
*
|
365 |
+
* @type filter
|
366 |
+
* @title um_submit_post_form
|
367 |
+
* @description Change submitted data on form submit
|
368 |
+
* @input_vars
|
369 |
+
* [{"var":"$data","type":"array","desc":"Submitted data"}]
|
370 |
+
* @change_log
|
371 |
+
* ["Since: 2.0"]
|
372 |
+
* @usage
|
373 |
+
* <?php add_filter( 'um_submit_post_form', 'function_name', 10, 1 ); ?>
|
374 |
+
* @example
|
375 |
+
* <?php
|
376 |
+
* add_filter( 'um_submit_post_form', 'my_submit_post_form', 10, 1 );
|
377 |
+
* function my_submit_post_form( $data ) {
|
378 |
+
* // your code here
|
379 |
+
* return $data;
|
380 |
+
* }
|
381 |
+
* ?>
|
382 |
+
*/
|
383 |
+
$this->post_form = apply_filters( 'um_submit_post_form', $_POST );
|
384 |
+
|
385 |
+
if ( isset( $this->post_form[ UM()->honeypot ] ) && '' !== $this->post_form[ UM()->honeypot ] ) {
|
386 |
+
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
|
387 |
+
}
|
388 |
+
|
389 |
+
$this->post_form = $this->beautify( $this->post_form );
|
390 |
+
$this->post_form = $this->sanitize( $this->post_form );
|
391 |
+
$this->post_form['submitted'] = $this->post_form;
|
392 |
+
|
393 |
+
$this->post_form = array_merge( $this->form_data, $this->post_form );
|
394 |
+
|
395 |
+
// Remove role from post_form at first if role ! empty and there aren't custom fields with role name
|
396 |
+
if ( ! empty( $_POST['role'] ) ) {
|
397 |
+
if ( ! isset( $this->form_data['custom_fields'] ) || ! strstr( $this->form_data['custom_fields'], 'role_' ) ) {
|
398 |
+
unset( $this->post_form['role'] );
|
399 |
+
unset( $this->post_form['submitted']['role'] );
|
400 |
+
}
|
401 |
+
}
|
402 |
+
|
403 |
+
// Secure sanitize of the submitted data
|
404 |
+
if ( ! empty( $this->post_form ) ) {
|
405 |
+
$this->post_form = array_diff_key( $this->post_form, array_flip( UM()->user()->banned_keys ) );
|
406 |
+
}
|
407 |
+
if ( ! empty( $this->post_form['submitted'] ) ) {
|
408 |
+
$this->post_form['submitted'] = array_diff_key( $this->post_form['submitted'], array_flip( UM()->user()->banned_keys ) );
|
409 |
+
}
|
410 |
+
|
411 |
+
// set default role from settings on registration form
|
412 |
+
if ( isset( $this->post_form['mode'] ) && 'register' === $this->post_form['mode'] ) {
|
413 |
+
$role = $this->assigned_role( $this->form_id );
|
414 |
+
$this->post_form['role'] = $role;
|
415 |
+
}
|
416 |
+
|
417 |
+
if ( isset( $this->form_data['custom_fields'] ) && strstr( $this->form_data['custom_fields'], 'role_' ) ) { // Secure selected role
|
418 |
+
|
419 |
+
if ( ! empty( $_POST['role'] ) ) {
|
420 |
+
$custom_field_roles = $this->custom_field_roles( $this->form_data['custom_fields'] );
|
421 |
+
|
422 |
+
if ( ! empty( $custom_field_roles ) ) {
|
423 |
+
if ( is_array( $_POST['role'] ) ) {
|
424 |
+
$role = current( $_POST['role'] );
|
425 |
+
$role = sanitize_key( $role );
|
426 |
+
} else {
|
427 |
+
$role = sanitize_key( $_POST['role'] );
|
428 |
+
}
|
429 |
+
|
430 |
+
global $wp_roles;
|
431 |
+
$role_keys = array_map(
|
432 |
+
function( $item ) {
|
433 |
+
return 'um_' . $item;
|
434 |
+
},
|
435 |
+
get_option( 'um_roles', array() )
|
436 |
+
);
|
437 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
438 |
+
|
439 |
+
if ( ! empty( $role ) &&
|
440 |
+
( ! in_array( $role, $custom_field_roles, true ) || in_array( $role, $exclude_roles, true ) ) ) {
|
441 |
+
wp_die( esc_html__( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
442 |
+
}
|
443 |
+
|
444 |
+
$this->post_form['role'] = $role;
|
445 |
+
$this->post_form['submitted']['role'] = $role;
|
446 |
+
} else {
|
447 |
+
unset( $this->post_form['role'] );
|
448 |
+
unset( $this->post_form['submitted']['role'] );
|
449 |
+
|
450 |
+
// set default role for registration form if custom field hasn't proper value
|
451 |
+
if ( isset( $this->post_form['mode'] ) && 'register' === $this->post_form['mode'] ) {
|
452 |
+
$role = $this->assigned_role( $this->form_id );
|
453 |
+
$this->post_form['role'] = $role;
|
454 |
+
}
|
455 |
+
}
|
456 |
+
}
|
457 |
+
}
|
458 |
+
|
459 |
+
/**
|
460 |
+
* UM hook
|
461 |
+
*
|
462 |
+
* @type filter
|
463 |
+
* @title um_submit_form_data
|
464 |
+
* @description Change submitted data on form submit
|
465 |
+
* @input_vars
|
466 |
+
* [{"var":"$data","type":"array","desc":"Submitted data"},
|
467 |
+
* {"var":"$mode","type":"string","desc":"Form mode"}]
|
468 |
+
* @change_log
|
469 |
+
* ["Since: 2.0"]
|
470 |
+
* @usage
|
471 |
+
* <?php add_filter( 'um_submit_form_data', 'function_name', 10, 2 ); ?>
|
472 |
+
* @example
|
473 |
+
* <?php
|
474 |
+
* add_filter( 'um_submit_form_data', 'my_submit_form_data', 10, 2 );
|
475 |
+
* function my_submit_form_data( $data ) {
|
476 |
+
* // your code here
|
477 |
+
* return $data;
|
478 |
+
* }
|
479 |
+
* ?>
|
480 |
+
*/
|
481 |
+
$this->post_form = apply_filters( 'um_submit_form_data', $this->post_form, $this->post_form['mode'] );
|
482 |
+
|
483 |
+
/* Continue based on form mode - pre-validation */
|
484 |
+
|
485 |
+
/**
|
486 |
+
* UM hook
|
487 |
+
*
|
488 |
+
* @type action
|
489 |
+
* @title um_submit_form_errors_hook
|
490 |
+
* @description Action on submit form
|
491 |
+
* @input_vars
|
492 |
+
* [{"var":"$post","type":"int","desc":"Post data"}]
|
493 |
+
* @change_log
|
494 |
+
* ["Since: 2.0"]
|
495 |
+
* @usage add_action( 'um_submit_form_errors_hook', 'function_name', 10, 1 );
|
496 |
+
* @example
|
497 |
+
* <?php
|
498 |
+
* add_action( 'um_submit_form_errors_hook', 'my_submit_form_errors', 10, 1 );
|
499 |
+
* function my_submit_form_errors( $post ) {
|
500 |
+
* // your code here
|
501 |
+
* }
|
502 |
+
* ?>
|
503 |
+
*/
|
504 |
+
do_action( 'um_submit_form_errors_hook', $this->post_form );
|
505 |
+
/**
|
506 |
+
* UM hook
|
507 |
+
*
|
508 |
+
* @type action
|
509 |
+
* @title um_submit_form_{$mode}
|
510 |
+
* @description Action on submit form
|
511 |
+
* @input_vars
|
512 |
+
* [{"var":"$post","type":"int","desc":"Post data"}]
|
513 |
+
* @change_log
|
514 |
+
* ["Since: 2.0"]
|
515 |
+
* @usage add_action( 'um_submit_form_{$mode}', 'function_name', 10, 1 );
|
516 |
+
* @example
|
517 |
+
* <?php
|
518 |
+
* add_action( 'um_submit_form_{$mode}', 'my_submit_form', 10, 1 );
|
519 |
+
* function my_submit_form( $post ) {
|
520 |
+
* // your code here
|
521 |
+
* }
|
522 |
+
* ?>
|
523 |
+
*/
|
524 |
+
do_action( "um_submit_form_{$this->post_form['mode']}", $this->post_form );
|
525 |
+
|
526 |
+
}
|
527 |
+
}
|
528 |
+
|
529 |
+
|
530 |
+
/**
|
531 |
+
* Beautify form data
|
532 |
+
*
|
533 |
+
* @param array $form
|
534 |
+
*
|
535 |
+
* @return array $form
|
536 |
+
*/
|
537 |
+
public function beautify( $form ) {
|
538 |
+
if ( isset( $form['form_id'] ) ) {
|
539 |
+
$this->form_suffix = '-' . $form['form_id'];
|
540 |
+
$this->processing = $form['form_id'];
|
541 |
+
|
542 |
+
foreach ( $form as $key => $value ) {
|
543 |
+
if ( strstr( $key, $this->form_suffix ) ) {
|
544 |
+
$a_key = str_replace( $this->form_suffix, '', $key );
|
545 |
+
$form[ $a_key ] = $value;
|
546 |
+
unset( $form[ $key ] );
|
547 |
+
}
|
548 |
+
}
|
549 |
+
}
|
550 |
+
|
551 |
+
return $form;
|
552 |
+
}
|
553 |
+
|
554 |
+
|
555 |
+
/**
|
556 |
+
* Beautify form data
|
557 |
+
*
|
558 |
+
* @param array $form
|
559 |
+
*
|
560 |
+
* @return array $form
|
561 |
+
*/
|
562 |
+
public function sanitize( $form ) {
|
563 |
+
|
564 |
+
if ( isset( $form['form_id'] ) ) {
|
565 |
+
if ( isset( $this->form_data['custom_fields'] ) ) {
|
566 |
+
$custom_fields = maybe_unserialize( $this->form_data['custom_fields'] );
|
567 |
+
|
568 |
+
if ( is_array( $custom_fields ) ) {
|
569 |
+
foreach ( $custom_fields as $k => $field ) {
|
570 |
+
|
571 |
+
if ( isset( $field['type'] ) ) {
|
572 |
+
if ( isset( $form[ $k ] ) ) {
|
573 |
+
|
574 |
+
switch ( $field['type'] ) {
|
575 |
+
default:
|
576 |
+
$form[ $k ] = apply_filters( 'um_sanitize_form_field', $form[ $k ], $field );
|
577 |
+
break;
|
578 |
+
case 'number':
|
579 |
+
$form[ $k ] = (int) $form[ $k ];
|
580 |
+
break;
|
581 |
+
case 'textarea':
|
582 |
+
if ( ! empty( $field['html'] ) ) {
|
583 |
+
$form[ $k ] = wp_kses_post( $form[ $k ] );
|
584 |
+
} else {
|
585 |
+
$form[ $k ] = sanitize_textarea_field( $form[ $k ] );
|
586 |
+
}
|
587 |
+
break;
|
588 |
+
case 'url':
|
589 |
+
$form[ $k ] = esc_url_raw( $form[ $k ] );
|
590 |
+
break;
|
591 |
+
case 'text':
|
592 |
+
case 'select':
|
593 |
+
case 'password':
|
594 |
+
case 'image':
|
595 |
+
case 'file':
|
596 |
+
case 'date':
|
597 |
+
case 'time':
|
598 |
+
case 'rating':
|
599 |
+
case 'googlemap':
|
600 |
+
case 'youtube_video':
|
601 |
+
case 'vimeo_video':
|
602 |
+
case 'soundcloud_track':
|
603 |
+
$form[ $k ] = sanitize_text_field( $form[ $k ] );
|
604 |
+
break;
|
605 |
+
case 'multiselect':
|
606 |
+
case 'radio':
|
607 |
+
case 'checkbox':
|
608 |
+
$form[ $k ] = array_map( 'sanitize_text_field', $form[ $k ] );
|
609 |
+
break;
|
610 |
+
}
|
611 |
+
}
|
612 |
+
}
|
613 |
+
}
|
614 |
+
}
|
615 |
+
}
|
616 |
+
}
|
617 |
+
|
618 |
+
return $form;
|
619 |
+
}
|
620 |
+
|
621 |
+
|
622 |
+
/**
|
623 |
+
* Display form type as Title
|
624 |
+
* @param string $mode
|
625 |
+
* @param integer $post_id
|
626 |
+
* @return string $output
|
627 |
+
*/
|
628 |
+
public function display_form_type( $mode, $post_id ) {
|
629 |
+
$output = null;
|
630 |
+
switch ( $mode ) {
|
631 |
+
case 'login':
|
632 |
+
$output = __( 'Login', 'ultimate-member' );
|
633 |
+
break;
|
634 |
+
case 'profile':
|
635 |
+
$output = __( 'Profile', 'ultimate-member' );
|
636 |
+
break;
|
637 |
+
case 'register':
|
638 |
+
$output = __( 'Register', 'ultimate-member' );
|
639 |
+
break;
|
640 |
+
}
|
641 |
+
return $output;
|
642 |
+
}
|
643 |
+
|
644 |
+
|
645 |
+
/**
|
646 |
+
* Assigned roles to a form
|
647 |
+
* @param integer $post_id
|
648 |
+
* @return string $role
|
649 |
+
*/
|
650 |
+
public function assigned_role( $post_id ) {
|
651 |
+
|
652 |
+
$global_role = get_option( 'default_role' ); // WP Global settings
|
653 |
+
|
654 |
+
$um_global_role = UM()->options()->get( 'register_role' ); // UM Settings Global settings
|
655 |
+
if ( ! empty( $um_global_role ) ) {
|
656 |
+
$global_role = $um_global_role; // Form Global settings
|
657 |
+
}
|
658 |
+
|
659 |
+
$mode = $this->form_type( $post_id );
|
660 |
+
|
661 |
+
/**
|
662 |
+
* @todo WPML integration to get role from original if it's empty
|
663 |
+
*/
|
664 |
+
$use_custom = get_post_meta( $post_id, "_um_{$mode}_use_custom_settings", true );
|
665 |
+
if ( $use_custom ) { // Custom Form settings
|
666 |
+
$role = get_post_meta( $post_id, "_um_{$mode}_role", true );
|
667 |
+
}
|
668 |
+
|
669 |
+
if ( empty( $role ) ) { // custom role is default, return default role's slug
|
670 |
+
$role = $global_role;
|
671 |
+
}
|
672 |
+
|
673 |
+
return $role;
|
674 |
+
}
|
675 |
+
|
676 |
+
|
677 |
+
/**
|
678 |
+
* Get form type
|
679 |
+
* @param integer $post_id
|
680 |
+
* @return string
|
681 |
+
*/
|
682 |
+
public function form_type( $post_id ) {
|
683 |
+
$mode = get_post_meta( $post_id, '_um_mode', true );
|
684 |
+
return $mode;
|
685 |
+
}
|
686 |
+
|
687 |
+
|
688 |
+
/**
|
689 |
+
* Get custom field roles
|
690 |
+
*
|
691 |
+
* @param string $custom_fields serialized
|
692 |
+
* @return bool|array roles
|
693 |
+
*/
|
694 |
+
public function custom_field_roles( $custom_fields ) {
|
695 |
+
|
696 |
+
$fields = maybe_unserialize( $custom_fields );
|
697 |
+
if ( ! is_array( $fields ) ) {
|
698 |
+
return false;
|
699 |
+
}
|
700 |
+
|
701 |
+
// role field
|
702 |
+
global $wp_roles;
|
703 |
+
$role_keys = array_map(
|
704 |
+
function( $item ) {
|
705 |
+
return 'um_' . $item;
|
706 |
+
},
|
707 |
+
get_option( 'um_roles', array() )
|
708 |
+
);
|
709 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
710 |
+
|
711 |
+
$roles = UM()->roles()->get_roles( false, $exclude_roles );
|
712 |
+
$roles = array_map(
|
713 |
+
function( $item ) {
|
714 |
+
return html_entity_decode( $item, ENT_QUOTES );
|
715 |
+
},
|
716 |
+
$roles
|
717 |
+
);
|
718 |
+
|
719 |
+
foreach ( $fields as $field_key => $field_settings ) {
|
720 |
+
|
721 |
+
if ( strstr( $field_key, 'role_' ) && is_array( $field_settings['options'] ) ) {
|
722 |
+
|
723 |
+
if ( isset( $this->post_form['mode'] ) && 'profile' === $this->post_form['mode'] &&
|
724 |
+
isset( $field_settings['editable'] ) && $field_settings['editable'] == 0 ) {
|
725 |
+
continue;
|
726 |
+
}
|
727 |
+
|
728 |
+
if ( ! um_can_view_field( $field_settings ) ) {
|
729 |
+
continue;
|
730 |
+
}
|
731 |
+
|
732 |
+
$intersected_options = array();
|
733 |
+
foreach ( $field_settings['options'] as $key => $title ) {
|
734 |
+
if ( false !== $search_key = array_search( $title, $roles ) ) {
|
735 |
+
$intersected_options[ $search_key ] = $title;
|
736 |
+
} elseif ( isset( $roles[ $key ] ) ) {
|
737 |
+
$intersected_options[ $key ] = $title;
|
738 |
+
}
|
739 |
+
}
|
740 |
+
|
741 |
+
// getting roles only from the first role fields
|
742 |
+
return array_keys( $intersected_options );
|
743 |
+
}
|
744 |
+
}
|
745 |
+
|
746 |
+
return false;
|
747 |
+
}
|
748 |
+
}
|
749 |
+
}
|
includes/um-short-functions.php
CHANGED
@@ -697,6 +697,7 @@ function um_user_submitted_registration_formatted( $style = false ) {
|
|
697 |
|
698 |
if ( isset( $submitted_data['form_id'] ) ) {
|
699 |
$fields = UM()->query()->get_attr( 'custom_fields', $submitted_data['form_id'] );
|
|
|
700 |
}
|
701 |
|
702 |
if ( isset( $fields ) ) {
|
@@ -717,10 +718,10 @@ function um_user_submitted_registration_formatted( $style = false ) {
|
|
717 |
if ( empty( $rows ) ) {
|
718 |
$rows = array(
|
719 |
'_um_row_1' => array(
|
720 |
-
'type'
|
721 |
-
'id'
|
722 |
-
'sub_rows'
|
723 |
-
'cols'
|
724 |
),
|
725 |
);
|
726 |
}
|
697 |
|
698 |
if ( isset( $submitted_data['form_id'] ) ) {
|
699 |
$fields = UM()->query()->get_attr( 'custom_fields', $submitted_data['form_id'] );
|
700 |
+
$fields = maybe_unserialize( $fields );
|
701 |
}
|
702 |
|
703 |
if ( isset( $fields ) ) {
|
718 |
if ( empty( $rows ) ) {
|
719 |
$rows = array(
|
720 |
'_um_row_1' => array(
|
721 |
+
'type' => 'row',
|
722 |
+
'id' => '_um_row_1',
|
723 |
+
'sub_rows' => 1,
|
724 |
+
'cols' => 1,
|
725 |
),
|
726 |
);
|
727 |
}
|
includes/widgets/class-um-search-widget.php
CHANGED
@@ -40,6 +40,13 @@ class UM_Search_Widget extends \WP_Widget {
|
|
40 |
* @param array $instance
|
41 |
*/
|
42 |
public function widget( $args, $instance ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
$title = array_key_exists( 'title', $instance ) ? $instance['title'] : '';
|
45 |
$title = apply_filters( 'widget_title', $title );
|
40 |
* @param array $instance
|
41 |
*/
|
42 |
public function widget( $args, $instance ) {
|
43 |
+
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
|
44 |
+
return;
|
45 |
+
}
|
46 |
+
|
47 |
+
if ( ! empty( $_GET['legacy-widget-preview'] ) && defined( 'IFRAME_REQUEST' ) && IFRAME_REQUEST ) {
|
48 |
+
return;
|
49 |
+
}
|
50 |
|
51 |
$title = array_key_exists( 'title', $instance ) ? $instance['title'] : '';
|
52 |
$title = apply_filters( 'widget_title', $title );
|
readme.txt
CHANGED
@@ -6,8 +6,8 @@ Donate link:
|
|
6 |
Tags: community, member, membership, user-profile, user-registration
|
7 |
Requires PHP: 5.6
|
8 |
Requires at least: 5.0
|
9 |
-
Tested up to: 5.
|
10 |
-
Stable tag: 2.
|
11 |
License: GNU Version 2 or Any Later Version
|
12 |
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
|
13 |
|
@@ -165,6 +165,7 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
|
|
165 |
- Added: Sanitizing handlers to the Ultimate Member > Forms > Add Field/Edit Field forms' fields
|
166 |
- Added: Sanitizing handlers to the Ultimate Member > User Roles forms' fields
|
167 |
- Added: Sanitizing handlers to the Restriction Content forms' fields in the posts/pages/menus additional fields
|
|
|
168 |
- Added: Custom placeholder setting for the Confirm Password field
|
169 |
|
170 |
* Bugfixes:
|
@@ -175,11 +176,20 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
|
|
175 |
- Fixed: Content restriction (CPT + Terms). Displaying the proper count of the posts. Restricted are excluded
|
176 |
- Fixed: Saving and displaying settings on the UM > Settings > Access screen
|
177 |
- Fixed: Saving and displaying default Member Directory settings
|
|
|
|
|
|
|
178 |
|
179 |
* Tweaks:
|
180 |
|
181 |
- WordPress 5.8 compatibility. Widgets screen changes based on the new features with Legacy Widget block
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
= 2.1.21: June 17, 2021 =
|
184 |
|
185 |
* Enhancements:
|
6 |
Tags: community, member, membership, user-profile, user-registration
|
7 |
Requires PHP: 5.6
|
8 |
Requires at least: 5.0
|
9 |
+
Tested up to: 5.8
|
10 |
+
Stable tag: 2.2.0
|
11 |
License: GNU Version 2 or Any Later Version
|
12 |
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
|
13 |
|
165 |
- Added: Sanitizing handlers to the Ultimate Member > Forms > Add Field/Edit Field forms' fields
|
166 |
- Added: Sanitizing handlers to the Ultimate Member > User Roles forms' fields
|
167 |
- Added: Sanitizing handlers to the Restriction Content forms' fields in the posts/pages/menus additional fields
|
168 |
+
- Added: Sanitizing handlers to the all (Login/Registration/Profile/Account) frontend forms' fields
|
169 |
- Added: Custom placeholder setting for the Confirm Password field
|
170 |
|
171 |
* Bugfixes:
|
176 |
- Fixed: Content restriction (CPT + Terms). Displaying the proper count of the posts. Restricted are excluded
|
177 |
- Fixed: Saving and displaying settings on the UM > Settings > Access screen
|
178 |
- Fixed: Saving and displaying default Member Directory settings
|
179 |
+
- Fixed: Minor PHP warnings on registration data preview
|
180 |
+
- Fixed: Member directory slider filter-type query and results
|
181 |
+
- Fixed: Uploader filename displaying
|
182 |
|
183 |
* Tweaks:
|
184 |
|
185 |
- WordPress 5.8 compatibility. Widgets screen changes based on the new features with Legacy Widget block
|
186 |
|
187 |
+
* Templates required update:
|
188 |
+
- members.php
|
189 |
+
- password-reset.php
|
190 |
+
|
191 |
+
* Cached and optimized/minified assets(JS/CSS) must be flushed/re-generated after upgrade
|
192 |
+
|
193 |
= 2.1.21: June 17, 2021 =
|
194 |
|
195 |
* Enhancements:
|
ultimate-member.php
CHANGED
@@ -1,24 +1,24 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Ultimate Member
|
4 |
-
Plugin URI: http://ultimatemember.com/
|
5 |
-
Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
|
6 |
-
Version: 2.2.0
|
7 |
-
Author: Ultimate Member
|
8 |
-
Author URI: http://ultimatemember.com/
|
9 |
-
Text Domain: ultimate-member
|
10 |
-
*/
|
11 |
-
|
12 |
-
defined( 'ABSPATH' ) || exit;
|
13 |
-
|
14 |
-
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
15 |
-
$plugin_data = get_plugin_data( __FILE__ );
|
16 |
-
|
17 |
-
define( 'um_url', plugin_dir_url( __FILE__ ) );
|
18 |
-
define( 'um_path', plugin_dir_path( __FILE__ ) );
|
19 |
-
define( 'um_plugin', plugin_basename( __FILE__ ) );
|
20 |
-
define( 'ultimatemember_version', $plugin_data['Version'] );
|
21 |
-
define( 'ultimatemember_plugin_name', $plugin_data['Name'] );
|
22 |
-
|
23 |
-
require_once 'includes/class-functions.php';
|
24 |
-
require_once 'includes/class-init.php';
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Ultimate Member
|
4 |
+
Plugin URI: http://ultimatemember.com/
|
5 |
+
Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
|
6 |
+
Version: 2.2.0
|
7 |
+
Author: Ultimate Member
|
8 |
+
Author URI: http://ultimatemember.com/
|
9 |
+
Text Domain: ultimate-member
|
10 |
+
*/
|
11 |
+
|
12 |
+
defined( 'ABSPATH' ) || exit;
|
13 |
+
|
14 |
+
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
15 |
+
$plugin_data = get_plugin_data( __FILE__ );
|
16 |
+
|
17 |
+
define( 'um_url', plugin_dir_url( __FILE__ ) );
|
18 |
+
define( 'um_path', plugin_dir_path( __FILE__ ) );
|
19 |
+
define( 'um_plugin', plugin_basename( __FILE__ ) );
|
20 |
+
define( 'ultimatemember_version', $plugin_data['Version'] );
|
21 |
+
define( 'ultimatemember_plugin_name', $plugin_data['Name'] );
|
22 |
+
|
23 |
+
require_once 'includes/class-functions.php';
|
24 |
+
require_once 'includes/class-init.php';
|