mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-11-10 13:10:36 +09:00
Merge pull request #852 from ultimatemember/development/2.1.22
Development process 2.2.0 done
This commit is contained in:
@@ -41,7 +41,7 @@ GNU Version 2 or Any Later Version
|
||||
|
||||
## Releases
|
||||
|
||||
[Official Release Version: 2.1.21](https://github.com/ultimatemember/ultimatemember/releases/tag/2.1.21).
|
||||
[Official Release Version: 2.2.0](https://github.com/ultimatemember/ultimatemember/releases/tag/2.2.0).
|
||||
|
||||
## Changelog
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
jQuery(document).ready(function(){var a=jQuery(".um-account-main").attr("data-current_tab");a&&(jQuery('.um-account-tab[data-tab="'+a+'"]').show(),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0)),jQuery(document.body).on("click",".um-account-side li a",function(a){a.preventDefault();var e=jQuery(this);e.parents("ul").find("li a").removeClass("current"),e.addClass("current");a=jQuery(this).attr("href"),e=jQuery(this).attr("data-tab");return jQuery('input[id="_um_account_tab"]:hidden').val(e),window.history.pushState("","",a),jQuery(".um-account-tab").hide(),jQuery('.um-account-tab[data-tab="'+e+'"]').fadeIn(),jQuery(".um-account-tab:visible").find("input, select, textarea").filter(".um_account_inactive:disabled").removeClass("um_account_inactive").prop("disabled",!1).attr("disabled",!1),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),jQuery(".um-account-nav a").removeClass("current"),jQuery('.um-account-nav a[data-tab="'+e+'"]').addClass("current"),wp.hooks.doAction("um_after_account_tab_changed",e),!1}),jQuery(document.body).on("click",".um-account-nav a",function(a){a.preventDefault();var e=jQuery(this).attr("data-tab"),t=jQuery(this).parents("div"),a=jQuery(this);return jQuery('input[id="_um_account_tab"]:hidden').val(e),jQuery(".um-account-tab").hide(),a.hasClass("current")?(t.next(".um-account-tab").slideUp(),a.removeClass("current")):(t.next(".um-account-tab").slideDown(),a.parents("div").find("a").removeClass("current"),a.addClass("current")),jQuery(".um-account-tab:visible").find("input, select, textarea").filter(".um_account_inactive:disabled").removeClass("um_account_inactive").prop("disabled",!1).attr("disabled",!1),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),jQuery(".um-account-side li a").removeClass("current"),jQuery('.um-account-side li a[data-tab="'+e+'"]').addClass("current"),wp.hooks.doAction("um_after_account_tab_changed",e),!1}),jQuery(document.body).on("click",".um-request-button",function(a){a.preventDefault();var e=jQuery(this).data("action"),t=jQuery("#"+e).val();jQuery(".um-field-area-response."+e).hide(),jQuery("#"+e).length&&""===t?jQuery(".um-field-error."+e).show():(jQuery(".um-field-error."+e).hide(),a={request_action:e,nonce:um_scripts.nonce},jQuery("#"+e).length&&(a.password=t),wp.ajax.send("um_request_user_data",{data:a,success:function(a){jQuery(".um-field-area-response."+e).text(a.answer).show()},error:function(a){console.log(a)}}))})});
|
||||
jQuery(document).ready(function(){var a=jQuery(".um-account-main").attr("data-current_tab");a&&(jQuery('.um-account-tab[data-tab="'+a+'"]').show(),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0)),jQuery(document.body).on("click",".um-account-side li a",function(a){a.preventDefault();var e=jQuery(this);e.parents("ul").find("li a").removeClass("current"),e.addClass("current");var t=jQuery(this).attr("href"),u=jQuery(this).attr("data-tab");return jQuery('input[id="_um_account_tab"]:hidden').val(u),window.history.pushState("","",t),jQuery(".um-account-tab").hide(),jQuery('.um-account-tab[data-tab="'+u+'"]').fadeIn(),jQuery(".um-account-tab:visible").find("input, select, textarea").filter(".um_account_inactive:disabled").removeClass("um_account_inactive").prop("disabled",!1).attr("disabled",!1),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),jQuery(".um-account-nav a").removeClass("current"),jQuery('.um-account-nav a[data-tab="'+u+'"]').addClass("current"),wp.hooks.doAction("um_after_account_tab_changed",u),!1}),jQuery(document.body).on("click",".um-account-nav a",function(a){a.preventDefault();var e=jQuery(this).attr("data-tab"),t=jQuery(this).parents("div"),u=jQuery(this);return jQuery('input[id="_um_account_tab"]:hidden').val(e),jQuery(".um-account-tab").hide(),u.hasClass("current")?(t.next(".um-account-tab").slideUp(),u.removeClass("current")):(t.next(".um-account-tab").slideDown(),u.parents("div").find("a").removeClass("current"),u.addClass("current")),jQuery(".um-account-tab:visible").find("input, select, textarea").filter(".um_account_inactive:disabled").removeClass("um_account_inactive").prop("disabled",!1).attr("disabled",!1),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),jQuery(".um-account-side li a").removeClass("current"),jQuery('.um-account-side li a[data-tab="'+e+'"]').addClass("current"),wp.hooks.doAction("um_after_account_tab_changed",e),!1}),jQuery(document.body).on("click",".um-request-button",function(a){a.preventDefault();var e=jQuery(this).data("action"),t=jQuery("#"+e).val();if(jQuery(".um-field-area-response."+e).hide(),jQuery("#"+e).length&&""===t)jQuery(".um-field-error."+e).show();else{jQuery(".um-field-error."+e).hide();var u={request_action:e,nonce:um_scripts.nonce};jQuery("#"+e).length&&(u.password=t),wp.ajax.send("um_request_user_data",{data:u,success:function(a){jQuery(".um-field-area-response."+e).text(a.answer).show()},error:function(a){console.log(a)}})}})});
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
||||
jQuery(document).ready(function(){jQuery(".um-profile.um-viewing .um-profile-body .um-row").each(function(){var e=jQuery(this);0==e.find(".um-field").length&&(e.prev(".um-row-heading").remove(),e.remove())}),jQuery(".um-profile.um-viewing .um-profile-body").length&&0==jQuery(".um-profile.um-viewing .um-profile-body").find(".um-field").length&&(jQuery(".um-profile.um-viewing .um-profile-body").find(".um-row-heading,.um-row").remove(),jQuery(".um-profile-note").show()),jQuery(document.body).on("click",".um-profile-save",function(e){return e.preventDefault(),jQuery(this).parents(".um").find("form").trigger("submit"),!1}),jQuery(document.body).on("click",".um-profile-edit-a",function(e){jQuery(this).addClass("active")}),jQuery(document.body).on("click",".um-cover a.um-cover-add, .um-photo a",function(e){e.preventDefault()}),jQuery(document.body).on("click",".um-photo-modal",function(e){e.preventDefault();e=jQuery(this).attr("data-src");return um_new_modal("um_view_photo","fit",!0,e),!1}),jQuery(document.body).on("click",".um-reset-profile-photo",function(e){return jQuery(".um-profile-photo-img img").attr("src",jQuery(this).attr("data-default_src")),user_id=jQuery(this).attr("data-user_id"),metakey="profile_photo",UM.dropdown.hideAll(),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_delete_profile_photo",metakey:metakey,user_id:user_id,nonce:um_scripts.nonce}}),jQuery(this).parents("li").hide(),!1}),jQuery(document.body).on("click",".um-reset-cover-photo",function(e){var r=jQuery(this);return jQuery(".um-cover-overlay").hide(),jQuery(".um-cover-e").html('<a href="javascript:void(0);" class="um-cover-add" style="height: 370px;"><span class="um-cover-add-i"><i class="um-icon-plus um-tip-n" original-title="Upload a cover photo"></i></span></a>'),um_responsive(),user_id=jQuery(this).attr("data-user_id"),metakey="cover_photo",jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_delete_cover_photo",metakey:metakey,user_id:user_id,nonce:um_scripts.nonce},success:function(e){r.hide()}}),UM.dropdown.hideAll(),!1}),jQuery(document.body).on("change, keyup",'textarea[id="um-meta-bio"]',function(){var e;void 0!==jQuery(this).val()&&(e=jQuery(this).attr("data-character-limit")-jQuery(this).val().length,jQuery("span.um-meta-bio-character span.um-bio-limit").text(e),e<5?jQuery("span.um-meta-bio-character").css("color","red"):jQuery("span.um-meta-bio-character").css("color",""))}),jQuery('textarea[id="um-meta-bio"]').trigger("change"),jQuery(".um-profile-edit a.um_delete-item").on("click",function(e){if(e.preventDefault(),!confirm(wp.i18n.__("Are you sure that you want to delete this user?","ultimate-member")))return!1}),jQuery(".um-profile-nav a").on("touchend",function(e){jQuery(e.currentTarget).trigger("click")})});
|
||||
jQuery(document).ready(function(){jQuery(".um-profile.um-viewing .um-profile-body .um-row").each(function(){var e=jQuery(this);0==e.find(".um-field").length&&(e.prev(".um-row-heading").remove(),e.remove())}),jQuery(".um-profile.um-viewing .um-profile-body").length&&0==jQuery(".um-profile.um-viewing .um-profile-body").find(".um-field").length&&(jQuery(".um-profile.um-viewing .um-profile-body").find(".um-row-heading,.um-row").remove(),jQuery(".um-profile-note").show()),jQuery(document.body).on("click",".um-profile-save",function(e){return e.preventDefault(),jQuery(this).parents(".um").find("form").trigger("submit"),!1}),jQuery(document.body).on("click",".um-profile-edit-a",function(e){jQuery(this).addClass("active")}),jQuery(document.body).on("click",".um-cover a.um-cover-add, .um-photo a",function(e){e.preventDefault()}),jQuery(document.body).on("click",".um-photo-modal",function(e){e.preventDefault();var r=jQuery(this).attr("data-src");return um_new_modal("um_view_photo","fit",!0,r),!1}),jQuery(document.body).on("click",".um-reset-profile-photo",function(e){return jQuery(".um-profile-photo-img img").attr("src",jQuery(this).attr("data-default_src")),user_id=jQuery(this).attr("data-user_id"),metakey="profile_photo",UM.dropdown.hideAll(),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_delete_profile_photo",metakey:metakey,user_id:user_id,nonce:um_scripts.nonce}}),jQuery(this).parents("li").hide(),!1}),jQuery(document.body).on("click",".um-reset-cover-photo",function(e){var r=jQuery(this);return jQuery(".um-cover-overlay").hide(),jQuery(".um-cover-e").html('<a href="javascript:void(0);" class="um-cover-add" style="height: 370px;"><span class="um-cover-add-i"><i class="um-icon-plus um-tip-n" original-title="Upload a cover photo"></i></span></a>'),um_responsive(),user_id=jQuery(this).attr("data-user_id"),metakey="cover_photo",jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_delete_cover_photo",metakey:metakey,user_id:user_id,nonce:um_scripts.nonce},success:function(e){r.hide()}}),UM.dropdown.hideAll(),!1}),jQuery(document.body).on("change, keyup",'textarea[id="um-meta-bio"]',function(){if(void 0!==jQuery(this).val()){var e=jQuery(this).attr("data-character-limit")-jQuery(this).val().length;jQuery("span.um-meta-bio-character span.um-bio-limit").text(e),e<5?jQuery("span.um-meta-bio-character").css("color","red"):jQuery("span.um-meta-bio-character").css("color","")}}),jQuery('textarea[id="um-meta-bio"]').trigger("change"),jQuery(".um-profile-edit a.um_delete-item").on("click",function(e){if(e.preventDefault(),!confirm(wp.i18n.__("Are you sure that you want to delete this user?","ultimate-member")))return!1}),jQuery(".um-profile-nav a").on("touchend",function(e){jQuery(e.currentTarget).trigger("click")})});
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
||||
!function(a){function l(t,e){return"function"==typeof t?t.call(e):t}function h(t,e){this.$element=a(t),this.options=e,this.enabled=!0,this.fixTitle()}h.prototype={show:function(){var t=this.getTitle();if(t&&this.enabled){var e=this.tip();e.find(".tipsy-inner")[this.options.html?"html":"text"](t),e[0].className="tipsy",e.remove().css({top:0,left:0,visibility:"hidden",display:"block"}).prependTo(document.body);var i,s=a.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight}),n=e[0].offsetWidth,o=e[0].offsetHeight,t=l(this.options.gravity,this.$element[0]);switch(t.charAt(0)){case"n":i={top:s.top+s.height+this.options.offset,left:s.left+s.width/2-n/2};break;case"s":i={top:s.top-o-this.options.offset,left:s.left+s.width/2-n/2};break;case"e":i={top:s.top+s.height/2-o/2,left:s.left-n-this.options.offset};break;case"w":(extra_gap=0)<a("body").css("position").length&&"relative"==a("body").css("position")&&a("#wpadminbar").length&&(extra_gap=a("#wpadminbar").height()),i={top:s.top+s.height/2-o/2-extra_gap,left:s.left+s.width+this.options.offset}}2==t.length&&("w"==t.charAt(1)?i.left=s.left+s.width/2-15:i.left=s.left+s.width/2-n+15),e.css(i).addClass("tipsy-"+t),e.find(".tipsy-arrow")[0].className="tipsy-arrow tipsy-arrow-"+t.charAt(0),this.options.className&&e.addClass(l(this.options.className,this.$element[0])),this.options.fade?e.stop().css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:this.options.opacity}):e.css({visibility:"visible",opacity:this.options.opacity})}},hide:function(){this.options.fade?this.tip().stop().fadeOut(function(){a(this).remove()}):this.tip().remove()},fixTitle:function(){var t=this.$element;!t.attr("title")&&"string"==typeof t.attr("original-title")||t.attr("original-title",t.attr("title")||"").removeAttr("title")},getTitle:function(){var t,e=this.$element,i=this.options;return this.fixTitle(),"string"==typeof(i=this.options).title?t=e.attr("title"==i.title?"original-title":i.title):"function"==typeof i.title&&(t=i.title.call(e[0])),(t=(""+t).replace(/(^\s*|\s*$)/,""))||i.fallback},tip:function(){return this.$tip||(this.$tip=a('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"></div>'),this.$tip.data("tipsy-pointee",this.$element[0])),this.$tip},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled}},a.fn.tipsy=function(i){if(!0===i)return this.data("tipsy");if("string"!=typeof i)return(i=a.extend({},a.fn.tipsy.defaults,i)).on||this.each(function(){e(this)}),"manual"!=i.trigger&&(n="hover"==i.trigger?"mouseenter":"focus",o="hover"==i.trigger?"mouseleave":"blur",i.on?a(document).on(n,this.selector,t).on(o,this.selector,s):this.on(n,t).on(o,s)),this;function e(t){var e=a.data(t,"tipsy");return e||(e=new h(t,a.fn.tipsy.elementOptions(t,i)),a.data(t,"tipsy",e)),e}function t(){var t=e(this);t.hoverState="in",0==i.delayIn?t.show():(t.fixTitle(),setTimeout(function(){"in"==t.hoverState&&t.show()},i.delayIn))}function s(){var t=e(this);t.hoverState="out",0==i.delayOut?t.hide():setTimeout(function(){"out"==t.hoverState&&t.hide()},i.delayOut)}var n,o=this.data("tipsy");return o&&o[i](),this},a.fn.tipsy.defaults={className:null,delayIn:0,delayOut:0,fade:!1,fallback:"",gravity:"n",html:!1,live:!1,offset:0,opacity:.8,title:"title",trigger:"hover"},a.fn.tipsy.revalidate=function(){a(".tipsy").each(function(){var t=a.data(this,"tipsy-pointee");t&&function(t){for(;t=t.parentNode;)if(t==document)return 1}(t)||a(this).remove()})},a.fn.tipsy.elementOptions=function(t,e){return a.metadata?a.extend({},e,a(t).metadata()):e},a.fn.tipsy.autoNS=function(){return a(this).offset().top>a(document).scrollTop()+a(window).height()/2?"s":"n"},a.fn.tipsy.autoWE=function(){return a(this).offset().left>a(document).scrollLeft()+a(window).width()/2?"e":"w"},a.fn.tipsy.autoBounds=function(n,o){return function(){var t={ns:o[0],ew:1<o.length&&o[1]},e=a(document).scrollTop()+n,i=a(document).scrollLeft()+n,s=a(this);return s.offset().top<e&&(t.ns="n"),s.offset().left<i&&(t.ew="w"),a(window).width()+a(document).scrollLeft()-s.offset().left<n&&(t.ew="e"),a(window).height()+a(document).scrollTop()-s.offset().top<n&&(t.ns="s"),t.ns+(t.ew||"")}}}(jQuery);
|
||||
!function(l){function f(t,e){return"function"==typeof t?t.call(e):t}function h(t,e){this.$element=l(t),this.options=e,this.enabled=!0,this.fixTitle()}h.prototype={show:function(){var t=this.getTitle();if(t&&this.enabled){var e=this.tip();e.find(".tipsy-inner")[this.options.html?"html":"text"](t),e[0].className="tipsy",e.remove().css({top:0,left:0,visibility:"hidden",display:"block"}).prependTo(document.body);var i,s=l.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight}),n=e[0].offsetWidth,o=e[0].offsetHeight,a=f(this.options.gravity,this.$element[0]);switch(a.charAt(0)){case"n":i={top:s.top+s.height+this.options.offset,left:s.left+s.width/2-n/2};break;case"s":i={top:s.top-o-this.options.offset,left:s.left+s.width/2-n/2};break;case"e":i={top:s.top+s.height/2-o/2,left:s.left-n-this.options.offset};break;case"w":(extra_gap=0)<l("body").css("position").length&&"relative"==l("body").css("position")&&l("#wpadminbar").length&&(extra_gap=l("#wpadminbar").height()),i={top:s.top+s.height/2-o/2-extra_gap,left:s.left+s.width+this.options.offset}}2==a.length&&("w"==a.charAt(1)?i.left=s.left+s.width/2-15:i.left=s.left+s.width/2-n+15),e.css(i).addClass("tipsy-"+a),e.find(".tipsy-arrow")[0].className="tipsy-arrow tipsy-arrow-"+a.charAt(0),this.options.className&&e.addClass(f(this.options.className,this.$element[0])),this.options.fade?e.stop().css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:this.options.opacity}):e.css({visibility:"visible",opacity:this.options.opacity})}},hide:function(){this.options.fade?this.tip().stop().fadeOut(function(){l(this).remove()}):this.tip().remove()},fixTitle:function(){var t=this.$element;(t.attr("title")||"string"!=typeof t.attr("original-title"))&&t.attr("original-title",t.attr("title")||"").removeAttr("title")},getTitle:function(){var t,e=this.$element,i=this.options;return this.fixTitle(),"string"==typeof(i=this.options).title?t=e.attr("title"==i.title?"original-title":i.title):"function"==typeof i.title&&(t=i.title.call(e[0])),(t=(""+t).replace(/(^\s*|\s*$)/,""))||i.fallback},tip:function(){return this.$tip||(this.$tip=l('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"></div>'),this.$tip.data("tipsy-pointee",this.$element[0])),this.$tip},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled}},l.fn.tipsy=function(i){if(!0===i)return this.data("tipsy");if("string"==typeof i){var t=this.data("tipsy");return t&&t[i](),this}function e(t){var e=l.data(t,"tipsy");return e||(e=new h(t,l.fn.tipsy.elementOptions(t,i)),l.data(t,"tipsy",e)),e}function s(){var t=e(this);t.hoverState="in",0==i.delayIn?t.show():(t.fixTitle(),setTimeout(function(){"in"==t.hoverState&&t.show()},i.delayIn))}function n(){var t=e(this);t.hoverState="out",0==i.delayOut?t.hide():setTimeout(function(){"out"==t.hoverState&&t.hide()},i.delayOut)}if((i=l.extend({},l.fn.tipsy.defaults,i)).on||this.each(function(){e(this)}),"manual"!=i.trigger){var o="hover"==i.trigger?"mouseenter":"focus",a="hover"==i.trigger?"mouseleave":"blur";i.on?l(document).on(o,this.selector,s).on(a,this.selector,n):this.on(o,s).on(a,n)}return this},l.fn.tipsy.defaults={className:null,delayIn:0,delayOut:0,fade:!1,fallback:"",gravity:"n",html:!1,live:!1,offset:0,opacity:.8,title:"title",trigger:"hover"},l.fn.tipsy.revalidate=function(){l(".tipsy").each(function(){var t=l.data(this,"tipsy-pointee");t&&function(t){for(;t=t.parentNode;)if(t==document)return!0;return!1}(t)||l(this).remove()})},l.fn.tipsy.elementOptions=function(t,e){return l.metadata?l.extend({},e,l(t).metadata()):e},l.fn.tipsy.autoNS=function(){return l(this).offset().top>l(document).scrollTop()+l(window).height()/2?"s":"n"},l.fn.tipsy.autoWE=function(){return l(this).offset().left>l(document).scrollLeft()+l(window).width()/2?"e":"w"},l.fn.tipsy.autoBounds=function(n,o){return function(){var t={ns:o[0],ew:1<o.length&&o[1]},e=l(document).scrollTop()+n,i=l(document).scrollLeft()+n,s=l(this);return s.offset().top<e&&(t.ns="n"),s.offset().left<i&&(t.ew="w"),l(window).width()+l(document).scrollLeft()-s.offset().left<n&&(t.ew="e"),l(window).height()+l(document).scrollTop()-s.offset().top<n&&(t.ns="s"),t.ns+(t.ew?t.ew:"")}}}(jQuery);
|
||||
@@ -557,7 +557,6 @@ jQuery(document).ready( function() {
|
||||
jQuery( '.um-multi-text-add-option' ).on('click', function() {
|
||||
var list = jQuery(this).siblings( 'ul.um-multi-text-list' );
|
||||
|
||||
var field_id = list.data( 'field_id' );
|
||||
var k = 0;
|
||||
if ( list.find( 'li:last input.um-forms-field' ).length > 0 ) {
|
||||
k = list.find( 'li:last input.um-forms-field' ).attr('id').split("-");
|
||||
@@ -566,7 +565,7 @@ jQuery(document).ready( function() {
|
||||
|
||||
var text_html = jQuery( '<div>' ).append( list.siblings('.um-hidden-multi-text').clone() ).html();
|
||||
|
||||
var classes = list.find('li:last').attr('class');
|
||||
var classes = list.data('item_class');
|
||||
|
||||
list.append(
|
||||
'<li class="' + classes + '"><span class="um-field-wrapper">' + text_html +
|
||||
@@ -986,4 +985,4 @@ jQuery(document).ready( function() {
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) {
|
||||
* @param bool $action
|
||||
*/
|
||||
function check_ajax_nonce( $action = false ) {
|
||||
$nonce = isset( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : '';
|
||||
$nonce = isset( $_REQUEST['nonce'] ) ? sanitize_text_field( $_REQUEST['nonce'] ) : '';
|
||||
$action = empty( $action ) ? 'um-admin-nonce' : $action;
|
||||
|
||||
if ( ! wp_verify_nonce( $nonce, $action ) ) {
|
||||
@@ -44,16 +44,18 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) {
|
||||
*/
|
||||
function is_um_screen() {
|
||||
global $current_screen;
|
||||
$screen_id = $current_screen->id;
|
||||
|
||||
$is_um_screen = false;
|
||||
|
||||
if ( strstr( $screen_id, 'ultimatemember') ||
|
||||
strstr( $screen_id, 'um_') ||
|
||||
strstr( $screen_id, 'user' ) ||
|
||||
strstr( $screen_id, 'profile' ) ||
|
||||
$screen_id == 'nav-menus' ) {
|
||||
$is_um_screen = true;
|
||||
if ( ! empty( $current_screen ) ) {
|
||||
$screen_id = $current_screen->id;
|
||||
if ( strstr( $screen_id, 'ultimatemember' ) ||
|
||||
strstr( $screen_id, 'um_' ) ||
|
||||
strstr( $screen_id, 'user' ) ||
|
||||
strstr( $screen_id, 'profile' ) ||
|
||||
$screen_id == 'nav-menus' ) {
|
||||
$is_um_screen = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->is_plugin_post_type() ) {
|
||||
@@ -81,7 +83,7 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) {
|
||||
if ( in_array( $post_type, $cpt ) ) {
|
||||
return true;
|
||||
}
|
||||
} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'edit' ) {
|
||||
} elseif ( isset( $_REQUEST['action'] ) && sanitize_key( $_REQUEST['action'] ) == 'edit' ) {
|
||||
$post_type = get_post_type();
|
||||
if ( in_array( $post_type, $cpt ) ) {
|
||||
return true;
|
||||
@@ -113,4 +115,4 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1501
-6
File diff suppressed because it is too large
Load Diff
@@ -615,10 +615,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
||||
$output['error'] = null;
|
||||
|
||||
$array = array(
|
||||
'field_type' => sanitize_key( $_POST['_type'] ),
|
||||
'form_id' => absint( $_POST['post_id'] ),
|
||||
'args' => UM()->builtin()->get_core_field_attrs( sanitize_key( $_POST['_type'] ) ),
|
||||
'post' => $_POST
|
||||
'field_type' => sanitize_key( $_POST['_type'] ),
|
||||
'form_id' => absint( $_POST['post_id'] ),
|
||||
'args' => UM()->builtin()->get_core_field_attrs( sanitize_key( $_POST['_type'] ) ),
|
||||
'post' => UM()->admin()->sanitize_builder_field_meta( $_POST ),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -678,8 +678,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
||||
$save[ $_metakey ] = null;
|
||||
foreach ( $array['post'] as $key => $val ) {
|
||||
|
||||
if ( substr( $key, 0, 1 ) === '_' && $val != '' ) { // field attribute
|
||||
$new_key = ltrim ($key,'_');
|
||||
if ( substr( $key, 0, 1 ) === '_' && $val !== '' ) { // field attribute
|
||||
$new_key = ltrim ( $key, '_' );
|
||||
|
||||
if ( $new_key == 'options' ) {
|
||||
//$save[ $_metakey ][$new_key] = explode(PHP_EOL, $val);
|
||||
@@ -689,7 +689,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
||||
}
|
||||
|
||||
} elseif ( strstr( $key, 'um_editor' ) ) {
|
||||
$save[ $_metakey ]['content'] = $val;
|
||||
|
||||
if ( 'block' === $array['post']['_type'] ) {
|
||||
$save[ $_metakey ]['content'] = wp_kses_post( $val );
|
||||
} else {
|
||||
$save[ $_metakey ]['content'] = sanitize_textarea_field( $val );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -781,7 +786,19 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
||||
*/
|
||||
extract( $_POST );
|
||||
|
||||
switch ( $act_id ) {
|
||||
if ( isset( $arg1 ) ) {
|
||||
$arg1 = sanitize_text_field( $arg1 );
|
||||
}
|
||||
|
||||
if ( isset( $arg2 ) ) {
|
||||
$arg2 = sanitize_text_field( $arg2 );
|
||||
}
|
||||
|
||||
if ( isset( $arg3 ) ) {
|
||||
$arg3 = sanitize_text_field( $arg3 );
|
||||
}
|
||||
|
||||
switch ( sanitize_key( $act_id ) ) {
|
||||
|
||||
default:
|
||||
|
||||
@@ -806,7 +823,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_admin_ajax_modal_content__hook', $act_id );
|
||||
do_action( 'um_admin_ajax_modal_content__hook', sanitize_key( $act_id ) );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
@@ -824,7 +841,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( "um_admin_ajax_modal_content__hook_{$act_id}" );
|
||||
do_action( "um_admin_ajax_modal_content__hook_" . sanitize_key( $act_id ) );
|
||||
|
||||
$output = ob_get_clean();
|
||||
break;
|
||||
@@ -1208,4 +1225,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
|
||||
/**
|
||||
* Update order of fields
|
||||
*/
|
||||
function update_order() {
|
||||
public function update_order() {
|
||||
UM()->admin()->check_ajax_nonce();
|
||||
|
||||
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
||||
@@ -38,14 +38,18 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
|
||||
*/
|
||||
extract( $_POST );
|
||||
|
||||
if ( isset( $form_id ) ) {
|
||||
$form_id = absint( $form_id );
|
||||
}
|
||||
|
||||
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
||||
|
||||
$this->row_data = get_option( 'um_form_rowdata_' . $form_id, array() );
|
||||
$this->row_data = get_option( 'um_form_rowdata_' . $form_id, array() );
|
||||
$this->exist_rows = array();
|
||||
|
||||
if ( ! empty( $fields ) ) {
|
||||
foreach ( $fields as $key => $array ) {
|
||||
if ( $array['type'] == 'row' ) {
|
||||
if ( 'row' === $array['type'] ) {
|
||||
$this->row_data[ $key ] = $array;
|
||||
unset( $fields[ $key ] );
|
||||
}
|
||||
@@ -56,6 +60,8 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
|
||||
|
||||
foreach ( $_POST as $key => $value ) {
|
||||
|
||||
$key = sanitize_key( $key );
|
||||
|
||||
// adding rows
|
||||
if ( 0 === strpos( $key, '_um_row_' ) ) {
|
||||
|
||||
@@ -64,18 +70,18 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
|
||||
$row_id = str_replace( '_um_row_', '', $key );
|
||||
|
||||
$row_array = array(
|
||||
'type' => 'row',
|
||||
'id' => $value,
|
||||
'sub_rows' => $_POST[ '_um_rowsub_' . $row_id . '_rows' ],
|
||||
'cols' => $_POST[ '_um_rowcols_' . $row_id . '_cols' ],
|
||||
'origin' => $_POST[ '_um_roworigin_' . $row_id . '_val' ],
|
||||
'type' => 'row',
|
||||
'id' => sanitize_key( $value ),
|
||||
'sub_rows' => absint( $_POST[ '_um_rowsub_' . $row_id . '_rows' ] ),
|
||||
'cols' => absint( $_POST[ '_um_rowcols_' . $row_id . '_cols' ] ),
|
||||
'origin' => sanitize_key( $_POST[ '_um_roworigin_' . $row_id . '_val' ] ),
|
||||
);
|
||||
|
||||
$row_args = $row_array;
|
||||
|
||||
if ( isset( $this->row_data[ $row_array['origin'] ] ) ) {
|
||||
foreach ( $this->row_data[ $row_array['origin'] ] as $k => $v ) {
|
||||
if ( $k != 'position' && $k != 'metakey' ) {
|
||||
if ( 'position' !== $k && 'metakey' !== $k ) {
|
||||
$update_args[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
@@ -93,7 +99,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
|
||||
if ( 0 === strpos( $key, 'um_position_' ) ) {
|
||||
$field_key = str_replace( 'um_position_', '', $key );
|
||||
if ( isset( $fields[ $field_key ] ) ) {
|
||||
$fields[ $field_key ]['position'] = $value;
|
||||
$fields[ $field_key ]['position'] = absint( $value );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +107,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
|
||||
if ( 0 === strpos( $key, 'um_row_' ) ) {
|
||||
$field_key = str_replace( 'um_row_', '', $key );
|
||||
if ( isset( $fields[ $field_key ] ) ) {
|
||||
$fields[ $field_key ]['in_row'] = $value;
|
||||
$fields[ $field_key ]['in_row'] = sanitize_key( $value );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +115,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
|
||||
if ( 0 === strpos( $key, 'um_subrow_' ) ) {
|
||||
$field_key = str_replace( 'um_subrow_', '', $key );
|
||||
if ( isset( $fields[ $field_key ] ) ) {
|
||||
$fields[ $field_key ]['in_sub_row'] = $value;
|
||||
$fields[ $field_key ]['in_sub_row'] = sanitize_key( $value );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +123,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
|
||||
if ( 0 === strpos( $key, 'um_col_' ) ) {
|
||||
$field_key = str_replace( 'um_col_', '', $key );
|
||||
if ( isset( $fields[ $field_key ] ) ) {
|
||||
$fields[ $field_key ]['in_column'] = $value;
|
||||
$fields[ $field_key ]['in_column'] = absint( $value );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,21 +131,20 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
|
||||
if ( 0 === strpos( $key, 'um_group_' ) ) {
|
||||
$field_key = str_replace( 'um_group_', '', $key );
|
||||
if ( isset( $fields[ $field_key ] ) ) {
|
||||
$fields[ $field_key ]['in_group'] = $value;
|
||||
$fields[ $field_key ]['in_group'] = absint( $value );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ( $this->row_data as $k => $v ) {
|
||||
if ( ! in_array( $k, $this->exist_rows ) ) {
|
||||
if ( ! in_array( $k, $this->exist_rows, true ) ) {
|
||||
unset( $this->row_data[ $k ] );
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'um_existing_rows_' . $form_id, $this->exist_rows );
|
||||
|
||||
update_option( 'um_form_rowdata_' . $form_id , $this->row_data );
|
||||
update_option( 'um_form_rowdata_' . $form_id, $this->row_data );
|
||||
|
||||
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
||||
|
||||
@@ -149,11 +154,11 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
|
||||
/**
|
||||
* Load form to maintain form order
|
||||
*/
|
||||
function load_field_order() {
|
||||
public function load_field_order() {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( ! isset( $screen->id ) || $screen->id != 'um_form' ) {
|
||||
if ( ! isset( $screen->id ) || 'um_form' !== $screen->id ) {
|
||||
return;
|
||||
} ?>
|
||||
|
||||
@@ -235,4 +240,4 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
|
||||
add_action( 'load-post-new.php', array( &$this, 'enqueue_cpt_scripts' ) );
|
||||
add_action( 'load-post.php', array( &$this, 'enqueue_cpt_scripts' ) );
|
||||
|
||||
add_filter( 'block_categories', array( &$this, 'blocks_category' ), 10, 2 );
|
||||
global $wp_version;
|
||||
if ( version_compare( $wp_version, '5.8-rc.1', '>=' ) ) {
|
||||
add_filter( 'block_categories_all', array( &$this, 'blocks_category' ), 10, 2 );
|
||||
} else {
|
||||
add_filter( 'block_categories', array( &$this, 'blocks_category' ), 10, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -96,10 +101,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
|
||||
*
|
||||
*/
|
||||
function enqueue_cpt_scripts() {
|
||||
if ( ( isset( $_GET['post_type'] ) && 'um_form' == sanitize_key( $_GET['post_type'] ) ) ||
|
||||
( isset( $_GET['post'] ) && 'um_form' == get_post_type( absint( $_GET['post'] ) ) ) ) {
|
||||
if ( ( isset( $_GET['post_type'] ) && 'um_form' === sanitize_key( $_GET['post_type'] ) ) ||
|
||||
( isset( $_GET['post'] ) && 'um_form' === get_post_type( absint( $_GET['post'] ) ) ) ) {
|
||||
$this->um_cpt_form_screen = true;
|
||||
add_action( 'admin_footer', array( $this, 'admin_footer_scripts' ), 20 );
|
||||
add_action( 'admin_footer', array( $this, 'admin_footer_scripts' ), 20 );
|
||||
}
|
||||
|
||||
$this->post_page = true;
|
||||
@@ -296,9 +301,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
|
||||
//and WP calculate page height
|
||||
$hide_footer = false;
|
||||
global $pagenow, $post;
|
||||
if ( ( 'post.php' == $pagenow || 'post-new.php' == $pagenow ) &&
|
||||
( ( isset( $_GET['post_type'] ) && 'um_form' == sanitize_key( $_GET['post_type'] ) ) ||
|
||||
( isset( $post->post_type ) && 'um_form' == $post->post_type ) ) ) {
|
||||
if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) &&
|
||||
( ( isset( $_GET['post_type'] ) && 'um_form' === sanitize_key( $_GET['post_type'] ) ) ||
|
||||
( isset( $post->post_type ) && 'um_form' === $post->post_type ) ) ) {
|
||||
$hide_footer = true;
|
||||
}
|
||||
|
||||
@@ -527,11 +532,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
|
||||
* Add Gutenberg category for UM shortcodes
|
||||
*
|
||||
* @param array $categories
|
||||
* @param $post
|
||||
* @param \WP_Block_Editor_Context $context
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function blocks_category( $categories, $post ) {
|
||||
function blocks_category( $categories, $context ) {
|
||||
$enable_blocks = UM()->options()->get( 'enable_blocks' );
|
||||
if ( empty( $enable_blocks ) ) {
|
||||
return $categories;
|
||||
|
||||
@@ -1151,8 +1151,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
|
||||
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
|
||||
|
||||
$data = array(
|
||||
'field_id' => $field_data['id'],
|
||||
'id_attr' => $id
|
||||
'field_id' => $field_data['id'],
|
||||
'id_attr' => $id,
|
||||
'item_class' => "um-multi-text-option-line {$size}",
|
||||
);
|
||||
|
||||
$data_attr = '';
|
||||
@@ -1604,4 +1605,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) {
|
||||
function um_roles_pages() {
|
||||
if ( empty( $_GET['tab'] ) ) {
|
||||
include_once um_path . 'includes/admin/core/list-tables/roles-list-table.php';
|
||||
} elseif ( sanitize_key( $_GET['tab'] ) == 'add' || sanitize_key( $_GET['tab'] ) == 'edit' ) {
|
||||
} elseif ( 'add' === sanitize_key( $_GET['tab'] ) || 'edit' === sanitize_key( $_GET['tab'] ) ) {
|
||||
include_once um_path . 'includes/admin/templates/role/role-edit.php';
|
||||
} else {
|
||||
um_js_redirect( add_query_arg( array( 'page' => 'um_roles' ), get_admin_url( 'admin.php' ) ) );
|
||||
@@ -340,4 +340,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
* @param $post_id
|
||||
* @param $post
|
||||
*/
|
||||
function save_metabox_custom( $post_id, $post ) {
|
||||
public function save_metabox_custom( $post_id, $post ) {
|
||||
// validate nonce
|
||||
if ( ! isset( $_POST['um_admin_save_metabox_custom_nonce'] ) ||
|
||||
! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) {
|
||||
@@ -313,7 +313,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
}
|
||||
|
||||
if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
|
||||
update_post_meta( $post_id, 'um_content_restriction', $_POST['um_content_restriction'] );
|
||||
$restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
|
||||
|
||||
update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
|
||||
} else {
|
||||
delete_post_meta( $post_id, 'um_content_restriction' );
|
||||
}
|
||||
@@ -340,7 +342,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
}
|
||||
|
||||
if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
|
||||
update_post_meta( $post_id, 'um_content_restriction', $_POST['um_content_restriction'] );
|
||||
$restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
|
||||
|
||||
update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
|
||||
} else {
|
||||
delete_post_meta( $post_id, 'um_content_restriction' );
|
||||
}
|
||||
@@ -666,7 +670,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
}
|
||||
|
||||
if ( ! empty( $_REQUEST['um_content_restriction'] ) && is_array( $_REQUEST['um_content_restriction'] ) ) {
|
||||
update_term_meta( $termID, 'um_content_restriction', $_REQUEST['um_content_restriction'] );
|
||||
$restriction_meta = UM()->admin()->sanitize_term_restriction_meta( $_REQUEST['um_content_restriction'] );
|
||||
|
||||
update_term_meta( $termID, 'um_content_restriction', $restriction_meta );
|
||||
} else {
|
||||
delete_term_meta( $termID, 'um_content_restriction' );
|
||||
}
|
||||
@@ -851,7 +857,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! isset( $_GET['id'] ) || 'administrator' != sanitize_key( $_GET['id'] ) ) {
|
||||
if ( ! isset( $_GET['id'] ) || 'administrator' !== sanitize_key( $_GET['id'] ) ) {
|
||||
$roles_metaboxes[] = array(
|
||||
'id' => 'um-admin-form-home',
|
||||
'title' => __( 'Homepage Options', 'ultimate-member' ),
|
||||
@@ -1093,14 +1099,17 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
delete_post_meta( $post_id, '_um_search_filters' );
|
||||
delete_post_meta( $post_id, '_um_search_filters_gmt' );
|
||||
|
||||
//save metadata
|
||||
foreach ( $_POST['um_metadata'] as $k => $v ) {
|
||||
delete_post_meta( $post_id, '_um_sorting_fields' );
|
||||
|
||||
if ( $k == '_um_show_these_users' && trim( $_POST['um_metadata'][ $k ] ) ) {
|
||||
//save metadata
|
||||
$metadata = UM()->admin()->sanitize_member_directory_meta( $_POST['um_metadata'] );
|
||||
foreach ( $metadata as $k => $v ) {
|
||||
|
||||
if ( $k == '_um_show_these_users' && trim( $v ) ) {
|
||||
$v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
|
||||
}
|
||||
|
||||
if ( $k == '_um_exclude_these_users' && trim( $_POST['um_metadata'][ $k ] ) ) {
|
||||
if ( $k == '_um_exclude_these_users' && trim( $v ) ) {
|
||||
$v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
|
||||
}
|
||||
|
||||
@@ -1172,7 +1181,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
|
||||
// save
|
||||
delete_post_meta( $post_id, '_um_profile_metafields' );
|
||||
foreach ( $_POST['form'] as $k => $v ) {
|
||||
|
||||
|
||||
$form_meta = UM()->admin()->sanitize_form_meta( $_POST['form'] );
|
||||
|
||||
foreach ( $form_meta as $k => $v ) {
|
||||
if ( strstr( $k, '_um_' ) ) {
|
||||
if ( $k === '_um_is_default' ) {
|
||||
$mode = UM()->query()->get_attr( 'mode', $post_id );
|
||||
@@ -2421,4 +2434,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,9 +146,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Navmenu' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* @param $menu_id
|
||||
* @param $menu_item_db_id
|
||||
* @param $menu_item_args
|
||||
* @param int $menu_id
|
||||
* @param int $menu_item_db_id
|
||||
* @param array $menu_item_args
|
||||
*/
|
||||
function _save( $menu_id, $menu_item_db_id, $menu_item_args ) {
|
||||
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
||||
@@ -167,7 +167,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Navmenu' ) ) {
|
||||
if ( ! empty( $_POST[ $key ][ $menu_item_db_id ] ) ) {
|
||||
// Do some checks here...
|
||||
$value = is_array( $_POST[ $key ][ $menu_item_db_id ] ) ?
|
||||
array_keys( $_POST[ $key ][ $menu_item_db_id ] ) : $_POST[ $key ][ $menu_item_db_id ];
|
||||
array_map( 'sanitize_key', array_keys( $_POST[ $key ][ $menu_item_db_id ] ) ) : (int) $_POST[ $key ][ $menu_item_db_id ];
|
||||
} else {
|
||||
$value = null;
|
||||
}
|
||||
|
||||
@@ -580,8 +580,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
'message' => $message,
|
||||
), 4 );
|
||||
} else {
|
||||
if ( isset( $_GET['msg'] ) && 'updated' == sanitize_key( $_GET['msg'] ) ) {
|
||||
if ( isset( $_GET['page'] ) && 'um_options' == sanitize_key( $_GET['page'] ) ) {
|
||||
if ( isset( $_GET['msg'] ) && 'updated' === sanitize_key( $_GET['msg'] ) ) {
|
||||
if ( isset( $_GET['page'] ) && 'um_options' === sanitize_key( $_GET['page'] ) ) {
|
||||
$this->add_notice( 'settings_upgrade', array(
|
||||
'class' => 'updated',
|
||||
'message' => '<p>' . __( 'Settings successfully upgraded', 'ultimate-member' ) . '</p>',
|
||||
@@ -697,4 +697,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
wp_send_json_success();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -306,13 +306,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
|
||||
* @param $query
|
||||
* @return mixed
|
||||
*/
|
||||
function sort_by_newest( $query ) {
|
||||
public function sort_by_newest( $query ) {
|
||||
global $pagenow;
|
||||
|
||||
if ( is_admin() && $pagenow == 'users.php' ) {
|
||||
if ( is_admin() && 'users.php' === $pagenow ) {
|
||||
if ( ! isset( $_REQUEST['orderby'] ) ) {
|
||||
$query->query_vars["order"] = 'desc';
|
||||
$query->query_orderby = " ORDER BY user_registered " . ( $query->query_vars["order"] == 'desc' ? 'desc ' : 'asc ' ); //set sort order
|
||||
$query->query_vars['order'] = 'desc';
|
||||
$query->query_orderby = ' ORDER BY user_registered ' . ( 'desc' === $query->query_vars['order'] ? 'desc ' : 'asc ' ); //set sort order
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,13 +326,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
|
||||
* @param $query
|
||||
* @return mixed
|
||||
*/
|
||||
function filter_users_by_status( $query ) {
|
||||
public function filter_users_by_status( $query ) {
|
||||
global $wpdb, $pagenow;
|
||||
if ( is_admin() && $pagenow == 'users.php' && ! empty( $_REQUEST['um_status'] ) ) {
|
||||
if ( is_admin() && 'users.php' === $pagenow && ! empty( $_REQUEST['um_status'] ) ) {
|
||||
|
||||
$status = sanitize_key( $_REQUEST['um_status'] );
|
||||
|
||||
if ( $status == 'needs-verification' ) {
|
||||
|
||||
if ( 'needs-verification' === $status ) {
|
||||
$query->query_where = str_replace('WHERE 1=1',
|
||||
"WHERE 1=1 AND {$wpdb->users}.ID IN (
|
||||
SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
|
||||
@@ -349,7 +349,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
|
||||
$query->query_where
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $query;
|
||||
@@ -360,9 +359,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
|
||||
* Add status links to WP Users List Table
|
||||
*
|
||||
* @param $views
|
||||
* @return array|mixed|void
|
||||
* @return array
|
||||
*/
|
||||
function add_status_links( $views ) {
|
||||
public function add_status_links( $views ) {
|
||||
remove_filter( 'pre_user_query', array( &$this, 'filter_users_by_status' ) );
|
||||
|
||||
$old_views = $views;
|
||||
@@ -375,17 +374,17 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
|
||||
}
|
||||
|
||||
$status = array(
|
||||
'approved' => __( 'Approved', 'ultimate-member' ),
|
||||
'awaiting_admin_review' => __( 'Pending review', 'ultimate-member' ),
|
||||
'awaiting_email_confirmation' => __( 'Waiting e-mail confirmation', 'ultimate-member' ),
|
||||
'inactive' => __( 'Inactive', 'ultimate-member' ),
|
||||
'rejected' => __( 'Rejected', 'ultimate-member' )
|
||||
'approved' => __( 'Approved', 'ultimate-member' ),
|
||||
'awaiting_admin_review' => __( 'Pending review', 'ultimate-member' ),
|
||||
'awaiting_email_confirmation' => __( 'Waiting e-mail confirmation', 'ultimate-member' ),
|
||||
'inactive' => __( 'Inactive', 'ultimate-member' ),
|
||||
'rejected' => __( 'Rejected', 'ultimate-member' ),
|
||||
);
|
||||
|
||||
UM()->query()->count_users_by_status( 'unassigned' );
|
||||
|
||||
foreach ( $status as $k => $v ) {
|
||||
if ( isset( $_REQUEST['um_status'] ) && sanitize_key( $_REQUEST['um_status'] ) == $k ) {
|
||||
if ( isset( $_REQUEST['um_status'] ) && sanitize_key( $_REQUEST['um_status'] ) === $k ) {
|
||||
$current = 'class="current"';
|
||||
} else {
|
||||
$current = '';
|
||||
@@ -429,11 +428,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
|
||||
|
||||
// hide filters with not accessible roles
|
||||
if ( ! current_user_can( 'administrator' ) ) {
|
||||
$wp_roles = wp_roles();
|
||||
$wp_roles = wp_roles();
|
||||
$can_view_roles = um_user( 'can_view_roles' );
|
||||
if ( ! empty( $can_view_roles ) ) {
|
||||
foreach ( $wp_roles->get_names() as $this_role => $name ) {
|
||||
if ( ! in_array( $this_role, $can_view_roles ) ) {
|
||||
if ( ! in_array( $this_role, $can_view_roles, true ) ) {
|
||||
unset( $views[ $this_role ] );
|
||||
}
|
||||
}
|
||||
@@ -447,20 +446,20 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
|
||||
/**
|
||||
* Bulk user editing actions
|
||||
*/
|
||||
function um_bulk_users_edit() {
|
||||
public function um_bulk_users_edit() {
|
||||
// bulk edit users
|
||||
if ( ! empty( $_REQUEST['users'] ) && ! empty( $_REQUEST['um_bulkedit'] ) && ! empty( $_REQUEST['um_bulk_action'] ) ) {
|
||||
|
||||
$rolename = UM()->roles()->get_priority_user_role( get_current_user_id() );
|
||||
$role = get_role( $rolename );
|
||||
$role = get_role( $rolename );
|
||||
|
||||
if ( ! current_user_can( 'edit_users' ) && ! $role->has_cap( 'edit_users' ) ) {
|
||||
wp_die( __( 'You do not have enough permissions to do that.', 'ultimate-member' ) );
|
||||
if ( ! current_user_can( 'edit_users' ) && ! $role->has_cap( 'edit_users' ) ) {
|
||||
wp_die( esc_html__( 'You do not have enough permissions to do that.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
check_admin_referer( 'bulk-users' );
|
||||
|
||||
$users = array_map( 'absint', (array) $_REQUEST['users'] );
|
||||
$users = array_map( 'absint', (array) $_REQUEST['users'] );
|
||||
$bulk_action = current( array_filter( $_REQUEST['um_bulk_action'] ) );
|
||||
|
||||
foreach ( $users as $user_id ) {
|
||||
@@ -552,4 +551,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
|
||||
if ( isset( $_REQUEST['_wp_http_referer'] ) ) {
|
||||
$redirect = remove_query_arg( array( '_wp_http_referer' ), wp_unslash( $_REQUEST['_wp_http_referer'] ) );
|
||||
} else {
|
||||
$redirect = get_admin_url(). 'admin.php?page=um_roles';
|
||||
$redirect = get_admin_url() . 'admin.php?page=um_roles';
|
||||
}
|
||||
|
||||
global $wp_roles;
|
||||
@@ -16,9 +18,9 @@ if ( isset( $_GET['action'] ) ) {
|
||||
case 'delete': {
|
||||
$role_keys = array();
|
||||
if ( isset( $_REQUEST['id'] ) ) {
|
||||
check_admin_referer( 'um_role_delete' . sanitize_key( $_REQUEST['id'] ) . get_current_user_id() );
|
||||
check_admin_referer( 'um_role_delete' . sanitize_key( $_REQUEST['id'] ) . get_current_user_id() );
|
||||
$role_keys = (array) sanitize_key( $_REQUEST['id'] );
|
||||
} elseif( isset( $_REQUEST['item'] ) ) {
|
||||
} elseif ( isset( $_REQUEST['item'] ) ) {
|
||||
check_admin_referer( 'bulk-' . sanitize_key( __( 'Roles', 'ultimate-member' ) ) );
|
||||
$role_keys = array_map( 'sanitize_key', $_REQUEST['item'] );
|
||||
}
|
||||
@@ -40,7 +42,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
delete_option( "um_role_{$role_key}_meta" );
|
||||
$um_roles = array_diff( $um_roles, array( $role_key ) );
|
||||
|
||||
$roleID = 'um_' . $role_key;
|
||||
$roleID = 'um_' . $role_key;
|
||||
$um_custom_roles[] = $roleID;
|
||||
|
||||
//check if role exist before removing it
|
||||
@@ -51,11 +53,11 @@ if ( isset( $_GET['action'] ) ) {
|
||||
|
||||
//set for users with deleted roles role "Subscriber"
|
||||
$args = array(
|
||||
'blog_id' => get_current_blog_id(),
|
||||
'role__in' => $um_custom_roles,
|
||||
'number' => -1,
|
||||
'count_total' => false,
|
||||
'fields' => 'ids',
|
||||
'blog_id' => get_current_blog_id(),
|
||||
'role__in' => $um_custom_roles,
|
||||
'number' => -1,
|
||||
'count_total' => false,
|
||||
'fields' => 'ids',
|
||||
);
|
||||
$users_to_subscriber = get_users( $args );
|
||||
if ( ! empty( $users_to_subscriber ) ) {
|
||||
@@ -70,7 +72,12 @@ if ( isset( $_GET['action'] ) ) {
|
||||
|
||||
//update user role if it's empty
|
||||
if ( empty( $object_user->roles ) ) {
|
||||
wp_update_user( array( 'ID' => $user_id, 'role' => 'subscriber' ) );
|
||||
wp_update_user(
|
||||
array(
|
||||
'ID' => $user_id,
|
||||
'role' => 'subscriber',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,7 +92,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
if ( isset( $_REQUEST['id'] ) ) {
|
||||
check_admin_referer( 'um_role_reset' . sanitize_key( $_REQUEST['id'] ) . get_current_user_id() );
|
||||
$role_keys = (array) sanitize_key( $_REQUEST['id'] );
|
||||
} elseif( isset( $_REQUEST['item'] ) ) {
|
||||
} elseif ( isset( $_REQUEST['item'] ) ) {
|
||||
check_admin_referer( 'bulk-' . sanitize_key( __( 'Roles', 'ultimate-member' ) ) );
|
||||
$role_keys = array_map( 'sanitize_key', $_REQUEST['item'] );
|
||||
}
|
||||
@@ -98,7 +105,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
$role_meta = get_option( "um_role_{$role_key}_meta" );
|
||||
|
||||
if ( ! empty( $role_meta['_um_is_custom'] ) ) {
|
||||
unset( $role_keys[ array_search( $role_key, $role_keys ) ] );
|
||||
unset( $role_keys[ array_search( $role_key, $role_keys, true ) ] );
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -113,14 +120,14 @@ if ( isset( $_GET['action'] ) ) {
|
||||
|
||||
//remove extra query arg
|
||||
if ( ! empty( $_GET['_wp_http_referer'] ) ) {
|
||||
um_js_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce'), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
|
||||
um_js_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
|
||||
}
|
||||
|
||||
$order_by = 'name';
|
||||
$order = ( isset( $_GET['order'] ) && 'asc' == strtolower( sanitize_key( $_GET['order'] ) ) ) ? 'ASC' : 'DESC';
|
||||
$order = ( isset( $_GET['order'] ) && 'asc' === strtolower( sanitize_key( $_GET['order'] ) ) ) ? 'ASC' : 'DESC';
|
||||
|
||||
if ( ! class_exists( 'WP_List_Table' ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
||||
}
|
||||
|
||||
|
||||
@@ -171,11 +178,11 @@ class UM_Roles_List_Table extends WP_List_Table {
|
||||
*
|
||||
* @param array $args
|
||||
*/
|
||||
function __construct( $args = array() ){
|
||||
function __construct( $args = array() ) {
|
||||
$args = wp_parse_args( $args, array(
|
||||
'singular' => __( 'item', 'ultimate-member' ),
|
||||
'plural' => __( 'items', 'ultimate-member' ),
|
||||
'ajax' => false
|
||||
'singular' => __( 'item', 'ultimate-member' ),
|
||||
'plural' => __( 'items', 'ultimate-member' ),
|
||||
'ajax' => false,
|
||||
) );
|
||||
|
||||
$this->no_items_message = $args['plural'] . ' ' . __( 'not found.', 'ultimate-member' );
|
||||
@@ -199,9 +206,9 @@ class UM_Roles_List_Table extends WP_List_Table {
|
||||
*
|
||||
*/
|
||||
function prepare_items() {
|
||||
$columns = $this->get_columns();
|
||||
$hidden = array();
|
||||
$sortable = $this->get_sortable_columns();
|
||||
$columns = $this->get_columns();
|
||||
$hidden = array();
|
||||
$sortable = $this->get_sortable_columns();
|
||||
$this->_column_headers = array( $columns, $hidden, $sortable );
|
||||
}
|
||||
|
||||
@@ -236,11 +243,11 @@ class UM_Roles_List_Table extends WP_List_Table {
|
||||
*/
|
||||
function set_sortable_columns( $args = array() ) {
|
||||
$return_args = array();
|
||||
foreach( $args as $k=>$val ) {
|
||||
if( is_numeric( $k ) ) {
|
||||
$return_args[ $val ] = array( $val, $val == $this->default_sorting_field );
|
||||
} else if( is_string( $k ) ) {
|
||||
$return_args[ $k ] = array( $val, $k == $this->default_sorting_field );
|
||||
foreach ( $args as $k => $val ) {
|
||||
if ( is_numeric( $k ) ) {
|
||||
$return_args[ $val ] = array( $val, $val === $this->default_sorting_field );
|
||||
} elseif ( is_string( $k ) ) {
|
||||
$return_args[ $k ] = array( $val, $k === $this->default_sorting_field );
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
@@ -336,21 +343,21 @@ class UM_Roles_List_Table extends WP_List_Table {
|
||||
function column_title( $item ) {
|
||||
$actions = array();
|
||||
|
||||
$actions['edit'] = '<a href="admin.php?page=um_roles&tab=edit&id=' . $item['key'] . '">' . __( 'Edit', 'ultimate-member' ). '</a>';
|
||||
$actions['edit'] = '<a href="admin.php?page=um_roles&tab=edit&id=' . esc_attr( $item['key'] ) . '">' . __( 'Edit', 'ultimate-member' ) . '</a>';
|
||||
|
||||
if ( ! empty( $item['_um_is_custom'] ) ) {
|
||||
$actions['delete'] = '<a href="admin.php?page=um_roles&action=delete&id=' . $item['key'] . '&_wpnonce=' . wp_create_nonce( 'um_role_delete' . $item['key'] . get_current_user_id() ) . '" onclick="return confirm( \'' . __( 'Are you sure you want to delete this role?', 'ultimate-member' ) . '\' );">' . __( 'Delete', 'ultimate-member' ). '</a>';
|
||||
$actions['delete'] = '<a href="admin.php?page=um_roles&action=delete&id=' . esc_attr( $item['key'] ) . '&_wpnonce=' . wp_create_nonce( 'um_role_delete' . $item['key'] . get_current_user_id() ) . '" onclick="return confirm( \'' . __( 'Are you sure you want to delete this role?', 'ultimate-member' ) . '\' );">' . __( 'Delete', 'ultimate-member' ) . '</a>';
|
||||
} else {
|
||||
$role_meta = get_option( "um_role_{$item['key']}_meta" );
|
||||
|
||||
if ( ! empty( $role_meta ) ) {
|
||||
$actions['reset'] = '<a href="admin.php?page=um_roles&action=reset&id=' . $item['key'] . '&_wpnonce=' . wp_create_nonce( 'um_role_reset' . $item['key'] . get_current_user_id() ) . '" onclick="return confirm( \'' . __( 'Are you sure you want to reset UM role meta?', 'ultimate-member' ) . '\' );">' . __( 'Reset UM Role meta', 'ultimate-member' ). '</a>';
|
||||
$actions['reset'] = '<a href="admin.php?page=um_roles&action=reset&id=' . esc_attr( $item['key'] ) . '&_wpnonce=' . wp_create_nonce( 'um_role_reset' . $item['key'] . get_current_user_id() ) . '" onclick="return confirm( \'' . __( 'Are you sure you want to reset UM role meta?', 'ultimate-member' ) . '\' );">' . __( 'Reset UM Role meta', 'ultimate-member' ) . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return sprintf('%1$s %2$s', '<strong><a class="row-title" href="admin.php?page=um_roles&tab=edit&id=' . $item['key'] . '">' . stripslashes( $item['name'] ) . '</a></strong>', $this->row_actions( $actions ) );
|
||||
return sprintf('%1$s %2$s', '<strong><a class="row-title" href="admin.php?page=um_roles&tab=edit&id=' . esc_attr( $item['key'] ) . '">' . stripslashes( $item['name'] ) . '</a></strong>', $this->row_actions( $actions ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -487,7 +494,7 @@ $ListTable->um_set_pagination_args( array( 'total_items' => count( $roles ), 'pe
|
||||
</h2>
|
||||
|
||||
<?php if ( ! empty( $_GET['msg'] ) ) {
|
||||
switch( sanitize_key( $_GET['msg'] ) ) {
|
||||
switch ( sanitize_key( $_GET['msg'] ) ) {
|
||||
case 'd':
|
||||
echo '<div id="message" class="updated fade"><p>' . __( 'User Role <strong>Deleted</strong> Successfully.', 'ultimate-member' ) . '</p></div>';
|
||||
break;
|
||||
@@ -498,4 +505,4 @@ $ListTable->um_set_pagination_args( array( 'total_items' => count( $roles ), 'pe
|
||||
<input type="hidden" name="page" value="um_roles" />
|
||||
<?php $ListTable->display(); ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -32,7 +32,7 @@ function um_upgrade_get_users_per_role20beta1() {
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'role',
|
||||
'value' => $_POST['key_in_meta']
|
||||
'value' => sanitize_key( $_POST['key_in_meta'] ),
|
||||
)
|
||||
),
|
||||
'number' => '',
|
||||
@@ -62,10 +62,10 @@ function um_upgrade_update_users_per_page20beta1() {
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'role',
|
||||
'value' => $_POST['key_in_meta']
|
||||
'value' => sanitize_key( $_POST['key_in_meta'] ),
|
||||
)
|
||||
),
|
||||
'paged' => $_POST['page'],
|
||||
'paged' => absint( $_POST['page'] ),
|
||||
'number' => $users_per_page,
|
||||
);
|
||||
$all_users = get_users( $args );
|
||||
@@ -74,17 +74,17 @@ function um_upgrade_update_users_per_page20beta1() {
|
||||
foreach ( $all_users as $k => $user ) {
|
||||
$user_object = get_userdata( $user->ID );
|
||||
|
||||
if ( ! in_array( $_POST['role_key'], $all_wp_roles ) ) {
|
||||
$user_object->add_role( 'um_' . $_POST['role_key'] );
|
||||
if ( ! in_array( sanitize_key( $_POST['role_key'] ), $all_wp_roles ) ) {
|
||||
$user_object->add_role( 'um_' . sanitize_key( $_POST['role_key'] ) );
|
||||
} else {
|
||||
if ( ! in_array( $_POST['role_key'], (array) $user_object->roles ) ) {
|
||||
$user_object->add_role( $_POST['role_key'] );
|
||||
if ( ! in_array( sanitize_key( $_POST['role_key'] ), (array) $user_object->roles ) ) {
|
||||
$user_object->add_role( sanitize_key( $_POST['role_key'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$from = ( $_POST['page'] * $users_per_page ) - $users_per_page + 1;
|
||||
$to = $_POST['page'] * $users_per_page;
|
||||
$from = ( absint( $_POST['page'] ) * $users_per_page ) - $users_per_page + 1;
|
||||
$to = absint( $_POST['page'] ) * $users_per_page;
|
||||
|
||||
wp_send_json_success( array( 'message' => sprintf( __( 'Users from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
|
||||
} else {
|
||||
@@ -184,7 +184,7 @@ function um_upgrade_update_forum_per_page20beta1() {
|
||||
$p_query = new WP_Query;
|
||||
$bb_forums = $p_query->query( array(
|
||||
'post_type' => 'forum',
|
||||
'paged' => $_POST['page'],
|
||||
'paged' => absint( $_POST['page'] ),
|
||||
'posts_per_page' => $posts_per_page,
|
||||
'fields' => 'ids'
|
||||
) );
|
||||
@@ -212,8 +212,8 @@ function um_upgrade_update_forum_per_page20beta1() {
|
||||
}
|
||||
}
|
||||
|
||||
$from = ( $_POST['page'] * $posts_per_page ) - $posts_per_page + 1;
|
||||
$to = $_POST['page'] * $posts_per_page;
|
||||
$from = ( absint( $_POST['page'] ) * $posts_per_page ) - $posts_per_page + 1;
|
||||
$to = absint( $_POST['page'] ) * $posts_per_page;
|
||||
|
||||
wp_send_json_success( array( 'message' => sprintf( __( 'Forums from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
|
||||
} else {
|
||||
@@ -250,7 +250,7 @@ function um_upgrade_update_products_per_page20beta1() {
|
||||
$p_query = new WP_Query;
|
||||
$wc_products = $p_query->query( array(
|
||||
'post_type' => 'product',
|
||||
'paged' => $_POST['page'],
|
||||
'paged' => absint( $_POST['page'] ),
|
||||
'posts_per_page' => $posts_per_page,
|
||||
'fields' => 'ids'
|
||||
) );
|
||||
@@ -299,8 +299,8 @@ function um_upgrade_update_products_per_page20beta1() {
|
||||
}
|
||||
}
|
||||
|
||||
$from = ( $_POST['page'] * $posts_per_page ) - $posts_per_page + 1;
|
||||
$to = $_POST['page'] * $posts_per_page;
|
||||
$from = ( absint( $_POST['page'] ) * $posts_per_page ) - $posts_per_page + 1;
|
||||
$to = absint( $_POST['page'] ) * $posts_per_page;
|
||||
|
||||
wp_send_json_success( array( 'message' => sprintf( __( 'Woocommerce Products from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
|
||||
} else {
|
||||
@@ -321,4 +321,4 @@ function um_upgrade_email_templates20beta1() {
|
||||
delete_option( 'um_roles_associations' );
|
||||
|
||||
wp_send_json_success( array( 'message' => __( 'Email Templates was upgraded successfully', 'ultimate-member' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ function um_upgrade_metadata_per_user213beta3() {
|
||||
ORDER BY u.ID
|
||||
LIMIT %d, %d
|
||||
) as dt",
|
||||
( $_POST['page'] - 1 ) * $per_page,
|
||||
( absint( $_POST['page'] ) - 1 ) * $per_page,
|
||||
$per_page
|
||||
), ARRAY_A );
|
||||
|
||||
@@ -112,8 +112,8 @@ function um_upgrade_metadata_per_user213beta3() {
|
||||
}
|
||||
}
|
||||
|
||||
$from = ( $_POST['page'] * $per_page ) - $per_page + 1;
|
||||
$to = $_POST['page'] * $per_page;
|
||||
$from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1;
|
||||
$to = absint( $_POST['page'] ) * $per_page;
|
||||
|
||||
wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %s to %s users were upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
|
||||
}
|
||||
@@ -144,4 +144,4 @@ KEY meta_value_indx (um_value(191))
|
||||
|
||||
update_option( 'um_last_version_upgrade', '2.1.3-beta3' );
|
||||
wp_send_json_success( array( 'message' => __( 'Usermeta table was upgraded successfully', 'ultimate-member' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} ?>
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
<?php UM()->admin_forms( array(
|
||||
'class' => 'um-member-directory-appearance um-top-label',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_directory_template',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Template', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_directory_template', null, UM()->options()->get( 'directory_template' ) ),
|
||||
'options' => UM()->shortcodes()->get_templates( 'members' ),
|
||||
)
|
||||
<?php
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'class' => 'um-member-directory-appearance um-top-label',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_directory_template',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Template', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_directory_template', null, UM()->options()->get( 'directory_template' ) ),
|
||||
'options' => UM()->shortcodes()->get_templates( 'members' ),
|
||||
),
|
||||
),
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
</div>
|
||||
)->render_form();
|
||||
?>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
global $post_id;
|
||||
|
||||
@@ -7,117 +9,123 @@ $_um_roles_value = empty( $_um_roles_value ) ? array() : $_um_roles_value;
|
||||
|
||||
$show_these_users = get_post_meta( get_the_ID(), '_um_show_these_users', true );
|
||||
if ( $show_these_users ) {
|
||||
$show_these_users = implode( "\n", str_replace( "\r", "", $show_these_users ) );
|
||||
$show_these_users = implode( "\n", str_replace( "\r", '', $show_these_users ) );
|
||||
}
|
||||
|
||||
$exclude_these_users = get_post_meta( get_the_ID(), '_um_exclude_these_users', true );
|
||||
if ( $exclude_these_users ) {
|
||||
$exclude_these_users = implode( "\n", str_replace( "\r", "", $exclude_these_users ) );
|
||||
$exclude_these_users = implode( "\n", str_replace( "\r", '', $exclude_these_users ) );
|
||||
}
|
||||
|
||||
$_um_view_types_value = get_post_meta( $post_id, '_um_view_types', true );
|
||||
$_um_view_types_value = empty( $_um_view_types_value ) ? array( 'grid', 'list' ) : $_um_view_types_value;
|
||||
|
||||
$view_types_options = array_map( function( $item ) {
|
||||
return $item['title'];
|
||||
}, UM()->member_directory()->view_types );
|
||||
$view_types_options = array_map(
|
||||
function( $item ) {
|
||||
return $item['title'];
|
||||
},
|
||||
UM()->member_directory()->view_types
|
||||
);
|
||||
|
||||
$conditional = array();
|
||||
foreach ( $view_types_options as $key => $value ) {
|
||||
$conditional[] = '_um_view_types_' . $key;
|
||||
} ?>
|
||||
}
|
||||
|
||||
|
||||
$fields = array(
|
||||
array(
|
||||
'id' => '_um_mode',
|
||||
'type' => 'hidden',
|
||||
'value' => 'directory',
|
||||
),
|
||||
array(
|
||||
'id' => '_um_view_types',
|
||||
'type' => 'multi_checkbox',
|
||||
'label' => __( 'View type(s)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'View type a specific parameter in the directory', 'ultimate-member' ),
|
||||
'options' => $view_types_options,
|
||||
'columns' => 3,
|
||||
'value' => $_um_view_types_value,
|
||||
'data' => array( 'fill__um_default_view' => 'checkbox_key' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_default_view',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Default view type', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Default directory view type', 'ultimate-member' ),
|
||||
'options' => $view_types_options,
|
||||
'value' => UM()->query()->get_meta_value( '_um_default_view', null, 'grid' ),
|
||||
'conditional' => array( implode( '|', $conditional ), '~', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_roles',
|
||||
'type' => 'multi_checkbox',
|
||||
'label' => __( 'User Roles to Display', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If you do not want to show all members, select only user roles to appear in this directory', 'ultimate-member' ),
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'columns' => 3,
|
||||
'value' => $_um_roles_value,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_has_profile_photo',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Only show members who have uploaded a profile photo', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If \'Use Gravatars\' as profile photo is enabled, this option is ignored', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_has_profile_photo' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_has_cover_photo',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Only show members who have uploaded a cover photo', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_has_cover_photo' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_these_users',
|
||||
'type' => 'textarea',
|
||||
'label' => __( 'Only show specific users (Enter one username per line)', 'ultimate-member' ),
|
||||
'value' => $show_these_users,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_exclude_these_users',
|
||||
'type' => 'textarea',
|
||||
'label' => __( 'Exclude specific users (Enter one username per line)', 'ultimate-member' ),
|
||||
'value' => $exclude_these_users,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_admin_extend_directory_options_general
|
||||
* @description Extend Directory options fields
|
||||
* @input_vars
|
||||
* [{"var":"$fields","type":"array","desc":"Directory options fields"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
|
||||
* function my_directory_sort_users_select( $sort_types ) {
|
||||
* // your code here
|
||||
* return $sort_types;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$fields = apply_filters( 'um_admin_extend_directory_options_general', $fields ); ?>
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
|
||||
<?php $fields = array(
|
||||
<?php
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'id' => '_um_mode',
|
||||
'type' => 'hidden',
|
||||
'value' => 'directory',
|
||||
),
|
||||
array(
|
||||
'id' => '_um_view_types',
|
||||
'type' => 'multi_checkbox',
|
||||
'label' => __( 'View type(s)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'View type a specific parameter in the directory', 'ultimate-member' ),
|
||||
'options' => $view_types_options,
|
||||
'columns' => 3,
|
||||
'value' => $_um_view_types_value,
|
||||
'data' => array( 'fill__um_default_view' => 'checkbox_key' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_default_view',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Default view type', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Default directory view type', 'ultimate-member' ),
|
||||
'options' => $view_types_options,
|
||||
'value' => UM()->query()->get_meta_value( '_um_default_view', null, 'grid' ),
|
||||
'conditional' => array( implode( '|', $conditional ), '~', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_roles',
|
||||
'type' => 'multi_checkbox',
|
||||
'label' => __( 'User Roles to Display', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If you do not want to show all members, select only user roles to appear in this directory', 'ultimate-member' ),
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'columns' => 3,
|
||||
'value' => $_um_roles_value,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_has_profile_photo',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Only show members who have uploaded a profile photo', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If \'Use Gravatars\' as profile photo is enabled, this option is ignored', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_has_profile_photo' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_has_cover_photo',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Only show members who have uploaded a cover photo', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_has_cover_photo' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_these_users',
|
||||
'type' => 'textarea',
|
||||
'label' => __( 'Only show specific users (Enter one username per line)', 'ultimate-member' ),
|
||||
'value' => $show_these_users,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_exclude_these_users',
|
||||
'type' => 'textarea',
|
||||
'label' => __( 'Exclude specific users (Enter one username per line)', 'ultimate-member' ),
|
||||
'value' => $exclude_these_users,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_admin_extend_directory_options_general
|
||||
* @description Extend Directory options fields
|
||||
* @input_vars
|
||||
* [{"var":"$fields","type":"array","desc":"Directory options fields"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
|
||||
* function my_directory_sort_users_select( $sort_types ) {
|
||||
* // your code here
|
||||
* return $sort_types;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$fields = apply_filters( 'um_admin_extend_directory_options_general', $fields );
|
||||
|
||||
UM()->admin_forms( array(
|
||||
'class' => 'um-member-directory-general um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => $fields
|
||||
) )->render_form(); ?>
|
||||
'class' => 'um-member-directory-general um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => $fields,
|
||||
)
|
||||
)->render_form();
|
||||
?>
|
||||
|
||||
<div class="um-admin-clear"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,68 +1,72 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} ?>
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
<?php UM()->admin_forms( array(
|
||||
'class' => 'um-member-directory-pagination um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_must_search',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show results only after search/filtration', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, member results will only appear after search/filter is performed', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_must_search' ),
|
||||
'conditional' => array( '_um_search||_um_filters', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_max_users',
|
||||
'type' => 'number',
|
||||
'label' => __( 'Maximum number of profiles', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Use this setting to control the maximum number of profiles to appear in this directory. Leave blank to disable this limit', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_max_users', null, 'na' ),
|
||||
'size' => 'small'
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profiles_per_page',
|
||||
'type' => 'number',
|
||||
'label' => __( 'Number of profiles per page', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Number of profiles to appear on page for standard users', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profiles_per_page', null, 12 ),
|
||||
'size' => 'small'
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profiles_per_page_mobile',
|
||||
'type' => 'number',
|
||||
'label' => __( 'Number of profiles per page (for Mobiles & Tablets)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Number of profiles to appear on page for mobile users', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profiles_per_page_mobile', null, 8 ),
|
||||
'size' => 'small'
|
||||
),
|
||||
array(
|
||||
'id' => '_um_directory_header',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Results Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the search result text . e.g. Found 3,000 Members. Leave this blank to not show result text', 'ultimate-member' ),
|
||||
'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_directory_header', null, 'na' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_directory_header_single',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Single Result Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Same as above but in case of 1 user found only', 'ultimate-member' ),
|
||||
'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_directory_header_single', null, 'na' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_directory_no_users',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Custom text if no users were found', 'ultimate-member' ),
|
||||
'tooltip' => __( 'This is the text that is displayed if no users are found during a search', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_directory_no_users', null, 'na' ),
|
||||
<?php
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'class' => 'um-member-directory-pagination um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_must_search',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show results only after search/filtration', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, member results will only appear after search/filter is performed', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_must_search' ),
|
||||
'conditional' => array( '_um_search||_um_filters', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_max_users',
|
||||
'type' => 'number',
|
||||
'label' => __( 'Maximum number of profiles', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Use this setting to control the maximum number of profiles to appear in this directory. Leave blank to disable this limit', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_max_users', null, 'na' ),
|
||||
'size' => 'small',
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profiles_per_page',
|
||||
'type' => 'number',
|
||||
'label' => __( 'Number of profiles per page', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Number of profiles to appear on page for standard users', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profiles_per_page', null, 12 ),
|
||||
'size' => 'small',
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profiles_per_page_mobile',
|
||||
'type' => 'number',
|
||||
'label' => __( 'Number of profiles per page (for Mobiles & Tablets)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Number of profiles to appear on page for mobile users', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profiles_per_page_mobile', null, 8 ),
|
||||
'size' => 'small',
|
||||
),
|
||||
array(
|
||||
'id' => '_um_directory_header',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Results Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the search result text . e.g. Found 3,000 Members. Leave this blank to not show result text', 'ultimate-member' ),
|
||||
'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_directory_header', null, 'na' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_directory_header_single',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Single Result Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Same as above but in case of 1 user found only', 'ultimate-member' ),
|
||||
'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_directory_header_single', null, 'na' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_directory_no_users',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Custom text if no users were found', 'ultimate-member' ),
|
||||
'tooltip' => __( 'This is the text that is displayed if no users are found during a search', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_directory_no_users', null, 'na' ),
|
||||
),
|
||||
),
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
|
||||
)->render_form();
|
||||
?>
|
||||
<div class="um-admin-clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,117 +1,120 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$user_fields = array();
|
||||
foreach ( UM()->builtin()->all_user_fields() as $key => $arr ) {
|
||||
$user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : '';
|
||||
}
|
||||
|
||||
$post_id = get_the_ID();
|
||||
$_um_tagline_fields = get_post_meta( $post_id, '_um_tagline_fields', true );
|
||||
$_um_reveal_fields = get_post_meta( $post_id, '_um_reveal_fields', true );
|
||||
|
||||
|
||||
$fields = array(
|
||||
array(
|
||||
'id' => '_um_profile_photo',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Profile Photo', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_photo' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_cover_photos',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Cover Photo', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, the users cover photo will appear in the directory', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_cover_photos' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_name',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show display name', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_name' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_tagline',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show tagline below profile name', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_tagline' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_tagline_fields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Choose field(s) to display in tagline', 'ultimate-member' ),
|
||||
'value' => $_um_tagline_fields,
|
||||
'conditional' => array( '_um_show_tagline', '=', 1 ),
|
||||
'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
|
||||
'options' => $user_fields,
|
||||
'show_default_number' => 1,
|
||||
'sorting' => true,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_userinfo',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show extra user information below tagline?', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_userinfo' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_reveal_fields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Choose field(s) to display in extra user information section', 'ultimate-member' ),
|
||||
'value' => $_um_reveal_fields,
|
||||
'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
|
||||
'conditional' => array( '_um_show_userinfo', '=', 1 ),
|
||||
'options' => $user_fields,
|
||||
'show_default_number' => 1,
|
||||
'sorting' => true,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_social',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show social connect icons in extra user information section', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_social' ),
|
||||
'conditional' => array( '_um_show_userinfo', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_userinfo_animate',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Hide extra user information to the reveal section', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If not checked always shown', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_userinfo_animate' ),
|
||||
'conditional' => array( '_um_show_userinfo', '=', 1 ),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_admin_extend_directory_options_general
|
||||
* @description Extend Directory options fields
|
||||
* @input_vars
|
||||
* [{"var":"$fields","type":"array","desc":"Directory options fields"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
|
||||
* function my_directory_sort_users_select( $sort_types ) {
|
||||
* // your code here
|
||||
* return $sort_types;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$fields = apply_filters( 'um_admin_extend_directory_options_profile', $fields ); ?>
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
|
||||
<?php $user_fields = array();
|
||||
foreach ( UM()->builtin()->all_user_fields() as $key => $arr ) {
|
||||
$user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : '';
|
||||
}
|
||||
|
||||
$post_id = get_the_ID();
|
||||
$_um_tagline_fields = get_post_meta( $post_id, '_um_tagline_fields', true );
|
||||
$_um_reveal_fields = get_post_meta( $post_id, '_um_reveal_fields', true );
|
||||
|
||||
|
||||
$fields = array(
|
||||
<?php
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'id' => '_um_profile_photo',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Profile Photo', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_photo', null, 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_cover_photos',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Cover Photo', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, the users cover photo will appear in the directory', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_cover_photos', null, 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_name',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show display name', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_name', null, 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_tagline',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show tagline below profile name', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_tagline' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_tagline_fields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Choose field(s) to display in tagline', 'ultimate-member' ),
|
||||
'value' => $_um_tagline_fields,
|
||||
'conditional' => array( '_um_show_tagline', '=', 1 ),
|
||||
'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
|
||||
'options' => $user_fields,
|
||||
'show_default_number' => 1,
|
||||
'sorting' => true,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_userinfo',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show extra user information below tagline?', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_userinfo' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_reveal_fields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Choose field(s) to display in extra user information section', 'ultimate-member' ),
|
||||
'value' => $_um_reveal_fields,
|
||||
'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
|
||||
'conditional' => array( '_um_show_userinfo', '=', 1 ),
|
||||
'options' => $user_fields,
|
||||
'show_default_number' => 1,
|
||||
'sorting' => true,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_social',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show social connect icons in extra user information section', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_social' ),
|
||||
'conditional' => array( '_um_show_userinfo', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_userinfo_animate',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Hide extra user information to the reveal section', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If not checked always shown', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_userinfo_animate' ),
|
||||
'conditional' => array( '_um_show_userinfo', '=', 1 )
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_admin_extend_directory_options_general
|
||||
* @description Extend Directory options fields
|
||||
* @input_vars
|
||||
* [{"var":"$fields","type":"array","desc":"Directory options fields"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
|
||||
* function my_directory_sort_users_select( $sort_types ) {
|
||||
* // your code here
|
||||
* return $sort_types;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$fields = apply_filters( 'um_admin_extend_directory_options_profile', $fields );
|
||||
|
||||
UM()->admin_forms( array(
|
||||
'class' => 'um-member-directory-profile um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => $fields,
|
||||
) )->render_form(); ?>
|
||||
|
||||
'class' => 'um-member-directory-profile um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => $fields,
|
||||
)
|
||||
)->render_form();
|
||||
?>
|
||||
<div class="um-admin-clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,97 +1,100 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
global $post_id; ?>
|
||||
global $post_id;
|
||||
|
||||
$_um_roles_search_value = get_post_meta( $post_id, '_um_roles_can_search', true );
|
||||
$_um_roles_search_value = empty( $_um_roles_search_value ) ? array() : $_um_roles_search_value;
|
||||
|
||||
$_um_roles_filter_value = get_post_meta( $post_id, '_um_roles_can_filter', true );
|
||||
$_um_roles_filter_value = empty( $_um_roles_filter_value ) ? array() : $_um_roles_filter_value;
|
||||
|
||||
$_um_search_fields = get_post_meta( $post_id, '_um_search_fields', true );
|
||||
$_um_search_filters = get_post_meta( $post_id, '_um_search_filters', true ); ?>
|
||||
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
<?php
|
||||
|
||||
$_um_roles_search_value = get_post_meta( $post_id, '_um_roles_can_search', true );
|
||||
$_um_roles_search_value = empty( $_um_roles_search_value ) ? array() : $_um_roles_search_value;
|
||||
|
||||
$_um_roles_filter_value = get_post_meta( $post_id, '_um_roles_can_filter', true );
|
||||
$_um_roles_filter_value = empty( $_um_roles_filter_value ) ? array() : $_um_roles_filter_value;
|
||||
|
||||
$_um_search_fields = get_post_meta( $post_id, '_um_search_fields', true );
|
||||
$_um_search_filters = get_post_meta( $post_id, '_um_search_filters', true );
|
||||
|
||||
UM()->admin_forms( array(
|
||||
'class' => 'um-member-directory-search um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_search',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Search feature', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, users will be able to search members in this directory', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_search' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_roles_can_search',
|
||||
'type' => 'multi_checkbox',
|
||||
'label' => __( 'User Roles that can use search', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If you want to allow specific user roles to be able to search only', 'ultimate-member' ),
|
||||
'value' => $_um_roles_search_value,
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'columns' => 3,
|
||||
'conditional' => array( '_um_search', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_filters',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Filters feature', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, users will be able to filter members in this directory', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_filters' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_roles_can_filter',
|
||||
'type' => 'multi_checkbox',
|
||||
'label' => __( 'User Roles that can use filters', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If you want to allow specific user roles to be able to filter only', 'ultimate-member' ),
|
||||
'value' => $_um_roles_filter_value,
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'columns' => 3,
|
||||
'conditional' => array( '_um_filters', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_search_fields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Choose filter(s) meta to enable', 'ultimate-member' ),
|
||||
'value' => $_um_search_fields,
|
||||
'conditional' => array( '_um_filters', '=', 1 ),
|
||||
'options' => UM()->member_directory()->filter_fields,
|
||||
'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
|
||||
'show_default_number' => 1,
|
||||
'sorting' => true,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_filters_expanded',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Expand the filter bar by default', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, filters bar will be visible after a page loading', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_filters_expanded' ),
|
||||
'conditional' => array( '_um_filters', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_filters_is_collapsible',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Can filter bar be collapsed', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, filters bar can be collapsed after a page loading', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_filters_is_collapsible' ),
|
||||
'conditional' => array( '_um_filters_expanded', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_search_filters',
|
||||
'type' => 'md_default_filters',
|
||||
'label' => __( 'Admin filtering', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Limit which users appear in the member directory e.g only display users from USA', 'ultimate-member' ),
|
||||
'value' => $_um_search_filters,
|
||||
'options' => UM()->member_directory()->filter_fields,
|
||||
'add_text' => __( 'Add New Filter', 'ultimate-member' ),
|
||||
'show_default_number' => 0,
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'class' => 'um-member-directory-search um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_search',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Search feature', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, users will be able to search members in this directory', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_search' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_roles_can_search',
|
||||
'type' => 'multi_checkbox',
|
||||
'label' => __( 'User Roles that can use search', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If you want to allow specific user roles to be able to search only', 'ultimate-member' ),
|
||||
'value' => $_um_roles_search_value,
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'columns' => 3,
|
||||
'conditional' => array( '_um_search', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_filters',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Filters feature', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, users will be able to filter members in this directory', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_filters' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_roles_can_filter',
|
||||
'type' => 'multi_checkbox',
|
||||
'label' => __( 'User Roles that can use filters', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If you want to allow specific user roles to be able to filter only', 'ultimate-member' ),
|
||||
'value' => $_um_roles_filter_value,
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'columns' => 3,
|
||||
'conditional' => array( '_um_filters', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_search_fields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Choose filter(s) meta to enable', 'ultimate-member' ),
|
||||
'value' => $_um_search_fields,
|
||||
'conditional' => array( '_um_filters', '=', 1 ),
|
||||
'options' => UM()->member_directory()->filter_fields,
|
||||
'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
|
||||
'show_default_number' => 0,
|
||||
'sorting' => true,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_filters_expanded',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Expand the filter bar by default', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, filters bar will be visible after a page loading', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_filters_expanded' ),
|
||||
'conditional' => array( '_um_filters', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_filters_is_collapsible',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Can filter bar be collapsed', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, filters bar can be collapsed after a page loading', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_filters_is_collapsible' ),
|
||||
'conditional' => array( '_um_filters_expanded', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_search_filters',
|
||||
'type' => 'md_default_filters',
|
||||
'label' => __( 'Admin filtering', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Limit which users appear in the member directory e.g only display users from USA', 'ultimate-member' ),
|
||||
'value' => $_um_search_filters,
|
||||
'options' => UM()->member_directory()->filter_fields,
|
||||
'add_text' => __( 'Add New Filter', 'ultimate-member' ),
|
||||
'show_default_number' => 0,
|
||||
),
|
||||
),
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
|
||||
)->render_form();
|
||||
?>
|
||||
<div class="um-admin-clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} ?>
|
||||
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
@@ -24,4 +26,4 @@
|
||||
|
||||
<p><?php echo UM()->shortcodes()->get_shortcode( get_the_ID() ); ?></p>
|
||||
<!-- <p>--><?php //echo UM()->shortcodes()->get_default_shortcode( get_the_ID() ); ?><!--</p>-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,62 +1,65 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
global $post_id;
|
||||
|
||||
|
||||
$_um_sorting_fields = get_post_meta( $post_id, '_um_sorting_fields', true );
|
||||
$_um_sorting_fields = empty( $_um_sorting_fields ) ? array() : $_um_sorting_fields; ?>
|
||||
$_um_sorting_fields = empty( $_um_sorting_fields ) ? array() : $_um_sorting_fields;
|
||||
|
||||
$fields = array(
|
||||
array(
|
||||
'id' => '_um_sortby',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Default sort users by', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Default sorting users by a specific parameter in the directory', 'ultimate-member' ),
|
||||
'options' => UM()->member_directory()->default_sorting,
|
||||
'value' => UM()->query()->get_meta_value( '_um_sortby' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_sortby_custom',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Meta key', 'ultimate-member' ),
|
||||
'tooltip' => __( 'To sort by a custom field, enter the meta key of field here', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_sortby_custom', null, 'na' ),
|
||||
'conditional' => array( '_um_sortby', '=', 'other' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_sortby_custom_label',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Label of custom sort', 'ultimate-member' ),
|
||||
'tooltip' => __( 'To sort by a custom field, enter the label of sorting here', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_sortby_custom_label', null, 'na' ),
|
||||
'conditional' => array( '_um_sortby', '=', 'other' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_enable_sorting',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable custom sorting', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Whether to provide an ability to change the sorting on the directory page', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_enable_sorting' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_sorting_fields',
|
||||
'type' => 'md_sorting_fields',
|
||||
'label' => __( 'Choose field(s) to enable in sorting', 'ultimate-member' ),
|
||||
'value' => $_um_sorting_fields,
|
||||
'options' => array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) ),
|
||||
'add_text' => __( 'Add New Field', 'ultimate-member' ),
|
||||
'show_default_number' => 0,
|
||||
'conditional' => array( '_um_enable_sorting', '=', 1 ),
|
||||
),
|
||||
); ?>
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
|
||||
<?php $fields = array(
|
||||
<?php
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'id' => '_um_sortby',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Default sort users by', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Default sorting users by a specific parameter in the directory', 'ultimate-member' ),
|
||||
'options' => UM()->member_directory()->default_sorting,
|
||||
'value' => UM()->query()->get_meta_value( '_um_sortby' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_sortby_custom',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Meta key', 'ultimate-member' ),
|
||||
'tooltip' => __( 'To sort by a custom field, enter the meta key of field here', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_sortby_custom', null, 'na' ),
|
||||
'conditional' => array( '_um_sortby', '=', 'other' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_sortby_custom_label',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Label of custom sort', 'ultimate-member' ),
|
||||
'tooltip' => __( 'To sort by a custom field, enter the label of sorting here', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_sortby_custom_label', null, 'na' ),
|
||||
'conditional' => array( '_um_sortby', '=', 'other' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_enable_sorting',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable custom sorting', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Whether to provide an ability to change the sorting on the directory page', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_enable_sorting' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_sorting_fields',
|
||||
'type' => 'md_sorting_fields',
|
||||
'label' => __( 'Choose field(s) to enable in sorting', 'ultimate-member' ),
|
||||
'value' => $_um_sorting_fields,
|
||||
'options' => array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) ),
|
||||
'add_text' => __( 'Add New Field', 'ultimate-member' ),
|
||||
'show_default_number' => 1,
|
||||
'conditional' => array( '_um_enable_sorting', '=', 1 ),
|
||||
'class' => 'um-member-directory-sorting um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => $fields,
|
||||
)
|
||||
);
|
||||
|
||||
UM()->admin_forms( array(
|
||||
'class' => 'um-member-directory-sorting um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => $fields
|
||||
) )->render_form(); ?>
|
||||
|
||||
)->render_form();
|
||||
?>
|
||||
<div class="um-admin-clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( empty( UM()->builder()->form_id ) ) {
|
||||
UM()->builder()->form_id = $this->form_id;
|
||||
@@ -9,8 +10,10 @@ if ( empty( UM()->builder()->form_id ) ) {
|
||||
|
||||
<div class="um-admin-drag-ctrls-demo um-admin-drag-ctrls">
|
||||
|
||||
<a href="javascript:void(0);" class="active" data-modal="UM_preview_form" data-modal-size="smaller" data-dynamic-content="um_admin_preview_form"
|
||||
data-arg1="<?php esc_attr( the_ID() ); ?>" data-arg2=""><?php _e('Live Preview','ultimate-member'); ?></a>
|
||||
<a href="javascript:void(0);" class="active" data-modal="UM_preview_form" data-modal-size="smaller"
|
||||
data-dynamic-content="um_admin_preview_form" data-arg1="<?php echo esc_attr( get_the_ID() ); ?>" data-arg2="">
|
||||
<?php esc_html_e( 'Live Preview', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -19,9 +22,7 @@ if ( empty( UM()->builder()->form_id ) ) {
|
||||
<div class="um-admin-drag">
|
||||
|
||||
<div class="um-admin-drag-ajax" data-form_id="<?php echo esc_attr( UM()->builder()->form_id ); ?>">
|
||||
|
||||
<?php UM()->builder()->show_builder(); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="um-admin-drag-addrow um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Master Row', 'ultimate-member' ); ?>"
|
||||
@@ -31,4 +32,4 @@ if ( empty( UM()->builder()->form_id ) ) {
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,102 +1,106 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} ?>
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
<?php UM()->admin_forms( array(
|
||||
'class' => 'um-form-login-customize um-top-label',
|
||||
'prefix_id' => 'form',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_login_use_custom_settings',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling & appearance', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_use_custom_settings', null, 0 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
<?php
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'class' => 'um-form-login-customize um-top-label',
|
||||
'prefix_id' => 'form',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_login_use_custom_settings',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling & appearance', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_use_custom_settings', null, 0 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_template',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Template', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_template', null, UM()->options()->get( 'login_template' ) ),
|
||||
'options' => UM()->shortcodes()->get_templates( 'login' ),
|
||||
'conditional' => array( '_um_login_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_max_width',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Max. Width (px)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_login_max_width', null, UM()->options()->get( 'login_max_width' ) ),
|
||||
'conditional' => array( '_um_login_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_icons',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Field Icons', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_icons', null, UM()->options()->get( 'login_icons' ) ) ,
|
||||
'options' => array(
|
||||
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
||||
'label' => __( 'Show with label', 'ultimate-member' ),
|
||||
'off' => __( 'Turn off', 'ultimate-member' )
|
||||
array(
|
||||
'id' => '_um_login_template',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Template', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_template', null, UM()->options()->get( 'login_template' ) ),
|
||||
'options' => UM()->shortcodes()->get_templates( 'login' ),
|
||||
'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
'conditional' => array( '_um_login_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_primary_btn_word',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Primary Button Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_primary_btn_word', null, UM()->options()->get( 'login_primary_btn_word' ) ),
|
||||
'conditional' => array( '_um_login_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_secondary_btn',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show Secondary Button', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn', null, UM()->options()->get( 'login_secondary_btn' ) ),
|
||||
'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_secondary_btn_word',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Secondary Button Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn_word', null, UM()->options()->get( 'login_secondary_btn_word' ) ),
|
||||
'conditional' => array( '_um_login_secondary_btn', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_forgot_pass_link',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show Forgot Password Link?', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_forgot_pass_link', null, UM()->options()->get('login_forgot_pass_link') ),
|
||||
'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
array(
|
||||
'id' => '_um_login_max_width',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Max. Width (px)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_max_width', null, UM()->options()->get( 'login_max_width' ) ),
|
||||
'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_show_rememberme',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show "Remember Me"?', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_show_rememberme', null, UM()->options()->get('login_show_rememberme') ),
|
||||
'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
array(
|
||||
'id' => '_um_login_icons',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Field Icons', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_icons', null, UM()->options()->get( 'login_icons' ) ),
|
||||
'options' => array(
|
||||
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
||||
'label' => __( 'Show with label', 'ultimate-member' ),
|
||||
'off' => __( 'Turn off', 'ultimate-member' ),
|
||||
),
|
||||
'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_primary_btn_word',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Primary Button Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_primary_btn_word', null, UM()->options()->get( 'login_primary_btn_word' ) ),
|
||||
'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_secondary_btn',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show Secondary Button', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn', null, UM()->options()->get( 'login_secondary_btn' ) ),
|
||||
'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_secondary_btn_word',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Secondary Button Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn_word', null, UM()->options()->get( 'login_secondary_btn_word' ) ),
|
||||
'conditional' => array( '_um_login_secondary_btn', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_forgot_pass_link',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show Forgot Password Link?', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_forgot_pass_link', null, UM()->options()->get( 'login_forgot_pass_link' ) ),
|
||||
'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_show_rememberme',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show "Remember Me"?', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_show_rememberme', null, UM()->options()->get( 'login_show_rememberme' ) ),
|
||||
'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
|
||||
)->render_form();
|
||||
?>
|
||||
<div class="um-admin-clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,34 +1,38 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} ?>
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
<?php UM()->admin_forms( array(
|
||||
'class' => 'um-form-login-settings um-top-label',
|
||||
'prefix_id' => 'form',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_login_after_login',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Redirection after Login', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Change this If you want to override role redirection settings after login only.', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_after_login', null, 0 ),
|
||||
'options' => array(
|
||||
'0' => __( 'Default', 'ultimate-member' ),
|
||||
'redirect_profile' => __( 'Redirect to profile', 'ultimate-member' ),
|
||||
'redirect_url' => __( 'Redirect to URL', 'ultimate-member' ),
|
||||
'refresh' => __( 'Refresh active page', 'ultimate-member' ),
|
||||
'redirect_admin' => __( 'Redirect to WordPress Admin', 'ultimate-member' ),
|
||||
<?php
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'class' => 'um-form-login-settings um-top-label',
|
||||
'prefix_id' => 'form',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_login_after_login',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Redirection after Login', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Change this If you want to override role redirection settings after login only.', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_after_login', null, 0 ),
|
||||
'options' => array(
|
||||
'0' => __( 'Default', 'ultimate-member' ),
|
||||
'redirect_profile' => __( 'Redirect to profile', 'ultimate-member' ),
|
||||
'redirect_url' => __( 'Redirect to URL', 'ultimate-member' ),
|
||||
'refresh' => __( 'Refresh active page', 'ultimate-member' ),
|
||||
'redirect_admin' => __( 'Redirect to WordPress Admin', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_redirect_url',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Set Custom Redirect URL', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_login_redirect_url', null, 'na' ),
|
||||
'conditional' => array( '_um_login_after_login', '=', 'redirect_url' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_redirect_url',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Set Custom Redirect URL', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_login_redirect_url', null, 'na' ),
|
||||
'conditional' => array( '_um_login_after_login', '=', 'redirect_url' )
|
||||
)
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
|
||||
)->render_form();
|
||||
?>
|
||||
<div class="um-admin-clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$is_core = get_post_meta( get_the_ID(), '_um_core', true ); ?>
|
||||
|
||||
<div class="um-admin-boxed-links um-admin-ajaxlink <?php if ( $is_core ) echo 'is-core-form'; ?>">
|
||||
<div class="um-admin-boxed-links um-admin-ajaxlink<?php echo $is_core ? ' is-core-form' : ''; ?>">
|
||||
|
||||
<?php if ( $is_core ) { ?>
|
||||
<p><?php _e( '<strong>Note:</strong> Form type cannot be changed for the default forms.', 'ultimate-member' ); ?></p>
|
||||
<p>
|
||||
<strong><?php esc_html_e( 'Note: ', 'ultimate-member' ); ?></strong><?php esc_html_e( 'Form type cannot be changed for the default forms.', 'ultimate-member' ); ?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
|
||||
<a href="javascript:void(0);" data-role="register"><?php _e( 'Registration Form', 'ultimate-member' ); ?></a>
|
||||
<a href="javascript:void(0);" data-role="register">
|
||||
<?php esc_html_e( 'Registration Form', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
|
||||
<a href="javascript:void(0);" data-role="profile"><?php _e('Profile Form', 'ultimate-member' ); ?></a>
|
||||
<a href="javascript:void(0);" data-role="profile">
|
||||
<?php esc_html_e( 'Profile Form', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
|
||||
<a href="javascript:void(0);" data-role="login"><?php _e( 'Login Form', 'ultimate-member' ); ?></a>
|
||||
<a href="javascript:void(0);" data-role="login">
|
||||
<?php esc_html_e( 'Login Form', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
|
||||
<input type="hidden" name="form[_um_mode]" id="form__um_mode" value="<?php echo esc_attr( UM()->query()->get_meta_value( '_um_mode', null, 'register' ) ); ?>" />
|
||||
|
||||
</div>
|
||||
<div class="um-admin-clear"></div>
|
||||
<div class="um-admin-clear"></div>
|
||||
|
||||
@@ -1,208 +1,211 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$profile_role_array = array();
|
||||
foreach ( UM()->roles()->get_roles() as $key => $value ) {
|
||||
$_um_profile_role = UM()->query()->get_meta_value( '_um_profile_role', $key );
|
||||
if ( ! empty( $_um_profile_role ) ) {
|
||||
$profile_role_array[] = $_um_profile_role;
|
||||
}
|
||||
} ?>
|
||||
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
|
||||
<?php $profile_role_array = array();
|
||||
foreach ( UM()->roles()->get_roles() as $key => $value ) {
|
||||
$_um_profile_role = UM()->query()->get_meta_value( '_um_profile_role', $key );
|
||||
if ( ! empty( $_um_profile_role ) ) {
|
||||
$profile_role_array[] = $_um_profile_role;
|
||||
}
|
||||
}
|
||||
|
||||
UM()->admin_forms( array(
|
||||
'class' => 'um-form-profile-customize um-top-label',
|
||||
'prefix_id' => 'form',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_profile_use_custom_settings',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling & appearance', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_use_custom_settings', null, 0 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
<?php
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'class' => 'um-form-profile-customize um-top-label',
|
||||
'prefix_id' => 'form',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_profile_use_custom_settings',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling & appearance', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_use_custom_settings', null, 0 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_role',
|
||||
'type' => 'select',
|
||||
'multi' => true,
|
||||
'label' => __( 'Make this profile form role-specific', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Please note if you make a profile form specific to a role then you must make sure that every other role is assigned a profile form', 'ultimate-member' ),
|
||||
'value' => $profile_role_array,
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_template',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Template', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_template', null, UM()->options()->get( 'profile_template' ) ),
|
||||
'options' => UM()->shortcodes()->get_templates( 'profile' ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_max_width',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Max. Width (px)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_max_width', null, UM()->options()->get( 'profile_max_width' ) ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_area_max_width',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Profile Area Max. Width (px)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_area_max_width', null, UM()->options()->get( 'profile_area_max_width' ) ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_icons',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Field Icons', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_icons', null, UM()->options()->get( 'profile_icons' ) ),
|
||||
'options' => array(
|
||||
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
||||
'label' => __( 'Show with label', 'ultimate-member' ),
|
||||
'off' => __( 'Turn off', 'ultimate-member' ),
|
||||
),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_primary_btn_word',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Primary Button Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_primary_btn_word', null, UM()->options()->get( 'profile_primary_btn_word' ) ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_secondary_btn',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show Secondary Button', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn', null, UM()->options()->get( 'profile_secondary_btn' ) ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_secondary_btn_word',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Secondary Button Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn_word', null, UM()->options()->get( 'profile_secondary_btn_word' ) ),
|
||||
'conditional' => array( '_um_profile_secondary_btn', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_cover_enabled',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Enable Cover Photos', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_cover_enabled', null, 1 ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_coversize',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Cover Photo Size', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_coversize', null, UM()->options()->get( 'profile_coversize' ) ),
|
||||
'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
|
||||
'conditional' => array( '_um_profile_cover_enabled', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_cover_ratio',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Cover photo ratio', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_cover_ratio', null, UM()->options()->get( 'profile_cover_ratio' ) ),
|
||||
'options' => array(
|
||||
'1.6:1' => '1.6:1',
|
||||
'2.7:1' => '2.7:1',
|
||||
'2.2:1' => '2.2:1',
|
||||
'3.2:1' => '3.2:1',
|
||||
),
|
||||
'conditional' => array( '_um_profile_cover_enabled', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_disable_photo_upload',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_disable_photo_upload', null, UM()->options()->get( 'disable_profile_photo_upload' ) ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_photosize',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Profile Photo Size', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_photosize', null, UM()->options()->get( 'profile_photosize' ) ),
|
||||
'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_photo_required',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Make Profile Photo Required', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Require user to update a profile photo when updating their profile', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_photo_required' ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_show_name',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show display name in profile header?', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_show_name', null, 1 ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_show_social_links',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show social links in profile header?', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_show_social_links', null, UM()->options()->get( 'profile_show_social_links' ) ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_show_bio',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show user description in profile header?', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_show_bio', null, 1 ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_role',
|
||||
'type' => 'select',
|
||||
'multi' => true,
|
||||
'label' => __( 'Make this profile form role-specific', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Please note if you make a profile form specific to a role then you must make sure that every other role is assigned a profile form', 'ultimate-member' ),
|
||||
'value' => $profile_role_array,
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_template',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Template', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_template', null, UM()->options()->get( 'profile_template' ) ),
|
||||
'options' => UM()->shortcodes()->get_templates( 'profile' ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_max_width',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Max. Width (px)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_profile_max_width', null, UM()->options()->get( 'profile_max_width' ) ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_area_max_width',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Profile Area Max. Width (px)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_profile_area_max_width', null, UM()->options()->get( 'profile_area_max_width' ) ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_icons',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Field Icons', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_icons', null, UM()->options()->get( 'profile_icons' ) ) ,
|
||||
'options' => array(
|
||||
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
||||
'label' => __( 'Show with label', 'ultimate-member' ),
|
||||
'off' => __( 'Turn off', 'ultimate-member' )
|
||||
),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_primary_btn_word',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Primary Button Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_primary_btn_word', null, UM()->options()->get( 'profile_primary_btn_word' ) ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_secondary_btn',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show Secondary Button', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn', null, UM()->options()->get( 'profile_secondary_btn' ) ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_secondary_btn_word',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Secondary Button Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn_word', null, UM()->options()->get( 'profile_secondary_btn_word' ) ),
|
||||
'conditional' => array( '_um_profile_secondary_btn', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_cover_enabled',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Enable Cover Photos', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_cover_enabled', null, 1 ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_coversize',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Cover Photo Size', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_coversize', null, UM()->options()->get( 'profile_coversize' ) ),
|
||||
'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
|
||||
'conditional' => array( '_um_profile_cover_enabled', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_cover_ratio',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Cover photo ratio', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_cover_ratio', null, UM()->options()->get( 'profile_cover_ratio' ) ),
|
||||
'options' => array(
|
||||
'1.6:1' => '1.6:1',
|
||||
'2.7:1' => '2.7:1',
|
||||
'2.2:1' => '2.2:1',
|
||||
'3.2:1' => '3.2:1'
|
||||
),
|
||||
'conditional' => array( '_um_profile_cover_enabled', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_disable_photo_upload',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_disable_photo_upload', null, UM()->options()->get( 'disable_profile_photo_upload' ) ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_photosize',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Profile Photo Size', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_photosize', null, UM()->options()->get( 'profile_photosize' ) ),
|
||||
'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_photo_required',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Make Profile Photo Required', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Require user to update a profile photo when updating their profile', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_photo_required' ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_show_name',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show display name in profile header?', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_show_name', null, 1 ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_show_social_links',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show social links in profile header?', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_show_social_links', null, UM()->options()->get( 'profile_show_social_links' ) ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_show_bio',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show user description in profile header?', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_show_bio', null, 1 ),
|
||||
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
|
||||
)->render_form();
|
||||
?>
|
||||
<div class="um-admin-clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,32 +1,37 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$user_fields = array();
|
||||
foreach ( UM()->builtin()->all_user_fields() as $key => $arr ) {
|
||||
$user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : '';
|
||||
}
|
||||
|
||||
$post_id = get_the_ID();
|
||||
$_um_search_fields = get_post_meta( $post_id, '_um_profile_metafields', true );
|
||||
$_um_search_fields = empty( $_um_search_fields ) ? array() : $_um_search_fields; ?>
|
||||
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
<?php $user_fields = array();
|
||||
foreach ( UM()->builtin()->all_user_fields() as $key => $arr ) {
|
||||
$user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : '';
|
||||
}
|
||||
|
||||
$post_id = get_the_ID();
|
||||
$_um_search_fields = get_post_meta( $post_id, '_um_profile_metafields', true );
|
||||
$_um_search_fields = empty( $_um_search_fields ) ? array() : $_um_search_fields;
|
||||
|
||||
UM()->admin_forms( array(
|
||||
'class' => 'um-form-profile-settings um-top-label',
|
||||
'prefix_id' => 'form',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_profile_metafields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Field(s) to show in user meta', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Fields selected here will appear in the profile header area below the user\'s display name', 'ultimate-member' ),
|
||||
'value' => $_um_search_fields,
|
||||
'options' => $user_fields,
|
||||
'add_text' => __( 'Add New Field', 'ultimate-member' ),
|
||||
'show_default_number' => 0,
|
||||
)
|
||||
<?php
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'class' => 'um-form-profile-settings um-top-label',
|
||||
'prefix_id' => 'form',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_profile_metafields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Field(s) to show in user meta', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Fields selected here will appear in the profile header area below the user\'s display name', 'ultimate-member' ),
|
||||
'value' => $_um_search_fields,
|
||||
'options' => $user_fields,
|
||||
'add_text' => __( 'Add New Field', 'ultimate-member' ),
|
||||
'show_default_number' => 0,
|
||||
),
|
||||
),
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
|
||||
)->render_form();
|
||||
?>
|
||||
<div class="um-admin-clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,95 +1,99 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ( UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ) as $key => $value ) {
|
||||
$_um_register_role = UM()->query()->get_meta_value( '_um_register_role', $key );
|
||||
if ( ! empty( $_um_register_role ) ) {
|
||||
$register_role = $_um_register_role;
|
||||
}
|
||||
} ?>
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
|
||||
<?php foreach ( UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ) as $key => $value ) {
|
||||
$_um_register_role = UM()->query()->get_meta_value( '_um_register_role', $key );
|
||||
if ( ! empty( $_um_register_role ) )
|
||||
$register_role = $_um_register_role;
|
||||
}
|
||||
|
||||
UM()->admin_forms( array(
|
||||
'class' => 'um-form-register-customize um-top-label',
|
||||
'prefix_id' => 'form',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_register_use_custom_settings',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling & appearance', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_use_custom_settings', null, 0 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
<?php
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'class' => 'um-form-register-customize um-top-label',
|
||||
'prefix_id' => 'form',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_register_use_custom_settings',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling & appearance', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_use_custom_settings', null, 0 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_role',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Assign role to form', 'ultimate-member' ),
|
||||
'value' => ! empty( $register_role ) ? $register_role : 0,
|
||||
'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
|
||||
'conditional' => array( '_um_register_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_template',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Template', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_template', null, UM()->options()->get( 'register_template' ) ),
|
||||
'options' => UM()->shortcodes()->get_templates( 'register' ),
|
||||
'conditional' => array( '_um_register_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_max_width',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Max. Width (px)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_max_width', null, UM()->options()->get( 'register_max_width' ) ),
|
||||
'conditional' => array( '_um_register_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_icons',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Field Icons', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_icons', null, UM()->options()->get( 'register_icons' ) ),
|
||||
'options' => array(
|
||||
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
||||
'label' => __( 'Show with label', 'ultimate-member' ),
|
||||
'off' => __( 'Turn off', 'ultimate-member' ),
|
||||
),
|
||||
'conditional' => array( '_um_register_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_primary_btn_word',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Primary Button Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_primary_btn_word', null, UM()->options()->get( 'register_primary_btn_word' ) ),
|
||||
'conditional' => array( '_um_register_use_custom_settings', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_secondary_btn',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show Secondary Button', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn', null, UM()->options()->get( 'register_secondary_btn' ) ),
|
||||
'conditional' => array( '_um_register_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_secondary_btn_word',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Secondary Button Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn_word', null, UM()->options()->get( 'register_secondary_btn_word' ) ),
|
||||
'conditional' => array( '_um_register_secondary_btn', '=', 1 ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_role',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Assign role to form', 'ultimate-member' ),
|
||||
'value' => ! empty( $register_role ) ? $register_role : 0,
|
||||
'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
|
||||
'conditional' => array( '_um_register_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_template',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Template', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_template', null, UM()->options()->get( 'register_template' ) ),
|
||||
'options' => UM()->shortcodes()->get_templates( 'register' ),
|
||||
'conditional' => array( '_um_register_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_max_width',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Max. Width (px)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_register_max_width', null, UM()->options()->get( 'register_max_width' ) ),
|
||||
'conditional' => array( '_um_register_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_icons',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Field Icons', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_icons', null, UM()->options()->get( 'register_icons' ) ) ,
|
||||
'options' => array(
|
||||
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
||||
'label' => __( 'Show with label', 'ultimate-member' ),
|
||||
'off' => __( 'Turn off', 'ultimate-member' )
|
||||
),
|
||||
'conditional' => array( '_um_register_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_primary_btn_word',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Primary Button Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_primary_btn_word', null, UM()->options()->get( 'register_primary_btn_word' ) ),
|
||||
'conditional' => array( '_um_register_use_custom_settings', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_secondary_btn',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Show Secondary Button', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn', null, UM()->options()->get( 'register_secondary_btn' ) ),
|
||||
'conditional' => array( '_um_register_use_custom_settings', '=', 1 ),
|
||||
'options' => array(
|
||||
0 => __( 'No', 'ultimate-member' ),
|
||||
1 => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_secondary_btn_word',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Secondary Button Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn_word', null, UM()->options()->get( 'register_secondary_btn_word' ) ),
|
||||
'conditional' => array( '_um_register_secondary_btn', '=', 1 )
|
||||
)
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
|
||||
)->render_form();
|
||||
?>
|
||||
<div class="um-admin-clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,74 +1,76 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$options = array(
|
||||
'' => __( 'Select page', 'ultimate-member' ),
|
||||
);
|
||||
|
||||
$pages = get_pages();
|
||||
foreach ( $pages as $page ) {
|
||||
$options[ $page->ID ] = $page->post_title;
|
||||
} ?>
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
|
||||
<?php
|
||||
$options = array(
|
||||
'' => __( 'Select page', 'ultimate-member' )
|
||||
);
|
||||
|
||||
$pages = get_pages();
|
||||
foreach ( $pages as $page ) {
|
||||
$options[$page->ID] = $page->post_title;
|
||||
}
|
||||
|
||||
UM()->admin_forms( array(
|
||||
'class' => 'um-form-register-gdpr um-top-label',
|
||||
'prefix_id' => 'form',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_register_use_gdpr',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Enable on this form', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr', null, '' ),
|
||||
'options' => array(
|
||||
'0' => __( 'No', 'ultimate-member' ),
|
||||
'1' => __( 'Yes', 'ultimate-member' )
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'class' => 'um-form-register-gdpr um-top-label',
|
||||
'prefix_id' => 'form',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_register_use_gdpr',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Enable on this form', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr', null, '' ),
|
||||
'options' => array(
|
||||
'0' => __( 'No', 'ultimate-member' ),
|
||||
'1' => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_use_gdpr_content_id',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Content', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_content_id', null, '' ),
|
||||
'options' => $options,
|
||||
'conditional' => array( '_um_register_use_gdpr', '=', '1' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_use_gdpr_toggle_show',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Toggle Show text', 'ultimate-member' ),
|
||||
'placeholder' => __( 'Show privacy policy', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_toggle_show', null, __( 'Show privacy policy', 'ultimate-member' ) ),
|
||||
'conditional' => array( '_um_register_use_gdpr', '=', '1' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_use_gdpr_toggle_hide',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Toggle Hide text', 'ultimate-member' ),
|
||||
'placeholder' => __( 'Hide privacy policy', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_toggle_hide', null, __( 'Hide privacy policy', 'ultimate-member' ) ),
|
||||
'conditional' => array( '_um_register_use_gdpr', '=', '1' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_use_gdpr_agreement',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Checkbox agreement description', 'ultimate-member' ),
|
||||
'placeholder' => __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_agreement', null, __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ) ),
|
||||
'conditional' => array( '_um_register_use_gdpr', '=', '1' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_use_gdpr_error_text',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Error Text', 'ultimate-member' ),
|
||||
'placeholder' => __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_error_text', null, __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ) ),
|
||||
'conditional' => array( '_um_register_use_gdpr', '=', '1' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_use_gdpr_content_id',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Content', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_content_id', null, '' ),
|
||||
'options' => $options,
|
||||
'conditional' => array( '_um_register_use_gdpr', '=', '1' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_use_gdpr_toggle_show',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Toggle Show text', 'ultimate-member' ),
|
||||
'placeholder' => __( 'Show privacy policy', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_toggle_show', null, __( 'Show privacy policy', 'ultimate-member' ) ),
|
||||
'conditional' => array( '_um_register_use_gdpr', '=', '1' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_use_gdpr_toggle_hide',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Toggle Hide text', 'ultimate-member' ),
|
||||
'placeholder' => __( 'Hide privacy policy', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_toggle_hide', null, __( 'Hide privacy policy', 'ultimate-member' ) ),
|
||||
'conditional' => array( '_um_register_use_gdpr', '=', '1' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_use_gdpr_agreement',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Checkbox agreement description', 'ultimate-member' ),
|
||||
'placeholder' => __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_agreement', null, __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ) ),
|
||||
'conditional' => array( '_um_register_use_gdpr', '=', '1' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_register_use_gdpr_error_text',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Error Text', 'ultimate-member' ),
|
||||
'placeholder' => __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_error_text', null, __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ) ),
|
||||
'conditional' => array( '_um_register_use_gdpr', '=', '1' )
|
||||
)
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
|
||||
)->render_form();
|
||||
?>
|
||||
<div class="um-admin-clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,27 +1,33 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$role = $object['data']; ?>
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
<?php UM()->admin_forms( array(
|
||||
'class' => 'um-role-publish um-top-label',
|
||||
'prefix_id' => 'role',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_priority',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Role Priority', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The higher the number, the higher the priority', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_priority'] ) ? $role['_um_priority'] : '',
|
||||
<?php
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'class' => 'um-role-publish um-top-label',
|
||||
'prefix_id' => 'role',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_priority',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Role Priority', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The higher the number, the higher the priority', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_priority'] ) ? $role['_um_priority'] : '',
|
||||
),
|
||||
),
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
)->render_form();
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="submitbox" id="submitpost">
|
||||
<div id="major-publishing-actions">
|
||||
<input type="submit" value="<?php echo ! empty( $_GET['id'] ) ? esc_attr__( 'Update Role', 'ultimate-member' ) : esc_attr__( 'Create Role', 'ultimate-member' ) ?>" class="button-primary" id="create_role" name="create_role">
|
||||
<input type="submit" value="<?php echo ! empty( $_GET['id'] ) ? esc_attr__( 'Update Role', 'ultimate-member' ) : esc_attr__( 'Create Role', 'ultimate-member' ) ?>" class="button-primary" id="create_role" name="create_role" />
|
||||
<input type="button" class="cancel_popup button" value="<?php esc_attr_e( 'Cancel', 'ultimate-member' ) ?>" onclick="window.location = '<?php echo add_query_arg( array( 'page' => 'um_roles' ), admin_url( 'admin.php' ) ) ?>';" />
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
wp_enqueue_script( 'postbox' );
|
||||
wp_enqueue_media();
|
||||
@@ -42,7 +44,7 @@ do_action( 'um_roles_add_meta_boxes', 'um_role_meta' );
|
||||
*/
|
||||
do_action( 'um_roles_add_meta_boxes_um_role_meta' );
|
||||
|
||||
$data = array();
|
||||
$data = array();
|
||||
$option = array();
|
||||
global $wp_roles;
|
||||
|
||||
@@ -60,11 +62,11 @@ if ( ! empty( $_GET['id'] ) ) {
|
||||
|
||||
if ( ! empty( $_POST['role'] ) ) {
|
||||
|
||||
$id = '';
|
||||
$id = '';
|
||||
$redirect = '';
|
||||
$error = '';
|
||||
$error = '';
|
||||
|
||||
if ( 'add' == sanitize_key( $_GET['tab'] ) ) {
|
||||
if ( 'add' === sanitize_key( $_GET['tab'] ) ) {
|
||||
if ( ! wp_verify_nonce( $_POST['um_nonce'], 'um-add-role' ) ) {
|
||||
$error = __( 'Security Issue', 'ultimate-member' ) . '<br />';
|
||||
}
|
||||
@@ -76,155 +78,9 @@ if ( ! empty( $_POST['role'] ) ) {
|
||||
|
||||
if ( empty( $error ) ) {
|
||||
|
||||
$data = $_POST['role'];
|
||||
$data = UM()->admin()->sanitize_role_meta( $_POST['role'] );
|
||||
|
||||
$all_roles = array_keys( UM()->roles()->get_roles() );
|
||||
|
||||
if ( array_key_exists( '_um_priority', $data ) ) {
|
||||
$data['_um_priority'] = (int) $data['_um_priority'];
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_can_access_wpadmin', $data ) ) {
|
||||
$data['_um_can_access_wpadmin'] = (bool) $data['_um_can_access_wpadmin'];
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_can_not_see_adminbar', $data ) ) {
|
||||
$data['_um_can_not_see_adminbar'] = (bool) $data['_um_can_not_see_adminbar'];
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_can_edit_everyone', $data ) ) {
|
||||
$data['_um_can_edit_everyone'] = (bool) $data['_um_can_edit_everyone'];
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_can_edit_roles', $data ) && ! empty( $data['_um_can_edit_roles'] ) ) {
|
||||
$data['_um_can_edit_roles'] = array_filter( $data['_um_can_edit_roles'], function( $v, $k ) use ( $all_roles ) {
|
||||
return in_array( $v, $all_roles );
|
||||
}, ARRAY_FILTER_USE_BOTH );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_can_delete_everyone', $data ) ) {
|
||||
$data['_um_can_delete_everyone'] = (bool) $data['_um_can_delete_everyone'];
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_can_delete_roles', $data ) && ! empty( $data['_um_can_delete_roles'] ) ) {
|
||||
$data['_um_can_delete_roles'] = array_filter( $data['_um_can_delete_roles'], function( $v, $k ) use ( $all_roles ) {
|
||||
return in_array( $v, $all_roles );
|
||||
}, ARRAY_FILTER_USE_BOTH );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_can_edit_profile', $data ) ) {
|
||||
$data['_um_can_edit_profile'] = (bool) $data['_um_can_edit_profile'];
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_can_delete_profile', $data ) ) {
|
||||
$data['_um_can_delete_profile'] = (bool) $data['_um_can_delete_profile'];
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_can_view_all', $data ) ) {
|
||||
$data['_um_can_view_all'] = (bool) $data['_um_can_view_all'];
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_can_view_roles', $data ) && ! empty( $data['_um_can_view_roles'] ) ) {
|
||||
$data['_um_can_view_roles'] = array_filter( $data['_um_can_view_roles'], function( $v, $k ) use ( $all_roles ) {
|
||||
return in_array( $v, $all_roles );
|
||||
}, ARRAY_FILTER_USE_BOTH );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_can_make_private_profile', $data ) ) {
|
||||
$data['_um_can_make_private_profile'] = (bool) $data['_um_can_make_private_profile'];
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_can_access_private_profile', $data ) ) {
|
||||
$data['_um_can_access_private_profile'] = (bool) $data['_um_can_access_private_profile'];
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_profile_noindex', $data ) ) {
|
||||
$data['_um_profile_noindex'] = $data['_um_profile_noindex'] !== '' ? (bool) $data['_um_profile_noindex'] : $data['_um_profile_noindex'];
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_default_homepage', $data ) ) {
|
||||
$data['_um_default_homepage'] = (bool) $data['_um_default_homepage'];
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_redirect_homepage', $data ) ) {
|
||||
$data['_um_redirect_homepage'] = esc_url_raw( $data['_um_redirect_homepage'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_status', $data ) ) {
|
||||
$data['_um_status'] = ! in_array( sanitize_key( $data['_um_status'] ), [ 'approved', 'checkmail', 'pending' ] ) ? 'approved' : sanitize_key( $data['_um_status'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_auto_approve_act', $data ) ) {
|
||||
$data['_um_auto_approve_act'] = ! in_array( sanitize_key( $data['_um_auto_approve_act'] ), [ 'redirect_profile', 'redirect_url' ] ) ? 'redirect_profile' : sanitize_key( $data['_um_auto_approve_act'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_auto_approve_url', $data ) ) {
|
||||
$data['_um_auto_approve_url'] = esc_url_raw( $data['_um_auto_approve_url'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_login_email_activate', $data ) ) {
|
||||
$data['_um_login_email_activate'] = (bool) $data['_um_login_email_activate'];
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_checkmail_action', $data ) ) {
|
||||
$data['_um_checkmail_action'] = ! in_array( sanitize_key( $data['_um_checkmail_action'] ), [ 'show_message', 'redirect_url' ] ) ? 'show_message' : sanitize_key( $data['_um_checkmail_action'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_checkmail_message', $data ) ) {
|
||||
$data['_um_checkmail_message'] = sanitize_textarea_field( $data['_um_checkmail_message'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_checkmail_url', $data ) ) {
|
||||
$data['_um_checkmail_url'] = esc_url_raw( $data['_um_checkmail_url'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_url_email_activate', $data ) ) {
|
||||
$data['_um_url_email_activate'] = esc_url_raw( $data['_um_url_email_activate'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_pending_action', $data ) ) {
|
||||
$data['_um_pending_action'] = ! in_array( sanitize_key( $data['_um_pending_action'] ), [ 'show_message', 'redirect_url' ] ) ? 'show_message' : sanitize_key( $data['_um_pending_action'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_pending_message', $data ) ) {
|
||||
$data['_um_pending_message'] = sanitize_textarea_field( $data['_um_pending_message'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_pending_url', $data ) ) {
|
||||
$data['_um_pending_url'] = esc_url_raw( $data['_um_pending_url'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_after_login', $data ) ) {
|
||||
$data['_um_after_login'] = ! in_array( sanitize_key( $data['_um_after_login'] ), [ 'redirect_profile', 'redirect_url', 'refresh', 'redirect_admin' ] ) ? 'redirect_profile' : sanitize_key( $data['_um_after_login'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_login_redirect_url', $data ) ) {
|
||||
$data['_um_login_redirect_url'] = esc_url_raw( $data['_um_login_redirect_url'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_after_logout', $data ) ) {
|
||||
$data['_um_after_logout'] = ! in_array( sanitize_key( $data['_um_after_logout'] ), [ 'redirect_home', 'redirect_url' ] ) ? 'redirect_home' : sanitize_key( $data['_um_after_logout'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_logout_redirect_url', $data ) ) {
|
||||
$data['_um_logout_redirect_url'] = esc_url_raw( $data['_um_logout_redirect_url'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_after_delete', $data ) ) {
|
||||
$data['_um_after_delete'] = ! in_array( sanitize_key( $data['_um_after_delete'] ), [ 'redirect_home', 'redirect_url' ] ) ? 'redirect_home' : sanitize_key( $data['_um_after_delete'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( '_um_delete_redirect_url', $data ) ) {
|
||||
$data['_um_delete_redirect_url'] = esc_url_raw( $data['_um_delete_redirect_url'] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'wp_capabilities', $data ) && ! empty( $data['wp_capabilities'] ) ) {
|
||||
$data['wp_capabilities'] = array_map( 'boolval', array_filter( $data['wp_capabilities'] ) );
|
||||
}
|
||||
|
||||
$data = apply_filters( 'um_save_role_meta_sanitize', $data );
|
||||
|
||||
if ( 'add' == sanitize_key( $_GET['tab'] ) ) {
|
||||
if ( 'add' === sanitize_key( $_GET['tab'] ) ) {
|
||||
|
||||
$data['name'] = trim( esc_html( strip_tags( $data['name'] ) ) );
|
||||
|
||||
@@ -237,11 +93,11 @@ if ( ! empty( $_POST['role'] ) ) {
|
||||
} else {
|
||||
$auto_increment = UM()->options()->get( 'custom_roles_increment' );
|
||||
$auto_increment = ! empty( $auto_increment ) ? $auto_increment : 1;
|
||||
$id = 'custom_role_' . $auto_increment;
|
||||
$id = 'custom_role_' . $auto_increment;
|
||||
}
|
||||
|
||||
$redirect = add_query_arg( array( 'page'=>'um_roles', 'tab'=>'edit', 'id'=>$id, 'msg'=>'a' ), admin_url( 'admin.php' ) );
|
||||
} elseif ( 'edit' == sanitize_key( $_GET['tab'] ) && ! empty( $_GET['id'] ) ) {
|
||||
} elseif ( 'edit' === sanitize_key( $_GET['tab'] ) && ! empty( $_GET['id'] ) ) {
|
||||
$id = sanitize_key( $_GET['id'] );
|
||||
|
||||
$pre_role_meta = get_option( "um_role_{$id}_meta", array() );
|
||||
@@ -254,16 +110,16 @@ if ( ! empty( $_POST['role'] ) ) {
|
||||
|
||||
|
||||
$all_roles = array_keys( get_editable_roles() );
|
||||
if ( 'add' == sanitize_key( $_GET['tab'] ) ) {
|
||||
if ( in_array( 'um_' . $id, $all_roles ) || in_array( $id, $all_roles ) ) {
|
||||
if ( 'add' === sanitize_key( $_GET['tab'] ) ) {
|
||||
if ( in_array( 'um_' . $id, $all_roles, true ) || in_array( $id, $all_roles, true ) ) {
|
||||
$error .= __( 'Role already exists!', 'ultimate-member' ) . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if ( '' == $error ) {
|
||||
if ( '' === $error ) {
|
||||
|
||||
if ( 'add' == sanitize_key( $_GET['tab'] ) ) {
|
||||
$roles = get_option( 'um_roles', array() );
|
||||
if ( 'add' === sanitize_key( $_GET['tab'] ) ) {
|
||||
$roles = get_option( 'um_roles', array() );
|
||||
$roles[] = $id;
|
||||
|
||||
update_option( 'um_roles', $roles );
|
||||
@@ -297,14 +153,30 @@ $screen_id = $current_screen->id; ?>
|
||||
|
||||
<div class="wrap">
|
||||
<h2>
|
||||
<?php echo ( 'add' == sanitize_key( $_GET['tab'] ) ) ? __( 'Add New Role', 'ultimate-member' ) : __( 'Edit Role', 'ultimate-member' ) ?>
|
||||
<?php if ( 'edit' == sanitize_key( $_GET['tab'] ) ) { ?>
|
||||
<a class="add-new-h2" href="<?php echo esc_url( add_query_arg( array( 'page' => 'um_roles', 'tab' => 'add' ), admin_url( 'admin.php' ) ) ) ?>"><?php _e( 'Add New', 'ultimate-member' ) ?></a>
|
||||
<?php } ?>
|
||||
<?php
|
||||
if ( 'add' === sanitize_key( $_GET['tab'] ) ) {
|
||||
esc_html_e( 'Add New Role', 'ultimate-member' );
|
||||
} elseif ( 'edit' === sanitize_key( $_GET['tab'] ) ) {
|
||||
esc_html_e( 'Edit Role', 'ultimate-member' );
|
||||
$add_new_link = add_query_arg(
|
||||
array(
|
||||
'page' => 'um_roles',
|
||||
'tab' => 'add',
|
||||
),
|
||||
admin_url( 'admin.php' )
|
||||
);
|
||||
?>
|
||||
<a class="add-new-h2" href="<?php echo esc_url( $add_new_link ); ?>">
|
||||
<?php esc_html_e( 'Add New', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</h2>
|
||||
|
||||
<?php if ( ! empty( $_GET['msg'] ) ) {
|
||||
switch( sanitize_key( $_GET['msg'] ) ) {
|
||||
<?php
|
||||
if ( ! empty( $_GET['msg'] ) ) {
|
||||
switch ( sanitize_key( $_GET['msg'] ) ) {
|
||||
case 'a':
|
||||
echo '<div id="message" class="updated fade"><p>' . __( 'User Role <strong>Added</strong> Successfully.', 'ultimate-member' ) . '</p></div>';
|
||||
break;
|
||||
@@ -316,13 +188,13 @@ $screen_id = $current_screen->id; ?>
|
||||
|
||||
if ( ! empty( $error ) ) { ?>
|
||||
<div id="message" class="error fade">
|
||||
<p><?php echo $error ?></p>
|
||||
<p><?php echo $error; ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<form id="um_edit_role" action="" method="post">
|
||||
<input type="hidden" name="role[id]" value="<?php echo isset( $_GET['id'] ) ? esc_attr( sanitize_key( $_GET['id'] ) ) : '' ?>" />
|
||||
<?php if ( 'add' == sanitize_key( $_GET['tab'] ) ) { ?>
|
||||
<?php if ( 'add' === sanitize_key( $_GET['tab'] ) ) { ?>
|
||||
<input type="hidden" name="role[_um_is_custom]" value="1" />
|
||||
<input type="hidden" name="um_nonce" value="<?php echo esc_attr( wp_create_nonce( 'um-add-role' ) ) ?>" />
|
||||
<?php } else { ?>
|
||||
@@ -335,7 +207,7 @@ $screen_id = $current_screen->id; ?>
|
||||
<div id="post-body-content">
|
||||
<div id="titlediv">
|
||||
<div id="titlewrap">
|
||||
<?php if ( 'add' == sanitize_key( $_GET['tab'] ) ) { ?>
|
||||
<?php if ( 'add' === sanitize_key( $_GET['tab'] ) ) { ?>
|
||||
<label for="title" class="screen-reader-text"><?php _e( 'Title', 'ultimate-member' ) ?></label>
|
||||
<input type="text" name="role[name]" placeholder="<?php esc_attr_e( 'Enter Title Here', 'ultimate-member' ) ?>" id="title" value="<?php echo isset( $data['name'] ) ? $data['name'] : '' ?>" />
|
||||
<?php } else { ?>
|
||||
@@ -345,11 +217,18 @@ $screen_id = $current_screen->id; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$object = array(
|
||||
'data' => $data,
|
||||
'option' => $option,
|
||||
);
|
||||
?>
|
||||
|
||||
<div id="postbox-container-1" class="postbox-container">
|
||||
<?php do_meta_boxes( 'um_role_meta', 'side', array( 'data' => $data, 'option' => $option ) ); ?>
|
||||
<?php do_meta_boxes( 'um_role_meta', 'side', $object ); ?>
|
||||
</div>
|
||||
<div id="postbox-container-2" class="postbox-container">
|
||||
<?php do_meta_boxes( 'um_role_meta', 'normal', array( 'data' => $data, 'option' => $option ) ); ?>
|
||||
<?php do_meta_boxes( 'um_role_meta', 'normal', $object ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -51,7 +51,8 @@
|
||||
</span>
|
||||
|
||||
|
||||
<?php $role = $object['data'];
|
||||
<?php
|
||||
$role = $object['data'];
|
||||
$role_capabilities = ! empty( $role['wp_capabilities'] ) ? array_keys( $role['wp_capabilities'] ) : array( 'read' );
|
||||
|
||||
if ( ! empty( $_GET['id'] ) ) {
|
||||
@@ -89,4 +90,4 @@
|
||||
)
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -48,7 +48,7 @@ if ( ! class_exists( 'UM_Functions' ) ) {
|
||||
* @param bool $action
|
||||
*/
|
||||
function check_ajax_nonce( $action = false ) {
|
||||
$nonce = isset( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : '';
|
||||
$nonce = isset( $_REQUEST['nonce'] ) ? sanitize_text_field( $_REQUEST['nonce'] ) : '';
|
||||
$action = empty( $action ) ? 'um-frontend-nonce' : $action;
|
||||
|
||||
if ( ! wp_verify_nonce( $nonce, $action ) ) {
|
||||
@@ -392,4 +392,4 @@ if ( ! class_exists( 'UM_Functions' ) ) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,13 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
$this->redirect_handler = false;
|
||||
$this->allow_access = false;
|
||||
|
||||
add_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 );
|
||||
add_action( 'pre_get_comments', array( &$this, 'exclude_posts_comments' ), 99, 1 );
|
||||
add_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 );
|
||||
add_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 );
|
||||
add_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99, 1 );
|
||||
add_filter( 'comment_feed_where', array( &$this, 'exclude_posts_comments_feed' ), 99, 2 );
|
||||
|
||||
//there is posts (Posts/Page/CPT) filtration if site is accessible
|
||||
//there also will be redirects if they need
|
||||
//protect posts types
|
||||
@@ -508,9 +515,10 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$enable_referer = apply_filters( "um_access_enable_referer", false );
|
||||
if ( ! $enable_referer )
|
||||
$enable_referer = apply_filters( 'um_access_enable_referer', false );
|
||||
if ( ! $enable_referer ) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
$url = add_query_arg( 'um_ref', $referer, $url );
|
||||
return $url;
|
||||
@@ -545,10 +553,14 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
* return false if post is not private
|
||||
* Restrict content new logic
|
||||
*
|
||||
* @param $post
|
||||
* @param \WP_Post|int $post Post ID or object
|
||||
* @return bool|array
|
||||
*/
|
||||
function get_post_privacy_settings( $post ) {
|
||||
if ( is_numeric( $post ) ) {
|
||||
$post = get_post( $post );
|
||||
}
|
||||
|
||||
$exclude = false;
|
||||
|
||||
//if logged in administrator all pages are visible
|
||||
@@ -703,7 +715,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
foreach ( $posts as $post ) {
|
||||
|
||||
//Woocommerce AJAX fixes....remove filtration on wc-ajax which goes to Front Page
|
||||
if ( ! empty( $_GET['wc-ajax'] ) && defined('WC_DOING_AJAX') && WC_DOING_AJAX /*&& $query->is_front_page()*/ ) {
|
||||
if ( ! empty( $_GET['wc-ajax'] ) && defined( 'WC_DOING_AJAX' ) && WC_DOING_AJAX ) {
|
||||
$filtered_posts[] = $post;
|
||||
continue;
|
||||
}
|
||||
@@ -1017,6 +1029,120 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exclude posts from query
|
||||
*
|
||||
* @param \WP_Query $query
|
||||
*/
|
||||
function exclude_posts( $query ) {
|
||||
if ( $query->is_main_query() ) {
|
||||
$exclude_posts = $this->exclude_posts_array();
|
||||
if ( ! empty( $exclude_posts ) ) {
|
||||
$post__not_in = $query->get( 'post__not_in', array() );
|
||||
$query->set( 'post__not_in', array_merge( $post__not_in, $exclude_posts ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exclude comments from restricted posts in widgets
|
||||
*
|
||||
* @param \WP_Comment_Query $query
|
||||
*
|
||||
*/
|
||||
function exclude_posts_comments( $query ) {
|
||||
$exclude_posts = $this->exclude_posts_array( false );
|
||||
if ( ! empty( $exclude_posts ) ) {
|
||||
$query->query_vars['post__not_in'] = $exclude_posts;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exclude comments from comments feed
|
||||
*
|
||||
* @param string $where
|
||||
* @param \WP_Query $query
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function exclude_posts_comments_feed( $where, $query ) {
|
||||
$exclude_posts = $this->exclude_posts_array( false );
|
||||
if ( ! empty( $exclude_posts ) ) {
|
||||
$exclude_string = implode( ',', $exclude_posts );
|
||||
$where .= ' AND comment_post_ID NOT IN ( ' . $exclude_string . ' )';
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get array with restricted posts
|
||||
*
|
||||
* @param bool $in_query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function exclude_posts_array( $in_query = true ) {
|
||||
global $wpdb;
|
||||
|
||||
$exclude_posts = array();
|
||||
$posts = $wpdb->get_col("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'um_content_restriction'");
|
||||
foreach ( $posts as $post ) {
|
||||
$content_restriction = $this->get_post_privacy_settings( $post );
|
||||
|
||||
if ( false === $in_query || ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) {
|
||||
if ( $this->is_restricted( $post ) ) {
|
||||
array_push( $exclude_posts, $post );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $exclude_posts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exclude posts from next, previous navigation
|
||||
*
|
||||
* @param string $where
|
||||
* @param bool $in_same_term
|
||||
* @param array $excluded_terms
|
||||
* @param string $taxonomy.
|
||||
* @param \WP_Post $post
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function exclude_navigation_posts( $where, $in_same_term, $excluded_terms, $taxonomy, $post ) {
|
||||
$exclude_posts = $this->exclude_posts_array();
|
||||
if ( ! empty( $exclude_posts ) ) {
|
||||
$exclude_string = implode( ',', $exclude_posts );
|
||||
$where .= ' AND ID NOT IN ( ' . $exclude_string . ' )';
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exclude restricted posts in widgets
|
||||
*
|
||||
* @param array $array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function exclude_restricted_posts_widget( $array ) {
|
||||
$exclude_posts = $this->exclude_posts_array();
|
||||
if ( ! empty( $exclude_posts ) ) {
|
||||
$array['post__not_in'] = $exclude_posts;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $single_template
|
||||
*
|
||||
@@ -1207,7 +1333,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
$restricted = false;
|
||||
} elseif ( '1' == $restriction[ '_um_accessible' ] ) {
|
||||
//if post for not logged in users and user is not logged in
|
||||
if ( !is_user_logged_in() ) {
|
||||
if ( ! is_user_logged_in() ) {
|
||||
$restricted = false;
|
||||
} else {
|
||||
|
||||
@@ -1468,4 +1594,4 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,6 +397,8 @@ if ( ! class_exists( 'um\core\Account' ) ) {
|
||||
$this->current_tab = UM()->form()->post_form['_um_account_tab'];
|
||||
}
|
||||
|
||||
$this->current_tab = sanitize_key( $this->current_tab );
|
||||
|
||||
if ( ! isset( UM()->form()->errors ) ) {
|
||||
/**
|
||||
* UM hook
|
||||
@@ -971,4 +973,4 @@ if ( ! class_exists( 'um\core\Account' ) ) {
|
||||
return $is_required;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
* Builtin constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
add_action( 'init', array(&$this, 'set_core_fields'), 1);
|
||||
add_action( 'init', array(&$this, 'set_predefined_fields'), 1);
|
||||
add_action( 'init', array(&$this, 'set_custom_fields'), 1);
|
||||
add_action( 'init', array( &$this, 'set_core_fields' ), 1 );
|
||||
add_action( 'init', array( &$this, 'set_predefined_fields' ), 1 );
|
||||
add_action( 'init', array( &$this, 'set_custom_fields' ), 1 );
|
||||
$this->saved_fields = get_option( 'um_fields' );
|
||||
}
|
||||
|
||||
@@ -61,13 +61,15 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
*/
|
||||
function is_dropdown_field( $field, $attrs ) {
|
||||
|
||||
if ( isset( $attrs['options'] ) )
|
||||
if ( isset( $attrs['options'] ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$fields = $this->all_user_fields;
|
||||
|
||||
if ( isset( $fields[$field]['options'] ) || ! empty( $fields[$field]['custom_dropdown_options_source'] ) )
|
||||
if ( isset( $fields[$field]['options'] ) || ! empty( $fields[$field]['custom_dropdown_options_source'] ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -134,14 +136,25 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
*
|
||||
* @param $key
|
||||
*
|
||||
* @return int|string|void
|
||||
* @return int|string
|
||||
*/
|
||||
function unique_field_err( $key ) {
|
||||
if ( empty( $key ) ) return __('Please provide a meta key','ultimate-member');
|
||||
if ( isset( $this->core_fields[ $key ] ) ) return __('Your meta key is a reserved core field and cannot be used','ultimate-member');
|
||||
if ( isset( $this->predefined_fields[ $key ] ) ) return __('Your meta key is a predefined reserved key and cannot be used','ultimate-member');
|
||||
if ( isset( $this->saved_fields[ $key ] ) ) return __('Your meta key already exists in your fields list','ultimate-member');
|
||||
if ( ! UM()->validation()->safe_string( $key ) ) return __('Your meta key contains illegal characters. Please correct it.','ultimate-member');
|
||||
if ( empty( $key ) ) {
|
||||
return __( 'Please provide a meta key', 'ultimate-member' );
|
||||
}
|
||||
if ( isset( $this->core_fields[ $key ] ) ) {
|
||||
return __( 'Your meta key is a reserved core field and cannot be used', 'ultimate-member' );
|
||||
}
|
||||
if ( isset( $this->predefined_fields[ $key ] ) ) {
|
||||
return __( 'Your meta key is a predefined reserved key and cannot be used', 'ultimate-member' );
|
||||
}
|
||||
if ( isset( $this->saved_fields[ $key ] ) ) {
|
||||
return __( 'Your meta key already exists in your fields list', 'ultimate-member' );
|
||||
}
|
||||
if ( ! UM()->validation()->safe_string( $key ) ) {
|
||||
return __( 'Your meta key contains illegal characters. Please correct it.', 'ultimate-member' );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -151,11 +164,16 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
*
|
||||
* @param $date
|
||||
*
|
||||
* @return int|string|void
|
||||
* @return int|string
|
||||
*/
|
||||
function date_range_start_err( $date ) {
|
||||
if ( empty( $date ) ) return __('Please provide a date range beginning','ultimate-member');
|
||||
if ( ! UM()->validation()->validate_date( $date ) ) return __('Please enter a valid start date in the date range','ultimate-member');
|
||||
if ( empty( $date ) ) {
|
||||
return __( 'Please provide a date range beginning', 'ultimate-member' );
|
||||
}
|
||||
if ( ! UM()->validation()->validate_date( $date ) ) {
|
||||
return __( 'Please enter a valid start date in the date range', 'ultimate-member' );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -166,12 +184,18 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
* @param $date
|
||||
* @param $start_date
|
||||
*
|
||||
* @return int|string|void
|
||||
* @return int|string
|
||||
*/
|
||||
function date_range_end_err( $date, $start_date ) {
|
||||
if ( empty( $date ) ) return __('Please provide a date range end','ultimate-member');
|
||||
if ( ! UM()->validation()->validate_date( $date ) ) return __('Please enter a valid end date in the date range','ultimate-member');
|
||||
if ( strtotime( $date ) <= strtotime( $start_date ) ) return __('The end of date range must be greater than the start of date range','ultimate-member');
|
||||
if ( empty( $date ) ) {
|
||||
return __( 'Please provide a date range end', 'ultimate-member' );
|
||||
}
|
||||
if ( ! UM()->validation()->validate_date( $date ) ) {
|
||||
return __( 'Please enter a valid end date in the date range', 'ultimate-member' );
|
||||
}
|
||||
if ( strtotime( $date ) <= strtotime( $start_date ) ) {
|
||||
return __( 'The end of date range must be greater than the start of date range', 'ultimate-member' );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1888,4 +1912,4 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
* Set value on form submission
|
||||
*/
|
||||
if ( isset( $_REQUEST[ $id ] ) ) {
|
||||
$checked = $_REQUEST[ $id ];
|
||||
$checked = (bool) $_REQUEST[ $id ];
|
||||
}
|
||||
|
||||
$class = $checked ? 'um-icon-android-checkbox-outline' : 'um-icon-android-checkbox-outline-blank';
|
||||
@@ -60,7 +60,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
<div class="um-field um-field-c">
|
||||
<div class="um-field-area">
|
||||
<label class="um-field-checkbox <?php echo ( $checked ) ? 'active' : '' ?>">
|
||||
<label class="um-field-checkbox<?php echo $checked ? ' active' : '' ?>">
|
||||
<input type="checkbox" name="<?php echo esc_attr( $id ); ?>" value="1" <?php checked( $checked ) ?> />
|
||||
<span class="um-field-checkbox-state"><i class="<?php echo esc_attr( $class ) ?>"></i></span>
|
||||
<span class="um-field-checkbox-option"> <?php echo esc_html( $title ); ?></span>
|
||||
@@ -2389,8 +2389,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
||||
|
||||
if ( ! empty( $data['label_confirm_pass'] ) ) {
|
||||
$data['label'] = __( $data['label_confirm_pass'], 'ultimate-member' );
|
||||
$output .= $this->field_label( $data['label'], $key, $data );
|
||||
$label_confirm_pass = __( $data['label_confirm_pass'], 'ultimate-member' );
|
||||
$output .= $this->field_label( $label_confirm_pass, $key, $data );
|
||||
} elseif ( isset( $data['label'] ) ) {
|
||||
$data['label'] = __( $data['label'], 'ultimate-member' );
|
||||
$output .= $this->field_label( sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] ), $key, $data );
|
||||
@@ -2409,9 +2409,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$name = $key;
|
||||
}
|
||||
|
||||
if( ! empty( $placeholder ) && ! isset( $data['label'] ) ){
|
||||
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $placeholder );
|
||||
}else if( isset( $data['label'] ) ){
|
||||
if ( ! empty( $label_confirm_pass ) ) {
|
||||
$placeholder = $label_confirm_pass;
|
||||
} elseif( ! empty( $placeholder ) && ! isset( $data['label'] ) ) {
|
||||
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $placeholder );
|
||||
} elseif( isset( $data['label'] ) ) {
|
||||
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] );
|
||||
}
|
||||
|
||||
@@ -3781,11 +3783,15 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
/**
|
||||
* Get fields in row
|
||||
*
|
||||
* @param integer $row_id
|
||||
* @param int $row_id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_fields_by_row( $row_id ) {
|
||||
if ( ! isset( $this->get_fields ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
foreach ( $this->get_fields as $key => $array ) {
|
||||
if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
|
||||
$results[ $key ] = $array;
|
||||
@@ -4762,4 +4768,4 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
return $html_atts;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ if ( ! class_exists( 'um\core\Files' ) ) {
|
||||
wp_send_json_error( __( 'Wrong mode', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$src = $_POST['src'];
|
||||
$src = esc_url_raw( $_POST['src'] );
|
||||
if ( strstr( $src, '?' ) ) {
|
||||
$splitted = explode( '?', $src );
|
||||
$src = $splitted[0];
|
||||
@@ -286,7 +286,7 @@ if ( ! class_exists( 'um\core\Files' ) ) {
|
||||
|
||||
$is_temp = um_is_temp_upload( $src );
|
||||
if ( ! $is_temp ) {
|
||||
if ( ! empty( $_POST['filename'] ) && file_exists( UM()->uploader()->get_upload_user_base_dir( $user_id ) . DIRECTORY_SEPARATOR . $_POST['filename'] ) ) {
|
||||
if ( ! empty( $_POST['filename'] ) && file_exists( UM()->uploader()->get_upload_user_base_dir( $user_id ) . DIRECTORY_SEPARATOR . sanitize_file_name( $_POST['filename'] ) ) ) {
|
||||
wp_send_json_success();
|
||||
}
|
||||
}
|
||||
@@ -324,7 +324,7 @@ if ( ! class_exists( 'um\core\Files' ) ) {
|
||||
wp_send_json_error( esc_js( __( 'Invalid coordinates', 'ultimate-member' ) ) );
|
||||
}
|
||||
|
||||
$user_id = empty( $_REQUEST['user_id'] ) ? get_current_user_id() : $_REQUEST['user_id'];
|
||||
$user_id = empty( $_REQUEST['user_id'] ) ? get_current_user_id() : absint( $_REQUEST['user_id'] );
|
||||
|
||||
UM()->fields()->set_id = filter_input( INPUT_POST, 'set_id', FILTER_SANITIZE_NUMBER_INT );
|
||||
UM()->fields()->set_mode = filter_input( INPUT_POST, 'set_mode', FILTER_SANITIZE_STRING );
|
||||
@@ -334,13 +334,15 @@ if ( ! class_exists( 'um\core\Files' ) ) {
|
||||
wp_send_json_error( $ret );
|
||||
}
|
||||
|
||||
$src = esc_url_raw( $src );
|
||||
|
||||
$image_path = um_is_file_owner( $src, $user_id, true );
|
||||
if ( ! $image_path ) {
|
||||
wp_send_json_error( esc_js( __( 'Invalid file ownership', 'ultimate-member' ) ) );
|
||||
}
|
||||
|
||||
UM()->uploader()->replace_upload_dir = true;
|
||||
$output = UM()->uploader()->resize_image( $image_path, $src, $key, $user_id, $coord );
|
||||
$output = UM()->uploader()->resize_image( $image_path, $src, sanitize_text_field( $key ), $user_id, sanitize_text_field( $coord ) );
|
||||
UM()->uploader()->replace_upload_dir = false;
|
||||
|
||||
delete_option( "um_cache_userdata_{$user_id}" );
|
||||
@@ -358,13 +360,13 @@ if ( ! class_exists( 'um\core\Files' ) ) {
|
||||
$ret['error'] = null;
|
||||
$ret = array();
|
||||
|
||||
$id = $_POST['key'];
|
||||
$timestamp = $_POST['timestamp'];
|
||||
$nonce = $_POST['_wpnonce'];
|
||||
$id = sanitize_text_field( $_POST['key'] );
|
||||
$timestamp = absint( $_POST['timestamp'] );
|
||||
$nonce = sanitize_text_field( $_POST['_wpnonce'] );
|
||||
$user_id = empty( $_POST['user_id'] ) ? get_current_user_id() : absint( $_POST['user_id'] );
|
||||
|
||||
UM()->fields()->set_id = $_POST['set_id'];
|
||||
UM()->fields()->set_mode = $_POST['set_mode'];
|
||||
UM()->fields()->set_id = absint( $_POST['set_id'] );
|
||||
UM()->fields()->set_mode = sanitize_key( $_POST['set_mode'] );
|
||||
|
||||
if ( UM()->fields()->set_mode != 'register' && ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
||||
$ret['error'] = __( 'You have no permission to edit this user', 'ultimate-member' );
|
||||
@@ -437,12 +439,12 @@ if ( ! class_exists( 'um\core\Files' ) ) {
|
||||
die( json_encode( $ret ) );
|
||||
}*/
|
||||
|
||||
$nonce = $_POST['_wpnonce'];
|
||||
$id = $_POST['key'];
|
||||
$timestamp = $_POST['timestamp'];
|
||||
$nonce = sanitize_text_field( $_POST['_wpnonce'] );
|
||||
$id = sanitize_text_field( $_POST['key'] );
|
||||
$timestamp = absint( $_POST['timestamp'] );
|
||||
|
||||
UM()->fields()->set_id = $_POST['set_id'];
|
||||
UM()->fields()->set_mode = $_POST['set_mode'];
|
||||
UM()->fields()->set_id = absint( $_POST['set_id'] );
|
||||
UM()->fields()->set_mode = sanitize_key( $_POST['set_mode'] );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
@@ -1296,4 +1298,4 @@ if ( ! class_exists( 'um\core\Files' ) ) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+318
-236
@@ -53,15 +53,28 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function ajax_muted_action() {
|
||||
public function ajax_muted_action() {
|
||||
UM()->check_ajax_nonce();
|
||||
|
||||
/**
|
||||
* @var $user_id
|
||||
* @var $hook
|
||||
*/
|
||||
extract( $_REQUEST );
|
||||
|
||||
if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) )
|
||||
die( __( 'You can not edit this user' ) );
|
||||
if ( isset( $user_id ) ) {
|
||||
$user_id = absint( $user_id );
|
||||
}
|
||||
|
||||
switch( $hook ) {
|
||||
if ( isset( $hook ) ) {
|
||||
$hook = sanitize_key( $hook );
|
||||
}
|
||||
|
||||
if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
||||
die( esc_html__( 'You can not edit this user', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
switch ( $hook ) {
|
||||
default:
|
||||
/**
|
||||
* UM hook
|
||||
@@ -91,32 +104,34 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function ajax_select_options() {
|
||||
public function ajax_select_options() {
|
||||
UM()->check_ajax_nonce();
|
||||
|
||||
$arr_options = array();
|
||||
$arr_options = array();
|
||||
$arr_options['status'] = 'success';
|
||||
$arr_options['post'] = $_POST;
|
||||
$arr_options['post'] = $_POST;
|
||||
|
||||
UM()->fields()->set_id = absint( $_POST['form_id'] );
|
||||
UM()->fields()->set_id = absint( $_POST['form_id'] );
|
||||
UM()->fields()->set_mode = 'profile';
|
||||
$form_fields = UM()->fields()->get_fields();
|
||||
$arr_options['fields'] = $form_fields;
|
||||
$form_fields = UM()->fields()->get_fields();
|
||||
$arr_options['fields'] = $form_fields;
|
||||
|
||||
if ( isset( $arr_options['post']['members_directory'] ) && $arr_options['post']['members_directory'] == 'yes' ) {
|
||||
if ( isset( $arr_options['post']['members_directory'] ) && 'yes' === $arr_options['post']['members_directory'] ) {
|
||||
$ajax_source_func = $_POST['child_callback'];
|
||||
if ( function_exists( $ajax_source_func ) ) {
|
||||
$arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$values_array = $wpdb->get_col( $wpdb->prepare(
|
||||
"SELECT DISTINCT meta_value
|
||||
FROM $wpdb->usermeta
|
||||
WHERE meta_key = %s AND
|
||||
meta_value != ''",
|
||||
$arr_options['post']['child_name']
|
||||
) );
|
||||
$values_array = $wpdb->get_col(
|
||||
$wpdb->prepare(
|
||||
"SELECT DISTINCT meta_value
|
||||
FROM $wpdb->usermeta
|
||||
WHERE meta_key = %s AND
|
||||
meta_value != ''",
|
||||
$arr_options['post']['child_name']
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! empty( $values_array ) ) {
|
||||
$arr_options['items'] = array_intersect( $arr_options['items'], $values_array );
|
||||
@@ -148,8 +163,8 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$debug = apply_filters('um_ajax_select_options__debug_mode', false );
|
||||
if( $debug ){
|
||||
$debug = apply_filters( 'um_ajax_select_options__debug_mode', false );
|
||||
if ( $debug ) {
|
||||
$arr_options['debug'] = array(
|
||||
$_POST,
|
||||
$form_fields,
|
||||
@@ -163,19 +178,17 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
// If the requested callback function is added in the form or added in the field option, execute it with call_user_func.
|
||||
if ( isset( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
|
||||
! empty( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
|
||||
$form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] == $ajax_source_func ) {
|
||||
$form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] === $ajax_source_func ) {
|
||||
|
||||
$arr_options['field'] = $form_fields[ $_POST['child_name'] ];
|
||||
|
||||
if ( function_exists( $ajax_source_func ) ) {
|
||||
$arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
|
||||
}
|
||||
|
||||
} else {
|
||||
$arr_options['status'] = 'error';
|
||||
$arr_options['status'] = 'error';
|
||||
$arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
wp_send_json( $arr_options );
|
||||
@@ -187,10 +200,10 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
* Count the form errors.
|
||||
* @return integer
|
||||
*/
|
||||
function count_errors() {
|
||||
public function count_errors() {
|
||||
$errors = $this->errors;
|
||||
|
||||
if( $errors && is_array( $errors ) ) {
|
||||
if ( $errors && is_array( $errors ) ) {
|
||||
return count( $errors );
|
||||
}
|
||||
|
||||
@@ -200,11 +213,12 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
|
||||
/**
|
||||
* Appends field errors
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $error
|
||||
*/
|
||||
function add_error( $key, $error ) {
|
||||
if ( ! isset( $this->errors[ $key ] ) ){
|
||||
public function add_error( $key, $error ) {
|
||||
if ( ! isset( $this->errors[ $key ] ) ) {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
@@ -227,8 +241,7 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$error = apply_filters( 'um_submit_form_error', $error, $key );
|
||||
$this->errors[ $key ] = $error;
|
||||
$this->errors[ $key ] = apply_filters( 'um_submit_form_error', $error, $key );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,8 +250,8 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
* @param string $key
|
||||
* @param string $notice
|
||||
*/
|
||||
function add_notice( $key, $notice ) {
|
||||
if ( ! isset( $this->notices[ $key ] ) ){
|
||||
public function add_notice( $key, $notice ) {
|
||||
if ( ! isset( $this->notices[ $key ] ) ) {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
@@ -261,30 +274,32 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$notice = apply_filters( 'um_submit_form_notice', $notice, $key );
|
||||
$this->notices[ $key ] = $notice;
|
||||
$this->notices[ $key ] = apply_filters( 'um_submit_form_notice', $notice, $key );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If a form has errors
|
||||
*
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
function has_error( $key ) {
|
||||
public function has_error( $key ) {
|
||||
if ( isset( $this->errors[ $key ] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If a form has notices/info
|
||||
*
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
function has_notice( $key ) {
|
||||
public function has_notice( $key ) {
|
||||
if ( isset( $this->notices[ $key ] ) ) {
|
||||
return true;
|
||||
}
|
||||
@@ -295,7 +310,7 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
/**
|
||||
* Declare all fields
|
||||
*/
|
||||
function field_declare() {
|
||||
public function field_declare() {
|
||||
if ( isset( UM()->builtin()->custom_fields ) ) {
|
||||
$this->all_fields = UM()->builtin()->custom_fields;
|
||||
} else {
|
||||
@@ -307,23 +322,29 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
/**
|
||||
* Validate form on submit
|
||||
*/
|
||||
function form_init() {
|
||||
public function form_init() {
|
||||
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
|
||||
$http_post = ( 'POST' == $_SERVER['REQUEST_METHOD'] );
|
||||
$http_post = ( 'POST' === $_SERVER['REQUEST_METHOD'] );
|
||||
} else {
|
||||
$http_post = 'POST';
|
||||
}
|
||||
|
||||
if ( $http_post && ! is_admin() && isset( $_POST['form_id'] ) && is_numeric( $_POST['form_id'] ) ) {
|
||||
|
||||
$this->form_id = absint( $_POST['form_id'] );
|
||||
$this->form_status = get_post_status( $this->form_id );
|
||||
$this->form_data = UM()->query()->post_data( $this->form_id );
|
||||
|
||||
if ( 'publish' !== $this->form_status ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_before_submit_form_post
|
||||
* @description Before submit form
|
||||
* @input_vars
|
||||
* [{"var":"$post","type":"int","desc":"Post data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_before_submit_form_post', 'function_name', 10, 1 );
|
||||
@@ -335,183 +356,174 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_before_submit_form_post', $_POST );
|
||||
do_action( 'um_before_submit_form_post' );
|
||||
|
||||
$this->form_id = $_POST['form_id'];
|
||||
$this->form_status = get_post_status( $this->form_id );
|
||||
|
||||
|
||||
if ( $this->form_status == 'publish' ) {
|
||||
/* save entire form as global */
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_submit_post_form
|
||||
* @description Change submitted data on form submit
|
||||
* @input_vars
|
||||
* [{"var":"$data","type":"array","desc":"Submitted data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_submit_post_form', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_submit_post_form', 'my_submit_post_form', 10, 1 );
|
||||
* function my_submit_post_form( $data ) {
|
||||
* // your code here
|
||||
* return $data;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$this->post_form = apply_filters( 'um_submit_post_form', $_POST );
|
||||
|
||||
if ( isset( $this->post_form[ UM()->honeypot ] ) && $this->post_form[ UM()->honeypot ] != '' ) {
|
||||
wp_die( __( 'Hello, spam bot!', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$this->post_form = $this->beautify( $this->post_form );
|
||||
$this->post_form['submitted'] = $this->post_form;
|
||||
|
||||
$this->form_data = UM()->query()->post_data( $this->form_id );
|
||||
|
||||
$this->post_form = array_merge( $this->form_data, $this->post_form );
|
||||
|
||||
// Remove role from post_form at first if role ! empty and there aren't custom fields with role name
|
||||
if ( ! empty( $_POST['role'] ) ) {
|
||||
if ( ! isset( $this->form_data['custom_fields'] ) || ! strstr( $this->form_data['custom_fields'], 'role_' ) ) {
|
||||
unset( $this->post_form['role'] );
|
||||
unset( $this->post_form['submitted']['role'] );
|
||||
}
|
||||
}
|
||||
|
||||
// Secure sanitize of the submitted data
|
||||
if ( ! empty( $this->post_form ) ) {
|
||||
$this->post_form = array_diff_key( $this->post_form, array_flip( UM()->user()->banned_keys ) );
|
||||
}
|
||||
if ( ! empty( $this->post_form['submitted'] ) ) {
|
||||
$this->post_form['submitted'] = array_diff_key( $this->post_form['submitted'], array_flip( UM()->user()->banned_keys ) );
|
||||
}
|
||||
|
||||
// set default role from settings on registration form
|
||||
if ( isset( $this->post_form['mode'] ) && $this->post_form['mode'] == 'register' ) {
|
||||
|
||||
$role = $this->assigned_role( $this->form_id );
|
||||
$this->post_form['role'] = $role;
|
||||
|
||||
}
|
||||
|
||||
if ( isset( $this->form_data['custom_fields'] ) && strstr( $this->form_data['custom_fields'], 'role_' ) ) { // Secure selected role
|
||||
|
||||
if ( ! empty( $_POST['role'] ) ) {
|
||||
|
||||
$custom_field_roles = $this->custom_field_roles( $this->form_data['custom_fields'] );
|
||||
|
||||
if ( ! empty( $custom_field_roles ) ) {
|
||||
$role = $_POST['role'];
|
||||
|
||||
if ( is_array( $_POST['role'] ) ) {
|
||||
$role = current( $_POST['role'] );
|
||||
}
|
||||
|
||||
global $wp_roles;
|
||||
$role_keys = array_map( function( $item ) {
|
||||
return 'um_' . $item;
|
||||
}, get_option( 'um_roles', array() ) );
|
||||
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
||||
|
||||
if ( ! empty( $role ) &&
|
||||
( ! in_array( $role, $custom_field_roles, true ) || in_array( $role, $exclude_roles ) ) ) {
|
||||
wp_die( __( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$this->post_form['role'] = $role;
|
||||
$this->post_form['submitted']['role'] = $role;
|
||||
} else {
|
||||
unset( $this->post_form['role'] );
|
||||
unset( $this->post_form['submitted']['role'] );
|
||||
|
||||
// set default role for registration form if custom field hasn't proper value
|
||||
if ( isset( $this->post_form['mode'] ) && $this->post_form['mode'] == 'register' ) {
|
||||
$role = $this->assigned_role( $this->form_id );
|
||||
$this->post_form['role'] = $role;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_submit_form_data
|
||||
* @description Change submitted data on form submit
|
||||
* @input_vars
|
||||
* [{"var":"$data","type":"array","desc":"Submitted data"},
|
||||
* {"var":"$mode","type":"string","desc":"Form mode"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_submit_form_data', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_submit_form_data', 'my_submit_form_data', 10, 2 );
|
||||
* function my_submit_form_data( $data ) {
|
||||
* // your code here
|
||||
* return $data;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$this->post_form = apply_filters( 'um_submit_form_data', $this->post_form, $this->post_form['mode'] );
|
||||
|
||||
/* Continue based on form mode - pre-validation */
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_submit_form_errors_hook
|
||||
* @description Action on submit form
|
||||
* @input_vars
|
||||
* [{"var":"$post","type":"int","desc":"Post data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_submit_form_errors_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_submit_form_errors_hook', 'my_submit_form_errors', 10, 1 );
|
||||
* function my_submit_form_errors( $post ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_submit_form_errors_hook', $this->post_form );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_submit_form_{$mode}
|
||||
* @description Action on submit form
|
||||
* @input_vars
|
||||
* [{"var":"$post","type":"int","desc":"Post data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_submit_form_{$mode}', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_submit_form_{$mode}', 'my_submit_form', 10, 1 );
|
||||
* function my_submit_form( $post ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( "um_submit_form_{$this->post_form['mode']}", $this->post_form );
|
||||
/* save entire form as global */
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_submit_post_form
|
||||
* @description Change submitted data on form submit
|
||||
* @input_vars
|
||||
* [{"var":"$data","type":"array","desc":"Submitted data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_submit_post_form', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_submit_post_form', 'my_submit_post_form', 10, 1 );
|
||||
* function my_submit_post_form( $data ) {
|
||||
* // your code here
|
||||
* return $data;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$this->post_form = apply_filters( 'um_submit_post_form', $_POST );
|
||||
|
||||
if ( isset( $this->post_form[ UM()->honeypot ] ) && '' !== $this->post_form[ UM()->honeypot ] ) {
|
||||
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
}
|
||||
$this->post_form = $this->beautify( $this->post_form );
|
||||
$this->post_form = $this->sanitize( $this->post_form );
|
||||
$this->post_form['submitted'] = $this->post_form;
|
||||
|
||||
$this->post_form = array_merge( $this->form_data, $this->post_form );
|
||||
|
||||
// Remove role from post_form at first if role ! empty and there aren't custom fields with role name
|
||||
if ( ! empty( $_POST['role'] ) ) {
|
||||
if ( ! isset( $this->form_data['custom_fields'] ) || ! strstr( $this->form_data['custom_fields'], 'role_' ) ) {
|
||||
unset( $this->post_form['role'] );
|
||||
unset( $this->post_form['submitted']['role'] );
|
||||
}
|
||||
}
|
||||
|
||||
// Secure sanitize of the submitted data
|
||||
if ( ! empty( $this->post_form ) ) {
|
||||
$this->post_form = array_diff_key( $this->post_form, array_flip( UM()->user()->banned_keys ) );
|
||||
}
|
||||
if ( ! empty( $this->post_form['submitted'] ) ) {
|
||||
$this->post_form['submitted'] = array_diff_key( $this->post_form['submitted'], array_flip( UM()->user()->banned_keys ) );
|
||||
}
|
||||
|
||||
// set default role from settings on registration form
|
||||
if ( isset( $this->post_form['mode'] ) && 'register' === $this->post_form['mode'] ) {
|
||||
$role = $this->assigned_role( $this->form_id );
|
||||
$this->post_form['role'] = $role;
|
||||
}
|
||||
|
||||
if ( isset( $this->form_data['custom_fields'] ) && strstr( $this->form_data['custom_fields'], 'role_' ) ) { // Secure selected role
|
||||
|
||||
if ( ! empty( $_POST['role'] ) ) {
|
||||
$custom_field_roles = $this->custom_field_roles( $this->form_data['custom_fields'] );
|
||||
|
||||
if ( ! empty( $custom_field_roles ) ) {
|
||||
if ( is_array( $_POST['role'] ) ) {
|
||||
$role = current( $_POST['role'] );
|
||||
$role = sanitize_key( $role );
|
||||
} else {
|
||||
$role = sanitize_key( $_POST['role'] );
|
||||
}
|
||||
|
||||
global $wp_roles;
|
||||
$role_keys = array_map(
|
||||
function( $item ) {
|
||||
return 'um_' . $item;
|
||||
},
|
||||
get_option( 'um_roles', array() )
|
||||
);
|
||||
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
||||
|
||||
if ( ! empty( $role ) &&
|
||||
( ! in_array( $role, $custom_field_roles, true ) || in_array( $role, $exclude_roles, true ) ) ) {
|
||||
wp_die( esc_html__( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$this->post_form['role'] = $role;
|
||||
$this->post_form['submitted']['role'] = $role;
|
||||
} else {
|
||||
unset( $this->post_form['role'] );
|
||||
unset( $this->post_form['submitted']['role'] );
|
||||
|
||||
// set default role for registration form if custom field hasn't proper value
|
||||
if ( isset( $this->post_form['mode'] ) && 'register' === $this->post_form['mode'] ) {
|
||||
$role = $this->assigned_role( $this->form_id );
|
||||
$this->post_form['role'] = $role;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_submit_form_data
|
||||
* @description Change submitted data on form submit
|
||||
* @input_vars
|
||||
* [{"var":"$data","type":"array","desc":"Submitted data"},
|
||||
* {"var":"$mode","type":"string","desc":"Form mode"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_submit_form_data', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_submit_form_data', 'my_submit_form_data', 10, 2 );
|
||||
* function my_submit_form_data( $data ) {
|
||||
* // your code here
|
||||
* return $data;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$this->post_form = apply_filters( 'um_submit_form_data', $this->post_form, $this->post_form['mode'] );
|
||||
|
||||
/* Continue based on form mode - pre-validation */
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_submit_form_errors_hook
|
||||
* @description Action on submit form
|
||||
* @input_vars
|
||||
* [{"var":"$post","type":"int","desc":"Post data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_submit_form_errors_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_submit_form_errors_hook', 'my_submit_form_errors', 10, 1 );
|
||||
* function my_submit_form_errors( $post ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_submit_form_errors_hook', $this->post_form );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_submit_form_{$mode}
|
||||
* @description Action on submit form
|
||||
* @input_vars
|
||||
* [{"var":"$post","type":"int","desc":"Post data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_submit_form_{$mode}', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_submit_form_{$mode}', 'my_submit_form', 10, 1 );
|
||||
* function my_submit_form( $post ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( "um_submit_form_{$this->post_form['mode']}", $this->post_form );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -519,24 +531,88 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
* Beautify form data
|
||||
*
|
||||
* @param array $form
|
||||
*
|
||||
* @return array $form
|
||||
*/
|
||||
function beautify( $form ) {
|
||||
|
||||
public function beautify( $form ) {
|
||||
if ( isset( $form['form_id'] ) ) {
|
||||
|
||||
$this->form_suffix = '-' . $form['form_id'];
|
||||
|
||||
$this->processing = $form['form_id'];
|
||||
$this->processing = $form['form_id'];
|
||||
|
||||
foreach ( $form as $key => $value ) {
|
||||
if ( strstr( $key, $this->form_suffix ) ) {
|
||||
$a_key = str_replace( $this->form_suffix, '', $key );
|
||||
$a_key = str_replace( $this->form_suffix, '', $key );
|
||||
$form[ $a_key ] = $value;
|
||||
unset( $form[ $key ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Beautify form data
|
||||
*
|
||||
* @param array $form
|
||||
*
|
||||
* @return array $form
|
||||
*/
|
||||
public function sanitize( $form ) {
|
||||
|
||||
if ( isset( $form['form_id'] ) ) {
|
||||
if ( isset( $this->form_data['custom_fields'] ) ) {
|
||||
$custom_fields = maybe_unserialize( $this->form_data['custom_fields'] );
|
||||
|
||||
if ( is_array( $custom_fields ) ) {
|
||||
foreach ( $custom_fields as $k => $field ) {
|
||||
|
||||
if ( isset( $field['type'] ) ) {
|
||||
if ( isset( $form[ $k ] ) ) {
|
||||
|
||||
switch ( $field['type'] ) {
|
||||
default:
|
||||
$form[ $k ] = apply_filters( 'um_sanitize_form_field', $form[ $k ], $field );
|
||||
break;
|
||||
case 'number':
|
||||
$form[ $k ] = (int) $form[ $k ];
|
||||
break;
|
||||
case 'textarea':
|
||||
if ( ! empty( $field['html'] ) ) {
|
||||
$form[ $k ] = wp_kses_post( $form[ $k ] );
|
||||
} else {
|
||||
$form[ $k ] = sanitize_textarea_field( $form[ $k ] );
|
||||
}
|
||||
break;
|
||||
case 'url':
|
||||
$form[ $k ] = esc_url_raw( $form[ $k ] );
|
||||
break;
|
||||
case 'text':
|
||||
case 'select':
|
||||
case 'password':
|
||||
case 'image':
|
||||
case 'file':
|
||||
case 'date':
|
||||
case 'time':
|
||||
case 'rating':
|
||||
case 'googlemap':
|
||||
case 'youtube_video':
|
||||
case 'vimeo_video':
|
||||
case 'soundcloud_track':
|
||||
$form[ $k ] = sanitize_text_field( $form[ $k ] );
|
||||
break;
|
||||
case 'multiselect':
|
||||
case 'radio':
|
||||
case 'checkbox':
|
||||
$form[ $k ] = array_map( 'sanitize_text_field', $form[ $k ] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $form;
|
||||
@@ -549,17 +625,17 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
* @param integer $post_id
|
||||
* @return string $output
|
||||
*/
|
||||
function display_form_type( $mode, $post_id ){
|
||||
public function display_form_type( $mode, $post_id ) {
|
||||
$output = null;
|
||||
switch( $mode ){
|
||||
switch ( $mode ) {
|
||||
case 'login':
|
||||
$output = 'Login';
|
||||
$output = __( 'Login', 'ultimate-member' );
|
||||
break;
|
||||
case 'profile':
|
||||
$output = 'Profile';
|
||||
$output = __( 'Profile', 'ultimate-member' );
|
||||
break;
|
||||
case 'register':
|
||||
$output = 'Register';
|
||||
$output = __( 'Register', 'ultimate-member' );
|
||||
break;
|
||||
}
|
||||
return $output;
|
||||
@@ -571,7 +647,7 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
* @param integer $post_id
|
||||
* @return string $role
|
||||
*/
|
||||
function assigned_role( $post_id ) {
|
||||
public function assigned_role( $post_id ) {
|
||||
|
||||
$global_role = get_option( 'default_role' ); // WP Global settings
|
||||
|
||||
@@ -603,7 +679,7 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
* @param integer $post_id
|
||||
* @return string
|
||||
*/
|
||||
function form_type( $post_id ) {
|
||||
public function form_type( $post_id ) {
|
||||
$mode = get_post_meta( $post_id, '_um_mode', true );
|
||||
return $mode;
|
||||
}
|
||||
@@ -611,10 +687,11 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
|
||||
/**
|
||||
* Get custom field roles
|
||||
*
|
||||
* @param string $custom_fields serialized
|
||||
* @return bool|array roles
|
||||
*/
|
||||
function custom_field_roles( $custom_fields ) {
|
||||
public function custom_field_roles( $custom_fields ) {
|
||||
|
||||
$fields = maybe_unserialize( $custom_fields );
|
||||
if ( ! is_array( $fields ) ) {
|
||||
@@ -623,21 +700,27 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
|
||||
// role field
|
||||
global $wp_roles;
|
||||
$role_keys = array_map( function( $item ) {
|
||||
return 'um_' . $item;
|
||||
}, get_option( 'um_roles', array() ) );
|
||||
$role_keys = array_map(
|
||||
function( $item ) {
|
||||
return 'um_' . $item;
|
||||
},
|
||||
get_option( 'um_roles', array() )
|
||||
);
|
||||
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
||||
|
||||
$roles = UM()->roles()->get_roles( false, $exclude_roles );
|
||||
$roles = array_map( function( $item ) {
|
||||
return html_entity_decode( $item, ENT_QUOTES );
|
||||
}, $roles );
|
||||
$roles = array_map(
|
||||
function( $item ) {
|
||||
return html_entity_decode( $item, ENT_QUOTES );
|
||||
},
|
||||
$roles
|
||||
);
|
||||
|
||||
foreach ( $fields as $field_key => $field_settings ) {
|
||||
|
||||
if ( strstr( $field_key, 'role_' ) && is_array( $field_settings['options'] ) ) {
|
||||
|
||||
if ( isset( $this->post_form['mode'] ) && $this->post_form['mode'] == 'profile' &&
|
||||
if ( isset( $this->post_form['mode'] ) && 'profile' === $this->post_form['mode'] &&
|
||||
isset( $field_settings['editable'] ) && $field_settings['editable'] == 0 ) {
|
||||
continue;
|
||||
}
|
||||
@@ -658,10 +741,9 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
// getting roles only from the first role fields
|
||||
return array_keys( $intersected_options );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,12 +70,12 @@ if ( ! class_exists( 'um\core\Logout' ) ) {
|
||||
|
||||
add_filter( 'wp_safe_redirect_fallback', array( &$this, 'safe_redirect_default' ), 10, 2 );
|
||||
|
||||
if ( isset( $_REQUEST['redirect_to'] ) && $_REQUEST['redirect_to'] !== '' ) {
|
||||
if ( isset( $_REQUEST['redirect_to'] ) && '' !== $_REQUEST['redirect_to'] ) {
|
||||
wp_destroy_current_session();
|
||||
wp_logout();
|
||||
session_unset();
|
||||
exit( wp_safe_redirect( $_REQUEST['redirect_to'] ) );
|
||||
} else if ( um_user('after_logout') == 'redirect_home' ) {
|
||||
exit( wp_safe_redirect( esc_url_raw( $_REQUEST['redirect_to'] ) ) );
|
||||
} else if ( 'redirect_home' === um_user( 'after_logout' ) ) {
|
||||
wp_destroy_current_session();
|
||||
wp_logout();
|
||||
session_unset();
|
||||
@@ -120,4 +120,4 @@ if ( ! class_exists( 'um\core\Logout' ) ) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -571,7 +571,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
|
||||
|
||||
|
||||
if ( ! empty( $_POST['search'] ) ) {
|
||||
$search_line = trim( stripslashes( $_POST['search'] ) );
|
||||
$search_line = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
||||
|
||||
$searches = array();
|
||||
foreach ( $this->core_search_fields as $field ) {
|
||||
@@ -582,7 +582,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
|
||||
|
||||
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_search ON umm_search.user_id = u.ID";
|
||||
|
||||
$additional_search = apply_filters( 'um_member_directory_meta_general_search_meta_query', '', stripslashes( $_POST['search'] ) );
|
||||
$additional_search = apply_filters( 'um_member_directory_meta_general_search_meta_query', '', stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
||||
|
||||
$search_like_string = apply_filters( 'um_member_directory_meta_search_like_type', '%' . $search_line . '%', $search_line );
|
||||
|
||||
@@ -610,6 +610,13 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
|
||||
$i = 1;
|
||||
foreach ( $filter_query as $field => $value ) {
|
||||
|
||||
$field = sanitize_text_field( $field );
|
||||
if ( is_array( $value ) ) {
|
||||
$value = array_map( 'sanitize_text_field', $value );
|
||||
} else {
|
||||
$value = sanitize_text_field( $value );
|
||||
}
|
||||
|
||||
$attrs = UM()->fields()->get_field( $field );
|
||||
// skip private invisible fields
|
||||
if ( ! um_can_view_field( $attrs ) ) {
|
||||
@@ -642,7 +649,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
|
||||
//}
|
||||
|
||||
$order = 'ASC';
|
||||
$sortby = ! empty( $_POST['sorting'] ) ? $_POST['sorting'] : $directory_data['sortby'];
|
||||
$sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
|
||||
$sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
|
||||
|
||||
$custom_sort = array();
|
||||
@@ -666,6 +673,10 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
|
||||
|
||||
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS {$custom_sort_type} ) {$order} ";
|
||||
|
||||
} elseif ( 'username' == $sortby ) {
|
||||
|
||||
$this->sql_order = " ORDER BY u.user_login {$order} ";
|
||||
|
||||
} elseif ( 'display_name' == $sortby ) {
|
||||
|
||||
$display_name = UM()->options()->get( 'display_name' );
|
||||
@@ -755,7 +766,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
|
||||
}
|
||||
|
||||
$query_number = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $profiles_per_page ) ? $directory_data['max_users'] : $profiles_per_page;
|
||||
$query_paged = ! empty( $_POST['page'] ) ? $_POST['page'] : 1;
|
||||
$query_paged = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
|
||||
|
||||
$number = $query_number;
|
||||
if ( ! empty( $directory_data['max_users'] ) && $query_paged*$query_number > $directory_data['max_users'] ) {
|
||||
@@ -850,4 +861,4 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
|
||||
wp_send_json_success( $member_directory_response );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,41 +199,46 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function before_save_data( $value, $key, $post_id ) {
|
||||
public function before_save_data( $value, $key, $post_id ) {
|
||||
|
||||
$post = get_post( $post_id );
|
||||
|
||||
if ( $post->post_type == 'um_directory' ) {
|
||||
if ( 'um_directory' === $post->post_type ) {
|
||||
|
||||
if ( ! empty( $value ) && in_array( $key, array( '_um_view_types', '_um_roles', '_um_roles_can_search', '_um_roles_can_filter' ) ) ) {
|
||||
if ( ! empty( $value ) && in_array( $key, array( '_um_view_types', '_um_roles', '_um_roles_can_search', '_um_roles_can_filter' ), true ) ) {
|
||||
$value = array_keys( $value );
|
||||
} elseif ( $key == '_um_search_filters' ) {
|
||||
} elseif ( '_um_search_filters' === $key ) {
|
||||
|
||||
$temp_value = array();
|
||||
|
||||
if ( ! empty( $value ) ) {
|
||||
foreach ( $value as $k ) {
|
||||
$filter_type = $this->filter_types[ $k ];
|
||||
if ( ! empty( $filter_type ) ) {
|
||||
if ( $filter_type == 'slider' ) {
|
||||
if ( ! empty( $filter_type ) ) {
|
||||
if ( 'slider' === $filter_type ) {
|
||||
if ( ! empty( $_POST[ $k ] ) ) {
|
||||
$temp_value[ $k ] = $_POST[ $k ];
|
||||
$temp_value[ $k ] = (int) $_POST[ $k ];
|
||||
}
|
||||
} elseif ( $filter_type == 'timepicker' || $filter_type == 'datepicker' ) {
|
||||
} elseif ( 'timepicker' === $filter_type || 'datepicker' === $filter_type ) {
|
||||
if ( ! empty( $_POST[ $k . '_from' ] ) && ! empty( $_POST[ $k . '_to' ] ) ) {
|
||||
$temp_value[ $k ] = array( $_POST[ $k . '_from' ], $_POST[ $k . '_to' ] );
|
||||
$temp_value[ $k ] = array(
|
||||
sanitize_text_field( $_POST[ $k . '_from' ] ),
|
||||
sanitize_text_field( $_POST[ $k . '_to' ] ),
|
||||
);
|
||||
}
|
||||
} elseif ( $filter_type == 'select' ) {
|
||||
} elseif ( 'select' === $filter_type ) {
|
||||
if ( ! empty( $_POST[ $k ] ) ) {
|
||||
if ( is_array( $_POST[ $k ] ) ) {
|
||||
$temp_value[ $k ] = array_map( 'trim', $_POST[ $k ] );
|
||||
} else {
|
||||
$temp_value[ $k ] = array( trim( $_POST[ $k ] ) );
|
||||
}
|
||||
|
||||
$temp_value[ $k ] = array_map( 'sanitize_text_field', $temp_value[ $k ] );
|
||||
}
|
||||
} else {
|
||||
if ( ! empty( $_POST[ $k ] ) ) {
|
||||
$temp_value[ $k ] = trim( $_POST[ $k ] );
|
||||
$temp_value[ $k ] = trim( sanitize_text_field( $_POST[ $k ] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,7 +246,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
}
|
||||
|
||||
$value = $temp_value;
|
||||
} elseif ( $key == '_um_sorting_fields' ) {
|
||||
} elseif ( '_um_sorting_fields' === $key ) {
|
||||
if ( ! empty( $value['other_data'] ) ) {
|
||||
$other_data = $value['other_data'];
|
||||
unset( $value['other_data'] );
|
||||
@@ -254,15 +259,15 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
$metalabel = wp_strip_all_tags( $other_data[ $k ]['label'] );
|
||||
}
|
||||
$row = array(
|
||||
$metakey => ! empty( $metalabel ) ? $metalabel : $metakey
|
||||
$metakey => ! empty( $metalabel ) ? $metalabel : $metakey,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ( $key == '_um_sortby_custom' ) {
|
||||
} elseif ( '_um_sortby_custom' === $key ) {
|
||||
$value = sanitize_text_field( $value );
|
||||
} elseif ( $key == '_um_sortby_custom_label' ) {
|
||||
} elseif ( '_um_sortby_custom_label' === $key ) {
|
||||
$value = wp_strip_all_tags( $value );
|
||||
}
|
||||
}
|
||||
@@ -518,7 +523,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
break;
|
||||
}
|
||||
case 'text': {
|
||||
$filter_from_url = ! empty( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ? $_GET[ 'filter_' . $filter . '_' . $unique_hash ] : $default_value; ?>
|
||||
$filter_from_url = ! empty( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ? sanitize_text_field( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) : $default_value; ?>
|
||||
<input type="text" autocomplete="off" id="<?php echo $filter; ?>" name="<?php echo $filter; ?>"
|
||||
placeholder="<?php esc_attr_e( stripslashes( $attrs['label'] ), 'ultimate-member' ); ?>"
|
||||
value="<?php echo esc_attr( $filter_from_url ) ?>" class="um-form-field"
|
||||
@@ -1224,7 +1229,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
}
|
||||
|
||||
$this->query_args['number'] = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $profiles_per_page ) ? $directory_data['max_users'] : $profiles_per_page;
|
||||
$this->query_args['paged'] = ! empty( $_POST['page'] ) ? $_POST['page'] : 1;
|
||||
$this->query_args['paged'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1236,7 +1241,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
function sorting_query( $directory_data ) {
|
||||
// sort members by
|
||||
$this->query_args['order'] = 'ASC';
|
||||
$sortby = ! empty( $_POST['sorting'] ) ? $_POST['sorting'] : $directory_data['sortby'];
|
||||
$sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
|
||||
$sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
|
||||
|
||||
$custom_sort = array();
|
||||
@@ -1250,7 +1255,12 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'display_name' == $sortby ) {
|
||||
if ( 'username' == $sortby ) {
|
||||
|
||||
$this->query_args['orderby'] = 'user_login';
|
||||
$this->query_args['order'] = 'ASC';
|
||||
|
||||
} elseif ( 'display_name' == $sortby ) {
|
||||
|
||||
$display_name = UM()->options()->get( 'display_name' );
|
||||
if ( $display_name == 'username' ) {
|
||||
@@ -1428,7 +1438,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
if ( ! empty( $_POST['search'] ) ) {
|
||||
// complex using with change_meta_sql function
|
||||
|
||||
$search = trim( stripslashes( $_POST['search'] ) );
|
||||
$search = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
||||
|
||||
$meta_query = array(
|
||||
'relation' => 'OR',
|
||||
@@ -1446,7 +1456,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
),
|
||||
);
|
||||
|
||||
$meta_query = apply_filters( 'um_member_directory_general_search_meta_query', $meta_query, stripslashes( $_POST['search'] ) );
|
||||
$meta_query = apply_filters( 'um_member_directory_general_search_meta_query', $meta_query, stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
||||
|
||||
$this->query_args['meta_query'][] = $meta_query;
|
||||
|
||||
@@ -1471,7 +1481,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
function change_meta_sql( $sql, $queries, $type, $primary_table, $primary_id_column, $context ) {
|
||||
if ( ! empty( $_POST['search'] ) ) {
|
||||
global $wpdb;
|
||||
$search = trim( stripslashes( $_POST['search'] ) );
|
||||
$search = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
||||
if ( ! empty( $search ) ) {
|
||||
|
||||
$meta_value = '%' . $wpdb->esc_like( $search ) . '%';
|
||||
@@ -1534,6 +1544,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
$filter_query = array();
|
||||
if ( ! empty( $directory_data['search_fields'] ) ) {
|
||||
$search_filters = maybe_unserialize( $directory_data['search_fields'] );
|
||||
|
||||
if ( ! empty( $search_filters ) && is_array( $search_filters ) ) {
|
||||
$filter_query = array_intersect_key( $_POST, array_flip( $search_filters ) );
|
||||
}
|
||||
@@ -1548,6 +1559,12 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
|
||||
$this->is_search = true;
|
||||
foreach ( $filter_query as $field => $value ) {
|
||||
$field = sanitize_text_field( $field );
|
||||
if ( is_array( $value ) ) {
|
||||
$value = array_map( 'sanitize_text_field', $value );
|
||||
} else {
|
||||
$value = sanitize_text_field( $value );
|
||||
}
|
||||
|
||||
$attrs = UM()->fields()->get_field( $field );
|
||||
// skip private invisible fields
|
||||
@@ -1660,6 +1677,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
'value' => $value,
|
||||
'compare' => 'BETWEEN',
|
||||
'inclusive' => true,
|
||||
'type' => 'NUMERIC',
|
||||
);
|
||||
|
||||
break;
|
||||
@@ -2066,7 +2084,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
*/
|
||||
function calculate_pagination( $directory_data, $total_users ) {
|
||||
|
||||
$current_page = ! empty( $_POST['page'] ) ? $_POST['page'] : 1;
|
||||
$current_page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
|
||||
|
||||
$total_users = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $total_users ) ? $directory_data['max_users'] : $total_users;
|
||||
|
||||
@@ -2320,7 +2338,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
function pagination_changes( $user_query ) {
|
||||
global $wpdb;
|
||||
|
||||
$directory_id = $this->get_directory_by_hash( $_POST['directory_id'] );
|
||||
$directory_id = $this->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
|
||||
$directory_data = UM()->query()->post_data( $directory_id );
|
||||
|
||||
$qv = $user_query->query_vars;
|
||||
@@ -2367,7 +2385,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$directory_id = $this->get_directory_by_hash( $_POST['directory_id'] );
|
||||
$directory_id = $this->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
|
||||
$directory_data = UM()->query()->post_data( $directory_id );
|
||||
|
||||
//predefined result for user without capabilities to see other members
|
||||
@@ -2619,4 +2637,4 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
wp_send_json_success( array( 'field_html' => $html ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,8 +100,9 @@ if ( ! class_exists( 'um\core\Options' ) ) {
|
||||
* @param $option_id
|
||||
*/
|
||||
function remove( $option_id ) {
|
||||
if ( ! empty( $this->options[ $option_id ] ) )
|
||||
if ( ! empty( $this->options[ $option_id ] ) ) {
|
||||
unset( $this->options[ $option_id ] );
|
||||
}
|
||||
|
||||
update_option( 'um_options', $this->options );
|
||||
}
|
||||
@@ -157,4 +158,4 @@ if ( ! class_exists( 'um\core\Options' ) ) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
* @return bool
|
||||
*/
|
||||
function is_reset_request() {
|
||||
if ( um_is_core_page( 'password-reset' ) && isset( $_POST['_um_password_reset'] ) == 1 ) {
|
||||
if ( um_is_core_page( 'password-reset' ) && isset( $_POST['_um_password_reset'] ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
* @return bool
|
||||
*/
|
||||
function is_change_request() {
|
||||
if ( isset( $_POST['_um_account'] ) == 1 && isset( $_POST['_um_account_tab'] ) && $_POST['_um_account_tab'] == 'password' ) {
|
||||
if ( isset( $_POST['_um_account'] ) == 1 && isset( $_POST['_um_account_tab'] ) && sanitize_key( $_POST['_um_account_tab'] ) === 'password' ) {
|
||||
return true;
|
||||
} elseif ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
|
||||
return true;
|
||||
@@ -275,12 +275,12 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
/**
|
||||
* Password page form
|
||||
*/
|
||||
function form_init() {
|
||||
public function form_init() {
|
||||
if ( um_is_core_page( 'password-reset' ) ) {
|
||||
UM()->fields()->set_mode = 'password';
|
||||
}
|
||||
|
||||
if ( um_is_core_page( 'password-reset' ) && isset( $_REQUEST['act'] ) && $_REQUEST['act'] == 'reset_password' ) {
|
||||
if ( um_is_core_page( 'password-reset' ) && isset( $_REQUEST['act'] ) && 'reset_password' === sanitize_key( $_REQUEST['act'] ) ) {
|
||||
wp_fix_server_vars();
|
||||
|
||||
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
||||
@@ -292,7 +292,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
exit;
|
||||
}
|
||||
$rp_login = $userdata->user_login;
|
||||
$rp_key = wp_unslash( $_GET['hash'] );
|
||||
$rp_key = wp_unslash( sanitize_text_field( $_GET['hash'] ) );
|
||||
|
||||
$user = check_password_reset_key( $rp_key, $rp_login );
|
||||
|
||||
@@ -300,11 +300,11 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
$this->setcookie( $rp_cookie, false );
|
||||
wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
|
||||
} else {
|
||||
$value = sprintf( '%s:%s', $rp_login, wp_unslash( $_GET['hash'] ) );
|
||||
$value = sprintf( '%s:%s', $rp_login, wp_unslash( sanitize_text_field( $_GET['hash'] ) ) );
|
||||
$this->setcookie( $rp_cookie, $value );
|
||||
wp_safe_redirect( remove_query_arg( array( 'hash', 'user_id' ) ) );
|
||||
}
|
||||
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -381,7 +381,6 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
do_action( 'um_reset_password_process_hook', UM()->form()->post_form );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $this->is_change_request() ) {
|
||||
@@ -432,7 +431,6 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
do_action( 'um_change_password_process_hook', UM()->form()->post_form );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,26 +440,25 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function um_reset_password_errors_hook( $args ) {
|
||||
|
||||
if ( $_POST[ UM()->honeypot ] != '' ) {
|
||||
wp_die( __( 'Hello, spam bot!', 'ultimate-member' ) );
|
||||
public function um_reset_password_errors_hook( $args ) {
|
||||
if ( '' !== $args[ UM()->honeypot ] ) {
|
||||
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$user = "";
|
||||
$user = '';
|
||||
|
||||
foreach ( $_POST as $key => $val ) {
|
||||
if ( strstr( $key, "username_b") ) {
|
||||
$user = trim( $val );
|
||||
foreach ( $args as $key => $val ) {
|
||||
if ( strstr( $key, 'username_b' ) ) {
|
||||
$user = trim( sanitize_text_field( $val ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( empty( $user ) ) {
|
||||
UM()->form()->add_error('username_b', __( 'Please provide your username or email', 'ultimate-member' ) );
|
||||
UM()->form()->add_error( 'username_b', __( 'Please provide your username or email', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( ( ! is_email( $user ) && ! username_exists( $user ) ) || ( is_email( $user ) && ! email_exists( $user ) ) ) {
|
||||
UM()->form()->add_error('username_b', __( 'We can\'t find an account registered with that address or username','ultimate-member') );
|
||||
UM()->form()->add_error( 'username_b', __( 'We can\'t find an account registered with that address or username', 'ultimate-member' ) );
|
||||
} else {
|
||||
|
||||
if ( is_email( $user ) ) {
|
||||
@@ -471,21 +468,19 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
}
|
||||
|
||||
$attempts = (int) get_user_meta( $user_id, 'password_rst_attempts', true );
|
||||
$is_admin = user_can( absint( $user_id ),'manage_options' );
|
||||
$is_admin = user_can( absint( $user_id ), 'manage_options' );
|
||||
|
||||
if ( UM()->options()->get( 'enable_reset_password_limit' ) ) { // if reset password limit is set
|
||||
|
||||
if ( UM()->options()->get( 'disable_admin_reset_password_limit' ) && $is_admin ) {
|
||||
// Triggers this when a user has admin capabilities and when reset password limit is disabled for admins
|
||||
} else {
|
||||
if ( ! ( UM()->options()->get( 'disable_admin_reset_password_limit' ) && $is_admin ) ) {
|
||||
// Doesn't trigger this when a user has admin capabilities and when reset password limit is disabled for admins
|
||||
$limit = UM()->options()->get( 'reset_password_limit_number' );
|
||||
if ( $attempts >= $limit ) {
|
||||
UM()->form()->add_error( 'username_b', __( 'You have reached the limit for requesting password change for this user already. Contact support if you cannot open the email','ultimate-member') );
|
||||
UM()->form()->add_error( 'username_b', __( 'You have reached the limit for requesting password change for this user already. Contact support if you cannot open the email', 'ultimate-member' ) );
|
||||
} else {
|
||||
update_user_meta( $user_id, 'password_rst_attempts', $attempts + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,12 +492,12 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function um_reset_password_process_hook( $args ) {
|
||||
public function um_reset_password_process_hook( $args ) {
|
||||
$user = null;
|
||||
|
||||
foreach ( $_POST as $key => $val ) {
|
||||
if ( strstr( $key, "username_b" ) ) {
|
||||
$user = trim( $val );
|
||||
foreach ( $args as $key => $val ) {
|
||||
if ( strstr( $key, 'username_b' ) ) {
|
||||
$user = trim( sanitize_text_field( $val ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,20 +520,27 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function um_change_password_errors_hook( $args ) {
|
||||
if ( isset( $_POST[ UM()->honeypot ] ) && $_POST[ UM()->honeypot ] != '' ) {
|
||||
wp_die( __( 'Hello, spam bot!', 'ultimate-member' ) );
|
||||
public function um_change_password_errors_hook( $args ) {
|
||||
if ( isset( $args[ UM()->honeypot ] ) && '' !== $args[ UM()->honeypot ] ) {
|
||||
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( ! is_user_logged_in() && isset( $args ) && ! um_is_core_page( 'password-reset' ) ||
|
||||
is_user_logged_in() && isset( $args['user_id'] ) && $args['user_id'] != get_current_user_id() ) {
|
||||
wp_die( __( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
||||
is_user_logged_in() && isset( $args['user_id'] ) && absint( $args['user_id'] ) !== get_current_user_id() ) {
|
||||
wp_die( esc_html__( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( isset( $args['user_password'] ) && empty( $args['user_password'] ) ) {
|
||||
UM()->form()->add_error( 'user_password', __( 'You must enter a new password', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( isset( $args['user_password'] ) ) {
|
||||
$args['user_password'] = sanitize_text_field( $args['user_password'] );
|
||||
}
|
||||
if ( isset( $args['confirm_user_password'] ) ) {
|
||||
$args['confirm_user_password'] = sanitize_text_field( $args['confirm_user_password'] );
|
||||
}
|
||||
|
||||
if ( UM()->options()->get( 'reset_require_strongpass' ) ) {
|
||||
|
||||
if ( strlen( utf8_decode( $args['user_password'] ) ) < 8 ) {
|
||||
@@ -552,14 +554,13 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
if ( ! UM()->validation()->strong_pass( $args['user_password'] ) ) {
|
||||
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( isset( $args['confirm_user_password'] ) && empty( $args['confirm_user_password'] ) ) {
|
||||
UM()->form()->add_error( 'confirm_user_password', __( 'You must confirm your new password', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( isset( $args['user_password'] ) && isset( $args['confirm_user_password'] ) && $args['user_password'] != $args['confirm_user_password'] ) {
|
||||
if ( isset( $args['user_password'] ) && isset( $args['confirm_user_password'] ) && $args['user_password'] !== $args['confirm_user_password'] ) {
|
||||
UM()->form()->add_error( 'confirm_user_password', __( 'Your passwords do not match', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
@@ -571,13 +572,11 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function um_change_password_process_hook( $args ) {
|
||||
extract( $args );
|
||||
|
||||
if ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
|
||||
public function um_change_password_process_hook( $args ) {
|
||||
if ( isset( $args['_um_password_change'] ) && $args['_um_password_change'] == 1 ) {
|
||||
|
||||
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
||||
$user = get_userdata( $args['user_id'] );
|
||||
$user = get_userdata( absint( $args['user_id'] ) );
|
||||
|
||||
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
|
||||
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
|
||||
@@ -586,7 +585,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
$user = false;
|
||||
} else {
|
||||
$user = check_password_reset_key( $rp_key, $rp_login );
|
||||
if ( isset( $_POST['user_password'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) {
|
||||
if ( isset( $args['user_password'] ) && ! hash_equals( $rp_key, $args['rp_key'] ) ) {
|
||||
$user = false;
|
||||
}
|
||||
}
|
||||
@@ -617,7 +616,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
do_action( 'validate_password_reset', $errors, $user );
|
||||
|
||||
if ( ( ! $errors->get_error_code() ) ) {
|
||||
reset_password( $user, $args['user_password'] );
|
||||
reset_password( $user, sanitize_text_field( $args['user_password'] ) );
|
||||
|
||||
// send the Password Changed Email
|
||||
UM()->user()->password_changed();
|
||||
@@ -653,9 +652,9 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_after_changing_user_password', $args['user_id'] );
|
||||
do_action( 'um_after_changing_user_password', absint( $args['user_id'] ) );
|
||||
|
||||
exit( wp_redirect( um_get_core_page('login', 'password_changed' ) ) );
|
||||
exit( wp_redirect( um_get_core_page( 'login', 'password_changed' ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -714,4 +713,4 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
return $replace_placeholders;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,15 +175,15 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
|
||||
/**
|
||||
* Activates an account via email
|
||||
*/
|
||||
function activate_account_via_email_link() {
|
||||
if ( isset( $_REQUEST['act'] ) && $_REQUEST['act'] == 'activate_via_email' && isset( $_REQUEST['hash'] ) && is_string( $_REQUEST['hash'] ) && strlen( $_REQUEST['hash'] ) == 40 &&
|
||||
public function activate_account_via_email_link() {
|
||||
if ( isset( $_REQUEST['act'] ) && 'activate_via_email' === sanitize_key( $_REQUEST['act'] ) && isset( $_REQUEST['hash'] ) && is_string( $_REQUEST['hash'] ) && strlen( $_REQUEST['hash'] ) == 40 &&
|
||||
isset( $_REQUEST['user_id'] ) && is_numeric( $_REQUEST['user_id'] ) ) { // valid token
|
||||
|
||||
$user_id = absint( $_REQUEST['user_id'] );
|
||||
delete_option( "um_cache_userdata_{$user_id}" );
|
||||
|
||||
$account_secret_hash = get_user_meta( $user_id, 'account_secret_hash', true );
|
||||
if ( empty( $account_secret_hash ) || strtolower( $_REQUEST['hash'] ) !== strtolower( $account_secret_hash ) ) {
|
||||
if ( empty( $account_secret_hash ) || strtolower( sanitize_text_field( $_REQUEST['hash'] ) ) !== strtolower( $account_secret_hash ) ) {
|
||||
wp_die( __( 'This activation link is expired or have already been used.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
@@ -536,4 +536,4 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,16 +55,17 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
/**
|
||||
* Delete profile avatar AJAX handler
|
||||
*/
|
||||
function ajax_delete_profile_photo() {
|
||||
public function ajax_delete_profile_photo() {
|
||||
UM()->check_ajax_nonce();
|
||||
|
||||
/**
|
||||
* @var $user_id
|
||||
*/
|
||||
extract( $_REQUEST );
|
||||
if ( ! array_key_exists( 'user_id', $_REQUEST ) ) {
|
||||
wp_send_json_error( __( 'Invalid data', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$user_id = absint( $_REQUEST['user_id'] );
|
||||
|
||||
if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
||||
die( __( 'You can not edit this user' ) );
|
||||
die( esc_html__( 'You can not edit this user', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
UM()->files()->delete_core_user_photo( $user_id, 'profile_photo' );
|
||||
@@ -74,16 +75,17 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
/**
|
||||
* Delete cover photo AJAX handler
|
||||
*/
|
||||
function ajax_delete_cover_photo() {
|
||||
public function ajax_delete_cover_photo() {
|
||||
UM()->check_ajax_nonce();
|
||||
|
||||
/**
|
||||
* @var $user_id
|
||||
*/
|
||||
extract( $_REQUEST );
|
||||
if ( ! array_key_exists( 'user_id', $_REQUEST ) ) {
|
||||
wp_send_json_error( __( 'Invalid data', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$user_id = absint( $_REQUEST['user_id'] );
|
||||
|
||||
if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
||||
die( __( 'You can not edit this user' ) );
|
||||
die( esc_html__( 'You can not edit this user', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
UM()->files()->delete_core_user_photo( $user_id, 'cover_photo' );
|
||||
@@ -95,15 +97,18 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function tabs_privacy() {
|
||||
$privacy = apply_filters( 'um_profile_tabs_privacy_list', array(
|
||||
0 => __( 'Anyone', 'ultimate-member' ),
|
||||
1 => __( 'Guests only', 'ultimate-member' ),
|
||||
2 => __( 'Members only', 'ultimate-member' ),
|
||||
3 => __( 'Only the owner', 'ultimate-member' ),
|
||||
4 => __( 'Only specific roles', 'ultimate-member' ),
|
||||
5 => __( 'Owner and specific roles', 'ultimate-member' ),
|
||||
) );
|
||||
public function tabs_privacy() {
|
||||
$privacy = apply_filters(
|
||||
'um_profile_tabs_privacy_list',
|
||||
array(
|
||||
0 => __( 'Anyone', 'ultimate-member' ),
|
||||
1 => __( 'Guests only', 'ultimate-member' ),
|
||||
2 => __( 'Members only', 'ultimate-member' ),
|
||||
3 => __( 'Only the owner', 'ultimate-member' ),
|
||||
4 => __( 'Only specific roles', 'ultimate-member' ),
|
||||
5 => __( 'Owner and specific roles', 'ultimate-member' ),
|
||||
)
|
||||
);
|
||||
|
||||
return $privacy;
|
||||
}
|
||||
@@ -505,4 +510,4 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ if ( ! class_exists( 'um\core\Query' ) ) {
|
||||
/**
|
||||
* Query constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
public function __construct() {
|
||||
|
||||
|
||||
}
|
||||
@@ -38,7 +38,7 @@ if ( ! class_exists( 'um\core\Query' ) ) {
|
||||
/**
|
||||
* Ajax pagination for posts
|
||||
*/
|
||||
function ajax_paginate() {
|
||||
public function ajax_paginate() {
|
||||
UM()->check_ajax_nonce();
|
||||
|
||||
/**
|
||||
|
||||
@@ -382,21 +382,25 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
|
||||
function get_priority_user_role( $user_id ) {
|
||||
$user = get_userdata( $user_id );
|
||||
|
||||
if ( empty( $user->roles ) )
|
||||
if ( empty( $user->roles ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// User has roles so look for a UM Role one
|
||||
$um_roles_keys = get_option( 'um_roles', array() );
|
||||
|
||||
if ( ! empty( $um_roles_keys ) ) {
|
||||
$um_roles_keys = array_map( function( $item ) {
|
||||
return 'um_' . $item;
|
||||
}, $um_roles_keys );
|
||||
$um_roles_keys = array_map(
|
||||
function( $item ) {
|
||||
return 'um_' . $item;
|
||||
},
|
||||
$um_roles_keys
|
||||
);
|
||||
}
|
||||
|
||||
$orders = array();
|
||||
foreach ( array_values( $user->roles ) as $userrole ) {
|
||||
if ( ! empty( $um_roles_keys ) && in_array( $userrole, $um_roles_keys ) ) {
|
||||
if ( ! empty( $um_roles_keys ) && in_array( $userrole, $um_roles_keys, true ) ) {
|
||||
$userrole_metakey = substr( $userrole, 3 );
|
||||
} else {
|
||||
$userrole_metakey = $userrole;
|
||||
@@ -727,4 +731,4 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,18 +161,16 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
|
||||
*/
|
||||
function parse_shortcode_args( $args ) {
|
||||
if ( $this->message_mode == true ) {
|
||||
|
||||
if ( ! empty( $_REQUEST['um_role'] ) ) {
|
||||
$args['template'] = 'message';
|
||||
$roleID = esc_attr( $_REQUEST['um_role'] );
|
||||
$roleID = sanitize_key( $_REQUEST['um_role'] );
|
||||
$role = UM()->roles()->role_data( $roleID );
|
||||
|
||||
if ( ! empty( $role ) && ! empty( $role["status"] ) ) {
|
||||
$message_key = $role["status"] . '_message';
|
||||
if ( ! empty( $role ) && ! empty( $role['status'] ) ) {
|
||||
$message_key = $role['status'] . '_message';
|
||||
$this->custom_message = ! empty( $role[ $message_key ] ) ? stripslashes( $role[ $message_key ] ) : '';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ( $args as $k => $v ) {
|
||||
@@ -676,7 +674,7 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
|
||||
extract( $args, EXTR_SKIP );
|
||||
|
||||
//not display on admin preview
|
||||
if ( empty( $_POST['act_id'] ) || $_POST['act_id'] != 'um_admin_preview_form' ) {
|
||||
if ( empty( $_POST['act_id'] ) || sanitize_key( $_POST['act_id'] ) !== 'um_admin_preview_form' ) {
|
||||
|
||||
$enable_loggedin_registration = apply_filters( 'um_registration_for_loggedin_users', false, $args );
|
||||
|
||||
@@ -1266,7 +1264,7 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
|
||||
|
||||
$hash = UM()->member_directory()->get_directory_hash( $directory_id );
|
||||
|
||||
$query[ 'search_' . $hash ] = ! empty( $_GET[ 'search_' . $hash ] ) ? $_GET[ 'search_' . $hash ] : '';
|
||||
$query[ 'search_' . $hash ] = ! empty( $_GET[ 'search_' . $hash ] ) ? sanitize_text_field( $_GET[ 'search_' . $hash ] ) : '';
|
||||
}
|
||||
|
||||
if ( empty( $query ) ) {
|
||||
|
||||
@@ -103,8 +103,8 @@ if ( ! class_exists( 'um\core\User_posts' ) ) {
|
||||
function load_posts() {
|
||||
UM()->check_ajax_nonce();
|
||||
|
||||
$author = ! empty( $_POST['author'] ) ? $_POST['author'] : get_current_user_id();
|
||||
$page = ! empty( $_POST['page'] ) ? $_POST['page'] : 0;
|
||||
$author = ! empty( $_POST['author'] ) ? absint( $_POST['author'] ) : get_current_user_id();
|
||||
$page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 0;
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'post',
|
||||
@@ -244,4 +244,4 @@ if ( ! class_exists( 'um\core\User_posts' ) ) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,8 +347,8 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
}
|
||||
|
||||
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
||||
if ( ! user_can( $user_id, $_POST['um-role'] ) ) {
|
||||
UM()->roles()->set_role( $user_id, $_POST['um-role'] );
|
||||
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
|
||||
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,8 +368,8 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
}
|
||||
|
||||
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
||||
if ( ! user_can( $user_id, $_POST['um-role'] ) ) {
|
||||
UM()->roles()->set_role( $user_id, $_POST['um-role'] );
|
||||
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
|
||||
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
function get_pending_users_count() {
|
||||
|
||||
$cached_users_queue = get_option( 'um_cached_users_queue' );
|
||||
if ( $cached_users_queue > 0 && ! isset( $_REQUEST['delete_count'] ) ){
|
||||
if ( $cached_users_queue > 0 && ! isset( $_REQUEST['delete_count'] ) ) {
|
||||
return $cached_users_queue;
|
||||
}
|
||||
|
||||
@@ -592,8 +592,8 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
//if there custom 2 role not empty
|
||||
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
||||
$user = get_userdata( $user_id );
|
||||
$user->add_role( $_POST['um-role'] );
|
||||
UM()->user()->profile['role'] = $_POST['um-role'];
|
||||
$user->add_role( sanitize_key( $_POST['um-role'] ) );
|
||||
UM()->user()->profile['role'] = sanitize_key( $_POST['um-role'] );
|
||||
UM()->user()->update_usermeta_info( 'role' );
|
||||
}
|
||||
|
||||
@@ -641,9 +641,9 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
|
||||
if ( is_admin() ) {
|
||||
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
||||
$new_roles = array_merge( $new_roles, array( $_POST['um-role'] ) );
|
||||
if ( ! user_can( $user_id, $_POST['um-role'] ) ) {
|
||||
UM()->roles()->set_role( $user_id, $_POST['um-role'] );
|
||||
$new_roles = array_merge( $new_roles, array( sanitize_key( $_POST['um-role'] ) ) );
|
||||
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
|
||||
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -7,161 +9,182 @@
|
||||
* @param array $args
|
||||
*/
|
||||
function um_submit_account_errors_hook( $args ) {
|
||||
if ( ! isset( $_POST['_um_account'] ) && ! isset( $_POST['_um_account_tab'] ) ) {
|
||||
if ( ! isset( $args['_um_account'] ) && ! isset( $args['_um_account_tab'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! wp_verify_nonce( $_POST[ 'um_account_nonce_' . $_POST['_um_account_tab'] ], 'um_update_account_' . $_POST['_um_account_tab'] ) ) {
|
||||
UM()->form()->add_error('um_account_security', __( 'Are you hacking? Please try again!', 'ultimate-member' ) );
|
||||
$tab = sanitize_key( $args['_um_account_tab'] );
|
||||
|
||||
if ( ! wp_verify_nonce( $args[ 'um_account_nonce_' . $tab ], 'um_update_account_' . $tab ) ) {
|
||||
UM()->form()->add_error( 'um_account_security', __( 'Are you hacking? Please try again!', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$user = get_user_by( 'login', um_user( 'user_login' ) );
|
||||
|
||||
if ( isset( $_POST['_um_account_tab'] ) ) {
|
||||
switch ( $_POST['_um_account_tab'] ) {
|
||||
case 'delete': {
|
||||
// delete account
|
||||
if ( UM()->account()->current_password_is_required( 'delete' ) ) {
|
||||
if ( strlen( trim( $_POST['single_user_password'] ) ) == 0 ) {
|
||||
UM()->form()->add_error( 'single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
|
||||
} else {
|
||||
if ( ! wp_check_password( $_POST['single_user_password'], $user->data->user_pass, $user->data->ID ) ) {
|
||||
UM()->form()->add_error( 'single_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
||||
}
|
||||
switch ( $tab ) {
|
||||
case 'delete': {
|
||||
// delete account
|
||||
if ( UM()->account()->current_password_is_required( 'delete' ) ) {
|
||||
if ( strlen( trim( sanitize_text_field( $args['single_user_password'] ) ) ) === 0 ) {
|
||||
UM()->form()->add_error( 'single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
|
||||
} else {
|
||||
if ( ! wp_check_password( sanitize_text_field( $args['single_user_password'] ), $user->data->user_pass, $user->data->ID ) ) {
|
||||
UM()->form()->add_error( 'single_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
|
||||
UM()->account()->current_tab = 'delete';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'password': {
|
||||
UM()->account()->current_tab = 'delete';
|
||||
|
||||
// change password
|
||||
UM()->account()->current_tab = 'password';
|
||||
|
||||
if ( empty( $_POST['user_password'] ) ) {
|
||||
UM()->form()->add_error('user_password', __( 'Password is required', 'ultimate-member' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( empty( $_POST['confirm_user_password'] ) ) {
|
||||
UM()->form()->add_error('user_password', __( 'Password confirmation is required', 'ultimate-member' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! empty( $_POST['user_password'] ) && ! empty( $_POST['confirm_user_password'] ) ) {
|
||||
|
||||
if ( UM()->account()->current_password_is_required( 'password' ) ) {
|
||||
if ( empty( $_POST['current_user_password'] ) ) {
|
||||
UM()->form()->add_error('current_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
||||
return;
|
||||
} else {
|
||||
if ( ! wp_check_password( $_POST['current_user_password'], $user->data->user_pass, $user->data->ID ) ) {
|
||||
UM()->form()->add_error('current_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $_POST['user_password'] != $_POST['confirm_user_password'] && $_POST['user_password'] ) {
|
||||
UM()->form()->add_error('user_password', __( 'Your new password does not match', 'ultimate-member' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( UM()->options()->get( 'account_require_strongpass' ) ) {
|
||||
if ( strlen( utf8_decode( $_POST['user_password'] ) ) < 8 ) {
|
||||
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least 8 characters', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( strlen( utf8_decode( $_POST['user_password'] ) ) > 30 ) {
|
||||
UM()->form()->add_error( 'user_password', __( 'Your password must contain less than 30 characters', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( ! UM()->validation()->strong_pass( $_POST['user_password'] ) ) {
|
||||
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'account':
|
||||
case 'general': {
|
||||
// errors on general tab
|
||||
|
||||
$account_name_require = UM()->options()->get( 'account_name_require' );
|
||||
|
||||
if ( ! empty( $_POST['user_login'] ) && ! validate_username( $_POST['user_login'] ) ) {
|
||||
UM()->form()->add_error('user_login', __( 'Your username is invalid', 'ultimate-member' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_POST['first_name'] ) && ( strlen( trim( $_POST['first_name'] ) ) == 0 && $account_name_require ) ) {
|
||||
UM()->form()->add_error( 'first_name', __( 'You must provide your first name', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['last_name'] ) && ( strlen( trim( $_POST['last_name'] ) ) == 0 && $account_name_require ) ) {
|
||||
UM()->form()->add_error( 'last_name', __( 'You must provide your last name', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['user_email'] ) ) {
|
||||
|
||||
if ( strlen( trim( $_POST['user_email'] ) ) == 0 ) {
|
||||
UM()->form()->add_error( 'user_email', __( 'You must provide your e-mail', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( ! is_email( $_POST['user_email'] ) ) {
|
||||
UM()->form()->add_error( 'user_email', __( 'Please provide a valid e-mail', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( email_exists( $_POST['user_email'] ) && email_exists( $_POST['user_email'] ) != get_current_user_id() ) {
|
||||
UM()->form()->add_error( 'user_email', __( 'Email already linked to another account', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
|
||||
// check account password
|
||||
if ( UM()->account()->current_password_is_required( 'general' ) ) {
|
||||
if ( strlen( trim( $_POST['single_user_password'] ) ) == 0 ) {
|
||||
UM()->form()->add_error('single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
|
||||
} else {
|
||||
if ( ! wp_check_password( $_POST['single_user_password'], $user->data->user_pass, $user->data->ID ) ) {
|
||||
UM()->form()->add_error('single_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_submit_account_{$tab}_tab_errors_hook
|
||||
* @description On submit account current $tab validation
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'function_name', 10 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'my_submit_account_tab_errors', 10 );
|
||||
* function my_submit_account_tab_errors() {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_submit_account_' . $_POST['_um_account_tab'] . '_tab_errors_hook' );
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
UM()->account()->current_tab = $_POST['_um_account_tab'];
|
||||
case 'password': {
|
||||
|
||||
// change password
|
||||
UM()->account()->current_tab = 'password';
|
||||
|
||||
if ( isset( $args['user_password'] ) ) {
|
||||
$args['user_password'] = sanitize_text_field( $args['user_password'] );
|
||||
}
|
||||
|
||||
if ( isset( $args['confirm_user_password'] ) ) {
|
||||
$args['confirm_user_password'] = sanitize_text_field( $args['confirm_user_password'] );
|
||||
}
|
||||
|
||||
if ( empty( $args['user_password'] ) ) {
|
||||
UM()->form()->add_error( 'user_password', __( 'Password is required', 'ultimate-member' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( empty( $args['confirm_user_password'] ) ) {
|
||||
UM()->form()->add_error( 'user_password', __( 'Password confirmation is required', 'ultimate-member' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! empty( $args['user_password'] ) && ! empty( $args['confirm_user_password'] ) ) {
|
||||
|
||||
if ( UM()->account()->current_password_is_required( 'password' ) ) {
|
||||
if ( empty( $args['current_user_password'] ) ) {
|
||||
UM()->form()->add_error( 'current_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
||||
return;
|
||||
} else {
|
||||
if ( ! wp_check_password( $args['current_user_password'], $user->data->user_pass, $user->data->ID ) ) {
|
||||
UM()->form()->add_error( 'current_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $args['user_password'] && $args['user_password'] !== $args['confirm_user_password'] ) {
|
||||
UM()->form()->add_error( 'user_password', __( 'Your new password does not match', 'ultimate-member' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( UM()->options()->get( 'account_require_strongpass' ) ) {
|
||||
if ( strlen( utf8_decode( $args['user_password'] ) ) < 8 ) {
|
||||
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least 8 characters', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( strlen( utf8_decode( $args['user_password'] ) ) > 30 ) {
|
||||
UM()->form()->add_error( 'user_password', __( 'Your password must contain less than 30 characters', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( ! UM()->validation()->strong_pass( $args['user_password'] ) ) {
|
||||
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'account':
|
||||
case 'general': {
|
||||
// errors on general tab
|
||||
$account_name_require = UM()->options()->get( 'account_name_require' );
|
||||
|
||||
if ( isset( $args['user_login'] ) ) {
|
||||
$args['user_login'] = sanitize_text_field( $args['user_login'] );
|
||||
}
|
||||
if ( isset( $args['first_name'] ) ) {
|
||||
$args['first_name'] = sanitize_text_field( $args['first_name'] );
|
||||
}
|
||||
if ( isset( $args['last_name'] ) ) {
|
||||
$args['last_name'] = sanitize_text_field( $args['last_name'] );
|
||||
}
|
||||
if ( isset( $args['user_email'] ) ) {
|
||||
$args['user_email'] = sanitize_email( $args['user_email'] );
|
||||
}
|
||||
if ( isset( $args['single_user_password'] ) ) {
|
||||
$args['single_user_password'] = sanitize_text_field( $args['single_user_password'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $args['user_login'] ) && ! validate_username( $args['user_login'] ) ) {
|
||||
UM()->form()->add_error( 'user_login', __( 'Your username is invalid', 'ultimate-member' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $args['first_name'] ) && ( strlen( trim( $args['first_name'] ) ) === 0 && $account_name_require ) ) {
|
||||
UM()->form()->add_error( 'first_name', __( 'You must provide your first name', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( isset( $args['last_name'] ) && ( strlen( trim( $args['last_name'] ) ) === 0 && $account_name_require ) ) {
|
||||
UM()->form()->add_error( 'last_name', __( 'You must provide your last name', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( isset( $args['user_email'] ) ) {
|
||||
|
||||
if ( strlen( trim( $args['user_email'] ) ) === 0 ) {
|
||||
UM()->form()->add_error( 'user_email', __( 'You must provide your e-mail', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( ! is_email( $args['user_email'] ) ) {
|
||||
UM()->form()->add_error( 'user_email', __( 'Please provide a valid e-mail', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( email_exists( $args['user_email'] ) && email_exists( $args['user_email'] ) !== get_current_user_id() ) {
|
||||
UM()->form()->add_error( 'user_email', __( 'Email already linked to another account', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
|
||||
// check account password
|
||||
if ( UM()->account()->current_password_is_required( 'general' ) ) {
|
||||
if ( strlen( trim( $args['single_user_password'] ) ) === 0 ) {
|
||||
UM()->form()->add_error( 'single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
|
||||
} else {
|
||||
if ( ! wp_check_password( $args['single_user_password'], $user->data->user_pass, $user->data->ID ) ) {
|
||||
UM()->form()->add_error( 'single_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_submit_account_{$tab}_tab_errors_hook
|
||||
* @description On submit account current $tab validation
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'function_name', 10 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'my_submit_account_tab_errors', 10 );
|
||||
* function my_submit_account_tab_errors() {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_submit_account_' . $tab . '_tab_errors_hook' );
|
||||
break;
|
||||
}
|
||||
|
||||
UM()->account()->current_tab = $tab;
|
||||
}
|
||||
add_action( 'um_submit_account_errors_hook', 'um_submit_account_errors_hook' );
|
||||
|
||||
@@ -172,16 +195,16 @@ add_action( 'um_submit_account_errors_hook', 'um_submit_account_errors_hook' );
|
||||
* @param $args
|
||||
*/
|
||||
function um_submit_account_details( $args ) {
|
||||
$tab = ( get_query_var('um_tab') ) ? get_query_var('um_tab') : 'general';
|
||||
$tab = ( get_query_var( 'um_tab' ) ) ? get_query_var( 'um_tab' ) : 'general';
|
||||
|
||||
$current_tab = isset( $_POST['_um_account_tab'] ) ? $_POST['_um_account_tab']: '';
|
||||
$current_tab = isset( $args['_um_account_tab'] ) ? sanitize_key( $args['_um_account_tab'] ) : '';
|
||||
|
||||
$user_id = um_user('ID');
|
||||
$user_id = um_user( 'ID' );
|
||||
|
||||
//change password account's tab
|
||||
if ( 'password' == $current_tab && $_POST['user_password'] && $_POST['confirm_user_password'] ) {
|
||||
if ( 'password' === $current_tab && $args['user_password'] && $args['confirm_user_password'] ) {
|
||||
|
||||
$changes['user_pass'] = $_POST['user_password'];
|
||||
$changes['user_pass'] = sanitize_text_field( $args['user_password'] );
|
||||
|
||||
$args['user_id'] = $user_id;
|
||||
|
||||
@@ -195,16 +218,20 @@ function um_submit_account_details( $args ) {
|
||||
|
||||
wp_set_password( $changes['user_pass'], $user_id );
|
||||
|
||||
wp_signon( array( 'user_login' => um_user( 'user_login' ), 'user_password' => $changes['user_pass'] ) );
|
||||
wp_signon(
|
||||
array(
|
||||
'user_login' => um_user( 'user_login' ),
|
||||
'user_password' => $changes['user_pass'],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// delete account
|
||||
if ( 'delete' == $current_tab ) {
|
||||
if ( 'delete' === $current_tab ) {
|
||||
if ( current_user_can( 'delete_users' ) || um_user( 'can_delete_profile' ) ) {
|
||||
UM()->user()->delete();
|
||||
|
||||
if ( um_user( 'after_delete' ) && um_user( 'after_delete' ) == 'redirect_home' ) {
|
||||
if ( um_user( 'after_delete' ) && um_user( 'after_delete' ) === 'redirect_home' ) {
|
||||
um_redirect_home();
|
||||
} elseif ( um_user( 'delete_redirect_url' ) ) {
|
||||
/**
|
||||
@@ -271,26 +298,40 @@ function um_submit_account_details( $args ) {
|
||||
}
|
||||
|
||||
$changes = array();
|
||||
foreach ( $_POST as $k => $v ) {
|
||||
if ( ! in_array( $k, $arr_fields ) ) {
|
||||
foreach ( $args as $k => $v ) {
|
||||
if ( ! in_array( $k, $arr_fields, true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $k == 'single_user_password' ) {
|
||||
if ( 'single_user_password' === $k ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( 'user_login' === $k ) {
|
||||
$v = sanitize_user( $v );
|
||||
} elseif ( 'first_name' === $k ) {
|
||||
$v = sanitize_text_field( $v );
|
||||
} elseif ( 'last_name' === $k ) {
|
||||
$v = sanitize_text_field( $v );
|
||||
} elseif ( 'user_email' === $k ) {
|
||||
$v = sanitize_email( $v );
|
||||
} elseif ( 'user_password' === $k ) {
|
||||
$v = sanitize_text_field( $v );
|
||||
} elseif ( 'hide_in_members' === $k ) {
|
||||
$v = array_map( 'sanitize_text_field', $v );
|
||||
}
|
||||
|
||||
$changes[ $k ] = $v;
|
||||
}
|
||||
|
||||
if ( isset( $changes['hide_in_members'] ) ) {
|
||||
if ( UM()->member_directory()->get_hide_in_members_default() ) {
|
||||
if ( $changes['hide_in_members'] == __( 'Yes', 'ultimate-member' ) || $changes['hide_in_members'] == 'Yes' || array_intersect( array( 'Yes', __( 'Yes', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
|
||||
if ( __( 'Yes', 'ultimate-member' ) === $changes['hide_in_members'] || 'Yes' === $changes['hide_in_members'] || array_intersect( array( 'Yes', __( 'Yes', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
|
||||
delete_user_meta( $user_id, 'hide_in_members' );
|
||||
unset( $changes['hide_in_members'] );
|
||||
}
|
||||
} else {
|
||||
if ( $changes['hide_in_members'] == __( 'No', 'ultimate-member' ) || $changes['hide_in_members'] == 'No' || array_intersect( array( 'No', __( 'No', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
|
||||
if ( __( 'No', 'ultimate-member' ) === $changes['hide_in_members'] || 'No' === $changes['hide_in_members'] || array_intersect( array( 'No', __( 'No', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
|
||||
delete_user_meta( $user_id, 'hide_in_members' );
|
||||
unset( $changes['hide_in_members'] );
|
||||
}
|
||||
@@ -667,19 +708,20 @@ function um_request_user_data() {
|
||||
wp_send_json_error( __( 'Wrong request.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$password = ! empty( $_POST['password'] ) ? $_POST['password'] : '';
|
||||
$user = get_userdata( $user_id );
|
||||
$hash = $user->data->user_pass;
|
||||
$user_id = get_current_user_id();
|
||||
$password = ! empty( $_POST['password'] ) ? sanitize_text_field( $_POST['password'] ) : '';
|
||||
$user = get_userdata( $user_id );
|
||||
$hash = $user->data->user_pass;
|
||||
$request_action = sanitize_key( $_POST['request_action'] );
|
||||
|
||||
if ( $_POST['request_action'] == 'um-export-data' ) {
|
||||
if ( 'um-export-data' === $request_action ) {
|
||||
if ( UM()->account()->current_password_is_required( 'privacy_download_data' ) ) {
|
||||
if ( ! wp_check_password( $password, $hash ) ) {
|
||||
$answer = esc_html__( 'The password you entered is incorrect.', 'ultimate-member' );
|
||||
wp_send_json_success( array( 'answer' => $answer ) );
|
||||
}
|
||||
}
|
||||
} elseif ( $_POST['request_action'] == 'um-erase-data' ) {
|
||||
} elseif ( 'um-erase-data' === $request_action ) {
|
||||
if ( UM()->account()->current_password_is_required( 'privacy_erase_data' ) ) {
|
||||
if ( ! wp_check_password( $password, $hash ) ) {
|
||||
$answer = esc_html__( 'The password you entered is incorrect.', 'ultimate-member' );
|
||||
@@ -688,13 +730,13 @@ function um_request_user_data() {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $_POST['request_action'] == 'um-export-data' ) {
|
||||
if ( 'um-export-data' === $request_action ) {
|
||||
$request_id = wp_create_user_request( $user->data->user_email, 'export_personal_data' );
|
||||
} elseif ( $_POST['request_action'] == 'um-erase-data' ) {
|
||||
} elseif ( 'um-erase-data' === $request_action ) {
|
||||
$request_id = wp_create_user_request( $user->data->user_email, 'remove_personal_data' );
|
||||
}
|
||||
|
||||
if ( ! isset( $request_id ) || empty( $request_id ) ) {
|
||||
if ( ! isset( $request_id ) || empty( $request_id ) ) {
|
||||
wp_send_json_error( __( 'Wrong request.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
@@ -707,4 +749,4 @@ function um_request_user_data() {
|
||||
|
||||
wp_send_json_success( array( 'answer' => $answer ) );
|
||||
}
|
||||
add_action( 'wp_ajax_um_request_user_data', 'um_request_user_data' );
|
||||
add_action( 'wp_ajax_um_request_user_data', 'um_request_user_data' );
|
||||
|
||||
@@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
function ultimatemember_check_username_exists() {
|
||||
UM()->check_ajax_nonce();
|
||||
|
||||
$username = isset( $_REQUEST['username'] ) ? $_REQUEST['username'] : '';
|
||||
$username = isset( $_REQUEST['username'] ) ? sanitize_user( $_REQUEST['username'] ) : '';
|
||||
$exists = username_exists( $username );
|
||||
|
||||
/**
|
||||
@@ -46,4 +46,4 @@ function ultimatemember_check_username_exists() {
|
||||
die();
|
||||
}
|
||||
add_action('wp_ajax_nopriv_ultimatemember_check_username_exists', 'ultimatemember_check_username_exists');
|
||||
add_action('wp_ajax_ultimatemember_check_username_exists', 'ultimatemember_check_username_exists');
|
||||
add_action('wp_ajax_ultimatemember_check_username_exists', 'ultimatemember_check_username_exists');
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the requests of UM actions
|
||||
@@ -18,29 +19,25 @@ function um_action_request_process() {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['uid'] ) && ! UM()->user()->user_exists_by_id( absint( $_REQUEST['uid'] ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['uid'] ) ) {
|
||||
if ( is_super_admin( $_REQUEST['uid'] ) ) {
|
||||
wp_die( __( 'Super administrators can not be modified.', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
|
||||
// if ( isset( $_REQUEST['um_action'] ) && $_REQUEST['um_action'] != "edit" && ! current_user_can( 'edit_users' ) ) {
|
||||
// wp_die( __( 'You do not have enough permissions to do that.','ultimate-member') );
|
||||
// }
|
||||
$action = sanitize_key( $_REQUEST['um_action'] );
|
||||
|
||||
$uid = 0;
|
||||
if ( isset( $_REQUEST['uid'] ) ) {
|
||||
$uid = absint( $_REQUEST['uid'] );
|
||||
}
|
||||
|
||||
$role = get_role( UM()->roles()->get_priority_user_role( get_current_user_id() ) );
|
||||
if ( ! empty( $uid ) && ! UM()->user()->user_exists_by_id( $uid ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! empty( $uid ) && is_super_admin( $uid ) ) {
|
||||
wp_die( esc_html__( 'Super administrators can not be modified.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$role = get_role( UM()->roles()->get_priority_user_role( get_current_user_id() ) );
|
||||
$can_edit_users = current_user_can( 'edit_users' ) && $role->has_cap( 'edit_users' );
|
||||
|
||||
switch ( $_REQUEST['um_action'] ) {
|
||||
switch ( $action ) {
|
||||
default:
|
||||
/**
|
||||
* UM hook
|
||||
@@ -62,7 +59,7 @@ function um_action_request_process() {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_action_user_request_hook', $_REQUEST['um_action'], $uid );
|
||||
do_action( 'um_action_user_request_hook', $action, $uid );
|
||||
break;
|
||||
|
||||
case 'edit':
|
||||
@@ -89,7 +86,7 @@ function um_action_request_process() {
|
||||
|
||||
case 'um_reject_membership':
|
||||
if ( ! $can_edit_users ) {
|
||||
wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
|
||||
wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
um_fetch_user( $uid );
|
||||
@@ -100,7 +97,7 @@ function um_action_request_process() {
|
||||
case 'um_approve_membership':
|
||||
case 'um_reenable':
|
||||
if ( ! $can_edit_users ) {
|
||||
wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
|
||||
wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
|
||||
@@ -113,7 +110,7 @@ function um_action_request_process() {
|
||||
|
||||
case 'um_put_as_pending':
|
||||
if ( ! $can_edit_users ) {
|
||||
wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
|
||||
wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
um_fetch_user( $uid );
|
||||
@@ -123,7 +120,7 @@ function um_action_request_process() {
|
||||
|
||||
case 'um_resend_activation':
|
||||
if ( ! $can_edit_users ) {
|
||||
wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
|
||||
wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
add_filter( 'um_template_tags_patterns_hook', array( UM()->user(), 'add_activation_placeholder' ), 10, 1 );
|
||||
@@ -136,7 +133,7 @@ function um_action_request_process() {
|
||||
|
||||
case 'um_deactivate':
|
||||
if ( ! $can_edit_users ) {
|
||||
wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
|
||||
wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
um_fetch_user( $uid );
|
||||
@@ -146,7 +143,7 @@ function um_action_request_process() {
|
||||
|
||||
case 'um_delete':
|
||||
if ( ! UM()->roles()->um_current_user_can( 'delete', $uid ) ) {
|
||||
wp_die( __( 'You do not have permission to delete this user.', 'ultimate-member' ) );
|
||||
wp_die( esc_html__( 'You do not have permission to delete this user.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
um_fetch_user( $uid );
|
||||
@@ -156,4 +153,4 @@ function um_action_request_process() {
|
||||
|
||||
}
|
||||
}
|
||||
add_action( 'template_redirect', 'um_action_request_process', 10000 );
|
||||
add_action( 'template_redirect', 'um_action_request_process', 10000 );
|
||||
|
||||
@@ -127,7 +127,7 @@ function um_submit_form_errors_hook_logincheck( $args ) {
|
||||
um_fetch_user( $user_id );
|
||||
|
||||
$status = um_user( 'account_status' ); // account status
|
||||
switch( $status ) {
|
||||
switch ( $status ) {
|
||||
|
||||
// If user can't login to site...
|
||||
case 'inactive':
|
||||
@@ -135,7 +135,7 @@ function um_submit_form_errors_hook_logincheck( $args ) {
|
||||
case 'awaiting_email_confirmation':
|
||||
case 'rejected':
|
||||
um_reset_user();
|
||||
exit( wp_redirect( add_query_arg( 'err', esc_attr( $status ), UM()->permalinks()->get_current_url() ) ) );
|
||||
exit( wp_redirect( add_query_arg( 'err', esc_attr( $status ), UM()->permalinks()->get_current_url() ) ) );
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -183,10 +183,10 @@ add_action( 'wp_login', 'um_store_lastlogin_timestamp_' );
|
||||
function um_user_login( $args ) {
|
||||
extract( $args );
|
||||
|
||||
$rememberme = ( isset( $args['rememberme'] ) && 1 == $args['rememberme'] && isset( $_REQUEST['rememberme'] ) ) ? 1 : 0;
|
||||
$rememberme = ( isset( $args['rememberme'] ) && 1 == $args['rememberme'] && isset( $_REQUEST['rememberme'] ) ) ? 1 : 0;
|
||||
|
||||
if ( ( UM()->options()->get( 'deny_admin_frontend_login' ) && ! isset( $_GET['provider'] ) ) && strrpos( um_user('wp_roles' ), 'administrator' ) !== false ) {
|
||||
wp_die( __( 'This action has been prevented for security measures.', 'ultimate-member' ) );
|
||||
wp_die( esc_html__( 'This action has been prevented for security measures.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
UM()->user()->auto_login( um_user( 'ID' ), $rememberme );
|
||||
@@ -475,4 +475,4 @@ add_action( 'um_after_login_fields', 'um_after_login_submit', 1001 );
|
||||
function um_add_login_fields( $args ) {
|
||||
echo UM()->fields()->display( 'login', $args );
|
||||
}
|
||||
add_action( 'um_main_login_fields', 'um_add_login_fields', 100 );
|
||||
add_action( 'um_main_login_fields', 'um_add_login_fields', 100 );
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@ function um_browser_url_redirect_to( $args ) {
|
||||
|
||||
if ( ! empty( $_REQUEST['redirect_to'] ) ) {
|
||||
|
||||
$url = $_REQUEST['redirect_to'];
|
||||
$url = esc_url_raw( $_REQUEST['redirect_to'] );
|
||||
|
||||
} elseif ( ! empty( $args['after_login'] ) ) {
|
||||
|
||||
@@ -75,12 +75,12 @@ add_action( 'um_after_form_fields', 'um_browser_url_redirect_to' );
|
||||
function um_add_update_notice( $args ) {
|
||||
extract( $args );
|
||||
|
||||
$output = '';
|
||||
$err = '';
|
||||
$output = '';
|
||||
$err = '';
|
||||
$success = '';
|
||||
|
||||
if ( ! empty( $_REQUEST['updated'] ) && ! UM()->form()->errors ) {
|
||||
switch ( $_REQUEST['updated'] ) {
|
||||
switch ( sanitize_key( $_REQUEST['updated'] ) ) {
|
||||
default:
|
||||
/**
|
||||
* UM hook
|
||||
@@ -104,7 +104,7 @@ function um_add_update_notice( $args ) {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$success = apply_filters( 'um_custom_success_message_handler', $success, $_REQUEST['updated'] );
|
||||
$success = apply_filters( 'um_custom_success_message_handler', $success, sanitize_key( $_REQUEST['updated'] ) );
|
||||
break;
|
||||
|
||||
case 'account':
|
||||
@@ -123,7 +123,7 @@ function um_add_update_notice( $args ) {
|
||||
}
|
||||
|
||||
if ( ! empty( $_REQUEST['err'] ) && ! UM()->form()->errors ) {
|
||||
switch( $_REQUEST['err'] ) {
|
||||
switch( sanitize_key( $_REQUEST['err'] ) ) {
|
||||
|
||||
default:
|
||||
/**
|
||||
@@ -148,7 +148,7 @@ function um_add_update_notice( $args ) {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$err = apply_filters( 'um_custom_error_message_handler', $err, $_REQUEST['err'] );
|
||||
$err = apply_filters( 'um_custom_error_message_handler', $err, sanitize_key( $_REQUEST['err'] ) );
|
||||
if ( ! $err ) {
|
||||
$err = __( 'An error has been encountered', 'ultimate-member' );
|
||||
}
|
||||
@@ -203,4 +203,4 @@ function um_add_update_notice( $args ) {
|
||||
|
||||
echo $output;
|
||||
}
|
||||
add_action( 'um_before_form', 'um_add_update_notice', 500 );
|
||||
add_action( 'um_before_form', 'um_add_update_notice', 500 );
|
||||
|
||||
@@ -168,16 +168,16 @@ function um_profile_content_main( $args ) {
|
||||
*/
|
||||
do_action( 'um_after_form', $args );
|
||||
|
||||
} else { ?>
|
||||
|
||||
} else {
|
||||
?>
|
||||
<div class="um-profile-note">
|
||||
<span>
|
||||
<i class="um-faicon-lock"></i>
|
||||
<?php echo $can_view; ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<?php }
|
||||
<?php
|
||||
}
|
||||
}
|
||||
add_action( 'um_profile_content_main', 'um_profile_content_main' );
|
||||
|
||||
@@ -1732,4 +1732,4 @@ function um_profile_menu( $args ) {
|
||||
}
|
||||
|
||||
}
|
||||
add_action( 'um_profile_menu', 'um_profile_menu', 9 );
|
||||
add_action( 'um_profile_menu', 'um_profile_menu', 9 );
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if user can access the backend
|
||||
*/
|
||||
function um_block_wpadmin_by_user_role() {
|
||||
|
||||
global $pagenow;
|
||||
|
||||
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
|
||||
@@ -49,4 +48,4 @@ add_filter( 'show_admin_bar', 'um_control_admin_bar', 9999, 1 );
|
||||
function um_force_admin_bar() {
|
||||
um_reset_user();
|
||||
}
|
||||
add_action( 'wp_footer', 'um_force_admin_bar' );
|
||||
add_action( 'wp_footer', 'um_force_admin_bar' );
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,7 +57,7 @@ function um_profile_field_filter_hook__youtube_video( $value, $data ) {
|
||||
if ( empty( $value ) ) {
|
||||
return '';
|
||||
}
|
||||
$value = ( strstr( $value, 'http') || strstr( $value, '://' ) ) ? um_youtube_id_from_url( $value ) : $value;
|
||||
$value = ( strstr( $value, 'http' ) || strstr( $value, '://' ) ) ? um_youtube_id_from_url( $value ) : $value;
|
||||
$value = '<div class="um-youtube">
|
||||
<iframe width="600" height="450" src="https://www.youtube.com/embed/' . $value . '" frameborder="0" allowfullscreen></iframe>
|
||||
</div>';
|
||||
@@ -78,9 +80,9 @@ function um_profile_field_filter_hook__vimeo_video( $value, $data ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$value = ( !is_numeric( $value ) ) ? (int) substr(parse_url($value, PHP_URL_PATH), 1) : $value;
|
||||
$value = ! is_numeric( $value ) ? (int) substr( parse_url( $value, PHP_URL_PATH ), 1 ) : $value;
|
||||
$value = '<div class="um-vimeo">
|
||||
<iframe src="https://player.vimeo.com/video/'. $value . '" width="600" height="450" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
|
||||
<iframe src="https://player.vimeo.com/video/' . $value . '" width="600" height="450" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
|
||||
</div>';
|
||||
return $value;
|
||||
}
|
||||
@@ -341,10 +343,10 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( ( isset( $data['validate'] ) && $data['validate'] != '' && strstr( $data['validate'], 'url' ) ) || ( isset( $data['type'] ) && $data['type'] == 'url' ) ) {
|
||||
if ( ( isset( $data['validate'] ) && $data['validate'] !== '' && strstr( $data['validate'], 'url' ) ) || ( isset( $data['type'] ) && $data['type'] == 'url' ) ) {
|
||||
$alt = ( isset( $data['url_text'] ) && !empty( $data['url_text'] ) ) ? $data['url_text'] : $value;
|
||||
$url_rel = ( isset( $data['url_rel'] ) && $data['url_rel'] == 'nofollow' ) ? 'rel="nofollow"' : '';
|
||||
if( !strstr( $value, 'http' )
|
||||
if ( ! strstr( $value, 'http' )
|
||||
&& !strstr( $value, '://' )
|
||||
&& !strstr( $value, 'www.' )
|
||||
&& !strstr( $value, '.com' )
|
||||
@@ -363,13 +365,9 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
|
||||
}
|
||||
|
||||
|
||||
if ( isset( $data['validate'] ) && $data['validate'] == 'skype' ) {
|
||||
if ( ! ( isset( $data['validate'] ) && $data['validate'] == 'skype' ) ) {
|
||||
|
||||
$value = $value;
|
||||
|
||||
} else {
|
||||
|
||||
if ( strpos($value, 'http://') !== 0 ) {
|
||||
if ( strpos( $value, 'http://' ) !== 0 ) {
|
||||
$value = 'http://' . $value;
|
||||
}
|
||||
$data['url_target'] = ( isset( $data['url_target'] ) ) ? $data['url_target'] : '_blank';
|
||||
@@ -456,7 +454,7 @@ function um_get_custom_field_array( $array, $fields ) {
|
||||
$condition_metakey = $fields[ $value[1] ]['metakey'];
|
||||
|
||||
if ( isset( $_POST[ $condition_metakey ] ) ) {
|
||||
$cond_value = ( $fields[ $value[1] ]['type'] == 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ];
|
||||
$cond_value = ( $fields[ $value[1] ]['type'] === 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ];
|
||||
list( $visibility, $parent_key, $op, $parent_value ) = $value;
|
||||
|
||||
if ( $visibility == 'hide' ) {
|
||||
@@ -849,4 +847,4 @@ function um_edit_url_field_value( $value, $key ) {
|
||||
$value = esc_attr( $value );
|
||||
return $value;
|
||||
}
|
||||
add_filter( 'um_edit_url_field_value', 'um_edit_url_field_value', 10, 2 );
|
||||
add_filter( 'um_edit_url_field_value', 'um_edit_url_field_value', 10, 2 );
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -10,16 +12,18 @@
|
||||
*/
|
||||
function um_whitelisted_wpadmin_access( $allowed ) {
|
||||
$ips = UM()->options()->get( 'wpadmin_allow_ips' );
|
||||
|
||||
if ( !$ips )
|
||||
|
||||
if ( ! $ips ) {
|
||||
return $allowed;
|
||||
|
||||
$ips = array_map("rtrim", explode("\n", $ips));
|
||||
}
|
||||
|
||||
$ips = array_map( 'rtrim', explode( "\n", $ips ) );
|
||||
$user_ip = um_user_ip();
|
||||
|
||||
if ( in_array( $user_ip, $ips ) )
|
||||
if ( in_array( $user_ip, $ips, true ) ) {
|
||||
$allowed = 1;
|
||||
|
||||
}
|
||||
|
||||
return $allowed;
|
||||
}
|
||||
add_filter( 'um_whitelisted_wpadmin_access', 'um_whitelisted_wpadmin_access' );
|
||||
@@ -35,7 +39,7 @@ add_filter( 'um_whitelisted_wpadmin_access', 'um_whitelisted_wpadmin_access' );
|
||||
function um_custom_wp_err_messages( $message ) {
|
||||
|
||||
if ( ! empty( $_REQUEST['err'] ) ) {
|
||||
switch( $_REQUEST['err'] ) {
|
||||
switch ( sanitize_key( $_REQUEST['err'] ) ) {
|
||||
case 'blocked_email':
|
||||
$err = __( 'This email address has been blocked.', 'ultimate-member' );
|
||||
break;
|
||||
@@ -126,4 +130,4 @@ function um_lostpassword_url( $lostpassword_url ) {
|
||||
|
||||
return $lostpassword_url;
|
||||
}
|
||||
add_filter( 'lostpassword_url', 'um_lostpassword_url', 10, 1 );
|
||||
add_filter( 'lostpassword_url', 'um_lostpassword_url', 10, 1 );
|
||||
|
||||
@@ -697,6 +697,7 @@ function um_user_submitted_registration_formatted( $style = false ) {
|
||||
|
||||
if ( isset( $submitted_data['form_id'] ) ) {
|
||||
$fields = UM()->query()->get_attr( 'custom_fields', $submitted_data['form_id'] );
|
||||
$fields = maybe_unserialize( $fields );
|
||||
}
|
||||
|
||||
if ( isset( $fields ) ) {
|
||||
@@ -717,10 +718,10 @@ function um_user_submitted_registration_formatted( $style = false ) {
|
||||
if ( empty( $rows ) ) {
|
||||
$rows = array(
|
||||
'_um_row_1' => array(
|
||||
'type' => 'row',
|
||||
'id' => '_um_row_1',
|
||||
'sub_rows' => 1,
|
||||
'cols' => 1
|
||||
'type' => 'row',
|
||||
'id' => '_um_row_1',
|
||||
'sub_rows' => 1,
|
||||
'cols' => 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1490,7 +1491,7 @@ function um_edit_my_profile_cancel_uri( $url = '' ) {
|
||||
* @return bool
|
||||
*/
|
||||
function um_is_on_edit_profile() {
|
||||
if ( isset( $_REQUEST['um_action'] ) && $_REQUEST['um_action'] == 'edit' ) {
|
||||
if ( isset( $_REQUEST['um_action'] ) && sanitize_key( $_REQUEST['um_action'] ) == 'edit' ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2623,15 +2624,15 @@ function um_secure_media_uri( $url ) {
|
||||
*/
|
||||
function um_force_utf8_string( $value ) {
|
||||
|
||||
if (is_array( $value )) {
|
||||
if ( is_array( $value ) ) {
|
||||
$arr_value = array();
|
||||
foreach ($value as $key => $value) {
|
||||
$utf8_decoded_value = utf8_decode( $value );
|
||||
foreach ( $value as $key => $v ) {
|
||||
$utf8_decoded_value = utf8_decode( $v );
|
||||
|
||||
if (mb_check_encoding( $utf8_decoded_value, 'UTF-8' )) {
|
||||
if ( mb_check_encoding( $utf8_decoded_value, 'UTF-8' ) ) {
|
||||
array_push( $arr_value, $utf8_decoded_value );
|
||||
} else {
|
||||
array_push( $arr_value, $value );
|
||||
array_push( $arr_value, $v );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2798,4 +2799,4 @@ function um_is_amp( $check_theme_support = true ) {
|
||||
}
|
||||
|
||||
return apply_filters( 'um_is_amp', $is_amp );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@ class UM_Search_Widget extends \WP_Widget {
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
|
||||
$title = apply_filters( 'widget_title', $instance['title'] );
|
||||
$title = array_key_exists( 'title', $instance ) ? $instance['title'] : '';
|
||||
$title = apply_filters( 'widget_title', $title );
|
||||
|
||||
// before and after widget arguments are defined by themes
|
||||
echo $args['before_widget'];
|
||||
@@ -107,4 +108,4 @@ class UM_Search_Widget extends \WP_Widget {
|
||||
return $instance;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+29
-1
@@ -7,7 +7,7 @@ Tags: community, member, membership, user-profile, user-registration
|
||||
Requires PHP: 5.6
|
||||
Requires at least: 5.0
|
||||
Tested up to: 5.7
|
||||
Stable tag: 2.1.21
|
||||
Stable tag: 2.2.0
|
||||
License: GNU Version 2 or Any Later Version
|
||||
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
|
||||
@@ -155,6 +155,34 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
|
||||
* To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0)
|
||||
* UM2.1+ is a significant update to the Member Directories' code base from 2.0.x. Please make sure you take a full-site backup with restore point before updating the plugin
|
||||
|
||||
= 2.2.0: July 20, 2021 =
|
||||
|
||||
* Enhancements:
|
||||
|
||||
- Added: Sanitizing handlers to the Ultimate Member > Settings forms' fields
|
||||
- Added: Sanitizing handlers to the Ultimate Member > User Role Add/Edit forms' fields
|
||||
- Added: Sanitizing handlers to the Ultimate Member > Forms forms' fields
|
||||
- Added: Sanitizing handlers to the Ultimate Member > Forms > Add Field/Edit Field forms' fields
|
||||
- Added: Sanitizing handlers to the Ultimate Member > User Roles forms' fields
|
||||
- Added: Sanitizing handlers to the Restriction Content forms' fields in the posts/pages/menus additional fields
|
||||
- Added: Sanitizing handlers to the all (Login/Registration/Profile/Account) frontend forms' fields
|
||||
- Added: Custom placeholder setting for the Confirm Password field
|
||||
|
||||
* Bugfixes:
|
||||
|
||||
- Fixed: Content restriction settings using in Avada theme with active page headers
|
||||
- Fixed: Content restriction (CPT + Terms). Avoid displaying comments if the post is restricted
|
||||
- Fixed: Content restriction (CPT + Terms). Avoid displaying comments and posts feed
|
||||
- Fixed: Content restriction (CPT + Terms). Displaying the proper count of the posts. Restricted are excluded
|
||||
- Fixed: Saving and displaying settings on the UM > Settings > Access screen
|
||||
- Fixed: Saving and displaying default Member Directory settings
|
||||
- Fixed: Minor PHP warnings on registration data preview
|
||||
- Fixed: Member directory slider filter-type query and results
|
||||
|
||||
* Tweaks:
|
||||
|
||||
- WordPress 5.8 compatibility. Widgets screen changes based on the new features with Legacy Widget block
|
||||
|
||||
= 2.1.21: June 17, 2021 =
|
||||
|
||||
* Enhancements:
|
||||
|
||||
@@ -25,4 +25,4 @@
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -95,17 +95,17 @@ if ( ! empty( $args['enable_sorting'] ) ) {
|
||||
}
|
||||
|
||||
$sorting_options = apply_filters( 'um_member_directory_pre_display_sorting', $sorting_options, $args );
|
||||
$sort_from_url = ( ! empty( $_GET[ 'sort_' . $unique_hash ] ) && in_array( $_GET[ 'sort_' . $unique_hash ], array_keys( $sorting_options ) ) ) ? $_GET[ 'sort_' . $unique_hash ] : $default_sorting;
|
||||
$sort_from_url = ( ! empty( $_GET[ 'sort_' . $unique_hash ] ) && in_array( sanitize_text_field( $_GET[ 'sort_' . $unique_hash ] ), array_keys( $sorting_options ) ) ) ? sanitize_text_field( $_GET[ 'sort_' . $unique_hash ] ) : $default_sorting;
|
||||
}
|
||||
|
||||
$current_page = ( ! empty( $_GET[ 'page_' . $unique_hash ] ) && is_numeric( $_GET[ 'page_' . $unique_hash ] ) ) ? (int) $_GET[ 'page_' . $unique_hash ] : 1;
|
||||
$current_page = ( ! empty( $_GET[ 'page_' . $unique_hash ] ) && is_numeric( $_GET[ 'page_' . $unique_hash ] ) ) ? absint( $_GET[ 'page_' . $unique_hash ] ) : 1;
|
||||
|
||||
//Search
|
||||
$search = isset( $args['search'] ) ? $args['search'] : false;
|
||||
$show_search = empty( $args['roles_can_search'] ) || ( ! empty( $priority_user_role ) && in_array( $priority_user_role, $args['roles_can_search'] ) );
|
||||
$search_from_url = '';
|
||||
if ( $search && $show_search ) {
|
||||
$search_from_url = ! empty( $_GET[ 'search_' . $unique_hash ] ) ? stripslashes( $_GET[ 'search_' . $unique_hash ] ) : '';
|
||||
$search_from_url = ! empty( $_GET[ 'search_' . $unique_hash ] ) ? stripslashes( sanitize_text_field( $_GET[ 'search_' . $unique_hash ] ) ) : '';
|
||||
}
|
||||
|
||||
|
||||
@@ -374,4 +374,4 @@ if ( ( ( $search && $show_search ) || ( $filters && $show_filters && count( $sea
|
||||
*/
|
||||
do_action( 'um_members_directory_footer', $args, $form_id, $not_searched ); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} ?>
|
||||
|
||||
<div class="um <?php echo esc_attr( $this->get_class( $mode ) ); ?> um-<?php echo esc_attr( $form_id ); ?>">
|
||||
<div class="um-form">
|
||||
<form method="post" action="">
|
||||
<?php if ( isset( $_GET['updated'] ) && 'checkemail' == $_GET['updated'] ) { ?>
|
||||
<?php if ( isset( $_GET['updated'] ) && 'checkemail' === sanitize_key( $_GET['updated'] ) ) { ?>
|
||||
<div class="um-field um-field-block um-field-type_block">
|
||||
<div class="um-field-block">
|
||||
<div style="text-align:center;">
|
||||
<?php _e( 'We have sent you a password reset link to your e-mail. Please check your inbox.', 'ultimate-member' ); ?>
|
||||
<?php esc_html_e( 'We have sent you a password reset link to your e-mail. Please check your inbox.', 'ultimate-member' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -41,9 +43,9 @@
|
||||
<div class="um-field um-field-block um-field-type_block">
|
||||
<div class="um-field-block">
|
||||
<div style="text-align:center;">
|
||||
<?php if ( 'expiredkey' == $_GET['updated'] ) {
|
||||
<?php if ( 'expiredkey' === sanitize_key( $_GET['updated'] ) ) {
|
||||
_e( 'Your password reset link has expired. Please request a new link below.', 'ultimate-member' );
|
||||
} elseif ( 'invalidkey' == $_GET['updated'] ) {
|
||||
} elseif ( 'invalidkey' === sanitize_key( $_GET['updated'] ) ) {
|
||||
_e( 'Your password reset link appears to be invalid. Please request a new link below.', 'ultimate-member' );
|
||||
} ?>
|
||||
</div>
|
||||
@@ -143,4 +145,4 @@
|
||||
} ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
Plugin Name: Ultimate Member
|
||||
Plugin URI: http://ultimatemember.com/
|
||||
Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
|
||||
Version: 2.1.21
|
||||
Version: 2.2.0
|
||||
Author: Ultimate Member
|
||||
Author URI: http://ultimatemember.com/
|
||||
Text Domain: ultimate-member
|
||||
|
||||
Reference in New Issue
Block a user