mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-18 06:03:38 +09:00
Merge branch 'some_changes'
This commit is contained in:
@@ -99,7 +99,7 @@
|
||||
.um img {box-shadow: none !important}
|
||||
|
||||
.um-col {padding-bottom: 20px}
|
||||
.um-col-alt {margin: 0 0 5px 0}
|
||||
.um-col-alt {margin: 15px 0 5px 0}
|
||||
.um-col-alt-s {padding-top: 10px}
|
||||
.um-col-alt-b {padding-top: 20px}
|
||||
|
||||
@@ -440,6 +440,10 @@ p.um-notice.warning {
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
.um-form .um-meta-text textarea {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.um-form .wp-editor-container {
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
@@ -455,9 +459,9 @@ p.um-notice.warning {
|
||||
*/
|
||||
|
||||
.um-field-c .um-field-checkbox {
|
||||
margin: 0 !important;
|
||||
margin-bottom: 14px;
|
||||
margin-top: 0 !important;
|
||||
position: relative;
|
||||
top: -14px;
|
||||
}
|
||||
|
||||
.um-field-checkbox,
|
||||
@@ -467,7 +471,7 @@ p.um-notice.warning {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.um-profile.um-editing .um-field-checkbox,
|
||||
.um-profile.um-editing .um-field-checkbox,
|
||||
.um-profile.um-editing .um-field-radio{
|
||||
cursor: pointer !important;
|
||||
}
|
||||
|
||||
@@ -7,5 +7,11 @@ print ".um-$form_id.um {
|
||||
}";
|
||||
}
|
||||
|
||||
if ( isset( $align ) && in_array( $align, ['left', 'right'] ) ) {
|
||||
print ".um-$form_id.um {
|
||||
margin-$align: 0px !important;
|
||||
}";
|
||||
}
|
||||
|
||||
?>
|
||||
</style>
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
||||
!function(t){"use strict";t(document).on("click","a.um-toggle-gdpr",function(){var e=jQuery(this);t(".um-gdpr-content").toggle("fast",function(){t(".um-gdpr-content").is(":visible")&&e.text(e.data("toggle-hide")),t(".um-gdpr-content").is(":hidden")&&e.text(e.data("toggle-show"))})})}(jQuery);
|
||||
!function(e){"use strict";e(document).on("click","a.um-toggle-gdpr",function(){var t=jQuery(this);e(".um-gdpr-content").toggle("fast",function(){e(".um-gdpr-content").is(":visible")&&t.text(t.data("toggle-hide")),e(".um-gdpr-content").is(":hidden")&&t.text(t.data("toggle-show"))})})}(jQuery);
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
||||
jQuery(document).ready(function(){jQuery(document).on("click",".um-popup-overlay",function(){remove_Modal()}),jQuery(document).on("click",'.um-modal-overlay, a[data-action="um_remove_modal"]',function(){um_remove_modal()}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"], .um-modal a',function(e){return e.preventDefault(),!1}),jQuery(document).on("click",".um-modal .um-single-file-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-fileinfo a").attr("href");return a.find(".um-single-file-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive(),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:t}}),!1}),jQuery(document).on("click",".um-modal .um-single-image-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview img").attr("src");return jQuery("img.cropper-hidden").cropper("destroy"),a.find(".um-single-image-preview img").attr("src",""),a.find(".um-single-image-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive(),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:t}}),!1}),jQuery(document).on("click",".um-finish-upload.file:not(.disabled)",function(){var e=jQuery(this).attr("data-key"),a=jQuery(this).parents(".um-modal-body").find(".um-single-file-preview").html();um_remove_modal(),jQuery(".um-single-file-preview[data-key="+e+"]").fadeIn().html(a);var t=jQuery(".um-field[data-key="+e+"]").find(".um-single-fileinfo a").data("file");jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find(".um-btn-auto-width").html(jQuery(this).attr("data-change")),jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find('input[type="hidden"]').val(t)}),jQuery(document).on("click",".um-finish-upload.image:not(.disabled)",function(){var e=jQuery(this),a=jQuery(this).attr("data-key"),t=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview"),i=t.find("img").attr("src"),r=t.attr("data-coord"),u=t.find("img").data("file"),m=0;jQuery(this).parents("#um_upload_single").data("user_id")&&(m=jQuery(this).parents("#um_upload_single").data("user_id")),r?(jQuery(this).html(jQuery(this).attr("data-processing")).addClass("disabled"),jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_resize_image",src:i,coord:r,user_id:m,key:a},success:function(t){1==t.success&&(d=new Date,"profile_photo"==a&&jQuery(".um-profile-photo-img img").attr("src",t.data.image.source_url+"?"+d.getTime()),"cover_photo"==a&&(jQuery(".um-cover-e").empty().html('<img src="'+t.data.image.source_url+"?"+d.getTime()+'" alt="" />'),jQuery(".um").hasClass("um-editing")&&jQuery(".um-cover-overlay").show()),jQuery(".um-single-image-preview[data-key="+a+"]").fadeIn().find("img").attr("src",t.data.image.source_url+"?"+d.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+a+"]").parents(".um-field").find(".um-btn-auto-width").html(e.attr("data-change")),jQuery(".um-single-image-preview[data-key="+a+"]").parents(".um-field").find('input[type="hidden"]').val(t.data.image.filename))}})):(d=new Date,jQuery(".um-single-image-preview[data-key="+a+"]").fadeIn().find("img").attr("src",i+"?"+d.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+a+"]").parents(".um-field").find(".um-btn-auto-width").html(e.attr("data-change")),jQuery(".um-single-image-preview[data-key="+a+"]").parents(".um-field").find("input[type=hidden]").val(u))}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"]',function(e){var a=jQuery(this).attr("data-modal"),t="normal";if(jQuery(this).data("modal-size"))var t=jQuery(this).data("modal-size");jQuery(this).data("modal-copy")?(jQuery("#"+a).html(jQuery(this).parents(".um-field").find(".um-modal-hidden-content").html()),jQuery(this).parents(".um-profile-photo").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-profile-photo").attr("data-user_id")),jQuery(this).parents(".um-cover").attr("data-ratio")&&jQuery("#"+a).attr("data-ratio",jQuery(this).parents(".um-cover").attr("data-ratio")),jQuery(this).parents(".um-cover").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-cover").attr("data-user_id")),jQuery("input[type=hidden][name='user_id']").length>0&&jQuery("#"+a).attr("data-user_id",jQuery("input[type=hidden][name='user_id']").val()),um_new_modal(a,t)):um_new_modal(a,t)})});
|
||||
jQuery(document).ready(function(){jQuery(document).on("click",".um-popup-overlay",function(){remove_Modal()}),jQuery(document).on("click",'.um-modal-overlay, a[data-action="um_remove_modal"]',function(){um_remove_modal()}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"], .um-modal a',function(e){return e.preventDefault(),!1}),jQuery(document).on("click",".um-modal .um-single-file-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-fileinfo a").attr("href");return a.find(".um-single-file-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive(),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:t}}),!1}),jQuery(document).on("click",".um-modal .um-single-image-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview img").attr("src");return jQuery("img.cropper-hidden").cropper("destroy"),a.find(".um-single-image-preview img").attr("src",""),a.find(".um-single-image-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive(),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:t}}),!1}),jQuery(document).on("click",".um-finish-upload.file:not(.disabled)",function(){var e=jQuery(this).attr("data-key"),a=jQuery(this).parents(".um-modal-body").find(".um-single-file-preview").html();um_remove_modal(),jQuery(".um-single-file-preview[data-key="+e+"]").fadeIn().html(a);var t=jQuery(".um-field[data-key="+e+"]").find(".um-single-fileinfo a").data("file");jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find(".um-btn-auto-width").html(jQuery(this).attr("data-change")),jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find('input[type="hidden"]').val(t)}),jQuery(document).on("click",".um-finish-upload.image:not(.disabled)",function(){var a=jQuery(this),t=jQuery(this).attr("data-key"),e=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview"),i=e.find("img").attr("src"),r=e.attr("data-coord"),u=e.find("img").data("file"),m=0;jQuery(this).parents("#um_upload_single").data("user_id")&&(m=jQuery(this).parents("#um_upload_single").data("user_id")),r?(jQuery(this).html(jQuery(this).attr("data-processing")).addClass("disabled"),jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_resize_image",src:i,coord:r,user_id:m,key:t},success:function(e){1==e.success&&(d=new Date,"profile_photo"==t&&jQuery(".um-profile-photo-img img").attr("src",e.data.image.source_url+"?"+d.getTime()),"cover_photo"==t&&(jQuery(".um-cover-e").empty().html('<img src="'+e.data.image.source_url+"?"+d.getTime()+'" alt="" />'),jQuery(".um").hasClass("um-editing")&&jQuery(".um-cover-overlay").show()),jQuery(".um-single-image-preview[data-key="+t+"]").fadeIn().find("img").attr("src",e.data.image.source_url+"?"+d.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find(".um-btn-auto-width").html(a.attr("data-change")),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find('input[type="hidden"]').val(e.data.image.filename))}})):(d=new Date,jQuery(".um-single-image-preview[data-key="+t+"]").fadeIn().find("img").attr("src",i+"?"+d.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find(".um-btn-auto-width").html(a.attr("data-change")),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find("input[type=hidden]").val(u))}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"]',function(e){var a=jQuery(this).attr("data-modal"),t="normal";if(jQuery(this).data("modal-size"))t=jQuery(this).data("modal-size");jQuery(this).data("modal-copy")&&(jQuery("#"+a).html(jQuery(this).parents(".um-field").find(".um-modal-hidden-content").html()),jQuery(this).parents(".um-profile-photo").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-profile-photo").attr("data-user_id")),jQuery(this).parents(".um-cover").attr("data-ratio")&&jQuery("#"+a).attr("data-ratio",jQuery(this).parents(".um-cover").attr("data-ratio")),jQuery(this).parents(".um-cover").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-cover").attr("data-user_id")),0<jQuery("input[type=hidden][name='user_id']").length&&jQuery("#"+a).attr("data-user_id",jQuery("input[type=hidden][name='user_id']").val())),um_new_modal(a,t)})});
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
jQuery(document).ready(function(){function e(){if("undefined"!=typeof jQuery("textarea[id=um-meta-bio]").val()){var e=jQuery("textarea[id=um-meta-bio]").attr("data-character-limit"),t=e-jQuery("textarea[id=um-meta-bio]").val().length;jQuery("span.um-meta-bio-character span.um-bio-limit").text(t),t<5?jQuery("span.um-meta-bio-character").css("color","red"):jQuery("span.um-meta-bio-character").css("color","")}}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-row-heading,.um-row").remove(),jQuery(".um-profile-note").show()),jQuery(document).on("click",".um-profile-save",function(e){return e.preventDefault(),jQuery(this).parents(".um").find("form").submit(),!1}),jQuery(document).on("click",".um-profile-edit-a",function(e){jQuery(this).addClass("active")}),jQuery(document).on("click",".um-cover a.um-cover-add, .um-photo a",function(e){return e.preventDefault(),!1}),jQuery(document).on("click",".um-photo-modal",function(e){e.preventDefault();var t=jQuery(this).attr("data-src");return um_new_modal("um_view_photo","fit",!0,t),!1}),jQuery(document).on("click",".um-reset-profile-photo",function(e){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",jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_delete_profile_photo",metakey:metakey,user_id:user_id}})}),jQuery(document).on("click",".um-reset-cover-photo",function(e){var t=jQuery(this);jQuery(".um-cover-overlay").hide(),jQuery(".um-cover-e").html('<a href="#" class="um-cover-add um-manual-trigger" data-parent=".um-cover" data-child=".um-btn-auto-width"><span class="um-cover-add-i"><i class="um-icon-plus um-tip-n" title="Upload a cover photo"></i></span></a>'),jQuery(".um-dropdown").hide(),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},success:function(e){t.hide()}})}),e(),jQuery("textarea[id=um-meta-bio]").change(e),jQuery("textarea[id=um-meta-bio]").keyup(e),jQuery(".um-profile-edit a.um_delete-item").click(function(e){e.preventDefault();var t=confirm("Are you sure that you want to delete this user?");if(!t)return!1})});
|
||||
jQuery(document).ready(function(){function e(){if(void 0!==jQuery("textarea[id=um-meta-bio]").val()){var e=jQuery("textarea[id=um-meta-bio]").attr("data-character-limit")-jQuery("textarea[id=um-meta-bio]").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(".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-row-heading,.um-row").remove(),jQuery(".um-profile-note").show()),jQuery(document).on("click",".um-profile-save",function(e){return e.preventDefault(),jQuery(this).parents(".um").find("form").submit(),!1}),jQuery(document).on("click",".um-profile-edit-a",function(e){jQuery(this).addClass("active")}),jQuery(document).on("click",".um-cover a.um-cover-add, .um-photo a",function(e){return e.preventDefault(),!1}),jQuery(document).on("click",".um-photo-modal",function(e){e.preventDefault();var t=jQuery(this).attr("data-src");return um_new_modal("um_view_photo","fit",!0,t),!1}),jQuery(document).on("click",".um-reset-profile-photo",function(e){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",jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_delete_profile_photo",metakey:metakey,user_id:user_id}})}),jQuery(document).on("click",".um-reset-cover-photo",function(e){var t=jQuery(this);jQuery(".um-cover-overlay").hide(),jQuery(".um-cover-e").html('<a href="#" class="um-cover-add um-manual-trigger" data-parent=".um-cover" data-child=".um-btn-auto-width"><span class="um-cover-add-i"><i class="um-icon-plus um-tip-n" title="Upload a cover photo"></i></span></a>'),jQuery(".um-dropdown").hide(),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},success:function(e){t.hide()}})}),e(),jQuery("textarea[id=um-meta-bio]").change(e),jQuery("textarea[id=um-meta-bio]").keyup(e),jQuery(".um-profile-edit a.um_delete-item").click(function(e){if(e.preventDefault(),!confirm("Are you sure that you want to delete this user?"))return!1})});
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -41,9 +41,9 @@ jQuery(document).ready(function() {
|
||||
var field = jQuery(this).parents('.um-field-area');
|
||||
var this_field = jQuery(this).parents('label');
|
||||
field.find('.um-field-radio').removeClass('active');
|
||||
field.find('.um-field-radio').find('i').removeClass().addClass('um-icon-android-radio-button-off');
|
||||
field.find('.um-field-radio').find('i').removeAttr('class').addClass('um-icon-android-radio-button-off');
|
||||
this_field.addClass('active');
|
||||
this_field.find('i').removeClass().addClass('um-icon-android-radio-button-on');
|
||||
this_field.find('i').removeAttr('class').addClass('um-icon-android-radio-button-on');
|
||||
});
|
||||
|
||||
jQuery(document).on('change', '.um-field-area input[type=checkbox]', function(){
|
||||
@@ -52,10 +52,10 @@ jQuery(document).ready(function() {
|
||||
var this_field = jQuery(this).parents('label');
|
||||
if ( this_field.hasClass('active') ) {
|
||||
this_field.removeClass('active');
|
||||
this_field.find('i').removeClass().addClass('um-icon-android-checkbox-outline-blank');
|
||||
this_field.find('i').removeAttr('class').addClass('um-icon-android-checkbox-outline-blank');
|
||||
} else {
|
||||
this_field.addClass('active');
|
||||
this_field.find('i').removeClass().addClass('um-icon-android-checkbox-outline');
|
||||
this_field.find('i').removeAttr('class').addClass('um-icon-android-checkbox-outline');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-2
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
||||
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"undefined"!=typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){"use strict";function t(t){return!t.nodeName||e.inArray(t.nodeName.toLowerCase(),["iframe","#document","html","body"])!==-1}function o(t){return e.isFunction(t)||e.isPlainObject(t)?t:{top:t,left:t}}var n=e.scrollTo=function(t,o,n){return e(window).scrollTo(t,o,n)};return n.defaults={axis:"xy",duration:0,limit:!0},e.fn.scrollTo=function(r,i,s){"object"==typeof i&&(s=i,i=0),"function"==typeof s&&(s={onAfter:s}),"max"===r&&(r=9e9),s=e.extend({},n.defaults,s),i=i||s.duration;var a=s.queue&&s.axis.length>1;return a&&(i/=2),s.offset=o(s.offset),s.over=o(s.over),this.each(function(){function f(t){var o=e.extend({},s,{queue:!0,duration:i,complete:t&&function(){t.call(l,m,s)}});d.animate(p,o)}if(null!==r){var u,c=t(this),l=c?this.contentWindow||window:this,d=e(l),m=r,p={};switch(typeof m){case"number":case"string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(m)){m=o(m);break}if(m=c?e(m):e(m,l),!m.length)return;case"object":(m.is||m.style)&&(u=(m=e(m)).offset())}var h=e.isFunction(s.offset)&&s.offset(l,m)||s.offset;e.each(s.axis.split(""),function(e,t){var o="x"===t?"Left":"Top",r=o.toLowerCase(),i="scroll"+o,x=d[i](),v=n.max(l,t);if(u)p[i]=u[r]+(c?0:x-d.offset()[r]),s.margin&&(p[i]-=parseInt(m.css("margin"+o),10)||0,p[i]-=parseInt(m.css("border"+o+"Width"),10)||0),p[i]+=h[r]||0,s.over[r]&&(p[i]+=m["x"===t?"width":"height"]()*s.over[r]);else{var w=m[r];p[i]=w.slice&&"%"===w.slice(-1)?parseFloat(w)/100*v:w}s.limit&&/^\d+$/.test(p[i])&&(p[i]=p[i]<=0?0:Math.min(p[i],v)),!e&&s.axis.length>1&&(x===p[i]?p={}:a&&(f(s.onAfterFirst),p={}))}),f(s.onAfter)}})},n.max=function(o,n){var r="x"===n?"Width":"Height",i="scroll"+r;if(!t(o))return o[i]-e(o)[r.toLowerCase()]();var s="client"+r,a=o.ownerDocument||o.document,f=a.documentElement,u=a.body;return Math.max(f[i],u[i])-Math.min(f[s],u[s])},e.Tween.propHooks.scrollLeft=e.Tween.propHooks.scrollTop={get:function(t){return e(t.elem)[t.prop]()},set:function(t){var o=this.get(t);if(t.options.interrupt&&t._last&&t._last!==o)return e(t.elem).stop();var n=Math.round(t.now);o!==n&&(e(t.elem)[t.prop](n),t._last=this.get(t))}},n});
|
||||
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"undefined"!=typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(w){"use strict";var y=w.scrollTo=function(e,t,o){return w(window).scrollTo(e,t,o)};function g(e){return!e.nodeName||-1!==w.inArray(e.nodeName.toLowerCase(),["iframe","#document","html","body"])}function t(e){return w.isFunction(e)||w.isPlainObject(e)?e:{top:e,left:e}}return y.defaults={axis:"xy",duration:0,limit:!0},w.fn.scrollTo=function(e,o,x){"object"==typeof o&&(x=o,o=0),"function"==typeof x&&(x={onAfter:x}),"max"===e&&(e=9e9),x=w.extend({},y.defaults,x),o=o||x.duration;var v=x.queue&&1<x.axis.length;return v&&(o/=2),x.offset=t(x.offset),x.over=t(x.over),this.each(function(){if(null!==e){var f,u=g(this),c=u?this.contentWindow||window:this,l=w(c),d=e,m={};switch(typeof d){case"number":case"string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(d)){d=t(d);break}if(!(d=u?w(d):w(d,c)).length)return;case"object":(d.is||d.style)&&(f=(d=w(d)).offset())}var p=w.isFunction(x.offset)&&x.offset(c,d)||x.offset;w.each(x.axis.split(""),function(e,t){var o="x"===t?"Left":"Top",n=o.toLowerCase(),r="scroll"+o,i=l[r](),s=y.max(c,t);if(f)m[r]=f[n]+(u?0:i-l.offset()[n]),x.margin&&(m[r]-=parseInt(d.css("margin"+o),10)||0,m[r]-=parseInt(d.css("border"+o+"Width"),10)||0),m[r]+=p[n]||0,x.over[n]&&(m[r]+=d["x"===t?"width":"height"]()*x.over[n]);else{var a=d[n];m[r]=a.slice&&"%"===a.slice(-1)?parseFloat(a)/100*s:a}x.limit&&/^\d+$/.test(m[r])&&(m[r]=m[r]<=0?0:Math.min(m[r],s)),!e&&1<x.axis.length&&(i===m[r]?m={}:v&&(h(x.onAfterFirst),m={}))}),h(x.onAfter)}function h(e){var t=w.extend({},x,{queue:!0,duration:o,complete:e&&function(){e.call(c,d,x)}});l.animate(m,t)}})},y.max=function(e,t){var o="x"===t?"Width":"Height",n="scroll"+o;if(!g(e))return e[n]-w(e)[o.toLowerCase()]();var r="client"+o,i=e.ownerDocument||e.document,s=i.documentElement,a=i.body;return Math.max(s[n],a[n])-Math.min(s[r],a[r])},w.Tween.propHooks.scrollLeft=w.Tween.propHooks.scrollTop={get:function(e){return w(e.elem)[e.prop]()},set:function(e){var t=this.get(e);if(e.options.interrupt&&e._last&&e._last!==t)return w(e.elem).stop();var o=Math.round(e.now);t!==o&&(w(e.elem)[e.prop](o),e._last=this.get(e))}},y});
|
||||
Vendored
+1
-2
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
||||
!function(t){function e(t,e){return"function"==typeof t?t.call(e):t}function i(t){for(;t=t.parentNode;)if(t==document)return!0;return!1}function s(e,i){this.$element=t(e),this.options=i,this.enabled=!0,this.fixTitle()}s.prototype={show:function(){var i=this.getTitle();if(i&&this.enabled){var s=this.tip();s.find(".tipsy-inner")[this.options.html?"html":"text"](i),s[0].className="tipsy",s.remove().css({top:0,left:0,visibility:"hidden",display:"block"}).prependTo(document.body);var n,o=t.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight}),a=s[0].offsetWidth,l=s[0].offsetHeight,f=e(this.options.gravity,this.$element[0]);switch(f.charAt(0)){case"n":n={top:o.top+o.height+this.options.offset,left:o.left+o.width/2-a/2};break;case"s":n={top:o.top-l-this.options.offset,left:o.left+o.width/2-a/2};break;case"e":n={top:o.top+o.height/2-l/2,left:o.left-a-this.options.offset};break;case"w":extra_gap=0,t("body").css("position").length>0&&"relative"==t("body").css("position")&&t("#wpadminbar").length&&(extra_gap=t("#wpadminbar").height()),n={top:o.top+o.height/2-l/2-extra_gap,left:o.left+o.width+this.options.offset}}2==f.length&&("w"==f.charAt(1)?n.left=o.left+o.width/2-15:n.left=o.left+o.width/2-a+15),s.css(n).addClass("tipsy-"+f),s.find(".tipsy-arrow")[0].className="tipsy-arrow tipsy-arrow-"+f.charAt(0),this.options.className&&s.addClass(e(this.options.className,this.$element[0])),this.options.fade?s.stop().css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:this.options.opacity}):s.css({visibility:"visible",opacity:this.options.opacity})}},hide:function(){this.options.fade?this.tip().stop().fadeOut(function(){t(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;this.fixTitle();var t,i=this.options;return"string"==typeof i.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*$)/,""),t||i.fallback},tip:function(){return this.$tip||(this.$tip=t('<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}},t.fn.tipsy=function(e){function i(i){var n=t.data(i,"tipsy");return n||(n=new s(i,t.fn.tipsy.elementOptions(i,e)),t.data(i,"tipsy",n)),n}function n(){var t=i(this);t.hoverState="in",0==e.delayIn?t.show():(t.fixTitle(),setTimeout(function(){"in"==t.hoverState&&t.show()},e.delayIn))}function o(){var t=i(this);t.hoverState="out",0==e.delayOut?t.hide():setTimeout(function(){"out"==t.hoverState&&t.hide()},e.delayOut)}if(e===!0)return this.data("tipsy");if("string"==typeof e){var a=this.data("tipsy");return a&&a[e](),this}if(e=t.extend({},t.fn.tipsy.defaults,e),e.live||this.each(function(){i(this)}),"manual"!=e.trigger){var l="hover"==e.trigger?"mouseenter":"focus",f="hover"==e.trigger?"mouseleave":"blur";e.live?t(document).on(l,this.selector,n).on(f,this.selector,o):this.bind(l,n).bind(f,o)}return this},t.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"},t.fn.tipsy.revalidate=function(){t(".tipsy").each(function(){var e=t.data(this,"tipsy-pointee");e&&i(e)||t(this).remove()})},t.fn.tipsy.elementOptions=function(e,i){return t.metadata?t.extend({},i,t(e).metadata()):i},t.fn.tipsy.autoNS=function(){return t(this).offset().top>t(document).scrollTop()+t(window).height()/2?"s":"n"},t.fn.tipsy.autoWE=function(){return t(this).offset().left>t(document).scrollLeft()+t(window).width()/2?"e":"w"},t.fn.tipsy.autoBounds=function(e,i){return function(){var s={ns:i[0],ew:i.length>1&&i[1]},n=t(document).scrollTop()+e,o=t(document).scrollLeft()+e,a=t(this);return a.offset().top<n&&(s.ns="n"),a.offset().left<o&&(s.ew="w"),t(window).width()+t(document).scrollLeft()-a.offset().left<e&&(s.ew="e"),t(window).height()+t(document).scrollTop()-a.offset().top<e&&(s.ns="s"),s.ns+(s.ew?s.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)).live||this.each(function(){e(this)}),"manual"!=i.trigger){var o="hover"==i.trigger?"mouseenter":"focus",a="hover"==i.trigger?"mouseleave":"blur";i.live?l(document).on(o,this.selector,s).on(a,this.selector,n):this.bind(o,s).bind(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);
|
||||
@@ -24,6 +24,10 @@ jQuery(document).ready(function() {
|
||||
});
|
||||
|
||||
|
||||
jQuery(document).on('click', '.um_secondary_dimiss', function (e) {
|
||||
jQuery(this).parents('.um-admin-notice').find( '.notice-dismiss' ).trigger('click');
|
||||
});
|
||||
|
||||
jQuery(document).on('click', '.um_opt_in_link', function (e) {
|
||||
jQuery(this).parents('.um-admin-notice').find( '.notice-dismiss' ).trigger('click');
|
||||
});
|
||||
|
||||
@@ -43,6 +43,8 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
||||
add_action( 'um_admin_do_action__um_hide_exif_notice', array( &$this, 'um_hide_notice' ) );
|
||||
add_action( 'um_admin_do_action__user_action', array( &$this, 'user_action' ) );
|
||||
|
||||
add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) );
|
||||
|
||||
add_action( 'parent_file', array( &$this, 'parent_file' ), 9 );
|
||||
add_filter( 'gettext', array( &$this, 'gettext' ), 10, 4 );
|
||||
add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
|
||||
@@ -83,6 +85,43 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Core pages installation
|
||||
*/
|
||||
function install_core_pages() {
|
||||
if ( ! is_admin() ) {
|
||||
die();
|
||||
}
|
||||
|
||||
UM()->setup()->install_default_pages();
|
||||
|
||||
//check empty pages in settings
|
||||
$empty_pages = array();
|
||||
|
||||
$pages = UM()->config()->permalinks;
|
||||
if ( $pages && is_array( $pages ) ) {
|
||||
foreach ( $pages as $slug => $page_id ) {
|
||||
$page = get_post( $page_id );
|
||||
|
||||
if ( ! isset( $page->ID ) && in_array( $slug, array_keys( UM()->config()->core_pages ) ) ) {
|
||||
$empty_pages[] = $slug;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if there aren't empty pages - then hide pages notice
|
||||
if ( empty( $empty_pages ) ) {
|
||||
$hidden_notices = get_option( 'um_hidden_admin_notices', array() );
|
||||
$hidden_notices[] = 'wrong_pages';
|
||||
|
||||
update_option( 'um_hidden_admin_notices', $hidden_notices );
|
||||
}
|
||||
|
||||
$url = add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) );
|
||||
exit( wp_redirect( $url ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear all users cache
|
||||
*
|
||||
|
||||
@@ -305,8 +305,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
||||
|
||||
$this->show_builder();
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$output = ob_get_clean();
|
||||
|
||||
if(is_array($output)){ print_r($output); }else{ echo $output; } die;
|
||||
}
|
||||
@@ -817,9 +816,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
||||
*/
|
||||
do_action( "um_admin_ajax_modal_content__hook_{$act_id}" );
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$output = ob_get_clean();
|
||||
break;
|
||||
|
||||
case 'um_admin_fonticon_selector':
|
||||
@@ -836,8 +833,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
||||
<?php } ?>
|
||||
</div><div class="um-admin-clear"></div>
|
||||
|
||||
<?php $output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
<?php $output = ob_get_clean();
|
||||
break;
|
||||
|
||||
case 'um_admin_show_fields':
|
||||
@@ -894,8 +890,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
||||
|
||||
</div>
|
||||
|
||||
<?php $output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
<?php $output = ob_get_clean();
|
||||
break;
|
||||
|
||||
case 'um_admin_edit_field_popup':
|
||||
@@ -973,9 +968,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
||||
|
||||
}
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$output = ob_get_clean();
|
||||
break;
|
||||
|
||||
case 'um_admin_new_field_popup':
|
||||
@@ -1037,9 +1030,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
||||
|
||||
}
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$output = ob_get_clean();
|
||||
break;
|
||||
|
||||
case 'um_admin_preview_form':
|
||||
|
||||
@@ -651,7 +651,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
|
||||
);
|
||||
|
||||
$html = ob_get_clean();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,36 +1,34 @@
|
||||
<?php
|
||||
namespace um\admin\core;
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
|
||||
if ( ! class_exists( 'um\admin\core\Admin_Navmenu' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* Class UM_Menu_Item_Custom_Fields_Editor
|
||||
* Class Admin_Navmenu
|
||||
* @package um\admin\core
|
||||
*/
|
||||
class UM_Menu_Item_Custom_Fields_Editor {
|
||||
|
||||
|
||||
class Admin_Navmenu {
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $fields = array();
|
||||
|
||||
|
||||
/**
|
||||
* Initialize plugin
|
||||
*/
|
||||
public static function init() {
|
||||
|
||||
function __construct() {
|
||||
self::$fields = array(
|
||||
'um_nav_public' => __( 'Display Mode' ),
|
||||
'um_nav_roles' => __( 'By Role' )
|
||||
'um_nav_public' => __( 'Display Mode', 'ultimate-member' ),
|
||||
'um_nav_roles' => __( 'By Role', 'ultimate-member' )
|
||||
);
|
||||
|
||||
add_action( 'wp_update_nav_menu_item', array( __CLASS__, '_save' ), 10, 3 );
|
||||
//add_filter( 'manage_nav-menus_columns', array( __CLASS__, '_columns' ), 99 );
|
||||
add_action( 'wp_update_nav_menu_item', array( &$this, '_save' ), 10, 3 );
|
||||
//add_filter( 'manage_nav-menus_columns', array( &$this, '_columns' ), 99 );
|
||||
|
||||
add_action( 'load-nav-menus.php', array( __CLASS__, 'enqueue_nav_menus_scripts' ) );
|
||||
add_action( 'admin_footer-nav-menus.php', array( __CLASS__, '_wp_template' ) );
|
||||
add_action( 'load-nav-menus.php', array( &$this, 'enqueue_nav_menus_scripts' ) );
|
||||
add_action( 'admin_footer-nav-menus.php', array( &$this, '_wp_template' ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +37,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
|
||||
* @param $menu_item_db_id
|
||||
* @param $menu_item_args
|
||||
*/
|
||||
public static function _save( $menu_id, $menu_item_db_id, $menu_item_args ) {
|
||||
function _save( $menu_id, $menu_item_db_id, $menu_item_args ) {
|
||||
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
||||
return;
|
||||
}
|
||||
@@ -56,7 +54,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
|
||||
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_keys( $_POST[ $key ][ $menu_item_db_id ] ) : $_POST[ $key ][ $menu_item_db_id ];
|
||||
} else {
|
||||
$value = null;
|
||||
}
|
||||
@@ -76,7 +74,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function _columns( $columns ) {
|
||||
function _columns( $columns ) {
|
||||
$columns = array_merge( $columns, self::$fields );
|
||||
|
||||
return $columns;
|
||||
@@ -86,20 +84,20 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function enqueue_nav_menus_scripts() {
|
||||
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) );
|
||||
function enqueue_nav_menus_scripts() {
|
||||
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function admin_enqueue_scripts() {
|
||||
function admin_enqueue_scripts() {
|
||||
UM()->admin_enqueue()->load_nav_manus_scripts();
|
||||
|
||||
$menus = get_posts( 'post_type=nav_menu_item&numberposts=-1' );
|
||||
$menu_restriction_data = array();
|
||||
|
||||
$menus = get_posts( 'post_type=nav_menu_item&numberposts=-1' );
|
||||
foreach ( $menus as $data ) {
|
||||
$_nav_roles_meta = get_post_meta( $data->ID, 'menu-item-um_nav_roles', true );
|
||||
|
||||
@@ -117,6 +115,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
|
||||
'um_nav_roles' => $um_nav_roles,
|
||||
);
|
||||
}
|
||||
|
||||
wp_localize_script( 'um_admin_nav_manus', 'um_menu_restriction_data', $menu_restriction_data );
|
||||
}
|
||||
|
||||
@@ -124,7 +123,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function _wp_template() {
|
||||
function _wp_template() {
|
||||
?>
|
||||
<script type="text/html" id="tmpl-um-nav-menus-fields">
|
||||
<div class="um-nav-edit">
|
||||
@@ -139,43 +138,43 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
|
||||
<select id="edit-menu-item-um_nav_public-{{data.menuItemID}}"
|
||||
name="menu-item-um_nav_public[{{data.menuItemID}}]" style="width:100%;">
|
||||
<option value="0" <# if( data.restriction_data.um_nav_public == '0' ){ #>selected="selected"<# } #>>
|
||||
<?php _e( 'Everyone', 'ultimate-member' ) ?>
|
||||
<?php _e( 'Everyone', 'ultimate-member' ) ?>
|
||||
</option>
|
||||
<option value="1" <# if( data.restriction_data.um_nav_public == '1' ){ #>selected="selected"<# } #>>
|
||||
<?php _e( 'Logged Out Users', 'ultimate-member' ) ?>
|
||||
<?php _e( 'Logged Out Users', 'ultimate-member' ) ?>
|
||||
</option>
|
||||
<option value="2" <# if( data.restriction_data.um_nav_public == '2' ){ #>selected="selected"<# } #>>
|
||||
<?php _e( 'Logged In Users', 'ultimate-member' ) ?>
|
||||
<?php _e( 'Logged In Users', 'ultimate-member' ) ?>
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</p>
|
||||
<p class="description description-wide um-nav-roles" <# if( data.restriction_data.um_nav_public == '2' ){ #>style="display: block;"<# } #>>
|
||||
<?php _e( "Select the member roles that can see this link", 'ultimate-member' ) ?><br/>
|
||||
<?php _e( "Select the member roles that can see this link", 'ultimate-member' ) ?><br/>
|
||||
|
||||
<?php $options = UM()->roles()->get_roles( false, array( 'administrator' ) );
|
||||
$i = 0;
|
||||
$html = '';
|
||||
$columns = 2;
|
||||
while ( $i < $columns ) {
|
||||
$per_page = ceil( count( $options ) / $columns );
|
||||
$section_fields_per_page = array_slice( $options, $i * $per_page, $per_page );
|
||||
$html .= '<span class="um-form-fields-section" style="width:' . floor( 100 / $columns ) . '% !important;">';
|
||||
<?php $options = UM()->roles()->get_roles( false, array( 'administrator' ) );
|
||||
$i = 0;
|
||||
$html = '';
|
||||
$columns = 2;
|
||||
while ( $i < $columns ) {
|
||||
$per_page = ceil( count( $options ) / $columns );
|
||||
$section_fields_per_page = array_slice( $options, $i * $per_page, $per_page );
|
||||
$html .= '<span class="um-form-fields-section" style="width:' . floor( 100 / $columns ) . '% !important;">';
|
||||
|
||||
foreach ( $section_fields_per_page as $k => $title ) {
|
||||
$id_attr = ' id="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" ';
|
||||
$for_attr = ' for="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" ';
|
||||
$html .= "<label $for_attr>
|
||||
foreach ( $section_fields_per_page as $k => $title ) {
|
||||
$id_attr = ' id="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" ';
|
||||
$for_attr = ' for="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" ';
|
||||
$html .= "<label $for_attr>
|
||||
<input type='checkbox' {$id_attr} name='menu-item-um_nav_roles[{{data.menuItemID}}][{$k}]' value='1' <# if( _.contains( data.restriction_data.um_nav_roles,'{$k}' ) ){ #>checked='checked'<# } #> />
|
||||
<span>{$title}</span>
|
||||
</label>";
|
||||
}
|
||||
|
||||
$html .= '</span>';
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo $html; ?>
|
||||
$html .= '</span>';
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo $html; ?>
|
||||
</p>
|
||||
|
||||
<div class="clear"></div>
|
||||
@@ -183,9 +182,5 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
UM_Menu_Item_Custom_Fields_Editor::init();
|
||||
}
|
||||
@@ -36,7 +36,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
|
||||
function create_list() {
|
||||
$this->old_extensions_notice();
|
||||
$this->main_notices();
|
||||
$this->install_core_page_notice();
|
||||
$this->exif_extension_notice();
|
||||
$this->localize_note();
|
||||
$this->show_update_messages();
|
||||
$this->check_wrong_install_folder();
|
||||
@@ -46,7 +47,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
|
||||
$this->reviews_notice();
|
||||
|
||||
|
||||
//$this->future_changed();
|
||||
|
||||
/**
|
||||
@@ -283,40 +283,40 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* Show main notices
|
||||
*/
|
||||
function main_notices() {
|
||||
|
||||
$hide_exif_notice = get_option( 'um_hide_exif_notice' );
|
||||
|
||||
if ( ! extension_loaded( 'exif' ) && ! $hide_exif_notice ) {
|
||||
$this->add_notice( 'exif_disabled', array(
|
||||
'class' => 'updated',
|
||||
'message' => '<p>' . sprintf(__( 'Exif is not enabled on your server. Mobile photo uploads will not be rotated correctly until you enable the exif extension. <a href="%s">Hide this notice</a>', 'ultimate-member' ), add_query_arg('um_adm_action', 'um_hide_exif_notice') ) . '</p>',
|
||||
), 10 );
|
||||
}
|
||||
|
||||
// Regarding page setup
|
||||
* Regarding page setup
|
||||
*/
|
||||
function install_core_page_notice() {
|
||||
$pages = UM()->config()->permalinks;
|
||||
|
||||
if ( $pages && is_array( $pages ) ) {
|
||||
|
||||
$err = false;
|
||||
|
||||
foreach ( $pages as $slug => $page_id ) {
|
||||
|
||||
$page = get_post( $page_id );
|
||||
|
||||
if ( ! isset( $page->ID ) && in_array( $slug, array( 'user', 'account', 'members', 'register', 'login', 'logout', 'password-reset' ) ) ) {
|
||||
$err = true;
|
||||
if ( ! isset( $page->ID ) && in_array( $slug, array_keys( UM()->config()->core_pages ) ) ) {
|
||||
|
||||
ob_start(); ?>
|
||||
|
||||
<p>
|
||||
<?php printf( __( 'One or more of your %s pages are not correctly setup. Please visit <strong>%s > Settings</strong> to re-assign your missing pages.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_plugin_name ); ?>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="<?php echo esc_attr( add_query_arg( 'um_adm_action', 'install_core_pages' ) ); ?>" class="button button-primary"><?php _e( 'Setup Pages', 'ultimate-member' ) ?></a>
|
||||
|
||||
<a href="javascript:void(0);" class="button-secondary um_secondary_dimiss"><?php _e( 'No thanks', 'ultimate-member' ) ?></a>
|
||||
</p>
|
||||
|
||||
<?php $message = ob_get_clean();
|
||||
|
||||
$this->add_notice( 'wrong_pages', array(
|
||||
'class' => 'updated',
|
||||
'message' => $message,
|
||||
'dismissible' => true
|
||||
), 20 );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $err ) {
|
||||
$this->add_notice( 'wrong_pages', array(
|
||||
'class' => 'updated',
|
||||
'message' => '<p>' . __( 'One or more of your Ultimate Member pages are not correctly setup. Please visit <strong>Ultimate Member > Settings</strong> to re-assign your missing pages.', 'ultimate-member' ) . '</p>',
|
||||
), 20 );
|
||||
}
|
||||
|
||||
if ( isset( $pages['user'] ) ) {
|
||||
@@ -343,6 +343,21 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* EXIF library notice
|
||||
*/
|
||||
function exif_extension_notice() {
|
||||
$hide_exif_notice = get_option( 'um_hide_exif_notice' );
|
||||
|
||||
if ( ! extension_loaded( 'exif' ) && ! $hide_exif_notice ) {
|
||||
$this->add_notice( 'exif_disabled', array(
|
||||
'class' => 'updated',
|
||||
'message' => '<p>' . sprintf(__( 'Exif is not enabled on your server. Mobile photo uploads will not be rotated correctly until you enable the exif extension. <a href="%s">Hide this notice</a>', 'ultimate-member' ), add_query_arg('um_adm_action', 'um_hide_exif_notice') ) . '</p>',
|
||||
), 10 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Localization notice
|
||||
*/
|
||||
|
||||
@@ -1170,7 +1170,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
*/
|
||||
do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" );
|
||||
|
||||
if ( 'licenses' == $current_tab || 'install_info' == $current_tab ) {
|
||||
if ( in_array( $current_tab, apply_filters('um_settings_custom_tabs', array( 'licenses', 'install_info' ) ) ) || in_array( $current_subtab, apply_filters('um_settings_custom_subtabs', array() ) ) ) {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
@@ -2011,7 +2011,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
$license_status = null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<tr class="um-settings-line">
|
||||
@@ -2184,7 +2184,6 @@ JS/CSS Compression: <?php if ( defined('SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { e
|
||||
<?php if( is_multisite() ): ?>
|
||||
Network Structure: <?php echo UM()->options()->get( 'network_permalink_structure' ). "\n"; ?>
|
||||
<?php endif; ?>
|
||||
Nav Menu Settings: <?php if( UM()->options()->get( 'disable_menu' ) == 0 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
||||
Port Forwarding in URL: <?php if( UM()->options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
||||
Exclude CSS/JS on Home: <?php if( UM()->options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
||||
|
||||
|
||||
@@ -194,62 +194,4 @@ if ( is_multisite() ) {
|
||||
restore_current_blog();
|
||||
} else {
|
||||
um_upgrade20beta1_email_templates_process();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transferring email templates to new logic
|
||||
*/
|
||||
/*$templates_in_theme = 0;
|
||||
$emails = UM()->config()->email_notifications;
|
||||
foreach ( $emails as $email_key => $value ) {
|
||||
|
||||
$in_theme = um_upgrade20beta1_template_in_theme( $email_key, true );
|
||||
$theme_template_path = um_upgrade20beta1_get_template_file( 'theme', $email_key );
|
||||
|
||||
if ( ! $in_theme ) {
|
||||
//there isn't HTML email template's file in theme, get from option
|
||||
//this value is correct for each multisite's subsites
|
||||
$setting_value = UM()->options()->get( $email_key );
|
||||
|
||||
$html_email = UM()->options()->get( 'email_html' );
|
||||
if ( $html_email ) {
|
||||
|
||||
if ( ! um_upgrade20beta1_copy_email_template( $email_key ) ) {
|
||||
|
||||
um_upgrade20beta1_insert_content( $theme_template_path, $setting_value );
|
||||
|
||||
} else {
|
||||
|
||||
$templates_in_theme++;
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
um_upgrade20beta1_insert_content( $theme_template_path, $setting_value );
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
//there is HTML email template in a theme's folder
|
||||
$theme_template_path_html = um_upgrade20beta1_get_template_file( 'theme', $email_key, true );
|
||||
|
||||
$setting_value = preg_replace( '/<\/body>|<\/head>|<html>|<\/html>|<body.*?>|<head.*?>/' , '', file_get_contents( $theme_template_path_html ) );
|
||||
|
||||
if ( file_exists( $theme_template_path_html ) ) {
|
||||
|
||||
if ( copy( $theme_template_path_html, $theme_template_path ) ) {
|
||||
|
||||
um_upgrade20beta1_insert_content( $theme_template_path, $setting_value );
|
||||
|
||||
$templates_in_theme++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$email_html = ( $templates_in_theme > 0 ) ? true : false;
|
||||
UM()->options()->update( 'email_html', $email_html );*/
|
||||
}
|
||||
@@ -38,6 +38,7 @@ if ( ! class_exists( 'um\Dependencies' ) ) {
|
||||
'groups' => '2.0',
|
||||
'instagram' => '2.0',
|
||||
'invitations' => '2.0',
|
||||
'frontend-posting' => '1.0',
|
||||
'mailchimp' => '2.0.1',
|
||||
'messaging' => '2.0.5',
|
||||
'mycred' => '2.0',
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<?php
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! class_exists( 'UM_Functions' ) ) {
|
||||
|
||||
@@ -11,23 +9,10 @@ if ( ! class_exists( 'UM_Functions' ) ) {
|
||||
class UM_Functions {
|
||||
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
var $options;
|
||||
|
||||
|
||||
/**
|
||||
* @var array variable for Flags
|
||||
*/
|
||||
var $screenload_flags;
|
||||
|
||||
|
||||
/**
|
||||
* UM_Functions constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->init_variables();
|
||||
}
|
||||
|
||||
|
||||
@@ -91,14 +76,6 @@ if ( ! class_exists( 'UM_Functions' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set variables
|
||||
*/
|
||||
function init_variables() {
|
||||
$this->options = get_option( 'um_options' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Help Tip displaying
|
||||
*
|
||||
@@ -344,6 +321,9 @@ if ( ! class_exists( 'UM_Functions' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed|void
|
||||
*/
|
||||
function cpt_list() {
|
||||
/**
|
||||
* UM hook
|
||||
|
||||
+117
-90
@@ -1,4 +1,4 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
if ( ! class_exists( 'UM' ) ) {
|
||||
@@ -50,12 +50,24 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
|
||||
/**
|
||||
* @var bool Old variable
|
||||
*
|
||||
* @todo deprecate this variable
|
||||
*/
|
||||
public $is_filtering;
|
||||
|
||||
|
||||
/**
|
||||
* @var array Languages
|
||||
* WP Native permalinks turned on?
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
public $is_permalinks;
|
||||
|
||||
|
||||
/**
|
||||
* UM Available Languages
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $available_languages;
|
||||
|
||||
@@ -132,9 +144,9 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
* @param bool $instance
|
||||
*/
|
||||
public function set_class( $class_name, $instance = false ) {
|
||||
if ( empty( $this->classes[$class_name] ) ) {
|
||||
if ( empty( $this->classes[ $class_name ] ) ) {
|
||||
$class = 'UM_' . $class_name;
|
||||
$this->classes[$class_name] = $instance ? $class::instance() : new $class;
|
||||
$this->classes[ $class_name ] = $instance ? $class::instance() : new $class;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,8 +190,13 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
|
||||
if ( get_option( 'permalink_structure' ) ) {
|
||||
$this->is_permalinks = true;
|
||||
}
|
||||
|
||||
$this->is_filtering = 0;
|
||||
$this->honeypot = 'request';
|
||||
|
||||
$this->available_languages = array(
|
||||
'en_US' => 'English (US)',
|
||||
'es_ES' => 'Español',
|
||||
@@ -205,82 +222,11 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
'ar' => 'العربية',
|
||||
);
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_language_textdomain
|
||||
* @description Change UM textdomain
|
||||
* @input_vars
|
||||
* [{"var":"$domain","type":"string","desc":"UM Textdomain"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_language_textdomain', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_language_textdomain', 'my_textdomain', 10, 1 );
|
||||
* function my_textdomain( $domain ) {
|
||||
* // your code here
|
||||
* return $domain;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$language_domain = apply_filters( 'um_language_textdomain', 'ultimate-member' );
|
||||
|
||||
$language_locale = ( get_locale() != '' ) ? get_locale() : 'en_US';
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_language_locale
|
||||
* @description Change UM language locale
|
||||
* @input_vars
|
||||
* [{"var":"$locale","type":"string","desc":"UM language locale"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_language_locale', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_language_locale', 'my_language_locale', 10, 1 );
|
||||
* function my_language_locale( $locale ) {
|
||||
* // your code here
|
||||
* return $locale;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$language_locale = apply_filters( 'um_language_locale', $language_locale );
|
||||
|
||||
$language_file = WP_LANG_DIR . '/plugins/' . $language_domain . '-' . $language_locale . '.mo';
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_language_file
|
||||
* @description Change UM language file path
|
||||
* @input_vars
|
||||
* [{"var":"$language_file","type":"string","desc":"UM language file path"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_language_file', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_language_file', 'my_language_file', 10, 1 );
|
||||
* function my_language_file( $language_file ) {
|
||||
* // your code here
|
||||
* return $language_file;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$language_file = apply_filters( 'um_language_file', $language_file );
|
||||
|
||||
load_textdomain( $language_domain, $language_file );
|
||||
|
||||
// textdomain loading
|
||||
$this->localize();
|
||||
|
||||
// include UM classes
|
||||
$this->includes();
|
||||
$this->plugins_loaded();
|
||||
|
||||
// include hook files
|
||||
add_action( 'plugins_loaded', array( &$this, 'init' ), 0 );
|
||||
@@ -293,7 +239,6 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
// init widgets
|
||||
add_action( 'widgets_init', array( &$this, 'widgets_init' ) );
|
||||
|
||||
|
||||
//include short non class functions
|
||||
require_once 'um-short-functions.php';
|
||||
require_once 'um-deprecated-functions.php';
|
||||
@@ -301,18 +246,90 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
}
|
||||
|
||||
|
||||
public function plugins_loaded() {
|
||||
//gravity forms
|
||||
if ( ! function_exists('members_get_capabilities' ) ) {
|
||||
/**
|
||||
* Loading UM textdomain
|
||||
*
|
||||
* 'ultimate-member' by default
|
||||
*/
|
||||
function localize() {
|
||||
$language_locale = ( get_locale() != '' ) ? get_locale() : 'en_US';
|
||||
|
||||
function members_get_capabilities() {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_language_locale
|
||||
* @description Change UM language locale
|
||||
* @input_vars
|
||||
* [{"var":"$locale","type":"string","desc":"UM language locale"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_language_locale', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_language_locale', 'my_language_locale', 10, 1 );
|
||||
* function my_language_locale( $locale ) {
|
||||
* // your code here
|
||||
* return $locale;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$language_locale = apply_filters( 'um_language_locale', $language_locale );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_language_textdomain
|
||||
* @description Change UM textdomain
|
||||
* @input_vars
|
||||
* [{"var":"$domain","type":"string","desc":"UM Textdomain"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_language_textdomain', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_language_textdomain', 'my_textdomain', 10, 1 );
|
||||
* function my_textdomain( $domain ) {
|
||||
* // your code here
|
||||
* return $domain;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$language_domain = apply_filters( 'um_language_textdomain', 'ultimate-member' );
|
||||
|
||||
$language_file = WP_LANG_DIR . '/plugins/' . $language_domain . '-' . $language_locale . '.mo';
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_language_file
|
||||
* @description Change UM language file path
|
||||
* @input_vars
|
||||
* [{"var":"$language_file","type":"string","desc":"UM language file path"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_language_file', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_language_file', 'my_language_file', 10, 1 );
|
||||
* function my_language_file( $language_file ) {
|
||||
* // your code here
|
||||
* return $language_file;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$language_file = apply_filters( 'um_language_file', $language_file );
|
||||
|
||||
load_textdomain( $language_domain, $language_file );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 1.3.x active extensions deactivate for properly running 2.0.x AJAX upgrades
|
||||
*/
|
||||
function old_update_patch() {
|
||||
global $um_woocommerce, $um_bbpress, $um_followers, $um_friends, $um_mailchimp, $um_messaging, $um_mycred, $um_notices, $um_notifications, $um_online, $um_private_content, $um_profile_completeness, $um_recaptcha, $um_reviews, $um_activity, $um_social_login, $um_user_tags, $um_verified;
|
||||
|
||||
@@ -421,7 +438,7 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
$array = explode( '\\', strtolower( $class ) );
|
||||
$array[ count( $array ) - 1 ] = 'class-'. end( $array );
|
||||
if ( strpos( $class, 'um_ext' ) === 0 ) {
|
||||
$full_path = str_replace( 'ultimate-member', '', rtrim( um_path, '/' ) ) . str_replace( '_', '-', $array[1] ) . '/includes/';
|
||||
$full_path = str_replace( 'ultimate-member', '', untrailingslashit( um_path ) ) . str_replace( '_', '-', $array[1] ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR;
|
||||
unset( $array[0], $array[1] );
|
||||
$path = implode( DIRECTORY_SEPARATOR, $array );
|
||||
$path = str_replace( '_', '-', $path );
|
||||
@@ -512,6 +529,7 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
$this->admin_gdpr();
|
||||
$this->columns();
|
||||
$this->notices();
|
||||
$this->admin_navmenu();
|
||||
} elseif ( $this->is_request( 'admin' ) ) {
|
||||
$this->admin();
|
||||
$this->admin_menu();
|
||||
@@ -525,6 +543,7 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
$this->dragdrop();
|
||||
$this->plugin_updater();
|
||||
$this->admin_gdpr();
|
||||
$this->admin_navmenu();
|
||||
} elseif ( $this->is_request( 'frontend' ) ) {
|
||||
$this->enqueue();
|
||||
$this->account();
|
||||
@@ -644,6 +663,19 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @since 2.0.26
|
||||
*
|
||||
* @return um\admin\core\Admin_Navmenu()
|
||||
*/
|
||||
function admin_navmenu() {
|
||||
if ( empty( $this->classes['admin_navmenu'] ) ) {
|
||||
$this->classes['admin_navmenu'] = new um\admin\core\Admin_Navmenu();
|
||||
}
|
||||
return $this->classes['admin_navmenu'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*
|
||||
@@ -1303,10 +1335,6 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
|
||||
ob_start();
|
||||
|
||||
if ( $this->options()->get( 'disable_menu' ) == 0 ) {
|
||||
require_once 'core/um-navmenu.php';
|
||||
}
|
||||
|
||||
require_once 'core/um-actions-form.php';
|
||||
require_once 'core/um-actions-access.php';
|
||||
require_once 'core/um-actions-wpadmin.php';
|
||||
@@ -1316,7 +1344,6 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
require_once 'core/um-actions-register.php';
|
||||
require_once 'core/um-actions-profile.php';
|
||||
require_once 'core/um-actions-account.php';
|
||||
require_once 'core/um-actions-password.php';
|
||||
require_once 'core/um-actions-members.php';
|
||||
require_once 'core/um-actions-global.php';
|
||||
require_once 'core/um-actions-user.php';
|
||||
|
||||
@@ -324,8 +324,9 @@ if ( ! class_exists( 'um\core\Account' ) ) {
|
||||
UM()->fields()->set_mode = 'account';
|
||||
UM()->fields()->editing = true;
|
||||
|
||||
if ( get_query_var('um_tab') )
|
||||
if ( get_query_var('um_tab') ) {
|
||||
$this->current_tab = get_query_var('um_tab');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -532,7 +533,7 @@ if ( ! class_exists( 'um\core\Account' ) ) {
|
||||
$fields = $this->account_secure_fields( $fields, $id );
|
||||
$fields = $this->filter_fields_by_attrs( $fields, $shortcode_args );
|
||||
|
||||
foreach ( $fields as $key => $data ){
|
||||
foreach ( $fields as $key => $data ) {
|
||||
$output .= UM()->fields()->edit_field( $key, $data );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1088,13 +1088,6 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
'private_use' => true,
|
||||
),
|
||||
|
||||
'password_reset_text' => array(
|
||||
'title' => __('Password Reset','ultimate-member'),
|
||||
'type' => 'block',
|
||||
'content' => '<div style="text-align:center">' . __('To reset your password, please enter your email address or username below','ultimate-member'). '</div>',
|
||||
'private_use' => true,
|
||||
),
|
||||
|
||||
'username_b' => array(
|
||||
'title' => __('Username or E-mail','ultimate-member'),
|
||||
'metakey' => 'username_b',
|
||||
|
||||
@@ -31,6 +31,23 @@ if ( ! class_exists( 'um\core\External_Integrations' ) ) {
|
||||
|
||||
add_filter( 'um_localize_permalink_filter', array( &$this, 'um_localize_permalink_filter' ), 10, 2 );
|
||||
add_filter( 'icl_ls_languages', array( &$this, 'um_core_page_wpml_permalink' ), 10, 1 );
|
||||
|
||||
$this->plugins_loaded();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gravity forms role capabilities compatibility
|
||||
*/
|
||||
public function plugins_loaded() {
|
||||
//gravity forms
|
||||
if ( ! function_exists('members_get_capabilities' ) ) {
|
||||
|
||||
function members_get_capabilities() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -838,7 +838,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
} else {
|
||||
|
||||
if (!isset( UM()->form()->post_form[$key] )) {
|
||||
if ( ! isset( UM()->form()->post_form[ $key ] ) ) {
|
||||
|
||||
$field_value = um_user( $key );
|
||||
|
||||
@@ -851,12 +851,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$field_value = 'um_' . $field_value;
|
||||
}
|
||||
}
|
||||
/*elseif( $this->set_mode == 'register' ){
|
||||
$data['default'] = UM()->options()->get( 'register_role' );
|
||||
}
|
||||
else{
|
||||
$data['default'] = get_option( 'default_role' );
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -881,6 +875,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
* ?>
|
||||
*/
|
||||
$field_value = apply_filters( 'um_is_selected_filter_value', $field_value, $key );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
@@ -905,27 +900,27 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
*/
|
||||
$data = apply_filters( 'um_is_selected_filter_data', $data, $key, $field_value );
|
||||
|
||||
if ($field_value && $this->editing == true && is_array( $field_value ) && ( in_array( $value, $field_value ) || in_array( html_entity_decode( $value ), $field_value ) )) {
|
||||
if ( $field_value && $this->editing == true && is_array( $field_value ) && ( in_array( $value, $field_value ) || in_array( html_entity_decode( $value ), $field_value ) ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($field_value && $this->editing == true && !is_array( $field_value ) && $field_value == $value) {
|
||||
if ( $field_value && $this->editing == true && ! is_array( $field_value ) && $field_value == $value ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($field_value && $this->editing == true && !is_array( $field_value ) && html_entity_decode( $field_value ) == html_entity_decode( $value )) {
|
||||
if ( $field_value && $this->editing == true && ! is_array( $field_value ) && html_entity_decode( $field_value ) == html_entity_decode( $value )) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strstr( $data['default'], ', ' )) {
|
||||
if ( strstr( $data['default'], ', ' ) ) {
|
||||
$data['default'] = explode( ', ', $data['default'] );
|
||||
}
|
||||
|
||||
if (isset( $data['default'] ) && !is_array( $data['default'] ) && $data['default'] == $value) {
|
||||
if ( isset( $data['default'] ) && ! is_array( $data['default'] ) && $data['default'] === $value ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isset( $data['default'] ) && is_array( $data['default'] ) && in_array( $value, $data['default'] )) {
|
||||
if ( isset( $data['default'] ) && is_array( $data['default'] ) && in_array( $value, $data['default'] )) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2229,13 +2224,19 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$output .= $this->field_label( $label, $key, $data );
|
||||
}
|
||||
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __( 'Upload Photo', 'ultimate-member' );
|
||||
$output .= '<div class="um-field-area" style="text-align: center">';
|
||||
if ($this->field_value( $key, $default, $data )) {
|
||||
$output .= '<div class="um-field-area" style="text-align: center;">';
|
||||
if ( $field_value ) {
|
||||
if ( ! in_array( $key, array( 'profile_photo', 'cover_photo' ) ) ) {
|
||||
if (isset( $this->set_mode ) && $this->set_mode == 'register') {
|
||||
if ( isset( $this->set_mode ) && 'register' == $this->set_mode ) {
|
||||
$image_info = get_transient("um_{$field_value}");
|
||||
} else {
|
||||
$image_info = um_user( $data['metakey']."_metadata" );
|
||||
}
|
||||
|
||||
if ( isset( $this->set_mode ) && $this->set_mode == 'register' ) {
|
||||
$imgValue = UM()->uploader()->get_core_temp_url() . "/" . $this->field_value( $key, $default, $data );
|
||||
} else {
|
||||
$imgValue = um_user_uploads_uri() . $this->field_value( $key, $default, $data );
|
||||
$imgValue = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) );
|
||||
}
|
||||
$img = '<img src="' . $imgValue . '" alt="" />';
|
||||
} else {
|
||||
@@ -2289,9 +2290,9 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
if (isset( $data['label'] )) {
|
||||
$output .= $this->field_label( $label, $key, $data );
|
||||
}
|
||||
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __( 'Upload Photo', 'ultimate-member' );
|
||||
$output .= '<div class="um-field-area" style="text-align: center">';
|
||||
if ($this->field_value( $key, $default, $data )) {
|
||||
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __( 'Upload File', 'ultimate-member' );
|
||||
$output .= '<div class="um-field-area" style="text-align: center;">';
|
||||
if ( $this->field_value( $key, $default, $data ) ) {
|
||||
$file_field_value = $this->field_value( $key, $default, $data );
|
||||
$file_type = wp_check_filetype( $file_field_value );
|
||||
|
||||
@@ -2310,8 +2311,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$file_url = UM()->uploader()->get_core_temp_url() . DIRECTORY_SEPARATOR . $this->field_value( $key, $default, $data );
|
||||
$file_dir = UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $this->field_value( $key, $default, $data );
|
||||
} else {
|
||||
$file_url = um_user_uploads_uri() . $this->field_value( $key, $default, $data );
|
||||
$file_dir = um_user_uploads_dir() . $this->field_value( $key, $default, $data );
|
||||
$file_url = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) );
|
||||
$file_dir = UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $this->field_value( $key, $default, $data );
|
||||
}
|
||||
|
||||
if ( file_exists( $file_dir ) ) {
|
||||
@@ -2369,7 +2370,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$output .= $this->field_error( $this->show_error( $key ) );
|
||||
}
|
||||
$output .= '</div>';
|
||||
|
||||
|
||||
break;
|
||||
|
||||
/* Select dropdown */
|
||||
@@ -2377,7 +2378,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
$output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
|
||||
|
||||
|
||||
if (isset( $data['allowclear'] ) && $data['allowclear'] == 0) {
|
||||
$class = 'um-s2';
|
||||
} else {
|
||||
@@ -2493,7 +2493,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
}
|
||||
|
||||
if( ! empty( $placeholder ) ) {
|
||||
if ( ! empty( $placeholder ) && is_string( $placeholder ) ) {
|
||||
$placeholder = strip_tags( $placeholder );
|
||||
}
|
||||
|
||||
@@ -2581,6 +2581,18 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
$field_value = '';
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_select_option_value
|
||||
* @description Enable options pair by field $data
|
||||
* @input_vars
|
||||
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
||||
* {"var":"$data","type":"array","desc":"Field Data"}]
|
||||
*/
|
||||
$options_pair = apply_filters( "um_select_options_pair", null, $data );
|
||||
|
||||
// switch options pair for custom options from a callback function
|
||||
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
||||
$options_pair = true;
|
||||
@@ -2613,17 +2625,15 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
$output .= '<option value="' . $option_value . '" ';
|
||||
|
||||
if ($this->is_selected( $form_key, $option_value, $data )) {
|
||||
if ( $this->is_selected( $form_key, $option_value, $data ) ) {
|
||||
$output .= 'selected';
|
||||
$field_value = $option_value;
|
||||
} else if (!isset( $options_pair ) && $this->is_selected( $form_key, $v, $data )) {
|
||||
} elseif ( ! isset( $options_pair ) && $this->is_selected( $form_key, $v, $data ) ) {
|
||||
$output .= 'selected';
|
||||
$field_value = $v;
|
||||
}
|
||||
|
||||
$output .= '>' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</option>';
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+148
-12
@@ -39,6 +39,8 @@ if ( ! class_exists( 'um\core\Files' ) ) {
|
||||
|
||||
$this->setup_paths();
|
||||
|
||||
add_action( 'template_redirect', array( &$this, 'download_routing' ) );
|
||||
|
||||
$this->fonticon = array(
|
||||
'pdf' => array('icon' => 'um-faicon-file-pdf-o', 'color' => '#D24D4D' ),
|
||||
'txt' => array('icon' => 'um-faicon-file-text-o' ),
|
||||
@@ -66,6 +68,143 @@ if ( ! class_exists( 'um\core\Files' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* File download link generate
|
||||
*
|
||||
* @param int $form_id
|
||||
* @param string $field_key
|
||||
* @param int $user_id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_download_link( $form_id, $field_key, $user_id ) {
|
||||
$field_key = urlencode( $field_key );
|
||||
|
||||
if ( UM()->is_permalinks ) {
|
||||
$url = get_site_url( get_current_blog_id() );
|
||||
$nonce = wp_create_nonce( $user_id . $form_id . 'um-download-nonce' );
|
||||
return $url . "/um-download/{$form_id}/{$field_key}/{$user_id}/{$nonce}";
|
||||
} else {
|
||||
$url = get_site_url( get_current_blog_id() );
|
||||
$nonce = wp_create_nonce( $user_id . $form_id . 'um-download-nonce' );
|
||||
return add_query_arg( array( 'um_action' => 'download', 'um_form' => $form_id, 'um_field' => $field_key, 'um_user' => $user_id, 'um_verify' => $nonce ), $url );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
function download_routing() {
|
||||
if ( 'download' !== get_query_var( 'um_action' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( get_query_var( 'um_form' ) ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$form_id = get_query_var( 'um_form' );
|
||||
|
||||
if ( empty( get_query_var( 'um_field' ) ) ) {
|
||||
return false;
|
||||
}
|
||||
$field_key = urldecode( get_query_var( 'um_field' ) );
|
||||
|
||||
if ( empty( get_query_var( 'um_user' ) ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$user_id = get_query_var( 'um_user' );
|
||||
$user = get_userdata( $user_id );
|
||||
|
||||
if ( empty( $user ) || is_wp_error( $user ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( get_query_var( 'um_verify' ) ) ||
|
||||
! wp_verify_nonce( get_query_var( 'um_verify' ), $user_id . $form_id . 'um-download-nonce' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
um_fetch_user( $user_id );
|
||||
$field_data = get_post_meta( $form_id, '_um_custom_fields', true );
|
||||
if ( empty( $field_data[ $field_key ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! um_can_view_field( $field_data[ $field_key ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$field_value = UM()->fields()->field_value( $field_key );
|
||||
if ( empty( $field_value ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$download_type = $field_data[ $field_key ]['type'];
|
||||
if ( $download_type === 'file' ) {
|
||||
$this->file_download( $user_id, $field_key, $field_value );
|
||||
} else {
|
||||
$this->image_download( $user_id, $field_key, $field_value );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @param $field_key
|
||||
* @param $field_value
|
||||
*/
|
||||
function image_download( $user_id, $field_key, $field_value ) {
|
||||
$file_path = UM()->uploader()->get_upload_base_dir() . $user_id . DIRECTORY_SEPARATOR . $field_value;
|
||||
$file_info = get_user_meta( $user_id, $field_key . "_metadata", true );
|
||||
|
||||
$size = filesize( $file_path );
|
||||
$originalname = $file_info['original_name'];
|
||||
$type = $file_info['type'];
|
||||
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: ' . $type );
|
||||
header('Content-Disposition: inline; filename="' . $originalname . '"');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . $size);
|
||||
readfile( $file_path );
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @param $field_key
|
||||
* @param $field_value
|
||||
*/
|
||||
function file_download( $user_id, $field_key, $field_value ) {
|
||||
$file_path = UM()->uploader()->get_upload_base_dir() . $user_id . DIRECTORY_SEPARATOR . $field_value;
|
||||
$file_info = get_user_meta( $user_id, $field_key . "_metadata", true );
|
||||
|
||||
$size = filesize( $file_path );
|
||||
$originalname = $file_info['original_name'];
|
||||
$type = $file_info['type'];
|
||||
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: ' . $type );
|
||||
header('Content-Disposition: attachment; filename="' . $originalname . '"');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . $size);
|
||||
readfile( $file_path );
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove file by AJAX
|
||||
*/
|
||||
@@ -104,7 +243,7 @@ if ( ! class_exists( 'um\core\Files' ) ) {
|
||||
if ( $coord_n != 3 ) {
|
||||
wp_send_json_error( esc_js( __( 'Invalid coordinates', 'ultimate-member' ) ) );
|
||||
}
|
||||
|
||||
|
||||
$image_path = um_is_file_owner( $src, $user_id, true );
|
||||
if ( ! $image_path ) {
|
||||
wp_send_json_error( esc_js( __( 'Invalid file ownership', 'ultimate-member' ) ) );
|
||||
@@ -134,7 +273,6 @@ if ( ! class_exists( 'um\core\Files' ) ) {
|
||||
UM()->fields()->set_id = $_POST['set_id'];
|
||||
UM()->fields()->set_mode = $_POST['set_mode'];
|
||||
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
@@ -156,26 +294,24 @@ if ( ! class_exists( 'um\core\Files' ) ) {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$um_image_upload_nonce = apply_filters("um_image_upload_nonce", true );
|
||||
$um_image_upload_nonce = apply_filters( "um_image_upload_nonce", true );
|
||||
|
||||
if( $um_image_upload_nonce ){
|
||||
if ( $um_image_upload_nonce ) {
|
||||
if ( ! wp_verify_nonce( $nonce, "um_upload_nonce-{$timestamp}" ) && is_user_logged_in() ) {
|
||||
// This nonce is not valid.
|
||||
$ret['error'] = 'Invalid nonce';
|
||||
$ret['error'] = __( 'Invalid nonce', 'ultimate-member' );
|
||||
wp_send_json_error( $ret );
|
||||
}
|
||||
}
|
||||
|
||||
if( isset( $_FILES[ $id ]['name'] ) ) {
|
||||
|
||||
if( ! is_array( $_FILES[ $id ]['name'] ) ) {
|
||||
if ( isset( $_FILES[ $id ]['name'] ) ) {
|
||||
|
||||
if ( ! is_array( $_FILES[ $id ]['name'] ) ) {
|
||||
|
||||
$uploaded = UM()->uploader()->upload_image( $_FILES[ $id ], $user_id, $id );
|
||||
if ( isset( $uploaded['error'] ) ){
|
||||
|
||||
$ret['error'] = $uploaded['error'];
|
||||
|
||||
}else{
|
||||
} else {
|
||||
$ts = current_time( 'timestamp' );
|
||||
$ret[ ] = $uploaded['handle_upload'];
|
||||
}
|
||||
@@ -183,7 +319,7 @@ if ( ! class_exists( 'um\core\Files' ) ) {
|
||||
}
|
||||
|
||||
} else {
|
||||
$ret['error'] = __('A theme or plugin compatibility issue','ultimate-member');
|
||||
$ret['error'] = __( 'A theme or plugin compatibility issue', 'ultimate-member' );
|
||||
}
|
||||
wp_send_json_success( $ret );
|
||||
}
|
||||
|
||||
@@ -338,7 +338,15 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
|
||||
|
||||
<?php } else {
|
||||
|
||||
echo $this->get_email_template( $slug, $args );
|
||||
//strip tags in plain text email
|
||||
//important don't use HTML in plain text emails!
|
||||
$raw_email_template = $this->get_email_template( $slug, $args );
|
||||
$plain_email_template = strip_tags( $raw_email_template );
|
||||
if( $plain_email_template !== $raw_email_template ){
|
||||
$plain_email_template = preg_replace( array('/ /mi', '/^\s+/mi'), array(' ', ''), $plain_email_template );
|
||||
}
|
||||
|
||||
echo $plain_email_template;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -198,6 +198,9 @@ if ( ! class_exists( 'um\core\Members' ) ) {
|
||||
$attrs = apply_filters( 'um_search_fields', $attrs );
|
||||
|
||||
if ( $type == 'select' ) {
|
||||
if( isset($attrs) && is_array( $attrs['options'] ) ){
|
||||
asort( $attrs['options'] );
|
||||
}
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
@@ -240,7 +243,9 @@ if ( ! class_exists( 'um\core\Members' ) ) {
|
||||
switch ( $type ) {
|
||||
|
||||
case 'select':
|
||||
|
||||
/*if( isset($attrs) && is_array( $attrs['options'] ) ){
|
||||
asort( $attrs['options'] );
|
||||
}*/
|
||||
?>
|
||||
|
||||
<select name="<?php echo $filter; ?>" id="<?php echo $filter; ?>" class="um-s1" style="width: 100%" data-placeholder="<?php echo __( stripslashes( $attrs['label'] ), 'ultimate-member' ); ?>" <?php if ( ! empty( $attrs['custom_dropdown_options_source'] ) ) { ?> data-um-parent="<?php echo $attrs['parent_dropdown_relationship']; ?>" data-mebers-directory="yes" data-um-ajax-source="<?php echo $attrs['custom_dropdown_options_source'] ?>"<?php } ?>>
|
||||
|
||||
+403
-200
@@ -14,212 +14,47 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
class Password {
|
||||
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
var $reset_request;
|
||||
|
||||
|
||||
/**
|
||||
* Password constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
add_shortcode( 'ultimatemember_password', array( &$this, 'ultimatemember_password' ) );
|
||||
|
||||
add_shortcode('ultimatemember_password', array(&$this, 'ultimatemember_password'));
|
||||
add_action( 'template_redirect', array( &$this, 'form_init' ), 10001 );
|
||||
|
||||
add_action('template_redirect', array(&$this, 'password_reset'), 10001 );
|
||||
|
||||
add_action('template_redirect', array(&$this, 'form_init'), 10002);
|
||||
|
||||
add_action('init', array(&$this, 'listen_to_password_reset_uri'), 1);
|
||||
add_action( 'um_reset_password_errors_hook', array( &$this, 'um_reset_password_errors_hook' ) );
|
||||
add_action( 'um_reset_password_process_hook', array( &$this,'um_reset_password_process_hook' ) );
|
||||
|
||||
add_action( 'um_change_password_errors_hook', array( &$this, 'um_change_password_errors_hook' ) );
|
||||
add_action( 'um_change_password_process_hook', array( &$this,'um_change_password_process_hook' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A listener to password reset uri
|
||||
*/
|
||||
function listen_to_password_reset_uri() {
|
||||
|
||||
if ( isset($_REQUEST['act']) && $_REQUEST['act'] == 'reset_password' && isset($_REQUEST['hash']) && strlen($_REQUEST['hash']) == 40 &&
|
||||
isset($_REQUEST['user_id']) && is_numeric($_REQUEST['user_id']) ) {
|
||||
|
||||
$user_id = absint( $_REQUEST['user_id'] );
|
||||
delete_option( "um_cache_userdata_{$user_id}" );
|
||||
|
||||
um_fetch_user( $user_id );
|
||||
|
||||
if ( $_REQUEST['hash'] != um_user('reset_pass_hash') ){
|
||||
wp_die( __('This is not a valid hash, or it has expired.','ultimate-member') );
|
||||
}
|
||||
|
||||
UM()->user()->profile['reset_pass_hash_token'] = current_time( 'timestamp' );
|
||||
UM()->user()->update_usermeta_info('reset_pass_hash_token');
|
||||
|
||||
$this->change_password = true;
|
||||
|
||||
um_reset_user();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* reset url
|
||||
* Get Reset URL
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
function reset_url(){
|
||||
if ( !um_user('reset_pass_hash') ) return false;
|
||||
|
||||
$user_id = um_user('ID');
|
||||
function reset_url() {
|
||||
$user_id = um_user( 'ID' );
|
||||
|
||||
delete_option( "um_cache_userdata_{$user_id}" );
|
||||
|
||||
$url = add_query_arg( 'act', 'reset_password', um_get_core_page('password-reset') );
|
||||
$url = add_query_arg( 'hash', esc_attr( um_user('reset_pass_hash') ), $url );
|
||||
$url = add_query_arg( 'user_id', esc_attr( um_user('ID') ), $url );
|
||||
//new reset password key via WP native field
|
||||
$user_data = get_userdata( $user_id );
|
||||
$key = get_password_reset_key( $user_data );
|
||||
|
||||
$url = add_query_arg( array( 'act' => 'reset_password', 'hash' => $key, 'user_id' => $user_id ), um_get_core_page( 'password-reset' ) );
|
||||
return $url;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* we are on password reset page
|
||||
*/
|
||||
function password_reset(){
|
||||
if ( um_is_core_page('password-reset') ) {
|
||||
|
||||
UM()->fields()->set_mode = 'password';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Password page form
|
||||
*/
|
||||
function form_init() {
|
||||
if ( um_requesting_password_reset() ) {
|
||||
|
||||
UM()->form()->post_form = $_POST;
|
||||
|
||||
if ( empty( UM()->form()->post_form['mode'] ) ) {
|
||||
UM()->form()->post_form['mode'] = 'password';
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_reset_password_errors_hook
|
||||
* @description Action on reset password submit form
|
||||
* @input_vars
|
||||
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_reset_password_errors_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_reset_password_errors_hook', 'my_reset_password_errors', 10, 1 );
|
||||
* function my_reset_password_errors( $post ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_reset_password_errors_hook', UM()->form()->post_form );
|
||||
|
||||
if ( ! isset( UM()->form()->errors ) ) {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_reset_password_process_hook
|
||||
* @description Action on reset password success submit form
|
||||
* @input_vars
|
||||
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_reset_password_process_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_reset_password_process_hook', 'my_reset_password_process', 10, 1 );
|
||||
* function my_reset_password_process( $post ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_reset_password_process_hook', UM()->form()->post_form );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( um_requesting_password_change() ) {
|
||||
|
||||
UM()->form()->post_form = $_POST;
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_change_password_errors_hook
|
||||
* @description Action on change password submit form
|
||||
* @input_vars
|
||||
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_change_password_errors_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_change_password_errors_hook', 'my_change_password_errors', 10, 1 );
|
||||
* function my_change_password_errors( $post ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_change_password_errors_hook', UM()->form()->post_form );
|
||||
|
||||
if ( ! isset( UM()->form()->errors ) ) {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_change_password_process_hook
|
||||
* @description Action on change password success submit form
|
||||
* @input_vars
|
||||
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_change_password_process_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_change_password_process_hook', 'my_change_password_process', 10, 1 );
|
||||
* function my_change_password_process( $post ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_change_password_process_hook', UM()->form()->post_form );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add class based on shortcode
|
||||
*
|
||||
* @param $mode
|
||||
* @param string $mode
|
||||
*
|
||||
* @return mixed|string|void
|
||||
* @return string
|
||||
*/
|
||||
function get_class( $mode ) {
|
||||
|
||||
@@ -262,6 +97,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
return $classes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Shortcode
|
||||
*
|
||||
@@ -270,26 +106,14 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
* @return string
|
||||
*/
|
||||
function ultimatemember_password( $args = array() ) {
|
||||
return $this->load( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a module with global function
|
||||
*
|
||||
* @param $args
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function load( $args ) {
|
||||
|
||||
ob_start();
|
||||
|
||||
$defaults = array(
|
||||
'template' => 'password-reset',
|
||||
'mode' => 'password',
|
||||
'form_id' => 'um_password_id',
|
||||
'template' => 'password-reset',
|
||||
'mode' => 'password',
|
||||
'form_id' => 'um_password_id',
|
||||
'max_width' => '450px',
|
||||
'align' => 'center',
|
||||
'align' => 'center',
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
@@ -323,12 +147,22 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
$args = apply_filters( 'um_reset_password_shortcode_args_filter', $args );
|
||||
|
||||
if ( isset( $this->change_password ) ) {
|
||||
|
||||
$args['user_id'] = $_REQUEST['user_id'];
|
||||
$args['template'] = 'password-change';
|
||||
$args['rp_key'] = '';
|
||||
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
||||
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
|
||||
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
|
||||
|
||||
$user = get_user_by( 'login', $rp_login );
|
||||
$args['user_id'] = $user->ID;
|
||||
$args['rp_key'] = $rp_key;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @var $mode
|
||||
* @var $template
|
||||
*/
|
||||
extract( $args, EXTR_SKIP );
|
||||
|
||||
/**
|
||||
@@ -398,11 +232,380 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
UM()->shortcodes()->dynamic_css( $args );
|
||||
}
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$output = ob_get_clean();
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a legitimate password reset request is in action
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_reset_request() {
|
||||
if ( um_is_core_page( 'password-reset' ) && isset( $_POST['_um_password_reset'] ) == 1 ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a legitimate password change request is in action
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_change_request() {
|
||||
if ( um_is_core_page( 'account' ) && isset( $_POST['_um_account'] ) == 1 && isset( $_POST['_um_account_tab'] ) && $_POST['_um_account_tab'] == 'password' ) {
|
||||
return true;
|
||||
} elseif ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Password page form
|
||||
*/
|
||||
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' ) {
|
||||
list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) );
|
||||
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
||||
if ( isset( $_GET['hash'] ) ) {
|
||||
$userdata = get_userdata( wp_unslash( $_GET['user_id'] ) );
|
||||
if ( ! $userdata || is_wp_error( $userdata ) ) {
|
||||
wp_redirect( add_query_arg( array( 'act' => 'reset_password', 'error' => 'invalidkey' ), get_permalink() ) );
|
||||
exit;
|
||||
}
|
||||
$rp_login = $userdata->user_login;
|
||||
$value = sprintf( '%s:%s', $rp_login, wp_unslash( $_GET['hash'] ) );
|
||||
setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
|
||||
wp_safe_redirect( remove_query_arg( array( 'hash', 'user_id' ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
|
||||
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
|
||||
$user = check_password_reset_key( $rp_key, $rp_login );
|
||||
} else {
|
||||
$user = false;
|
||||
}
|
||||
|
||||
if ( ! $user || is_wp_error( $user ) ) {
|
||||
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
|
||||
if ( $user && $user->get_error_code() === 'expired_key' ) {
|
||||
wp_redirect( add_query_arg( array( 'updated' => 'expiredkey' ), get_permalink() ) );
|
||||
} else {
|
||||
wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->change_password = true;
|
||||
}
|
||||
|
||||
if ( $this->is_reset_request() ) {
|
||||
|
||||
UM()->form()->post_form = $_POST;
|
||||
|
||||
if ( empty( UM()->form()->post_form['mode'] ) ) {
|
||||
UM()->form()->post_form['mode'] = 'password';
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_reset_password_errors_hook
|
||||
* @description Action on reset password submit form
|
||||
* @input_vars
|
||||
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_reset_password_errors_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_reset_password_errors_hook', 'my_reset_password_errors', 10, 1 );
|
||||
* function my_reset_password_errors( $post ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_reset_password_errors_hook', UM()->form()->post_form );
|
||||
|
||||
if ( ! isset( UM()->form()->errors ) ) {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_reset_password_process_hook
|
||||
* @description Action on reset password success submit form
|
||||
* @input_vars
|
||||
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_reset_password_process_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_reset_password_process_hook', 'my_reset_password_process', 10, 1 );
|
||||
* function my_reset_password_process( $post ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_reset_password_process_hook', UM()->form()->post_form );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $this->is_change_request() ) {
|
||||
UM()->form()->post_form = $_POST;
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_change_password_errors_hook
|
||||
* @description Action on change password submit form
|
||||
* @input_vars
|
||||
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_change_password_errors_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_change_password_errors_hook', 'my_change_password_errors', 10, 1 );
|
||||
* function my_change_password_errors( $post ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_change_password_errors_hook', UM()->form()->post_form );
|
||||
|
||||
if ( ! isset( UM()->form()->errors ) ) {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_change_password_process_hook
|
||||
* @description Action on change password success submit form
|
||||
* @input_vars
|
||||
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_change_password_process_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_change_password_process_hook', 'my_change_password_process', 10, 1 );
|
||||
* function my_change_password_process( $post ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_change_password_process_hook', UM()->form()->post_form );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Error handler: reset password
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function um_reset_password_errors_hook( $args ) {
|
||||
|
||||
if ( $_POST[ UM()->honeypot ] != '' )
|
||||
wp_die('Hello, spam bot!','ultimate-member');
|
||||
|
||||
$user = "";
|
||||
|
||||
foreach ( $_POST as $key => $val ) {
|
||||
if( strstr( $key, "username_b") ){
|
||||
$user = trim( $val );
|
||||
}
|
||||
}
|
||||
|
||||
if ( empty( $user ) ) {
|
||||
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') );
|
||||
} else {
|
||||
|
||||
if ( is_email( $user ) ) {
|
||||
$user_id = email_exists( $user );
|
||||
} else {
|
||||
$user_id = username_exists( $user );
|
||||
}
|
||||
|
||||
$attempts = (int)get_user_meta( $user_id, 'password_rst_attempts', true );
|
||||
$is_admin = user_can( intval( $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 {
|
||||
$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') );
|
||||
} else {
|
||||
update_user_meta( $user_id, 'password_rst_attempts', $attempts + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process a new request
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function um_reset_password_process_hook( $args ) {
|
||||
$user = null;
|
||||
|
||||
foreach ( $_POST as $key => $val ) {
|
||||
if ( strstr( $key, "username_b" ) ) {
|
||||
$user = trim( $val );
|
||||
}
|
||||
}
|
||||
|
||||
if ( username_exists( $user ) ) {
|
||||
$data = get_user_by( 'login', $user );
|
||||
} elseif ( email_exists( $user ) ) {
|
||||
$data = get_user_by( 'email', $user );
|
||||
}
|
||||
|
||||
um_fetch_user( $data->ID );
|
||||
|
||||
UM()->user()->password_reset();
|
||||
|
||||
exit( wp_redirect( um_get_core_page('password-reset', 'checkemail' ) ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Error handler: changing 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');
|
||||
}
|
||||
|
||||
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') );
|
||||
}
|
||||
|
||||
if ( isset( $args['user_password'] ) && empty( $args['user_password'] ) ) {
|
||||
UM()->form()->add_error('user_password', __('You must enter a new password','ultimate-member') );
|
||||
}
|
||||
|
||||
if ( UM()->options()->get( 'reset_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') );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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'] ) {
|
||||
UM()->form()->add_error('confirm_user_password', __('Your passwords do not match','ultimate-member') );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process a change request
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function um_change_password_process_hook( $args ) {
|
||||
extract( $args );
|
||||
|
||||
if ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_after_changing_user_password
|
||||
* @description Hook that runs after user change their password
|
||||
* @input_vars
|
||||
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_after_changing_user_password', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_after_changing_user_password', 'my_after_changing_user_password', 10, 1 );
|
||||
* function my_user_login_extra( $user_id ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_after_changing_user_password', $args['user_id'] );
|
||||
|
||||
$user = get_userdata( $args['user_id'] );
|
||||
$errors = new \WP_Error();
|
||||
/**
|
||||
* Fires before the password reset procedure is validated.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param object $errors WP Error object.
|
||||
* @param \WP_User|\WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise.
|
||||
*/
|
||||
do_action( 'validate_password_reset', $errors, $user );
|
||||
|
||||
list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) );
|
||||
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
||||
|
||||
if ( ( ! $errors->get_error_code() ) ) {
|
||||
reset_password( $user, $args['user_password'] );
|
||||
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
|
||||
delete_user_meta( $args['user_id'], 'password_rst_attempts' );
|
||||
|
||||
if ( is_user_logged_in() ) {
|
||||
wp_logout();
|
||||
}
|
||||
|
||||
exit( wp_redirect( um_get_core_page('login', 'password_changed' ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
/**
|
||||
* All tab data
|
||||
*
|
||||
* @return mixed|void
|
||||
* @return array
|
||||
*/
|
||||
function tabs() {
|
||||
|
||||
@@ -141,7 +141,7 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
/**
|
||||
* Tabs that are active
|
||||
*
|
||||
* @return mixed|void
|
||||
* @return array
|
||||
*/
|
||||
function tabs_active() {
|
||||
$tabs = $this->tabs();
|
||||
@@ -161,7 +161,7 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function tabs_primary(){
|
||||
function tabs_primary() {
|
||||
$tabs = $this->tabs();
|
||||
$primary = array();
|
||||
foreach ( $tabs as $id => $info ) {
|
||||
@@ -178,7 +178,7 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function tabs_enabled(){
|
||||
function tabs_enabled() {
|
||||
$tabs = $this->tabs();
|
||||
foreach( $tabs as $id => $info ){
|
||||
if ( isset( $info['name'] ) ) {
|
||||
@@ -266,7 +266,7 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
/**
|
||||
* Get active_tab
|
||||
*
|
||||
* @return mixed|void
|
||||
* @return string
|
||||
*/
|
||||
function active_tab() {
|
||||
|
||||
@@ -306,7 +306,7 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
/**
|
||||
* Get active active_subnav
|
||||
*
|
||||
* @return mixed|null
|
||||
* @return string|null
|
||||
*/
|
||||
function active_subnav() {
|
||||
|
||||
|
||||
@@ -68,8 +68,7 @@ if ( ! class_exists( 'um\core\Query' ) ) {
|
||||
*/
|
||||
do_action( "um_ajax_load_posts__{$hook}", $args );
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$output = ob_get_clean();
|
||||
|
||||
die( $output );
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ if ( ! class_exists( 'um\core\Rewrite' ) ) {
|
||||
|
||||
$public_query_vars[] = 'um_page';
|
||||
$public_query_vars[] = 'um_action';
|
||||
$public_query_vars[] = 'um_field';
|
||||
$public_query_vars[] = 'um_form';
|
||||
$public_query_vars[] = 'um_resource';
|
||||
$public_query_vars[] = 'um_method';
|
||||
$public_query_vars[] = 'um_verify';
|
||||
@@ -63,6 +65,7 @@ if ( ! class_exists( 'um\core\Rewrite' ) ) {
|
||||
$newrules = array();
|
||||
|
||||
$newrules['um-api/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?um_page=api&um_action=$matches[1]&um_resource=$matches[2]&um_method=$matches[3]&um_verify=$matches[4]';
|
||||
$newrules['um-download/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?um_action=download&um_form=$matches[1]&um_field=$matches[2]&um_user=$matches[3]&um_verify=$matches[4]';
|
||||
|
||||
if ( isset( UM()->config()->permalinks['user'] ) ) {
|
||||
|
||||
|
||||
@@ -532,8 +532,11 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
|
||||
foreach ( $role_data as $key=>$value ) {
|
||||
if ( strpos( $key, '_um_' ) === 0 )
|
||||
$key = str_replace( '_um_', '', $key );
|
||||
$temp[$key] = $value;
|
||||
$temp[ $key ] = $value;
|
||||
}
|
||||
|
||||
$temp = apply_filters( 'um_change_role_data', $temp, $roleID );
|
||||
|
||||
return $temp;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,12 +14,6 @@ if ( ! class_exists( 'um\core\Setup' ) ) {
|
||||
class Setup {
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
var $setup_shortcode = array();
|
||||
|
||||
|
||||
/**
|
||||
* Setup constructor.
|
||||
*/
|
||||
@@ -34,6 +28,7 @@ if ( ! class_exists( 'um\core\Setup' ) ) {
|
||||
function run_setup() {
|
||||
$this->install_basics();
|
||||
$this->install_default_forms();
|
||||
//$this->install_default_pages();
|
||||
$this->set_default_settings();
|
||||
$this->set_default_role_meta();
|
||||
}
|
||||
@@ -43,8 +38,9 @@ if ( ! class_exists( 'um\core\Setup' ) ) {
|
||||
* Basics
|
||||
*/
|
||||
function install_basics() {
|
||||
if ( ! get_option( '__ultimatemember_sitekey' ) )
|
||||
if ( ! get_option( '__ultimatemember_sitekey' ) ) {
|
||||
update_option( '__ultimatemember_sitekey', str_replace( array( 'http://', 'https://' ), '', sanitize_user( get_bloginfo('url') ) ) . '-' . wp_generate_password( 20, false ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,11 +48,8 @@ if ( ! class_exists( 'um\core\Setup' ) ) {
|
||||
* Default Forms
|
||||
*/
|
||||
function install_default_forms() {
|
||||
|
||||
$options = get_option( 'um_options' );
|
||||
$options = empty( $options ) ? array() : $options;
|
||||
|
||||
if ( current_user_can( 'manage_options' ) && ! get_option( 'um_is_installed' ) ) {
|
||||
$options = get_option( 'um_options', array() );
|
||||
|
||||
update_option( 'um_is_installed', 1 );
|
||||
|
||||
@@ -101,17 +94,14 @@ if ( ! class_exists( 'um\core\Setup' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
$this->setup_shortcode[$id] = '[ultimatemember form_id='.$form_id.']';
|
||||
|
||||
$core_forms[ $form_id ] = $form_id;
|
||||
|
||||
$core_forms[ $id ] = $form_id;
|
||||
}
|
||||
/** DONE **/
|
||||
|
||||
}
|
||||
|
||||
if ( isset( $core_forms ) )
|
||||
if ( isset( $core_forms ) ) {
|
||||
update_option( 'um_core_forms', $core_forms );
|
||||
}
|
||||
|
||||
// Install Core Directories
|
||||
foreach ( UM()->config()->core_directories as $id ) {
|
||||
@@ -134,7 +124,7 @@ if ( ! class_exists( 'um\core\Setup' ) ) {
|
||||
|
||||
$form_id = wp_insert_post( $form );
|
||||
|
||||
foreach ( UM()->config()->core_directory_meta[$id] as $key => $value ) {
|
||||
foreach ( UM()->config()->core_directory_meta[ $id ] as $key => $value ) {
|
||||
if ( $key == '_um_custom_fields' ) {
|
||||
$array = unserialize( $value );
|
||||
update_post_meta( $form_id, $key, $array );
|
||||
@@ -143,68 +133,78 @@ if ( ! class_exists( 'um\core\Setup' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
$this->setup_shortcode[$id] = '[ultimatemember form_id='.$form_id.']';
|
||||
|
||||
$core_directories[ $form_id ] = $form_id;
|
||||
|
||||
$core_directories[ $id ] = $form_id;
|
||||
}
|
||||
/** DONE **/
|
||||
|
||||
}
|
||||
|
||||
if ( isset( $core_directories ) ) update_option( 'um_core_directories', $core_directories );
|
||||
|
||||
|
||||
// Install Core Pages
|
||||
$core_pages = array();
|
||||
foreach ( UM()->config()->core_pages as $slug => $array ) {
|
||||
|
||||
/**
|
||||
If page does not exist
|
||||
Create it
|
||||
**/
|
||||
$page_exists = UM()->query()->find_post_id( 'page', '_um_core', $slug );
|
||||
if ( ! $page_exists ) {
|
||||
|
||||
if ( $slug == 'logout' ) {
|
||||
$content = '';
|
||||
} else if ( $slug == 'account' ) {
|
||||
$content = '[ultimatemember_account]';
|
||||
} else if ( $slug == 'password-reset' ) {
|
||||
$content = '[ultimatemember_password]';
|
||||
} else if ( $slug == 'user' ){
|
||||
$content = $this->setup_shortcode['profile'];
|
||||
} else {
|
||||
$content = $this->setup_shortcode[$slug];
|
||||
}
|
||||
|
||||
$user_page = array(
|
||||
'post_title' => $array['title'],
|
||||
'post_content' => $content,
|
||||
'post_name' => $slug,
|
||||
'post_type' => 'post',
|
||||
'post_status' => 'publish',
|
||||
'post_author' => get_current_user_id(),
|
||||
'comment_status' => 'closed'
|
||||
);
|
||||
|
||||
$post_id = wp_insert_post( $user_page );
|
||||
wp_update_post( array( 'ID' => $post_id, 'post_type' => 'page' ) );
|
||||
|
||||
update_post_meta( $post_id, '_um_core', $slug );
|
||||
|
||||
$core_pages[ $slug ] = $post_id;
|
||||
|
||||
} else {
|
||||
$core_pages[ $slug ] = $page_exists;
|
||||
}
|
||||
/** DONE **/
|
||||
if ( isset( $core_directories ) ) {
|
||||
update_option( 'um_core_directories', $core_directories );
|
||||
}
|
||||
|
||||
foreach ( $core_pages as $slug => $page_id ) {
|
||||
$key = UM()->options()->get_core_page_id( $slug );
|
||||
$options[ $key ] = $page_id;
|
||||
update_option( 'um_options', $options );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Install Pre-defined pages with shortcodes
|
||||
*/
|
||||
function install_default_pages() {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$core_forms = get_option( 'um_core_forms', array() );
|
||||
$core_directories = get_option( 'um_core_directories', array() );
|
||||
|
||||
$setup_shortcodes = array_merge( $core_forms, $core_directories );
|
||||
|
||||
//Install Core Pages
|
||||
$core_pages = array();
|
||||
foreach ( UM()->config()->core_pages as $slug => $array ) {
|
||||
|
||||
$page_exists = UM()->query()->find_post_id( 'page', '_um_core', $slug );
|
||||
if ( $page_exists ) {
|
||||
$core_pages[ $slug ] = $page_exists;
|
||||
continue;
|
||||
}
|
||||
|
||||
//If page does not exist - create it
|
||||
if ( $slug == 'logout' ) {
|
||||
$content = '';
|
||||
} elseif ( $slug == 'account' ) {
|
||||
$content = '[ultimatemember_account]';
|
||||
} elseif ( $slug == 'password-reset' ) {
|
||||
$content = '[ultimatemember_password]';
|
||||
} elseif ( $slug == 'user' ) {
|
||||
$content = '[ultimatemember form_id="' . $setup_shortcodes['profile'] . '"]';
|
||||
} else {
|
||||
$content = '[ultimatemember form_id="' . $setup_shortcodes[ $slug ] . '"]';
|
||||
}
|
||||
|
||||
$user_page = array(
|
||||
'post_title' => $array['title'],
|
||||
'post_content' => $content,
|
||||
'post_name' => $slug,
|
||||
'post_type' => 'page',
|
||||
'post_status' => 'publish',
|
||||
'post_author' => get_current_user_id(),
|
||||
'comment_status' => 'closed'
|
||||
);
|
||||
|
||||
$post_id = wp_insert_post( $user_page );
|
||||
update_post_meta( $post_id, '_um_core', $slug );
|
||||
|
||||
$core_pages[ $slug ] = $post_id;
|
||||
}
|
||||
|
||||
$options = get_option( 'um_options', array() );
|
||||
|
||||
foreach ( $core_pages as $slug => $page_id ) {
|
||||
$key = UM()->options()->get_core_page_id( $slug );
|
||||
$options[ $key ] = $page_id;
|
||||
}
|
||||
|
||||
update_option( 'um_options', $options );
|
||||
|
||||
@@ -385,14 +385,13 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
|
||||
ob_start();
|
||||
|
||||
// Hide for logged in users
|
||||
if (is_user_logged_in()) {
|
||||
if ( is_user_logged_in() ) {
|
||||
echo '';
|
||||
} else {
|
||||
echo do_shortcode(wpautop($content));
|
||||
echo do_shortcode( wpautop( $content ) );
|
||||
}
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$output = ob_get_clean();
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -417,8 +416,6 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
|
||||
* @return string
|
||||
*/
|
||||
function load( $args ) {
|
||||
ob_start();
|
||||
|
||||
$defaults = array();
|
||||
$args = wp_parse_args($args, $defaults);
|
||||
|
||||
@@ -436,6 +433,8 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
|
||||
// get data into one global array
|
||||
$post_data = UM()->query()->post_data($this->form_id);
|
||||
|
||||
ob_start();
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
@@ -459,7 +458,7 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
|
||||
*/
|
||||
$args = apply_filters( 'um_pre_args_setup', $post_data );
|
||||
|
||||
if (!isset($args['template'])) {
|
||||
if ( ! isset( $args['template'] ) ) {
|
||||
$args['template'] = '';
|
||||
}
|
||||
|
||||
@@ -515,6 +514,7 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
|
||||
//not display on admin preview
|
||||
if ( empty( $_POST['act_id'] ) || $_POST['act_id'] != 'um_admin_preview_form' ) {
|
||||
if ( 'register' == $mode && is_user_logged_in() ) {
|
||||
ob_get_clean();
|
||||
return __( 'You are already registered', 'ultimate-member' );
|
||||
}
|
||||
}
|
||||
@@ -529,10 +529,12 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
|
||||
if ( ! empty( $args['role'] ) ) {
|
||||
if ( is_array( $args['role'] ) ) {
|
||||
if ( ! count( array_intersect( $args['role'], $current_user_roles ) ) ) {
|
||||
ob_get_clean();
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
if ( ! in_array( $args['role'], $current_user_roles ) ) {
|
||||
ob_get_clean();
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -628,8 +630,7 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
|
||||
*/
|
||||
do_action( 'um_after_everything_output' );
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$output = ob_get_clean();
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -998,10 +999,7 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
|
||||
$this->load_template( 'searchform' );
|
||||
|
||||
// get the buffer
|
||||
$template = ob_get_contents();
|
||||
|
||||
// clear the buffer
|
||||
ob_end_clean();
|
||||
$template = ob_get_clean();
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
+157
-148
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
namespace um\core;
|
||||
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
|
||||
|
||||
@@ -13,179 +15,196 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
*/
|
||||
class Uploader {
|
||||
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
var $user_id;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $field_key;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $wp_upload_dir;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $temp_upload_dir;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $core_upload_dir;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $core_upload_url;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $upload_baseurl;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $upload_basedir;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $upload_user_baseurl;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $upload_user_basedir;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $upload_image_type;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $upload_type;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Uploader constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
|
||||
$this->core_upload_dir = "/ultimatemember/";
|
||||
$this->core_upload_dir = DIRECTORY_SEPARATOR . "ultimatemember" . DIRECTORY_SEPARATOR;
|
||||
$this->core_upload_url = "/ultimatemember/";
|
||||
$this->upload_image_type = 'stream_photo';
|
||||
$this->wp_upload_dir = wp_upload_dir();
|
||||
$this->temp_upload_dir = "temp";
|
||||
|
||||
add_filter("upload_dir", array( $this, "set_upload_directory" ), 10, 1 );
|
||||
add_filter("wp_handle_upload_prefilter", array( $this, "validate_upload" ) );
|
||||
add_filter("um_upload_image_process__profile_photo", array( $this, "profile_photo" ), 10, 6 );
|
||||
add_filter("um_upload_image_process__cover_photo", array( $this, "cover_photo" ), 10, 6 );
|
||||
add_filter("um_upload_stream_image_process", array( $this, "stream_photo" ), 10, 6 );
|
||||
add_filter("um_custom_image_handle_wall_img_upload", array( $this, "stream_photo_data"), 10, 1 );
|
||||
|
||||
add_action("init", array( $this, "init" ) );
|
||||
add_filter( "upload_dir", array( $this, "set_upload_directory" ), 10, 1 );
|
||||
add_filter( "wp_handle_upload_prefilter", array( $this, "validate_upload" ) );
|
||||
add_filter( "um_upload_image_process__profile_photo", array( $this, "profile_photo" ), 10, 6 );
|
||||
add_filter( "um_upload_image_process__cover_photo", array( $this, "cover_photo" ), 10, 6 );
|
||||
add_filter( "um_upload_stream_image_process", array( $this, "stream_photo" ), 10, 6 );
|
||||
add_filter( "um_custom_image_handle_wall_img_upload", array( $this, "stream_photo_data"), 10, 1 );
|
||||
|
||||
add_action( "init", array( $this, "init" ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Init
|
||||
*/
|
||||
function init(){
|
||||
$this->user_id = get_current_user_id();
|
||||
function init() {
|
||||
$this->user_id = get_current_user_id();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get core temporary directory path
|
||||
*
|
||||
* @since 2.0.22
|
||||
* @return string
|
||||
*/
|
||||
public function get_core_temp_dir(){
|
||||
|
||||
return $this->get_upload_base_dir(). $this->temp_upload_dir;
|
||||
public function get_core_temp_dir() {
|
||||
return $this->get_upload_base_dir(). $this->temp_upload_dir;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get core temporary directory URL
|
||||
*
|
||||
* @since 2.0.22
|
||||
* @return string
|
||||
*/
|
||||
public function get_core_temp_url(){
|
||||
|
||||
return $this->get_upload_base_url(). $this->temp_upload_dir;
|
||||
public function get_core_temp_url() {
|
||||
return $this->get_upload_base_url(). $this->temp_upload_dir;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get core upload directory
|
||||
*
|
||||
* @since 2.0.22
|
||||
* @return string
|
||||
*/
|
||||
public function get_core_upload_dir(){
|
||||
|
||||
public function get_core_upload_dir() {
|
||||
return $this->core_upload_dir;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get core upload base url
|
||||
*
|
||||
* @since 2.0.22
|
||||
* @return string
|
||||
*/
|
||||
public function get_upload_base_url(){
|
||||
|
||||
public function get_upload_base_url() {
|
||||
$wp_baseurl = $this->wp_upload_dir['baseurl'];
|
||||
|
||||
$this->upload_baseurl = $wp_baseurl . $this->core_upload_dir;
|
||||
$this->upload_baseurl = set_url_scheme( $wp_baseurl . $this->core_upload_dir );
|
||||
|
||||
return $this->upload_baseurl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get core upload base directory
|
||||
*
|
||||
* @since 2.0.22
|
||||
* @return string
|
||||
*/
|
||||
public function get_upload_base_dir(){
|
||||
|
||||
public function get_upload_base_dir() {
|
||||
$wp_basedir = $this->wp_upload_dir['basedir'];
|
||||
|
||||
$this->upload_basedir = $wp_basedir . $this->core_upload_dir;
|
||||
|
||||
|
||||
return $this->upload_basedir;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get user upload base directory
|
||||
*
|
||||
* @param integer $user_id
|
||||
* @since 2.0.22
|
||||
* @param bool $create_dir
|
||||
*
|
||||
* @since 2.0.22
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_upload_user_base_dir( $user_id = null, $create_dir = false){
|
||||
|
||||
if( $user_id ){
|
||||
public function get_upload_user_base_dir( $user_id = null, $create_dir = false ) {
|
||||
if ( $user_id ) {
|
||||
$this->user_id = $user_id;
|
||||
}
|
||||
|
||||
$this->upload_user_basedir = $this->get_upload_base_dir() . $this->user_id;
|
||||
$this->upload_user_basedir = $this->get_upload_base_dir() . $this->user_id;
|
||||
|
||||
if( $create_dir ){
|
||||
if ( $create_dir ) {
|
||||
wp_mkdir_p( $this->upload_user_basedir );
|
||||
}
|
||||
|
||||
return $this->upload_user_basedir;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get user upload base url
|
||||
*
|
||||
@@ -193,17 +212,16 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
* @since 2.0.22
|
||||
* @return string
|
||||
*/
|
||||
public function get_upload_user_base_url( $user_id = null ){
|
||||
|
||||
if( $user_id ){
|
||||
public function get_upload_user_base_url( $user_id = null ) {
|
||||
if ( $user_id ) {
|
||||
$this->user_id = $user_id;
|
||||
}
|
||||
|
||||
$this->upload_user_baseurl = $this->get_upload_base_url() . $this->user_id;
|
||||
$this->upload_user_baseurl = $this->get_upload_base_url() . $this->user_id;
|
||||
|
||||
return $this->upload_user_baseurl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate file size
|
||||
@@ -211,7 +229,6 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
* @return array
|
||||
*/
|
||||
public function validate_upload( $file ) {
|
||||
|
||||
$error = false;
|
||||
if ( 'image' == $this->upload_type ) {
|
||||
$error = $this->validate_image_data( $file['tmp_name'], $this->field_key );
|
||||
@@ -226,6 +243,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set upload directory
|
||||
*
|
||||
@@ -233,29 +251,36 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function set_upload_directory( $args ){
|
||||
|
||||
$this->upload_baseurl = $args['baseurl'] . $this->core_upload_dir;
|
||||
public function set_upload_directory( $args ) {
|
||||
$this->upload_baseurl = $args['baseurl'] . $this->core_upload_url;
|
||||
$this->upload_basedir = $args['basedir'] . $this->core_upload_dir;
|
||||
|
||||
if( 'image' == $this->upload_type && 'wall_img_upload' != $this->field_key && is_user_logged_in() ){
|
||||
$this->upload_user_baseurl = $this->upload_baseurl . $this->user_id;
|
||||
$this->upload_user_basedir = $this->upload_basedir . $this->user_id;
|
||||
}else{
|
||||
$this->upload_user_baseurl = $this->upload_baseurl . $this->temp_upload_dir;
|
||||
$this->upload_user_basedir = $this->upload_basedir . $this->temp_upload_dir;
|
||||
if ( 'image' == $this->upload_type && is_user_logged_in() ) {
|
||||
if ( 'stream_photo' == $this->upload_image_type ) {
|
||||
$this->upload_user_baseurl = $this->upload_baseurl . $this->temp_upload_dir;
|
||||
$this->upload_user_basedir = $this->upload_basedir . $this->temp_upload_dir;
|
||||
} else {
|
||||
$this->upload_user_baseurl = $this->upload_baseurl . $this->user_id;
|
||||
$this->upload_user_basedir = $this->upload_basedir . $this->user_id;
|
||||
}
|
||||
} else {
|
||||
$this->upload_user_baseurl = $this->upload_baseurl . $this->temp_upload_dir;
|
||||
$this->upload_user_basedir = $this->upload_basedir . $this->temp_upload_dir;
|
||||
}
|
||||
|
||||
list( $this->upload_user_baseurl, $this->upload_user_basedir ) = apply_filters( 'um_change_upload_user_path', array( $this->upload_user_baseurl, $this->upload_user_basedir ), $this->field_key, $this->upload_type );
|
||||
|
||||
$args['path'] = $this->upload_user_basedir;
|
||||
$args['url'] = $this->upload_user_baseurl;
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Upload Image files
|
||||
*
|
||||
* @param $uploadedfile
|
||||
* @param array $uploadedfile
|
||||
* @param int|null $user_id
|
||||
* @param string $field_key
|
||||
* @param string $upload_type
|
||||
@@ -265,15 +290,13 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
* @return array
|
||||
*/
|
||||
public function upload_image( $uploadedfile, $user_id = null, $field_key = '', $upload_type = 'stream_photo' ) {
|
||||
|
||||
|
||||
$response = array();
|
||||
|
||||
if ( ! function_exists( 'wp_handle_upload' ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
||||
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
||||
}
|
||||
|
||||
if( empty( $field_key ) ){
|
||||
if ( empty( $field_key ) ) {
|
||||
$field_key = "custom_field";
|
||||
}
|
||||
|
||||
@@ -283,35 +306,35 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
|
||||
$this->upload_image_type = $upload_type;
|
||||
|
||||
if( $user_id && is_user_logged_in() ){
|
||||
if ( $user_id && is_user_logged_in() ) {
|
||||
$this->user_id = $user_id;
|
||||
}
|
||||
|
||||
if( in_array( $field_key, array( 'profile_photo','cover_photo' ) ) ){
|
||||
|
||||
if ( in_array( $field_key, array( 'profile_photo','cover_photo' ) ) ) {
|
||||
$this->upload_image_type = $field_key;
|
||||
}
|
||||
|
||||
$field_data = UM()->fields()->get_field( $field_key );
|
||||
|
||||
if( isset( $field_data['allowed_types'] ) && ! empty( $field_data['allowed_types'] ) ){
|
||||
|
||||
if ( isset( $field_data['allowed_types'] ) && ! empty( $field_data['allowed_types'] ) ) {
|
||||
$field_allowed_file_types = explode(",", $field_data['allowed_types'] );
|
||||
}else{
|
||||
} else {
|
||||
$field_allowed_file_types = apply_filters("um_uploader_image_default_filetypes", array('JPG','JPEG','PNG','GIF') );
|
||||
}
|
||||
|
||||
$allowed_image_mimes = array();
|
||||
|
||||
foreach( $field_allowed_file_types as $a ){
|
||||
|
||||
foreach ( $field_allowed_file_types as $a ) {
|
||||
$atype = wp_check_filetype( "test.{$a}" );
|
||||
$allowed_image_mimes[ $atype['ext'] ] = $atype['type'];
|
||||
}
|
||||
|
||||
$image_compression = UM()->options()->get('image_compression');
|
||||
$image_compression = UM()->options()->get('image_compression');
|
||||
|
||||
$upload_overrides = array(
|
||||
'test_form' => false,
|
||||
'mimes' => apply_filters( "um_uploader_allowed_image_mimes", $allowed_image_mimes ),
|
||||
'unique_filename_callback' => array( $this, "unique_filename"),
|
||||
'test_form' => false,
|
||||
'mimes' => apply_filters( "um_uploader_allowed_image_mimes", $allowed_image_mimes ),
|
||||
'unique_filename_callback' => array( $this, "unique_filename"),
|
||||
);
|
||||
|
||||
$upload_overrides = apply_filters( "um_image_upload_handler_overrides__{$field_key}", $upload_overrides );
|
||||
@@ -319,12 +342,12 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
|
||||
|
||||
if ( isset( $movefile['error'] ) ) {
|
||||
/*
|
||||
/*
|
||||
* Error generated by _wp_handle_upload()
|
||||
* @see _wp_handle_upload() in wp-admin/includes/file.php
|
||||
*/
|
||||
$response['error'] = $movefile['error'];
|
||||
}else{
|
||||
$response['error'] = $movefile['error'];
|
||||
} else {
|
||||
|
||||
$movefile['url'] = set_url_scheme( $movefile['url'] );
|
||||
|
||||
@@ -425,13 +448,13 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
*/
|
||||
do_action( "um_after_upload_db_meta_{$field_key}", $this->user_id );
|
||||
|
||||
update_user_meta( $this->user_id, $field_key, wp_basename( $movefile['url'] ) );
|
||||
if ( 'stream_photo' !== $this->upload_image_type ) {
|
||||
update_user_meta( $this->user_id, $field_key, wp_basename( $movefile['url'] ) );
|
||||
}
|
||||
|
||||
$filename = wp_basename( $movefile['url'] );
|
||||
|
||||
set_transient( "um_{$filename}", $movefile['file_info'], 2 * HOUR_IN_SECONDS );
|
||||
|
||||
|
||||
set_transient( "um_{$filename}", $movefile['file_info'], 2 * HOUR_IN_SECONDS );
|
||||
}
|
||||
|
||||
$response['handle_upload'] = $movefile;
|
||||
@@ -451,11 +474,11 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function upload_file( $uploadedfile, $user_id = null, $field_key = '' ){
|
||||
public function upload_file( $uploadedfile, $user_id = null, $field_key = '' ) {
|
||||
$response = array();
|
||||
|
||||
if ( ! function_exists( 'wp_handle_upload' ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
||||
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
||||
}
|
||||
|
||||
$this->field_key = $field_key;
|
||||
@@ -467,20 +490,20 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
$this->upload_type = 'file';
|
||||
|
||||
$field_data = UM()->fields()->get_field( $field_key );
|
||||
|
||||
|
||||
$field_allowed_file_types = explode(",", $field_data['allowed_types'] );
|
||||
|
||||
$allowed_file_mimes = array();
|
||||
|
||||
|
||||
foreach ( $field_allowed_file_types as $a ) {
|
||||
$atype = wp_check_filetype( "test.{$a}" );
|
||||
$allowed_file_mimes[ $atype['ext'] ] = $atype['type'];
|
||||
}
|
||||
|
||||
$upload_overrides = array(
|
||||
'test_form' => false,
|
||||
'mimes' => apply_filters( "um_uploader_allowed_file_mimes", $allowed_file_mimes ),
|
||||
'unique_filename_callback' => array( $this, "unique_filename"),
|
||||
'test_form' => false,
|
||||
'mimes' => apply_filters( "um_uploader_allowed_file_mimes", $allowed_file_mimes ),
|
||||
'unique_filename_callback' => array( $this, "unique_filename"),
|
||||
);
|
||||
|
||||
$upload_overrides = apply_filters( "um_file_upload_handler_overrides__{$field_key}", $upload_overrides );
|
||||
@@ -488,11 +511,11 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
|
||||
|
||||
if ( isset( $movefile['error'] ) ) {
|
||||
/*
|
||||
/*
|
||||
* Error generated by _wp_handle_upload()
|
||||
* @see _wp_handle_upload() in wp-admin/includes/file.php
|
||||
*/
|
||||
$response['error'] = $movefile['error'];
|
||||
$response['error'] = $movefile['error'];
|
||||
} else {
|
||||
|
||||
$file_type = wp_check_filetype( $movefile['file'] );
|
||||
@@ -592,13 +615,11 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
*/
|
||||
do_action( "um_after_upload_db_meta_{$field_key}", $this->user_id );
|
||||
|
||||
update_user_meta( $this->user_id, $field_key, wp_basename( $movefile['url'] ) );
|
||||
//update_user_meta( $this->user_id, $field_key, wp_basename( $movefile['url'] ) );
|
||||
|
||||
$filename = wp_basename( $movefile['url'] );
|
||||
|
||||
set_transient( "um_{$filename}", $movefile['file_info'], 2 * HOUR_IN_SECONDS );
|
||||
|
||||
|
||||
}
|
||||
|
||||
$response['handle_upload'] = $movefile;
|
||||
@@ -619,7 +640,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
$error = null;
|
||||
|
||||
if ( ! function_exists( 'wp_get_image_editor' ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/media.php' );
|
||||
require_once( ABSPATH . 'wp-admin/includes/media.php' );
|
||||
}
|
||||
|
||||
$image = wp_get_image_editor( $file );
|
||||
@@ -634,12 +655,12 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
$image_info['ratio'] = $image_sizes['width'] / $image_sizes['height'];
|
||||
|
||||
$image_info['quality'] = $image->get_quality();
|
||||
|
||||
|
||||
$image_type = wp_check_filetype( $file );
|
||||
$image_info['extension'] = $image_type['ext'];
|
||||
$image_info['mime']= $image_type['type'];
|
||||
$image_info['size'] = filesize( $file );
|
||||
|
||||
|
||||
|
||||
$data = UM()->fields()->get_field( $field_key );
|
||||
|
||||
@@ -725,7 +746,6 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
$error = sprintf(__('Your photo is too small. It must be at least %spx wide.','ultimate-member'), $data['min_height']);
|
||||
}
|
||||
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
@@ -742,7 +762,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
$error = null;
|
||||
|
||||
if ( ! function_exists( 'wp_get_image_editor' ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/media.php' );
|
||||
require_once( ABSPATH . 'wp-admin/includes/media.php' );
|
||||
}
|
||||
|
||||
$file_type = wp_check_filetype( $file );
|
||||
@@ -750,7 +770,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
$file_info['extension'] = $file_type['ext'];
|
||||
$file_info['mime']= $file_type['type'];
|
||||
$file_info['size'] = filesize( $file );
|
||||
|
||||
|
||||
$data = UM()->fields()->get_field( $field_key );
|
||||
|
||||
if ( $data == null ) {
|
||||
@@ -841,15 +861,14 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
*
|
||||
* @since 2.0.22
|
||||
*/
|
||||
public function unique_filename( $filename, $ext, $dir ){
|
||||
|
||||
public function unique_filename( $filename, $ext, $dir ) {
|
||||
$image_type = wp_check_filetype( $ext );
|
||||
|
||||
|
||||
$ext = $image_type['ext'];
|
||||
|
||||
if( 'image' == $this->upload_type ){
|
||||
if ( 'image' == $this->upload_type ) {
|
||||
|
||||
switch( $this->upload_image_type ){
|
||||
switch ( $this->upload_image_type ) {
|
||||
|
||||
case 'stream_photo':
|
||||
$hashed = hash('ripemd160', time(). mt_rand(10,1000) );
|
||||
@@ -865,11 +884,9 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}else if( 'file' == $this->upload_type ){
|
||||
$hashed = hash('ripemd160', time(). mt_rand(10,1000) );
|
||||
$filename = "file_{$hashed}.{$ext}";
|
||||
|
||||
} elseif ( 'file' == $this->upload_type ) {
|
||||
$hashed = hash('ripemd160', time(). mt_rand(10,1000) );
|
||||
$filename = "file_{$hashed}.{$ext}";
|
||||
}
|
||||
|
||||
$this->delete_existing_file( $filename, $ext, $dir );
|
||||
@@ -877,6 +894,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
return $filename;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete file
|
||||
* @param string $filename
|
||||
@@ -885,14 +903,13 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
*
|
||||
* @since 2.0.22
|
||||
*/
|
||||
public function delete_existing_file( $filename, $ext = '', $dir = '' ){
|
||||
|
||||
if( file_exists( $this->upload_user_basedir . DIRECTORY_SEPARATOR . $filename ) && ! empty( $filename ) ){
|
||||
public function delete_existing_file( $filename, $ext = '', $dir = '' ) {
|
||||
if( file_exists( $this->upload_user_basedir . DIRECTORY_SEPARATOR . $filename ) && ! empty( $filename ) ) {
|
||||
unlink( $this->upload_user_basedir . DIRECTORY_SEPARATOR . $filename );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Profile photo image process
|
||||
* @param string $src
|
||||
@@ -902,16 +919,14 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
*
|
||||
* @since 2.0.22
|
||||
*/
|
||||
public function profile_photo( $image_path, $src, $key, $user_id, $coord, $crop ){
|
||||
|
||||
public function profile_photo( $image_path, $src, $key, $user_id, $coord, $crop ) {
|
||||
$sizes = UM()->options()->get( 'photo_thumb_sizes' );
|
||||
|
||||
|
||||
$quality = UM()->options()->get( 'image_compression' );
|
||||
|
||||
$image = wp_get_image_editor( $image_path ); // Return an implementation that extends WP_Image_Editor
|
||||
|
||||
if ( ! is_wp_error( $image ) ) {
|
||||
|
||||
$src_x = $crop[0];
|
||||
$src_y = $crop[1];
|
||||
$src_w = $crop[2];
|
||||
@@ -933,12 +948,9 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
|
||||
delete_user_meta( $user_id, 'synced_profile_photo' );
|
||||
|
||||
}else{
|
||||
|
||||
wp_send_json_error( esc_js( __( "Unable to crop image file: {$src}", 'ultimate-member' ) ) );
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
wp_send_json_error( esc_js( __( "Unable to crop image file: {$src}", 'ultimate-member' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -954,13 +966,13 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
public function cover_photo( $image_path, $src, $key, $user_id, $coord, $crop ){
|
||||
|
||||
$sizes = UM()->options()->get( 'cover_thumb_sizes' );
|
||||
|
||||
|
||||
$quality = UM()->options()->get( 'image_compression' );
|
||||
|
||||
$image = wp_get_image_editor( $image_path ); // Return an implementation that extends WP_Image_Editor
|
||||
|
||||
if ( ! is_wp_error( $image ) ) {
|
||||
|
||||
|
||||
$src_x = $crop[0];
|
||||
$src_y = $crop[1];
|
||||
$src_w = $crop[2];
|
||||
@@ -980,14 +992,12 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
|
||||
$image->multi_resize( $sizes_array );
|
||||
|
||||
}else{
|
||||
|
||||
wp_send_json_error( esc_js( __( "Unable to crop image file: {$src}", 'ultimate-member' ) ) );
|
||||
|
||||
} else {
|
||||
wp_send_json_error( esc_js( __( "Unable to crop image file: {$src}", 'ultimate-member' ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stream photo image process
|
||||
* @param string $src
|
||||
@@ -1004,10 +1014,9 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
$quality = UM()->options()->get( 'image_compression' );
|
||||
|
||||
if ( ! is_wp_error( $image ) ) {
|
||||
|
||||
if( ! empty( $crop ) ){
|
||||
if ( ! empty( $crop ) ) {
|
||||
|
||||
if( ! is_array( $crop ) ){
|
||||
if( ! is_array( $crop ) ) {
|
||||
$crop = explode(",", $crop );
|
||||
}
|
||||
|
||||
@@ -1023,14 +1032,12 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
|
||||
$image->set_quality( $quality );
|
||||
|
||||
}else{
|
||||
|
||||
wp_send_json_error( esc_js( __( "Unable to crop stream image file: {$image_path}", 'ultimate-member' ) ) );
|
||||
|
||||
} else {
|
||||
wp_send_json_error( esc_js( __( "Unable to crop stream image file: {$image_path}", 'ultimate-member' ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set stream photo default settings
|
||||
* @param array $args
|
||||
@@ -1038,34 +1045,34 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
*
|
||||
* @since 2.0.22
|
||||
*/
|
||||
public function stream_photo_data( $args ){
|
||||
public function stream_photo_data( $args ) {
|
||||
$args['max_file_size'] = apply_filters( "um_upload_images_stream_maximum_file_size", 9999999 );
|
||||
$args['max_file_size_error'] = sprintf( __( "Maximum file size allowed: %s", 'ultimate-member' ), size_format( $args['max_file_size'] ) );
|
||||
|
||||
$args['max_file_size'] = apply_filters("um_upload_images_stream_maximum_file_size", 9999999 );
|
||||
$args['max_file_size_error'] = sprintf(__("Maximum file size allowed: ".size_format( $args['max_file_size'] ),'ultimate-member') );
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resize Image
|
||||
* @param string $image_path
|
||||
* @param string $src
|
||||
* @param string $key
|
||||
* @param integer $user_id
|
||||
* @param string $coord
|
||||
* @return string $src
|
||||
*
|
||||
* @param string $src
|
||||
* @param string $key
|
||||
* @param integer $user_id
|
||||
* @param string $coord
|
||||
*
|
||||
* @since 2.0.22
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function resize_image( $image_path, $src, $key, $user_id, $coord ){
|
||||
|
||||
public function resize_image( $image_path, $src, $key, $user_id, $coord ) {
|
||||
$crop = explode( ',', $coord );
|
||||
$crop = array_map( 'intval', $crop );
|
||||
|
||||
do_action("um_upload_image_process__{$key}", $image_path, $src, $key, $user_id, $coord, $crop );
|
||||
|
||||
if( ! in_array( $key, array('profile_photo','cover_photo') ) ){
|
||||
do_action("um_upload_stream_image_process", $image_path, $src, $key, $user_id, $coord, $crop );
|
||||
if ( ! in_array( $key, array('profile_photo','cover_photo') ) ) {
|
||||
do_action( "um_upload_stream_image_process", $image_path, $src, $key, $user_id, $coord, $crop );
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
@@ -1120,6 +1127,8 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
}
|
||||
|
||||
$submitted = get_user_meta( $user_id, 'submitted', true );
|
||||
$submitted = ! empty( $submitted ) ? $submitted : array();
|
||||
|
||||
$submitted[ $key ] = $new_filename;
|
||||
update_user_meta( $user_id, 'submitted', $submitted );
|
||||
|
||||
@@ -1169,9 +1178,9 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
}
|
||||
$_array = array_merge( $_array, $new_files );
|
||||
|
||||
$files = glob( um_user_uploads_dir() . '*', GLOB_BRACE );
|
||||
$files = glob( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . '*', GLOB_BRACE );
|
||||
$error = array();
|
||||
if ( file_exists( um_user_uploads_dir() ) && $files && isset( $_array ) && is_array( $_array ) ) {
|
||||
if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR ) && $files && isset( $_array ) && is_array( $_array ) ) {
|
||||
foreach ( $files as $file ) {
|
||||
$str = basename( $file );
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
}
|
||||
|
||||
// remove uploads
|
||||
UM()->files()->remove_dir( um_user_uploads_dir() );
|
||||
UM()->files()->remove_dir( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR );
|
||||
}
|
||||
|
||||
|
||||
@@ -1135,15 +1135,6 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set user's hash for password reset
|
||||
*/
|
||||
function password_reset_hash() {
|
||||
$this->profile['reset_pass_hash'] = UM()->validation()->generate();
|
||||
$this->update_usermeta_info('reset_pass_hash');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set user's hash
|
||||
*/
|
||||
@@ -1194,7 +1185,8 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
* Password reset email
|
||||
*/
|
||||
function password_reset() {
|
||||
$this->password_reset_hash();
|
||||
$userdata = get_userdata( um_user('ID') );
|
||||
get_password_reset_key( $userdata );
|
||||
UM()->mail()->send( um_user('user_email'), 'resetpw_email' );
|
||||
}
|
||||
|
||||
@@ -1224,14 +1216,22 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
*/
|
||||
function approve() {
|
||||
$user_id = um_user('ID');
|
||||
|
||||
$status = get_user_meta( $user_id, 'account_status', true );
|
||||
if ( 'approved' === $status ) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete_option( "um_cache_userdata_{$user_id}" );
|
||||
|
||||
if ( um_user('account_status') == 'awaiting_admin_review' ) {
|
||||
$this->password_reset_hash();
|
||||
$userdata = get_userdata( $user_id );
|
||||
get_password_reset_key( $userdata );
|
||||
UM()->mail()->send( um_user('user_email'), 'approved_email' );
|
||||
|
||||
} else {
|
||||
$this->password_reset_hash();
|
||||
$userdata = get_userdata( $user_id );
|
||||
get_password_reset_key( $userdata );
|
||||
UM()->mail()->send( um_user('user_email'), 'welcome_email');
|
||||
}
|
||||
|
||||
@@ -1673,7 +1673,6 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
|
||||
// update user
|
||||
if ( count( $args ) > 1 ) {
|
||||
|
||||
//if isset roles argument validate role to properly for security reasons
|
||||
if ( isset( $args['role'] ) ) {
|
||||
global $wp_roles;
|
||||
|
||||
@@ -21,7 +21,7 @@ function um_submit_account_errors_hook( $args ) {
|
||||
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 ) ) {
|
||||
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') );
|
||||
}
|
||||
}
|
||||
@@ -149,8 +149,14 @@ function um_submit_account_details( $args ) {
|
||||
|
||||
$args['user_id'] = um_user('ID');
|
||||
|
||||
UM()->user()->password_changed();
|
||||
|
||||
do_action( 'send_password_change_email', $args );
|
||||
|
||||
//clear all sessions with old passwords
|
||||
$user = WP_Session_Tokens::get_instance( um_user( 'ID' ) );
|
||||
$user->destroy_all();
|
||||
|
||||
wp_set_password( $changes['user_pass'], um_user( 'ID' ) );
|
||||
|
||||
wp_signon( array( 'user_login' => um_user( 'user_login' ), 'user_password' => $changes['user_pass'] ) );
|
||||
|
||||
@@ -346,7 +346,10 @@ function um_submit_form_errors_hook_( $args ) {
|
||||
continue 2;
|
||||
}
|
||||
} elseif ( $op == 'contains' ) {
|
||||
if ( strstr( $cond_value, $parent_value ) ) {
|
||||
if ( is_string( $cond_value ) && strstr( $cond_value, $parent_value ) ) {
|
||||
continue 2;
|
||||
}
|
||||
if( is_array( $cond_value ) && in_array( $parent_value, $cond_value ) ) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
@@ -376,7 +379,10 @@ function um_submit_form_errors_hook_( $args ) {
|
||||
continue 2;
|
||||
}
|
||||
} elseif ( $op == 'contains' ) {
|
||||
if ( ! strstr( $cond_value, $parent_value ) ) {
|
||||
if ( is_string( $cond_value ) && ! strstr( $cond_value, $parent_value ) ) {
|
||||
continue 2;
|
||||
}
|
||||
if( is_array( $cond_value ) && !in_array( $parent_value, $cond_value ) ) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
@@ -425,7 +431,7 @@ function um_submit_form_errors_hook_( $args ) {
|
||||
*/
|
||||
do_action( 'um_add_error_on_form_submit_validation', $array, $key, $args );
|
||||
|
||||
if ( isset( $args[$key] ) ) {
|
||||
if ( isset( $args[ $key ] ) ) {
|
||||
|
||||
if ( isset( $array['required'] ) && $array['required'] == 1 ) {
|
||||
if ( ! isset( $args[$key] ) || $args[$key] == '' || $args[$key] == 'empty_file') {
|
||||
|
||||
@@ -1,342 +0,0 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
|
||||
/**
|
||||
* Process a new request
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function um_reset_password_process_hook( $args ) {
|
||||
$user = null;
|
||||
|
||||
foreach ( $_POST as $key => $val ) {
|
||||
if( strstr( $key, "username_b") ){
|
||||
$user = trim( $val );
|
||||
}
|
||||
}
|
||||
|
||||
if ( username_exists( $user ) ) {
|
||||
$data = get_user_by( 'login', $user );
|
||||
$user_email = $data->user_email;
|
||||
} else if( email_exists( $user ) ) {
|
||||
$data = get_user_by( 'email', $user );
|
||||
$user_email = $user;
|
||||
}
|
||||
|
||||
UM()->password()->reset_request['user_id'] = $data->ID;
|
||||
UM()->password()->reset_request['user_email'] = $user_email;
|
||||
|
||||
um_fetch_user( $data->ID );
|
||||
|
||||
UM()->user()->password_reset();
|
||||
|
||||
um_reset_user();
|
||||
|
||||
}
|
||||
add_action( 'um_reset_password_process_hook', 'um_reset_password_process_hook' );
|
||||
|
||||
|
||||
/**
|
||||
* Process a change request
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function um_change_password_process_hook( $args ) {
|
||||
extract( $args );
|
||||
|
||||
wp_set_password( $args['user_password'], $args['user_id'] );
|
||||
|
||||
delete_user_meta( $args['user_id'], 'reset_pass_hash');
|
||||
delete_user_meta( $args['user_id'], 'reset_pass_hash_token');
|
||||
delete_user_meta( $args['user_id'], 'password_rst_attempts');
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_after_changing_user_password
|
||||
* @description Hook that runs after user change their password
|
||||
* @input_vars
|
||||
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_after_changing_user_password', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_after_changing_user_password', 'my_after_changing_user_password', 10, 1 );
|
||||
* function my_user_login_extra( $user_id ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_after_changing_user_password', $args['user_id'] );
|
||||
|
||||
|
||||
if ( is_user_logged_in() ) {
|
||||
wp_logout();
|
||||
}
|
||||
|
||||
exit( wp_redirect( um_get_core_page('login', 'password_changed') ) );
|
||||
}
|
||||
add_action( 'um_change_password_process_hook','um_change_password_process_hook' );
|
||||
|
||||
|
||||
/**
|
||||
* Overrides password changed notification
|
||||
*
|
||||
* @param $args
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function um_send_password_change_email( $args ) {
|
||||
|
||||
if ( ! is_array( $args ) )
|
||||
return false;
|
||||
|
||||
/**
|
||||
* @var $user_id
|
||||
*/
|
||||
extract( $args );
|
||||
|
||||
if ( ! isset( $user_id ) )
|
||||
return false;
|
||||
|
||||
um_fetch_user( $user_id );
|
||||
|
||||
UM()->user()->password_changed();
|
||||
|
||||
um_reset_user();
|
||||
|
||||
return false;
|
||||
}
|
||||
add_action( 'send_password_change_email','um_send_password_change_email', 10, 1 );
|
||||
|
||||
|
||||
/**
|
||||
* This is executed after changing password
|
||||
*
|
||||
* @param $user_id
|
||||
*/
|
||||
function um_after_changing_user_password( $user_id ) {
|
||||
|
||||
}
|
||||
add_action( 'um_after_changing_user_password', 'um_after_changing_user_password' );
|
||||
|
||||
|
||||
/**
|
||||
* Error handler: reset password
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function um_reset_password_errors_hook( $args ) {
|
||||
|
||||
if ( $_POST[ UM()->honeypot ] != '' )
|
||||
wp_die('Hello, spam bot!','ultimate-member');
|
||||
|
||||
$user = "";
|
||||
|
||||
foreach ( $_POST as $key => $val ) {
|
||||
if( strstr( $key, "username_b") ){
|
||||
$user = trim( $val );
|
||||
}
|
||||
}
|
||||
|
||||
if ( empty( $user ) ) {
|
||||
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') );
|
||||
} else {
|
||||
|
||||
if ( is_email( $user ) ) {
|
||||
$user_id = email_exists( $user );
|
||||
} else {
|
||||
$user_id = username_exists( $user );
|
||||
}
|
||||
|
||||
$attempts = (int)get_user_meta( $user_id, 'password_rst_attempts', true );
|
||||
$is_admin = user_can( intval( $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 {
|
||||
$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') );
|
||||
} else {
|
||||
update_user_meta( $user_id, 'password_rst_attempts', $attempts + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
add_action( 'um_reset_password_errors_hook', 'um_reset_password_errors_hook' );
|
||||
|
||||
|
||||
/**
|
||||
* Error handler: changing 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');
|
||||
}
|
||||
|
||||
$reset_pass_hash = '';
|
||||
|
||||
if( isset( $_REQUEST['act'] ) && $_REQUEST['act'] == 'reset_password' && um_is_core_page('password-reset') ){
|
||||
$reset_pass_hash = get_user_meta( $args['user_id'], 'reset_pass_hash', true );
|
||||
|
||||
}
|
||||
|
||||
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() ||
|
||||
!is_user_logged_in() && isset( $_REQUEST['hash'] ) && $reset_pass_hash != $_REQUEST['hash'] && um_is_core_page('password-reset')
|
||||
){
|
||||
wp_die( __( '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 ( UM()->options()->get( 'reset_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') );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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'] ) {
|
||||
UM()->form()->add_error('confirm_user_password', __('Your passwords do not match','ultimate-member') );
|
||||
}
|
||||
|
||||
}
|
||||
add_action( 'um_change_password_errors_hook', 'um_change_password_errors_hook' );
|
||||
|
||||
|
||||
/**
|
||||
* Hidden fields
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function um_change_password_page_hidden_fields( $args ) {
|
||||
?>
|
||||
|
||||
<input type="hidden" name="_um_password_change" id="_um_password_change" value="1" />
|
||||
|
||||
<input type="hidden" name="user_id" id="user_id" value="<?php echo $args['user_id']; ?>" />
|
||||
|
||||
<?php
|
||||
}
|
||||
add_action( 'um_change_password_page_hidden_fields', 'um_change_password_page_hidden_fields' );
|
||||
|
||||
|
||||
/**
|
||||
* Hidden fields
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function um_reset_password_page_hidden_fields( $args ) {
|
||||
?>
|
||||
|
||||
<input type="hidden" name="_um_password_reset" id="_um_password_reset" value="1" />
|
||||
|
||||
<?php
|
||||
}
|
||||
add_action( 'um_reset_password_page_hidden_fields', 'um_reset_password_page_hidden_fields' );
|
||||
|
||||
|
||||
/**
|
||||
* Form content
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function um_reset_password_form( $args ) {
|
||||
|
||||
$fields = UM()->builtin()->get_specific_fields('password_reset_text,username_b'); ?>
|
||||
|
||||
<?php $output = null;
|
||||
foreach( $fields as $key => $data ) {
|
||||
$output .= UM()->fields()->edit_field( $key, $data );
|
||||
} echo $output; ?>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_after_password_reset_fields
|
||||
* @description Hook that runs after user reset their password
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Form data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_after_password_reset_fields', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_after_password_reset_fields', 'my_after_password_reset_fields', 10, 1 );
|
||||
* function my_after_password_reset_fields( $args ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_after_password_reset_fields', $args ); ?>
|
||||
|
||||
<div class="um-col-alt um-col-alt-b">
|
||||
|
||||
<div class="um-center"><input type="submit" value="<?php _e('Reset my password','ultimate-member'); ?>" class="um-button" id="um-submit-btn" /></div>
|
||||
|
||||
<div class="um-clear"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
add_action( 'um_reset_password_form', 'um_reset_password_form' );
|
||||
|
||||
|
||||
/**
|
||||
* Change password form
|
||||
*/
|
||||
function um_change_password_form() {
|
||||
|
||||
$fields = UM()->builtin()->get_specific_fields('user_password'); ?>
|
||||
|
||||
<?php $output = null;
|
||||
foreach( $fields as $key => $data ) {
|
||||
$output .= UM()->fields()->edit_field( $key, $data );
|
||||
}echo $output; ?>
|
||||
|
||||
<div class="um-col-alt um-col-alt-b">
|
||||
|
||||
<div class="um-center"><input type="submit" value="<?php _e('Change my password','ultimate-member'); ?>" class="um-button" id="um-submit-btn" /></div>
|
||||
|
||||
<div class="um-clear"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
add_action( 'um_change_password_form', 'um_change_password_form' );
|
||||
@@ -229,9 +229,9 @@ function um_user_edit_profile( $args ) {
|
||||
}
|
||||
|
||||
if ( isset( $args['submitted'][ $key ] ) ) {
|
||||
|
||||
if ( isset( $fields[ $key ]['type'] ) && in_array( $fields[ $key ]['type'], array( 'image', 'file' ) ) &&
|
||||
( um_is_temp_file( $args['submitted'][ $key ] ) || $args['submitted'][ $key ] == 'empty_file' ) ) {
|
||||
( /*um_is_file_owner( UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . '/' . $args['submitted'][ $key ], um_user( 'ID' ) ) ||*/
|
||||
um_is_temp_file( $args['submitted'][ $key ] ) || $args['submitted'][ $key ] == 'empty_file' ) ) {
|
||||
|
||||
$files[ $key ] = $args['submitted'][ $key ];
|
||||
|
||||
|
||||
@@ -55,10 +55,10 @@ function um_after_insert_user( $user_id, $args ) {
|
||||
UM()->user()->remove_cached_queue();
|
||||
|
||||
um_fetch_user( $user_id );
|
||||
UM()->user()->set_status( um_user( 'status' ) );
|
||||
if ( ! empty( $args['submitted'] ) ) {
|
||||
UM()->user()->set_registration_details( $args['submitted'] );
|
||||
}
|
||||
UM()->user()->set_status( um_user( 'status' ) );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
@@ -670,7 +670,7 @@ function um_registration_save_files( $user_id, $args ) {
|
||||
*/
|
||||
$files = apply_filters( 'um_user_pre_updating_files_array', $files );
|
||||
|
||||
if ( !empty( $files ) ) {
|
||||
if ( ! empty( $files ) ) {
|
||||
UM()->uploader()->move_temporary_files( $user_id, $files );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,26 +223,26 @@ add_filter( 'um_profile_field_filter_hook__date', 'um_profile_field_filter_hook_
|
||||
* @return string
|
||||
*/
|
||||
function um_profile_field_filter_hook__file( $value, $data ) {
|
||||
$uri = um_user_uploads_uri() . $value;
|
||||
$file_type = wp_check_filetype( $value );
|
||||
|
||||
if ( ! file_exists( um_user_uploads_dir() . $value ) ) {
|
||||
$value = __('This file has been removed.','ultimate-member');
|
||||
$uri = UM()->files()->get_download_link( UM()->fields()->set_id, $data['metakey'], um_user( 'ID' ) );
|
||||
|
||||
if ( ! file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value ) ) {
|
||||
$value = __( 'This file has been removed.', 'ultimate-member' );
|
||||
} else {
|
||||
$file_info = um_user( $data['metakey']."_metadata" );
|
||||
if( isset( $file_info['original_name'] ) && ! empty( $file_info['original_name'] ) ){
|
||||
$file_info = um_user( $data['metakey'] . "_metadata" );
|
||||
if ( ! empty( $file_info['original_name'] ) ) {
|
||||
$value = $file_info['original_name'];
|
||||
}
|
||||
$value = '<div class="um-single-file-preview show">
|
||||
<div class="um-single-fileinfo">
|
||||
<a href="' . $uri . '" target="_blank">
|
||||
<a href="' . esc_attr( $uri ) . '" target="_blank">
|
||||
<span class="icon" style="background:'. UM()->files()->get_fonticon_bg_by_ext( $file_type['ext'] ) . '"><i class="'. UM()->files()->get_fonticon_by_ext( $file_type['ext'] ) .'"></i></span>
|
||||
<span class="filename">' . esc_attr( $value ) . '</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
|
||||
return $value;
|
||||
}
|
||||
add_filter( 'um_profile_field_filter_hook__file', 'um_profile_field_filter_hook__file', 99, 2 );
|
||||
@@ -257,15 +257,15 @@ add_filter( 'um_profile_field_filter_hook__file', 'um_profile_field_filter_hook_
|
||||
* @return string
|
||||
*/
|
||||
function um_profile_field_filter_hook__image( $value, $data ) {
|
||||
$uri = um_user_uploads_uri() . $value;
|
||||
$title = ( isset( $data['title'] ) ) ? $data['title'] : __('Untitled photo');
|
||||
$uri = UM()->files()->get_download_link( UM()->fields()->set_id, $data['metakey'], um_user( 'ID' ) );
|
||||
$title = ( isset( $data['title'] ) ) ? $data['title'] : __( 'Untitled photo', 'ultimate-member' );
|
||||
|
||||
// if value is an image tag
|
||||
if( preg_match( '/\<img.*src=\"([^"]+).*/', $value, $matches ) ) {
|
||||
$uri = $matches[1];
|
||||
$value = '<div class="um-photo"><a href="#" class="um-photo-modal" data-src="'.$uri.'"><img src="'. $uri .'" alt="'.$title.'" title="'.$title.'" class="" /></a></div>';
|
||||
} else if ( file_exists( um_user_uploads_dir() . $value ) ) {
|
||||
$value = '<div class="um-photo"><a href="#" class="um-photo-modal" data-src="'.$uri.'"><img src="'. $uri .'" alt="'.$title.'" title="'.$title.'" class="" /></a></div>';
|
||||
$value = '<div class="um-photo"><a href="#" class="um-photo-modal" data-src="' . esc_attr( $uri ) . '"><img src="' . esc_attr( $uri ) . '" alt="' . esc_attr( $title ) . '" title="' . esc_attr( $title ) . '" class="" /></a></div>';
|
||||
} else if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value ) ) {
|
||||
$value = '<div class="um-photo"><a href="#" class="um-photo-modal" data-src="' . esc_attr( $uri ) . '"><img src="' . esc_attr( $uri ) . '" alt="' . esc_attr( $title ) . '" title="' . esc_attr( $title ) . '" class="" /></a></div>';
|
||||
} else {
|
||||
$value = '';
|
||||
}
|
||||
@@ -405,7 +405,10 @@ function um_get_custom_field_array( $array, $fields ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
} elseif ( $op == 'contains' ) {
|
||||
if ( strstr( $cond_value, $parent_value ) ) {
|
||||
if ( is_string( $cond_value ) && strstr( $cond_value, $parent_value ) ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
if( is_array( $cond_value ) && in_array( $parent_value, $cond_value ) ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
}
|
||||
@@ -435,7 +438,10 @@ function um_get_custom_field_array( $array, $fields ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
} elseif ( $op == 'contains' ) {
|
||||
if ( ! strstr( $cond_value, $parent_value ) ) {
|
||||
if( is_string( $cond_value ) && !strstr( $cond_value, $parent_value ) ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
if( is_array( $cond_value ) && !in_array( $parent_value, $cond_value ) ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
<?php
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
class Array2XML {
|
||||
|
||||
@@ -132,5 +129,4 @@ class Array2XML {
|
||||
$pattern = '/^[a-z_]+[a-z0-9\:\-\.\_]*[^:]*$/i';
|
||||
return preg_match($pattern, $tag, $matches) && $matches[0] == $tag;
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
<?php
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
/**
|
||||
* Modified to remove var
|
||||
@@ -1100,4 +1097,4 @@ class Browser {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -335,4 +335,68 @@ function um_core_is_local() {
|
||||
function um_get_url_for_language( $post_id, $language ) {
|
||||
//um_deprecated_function( 'um_get_url_for_language', '2.0', 'UM()->external_integrations()->get_url_for_language' );
|
||||
return UM()->external_integrations()->get_url_for_language( $post_id, $language );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* user uploads directory
|
||||
*
|
||||
* @deprecated 2.0.26
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function um_user_uploads_dir() {
|
||||
//um_deprecated_function( 'um_user_uploads_dir', '2.0.26', 'UM()->external_integrations()->get_url_for_language' );
|
||||
$uri = UM()->files()->upload_basedir . um_user( 'ID' ) . '/';
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* user uploads uri
|
||||
*
|
||||
* @deprecated 2.0.26
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function um_user_uploads_uri() {
|
||||
//um_deprecated_function( 'um_user_uploads_uri', '2.0.26', 'UM()->external_integrations()->get_url_for_language' );
|
||||
UM()->files()->upload_baseurl = set_url_scheme( UM()->files()->upload_baseurl );
|
||||
$uri = UM()->files()->upload_baseurl . um_user( 'ID' ) . '/';
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a legitimate password reset request is in action
|
||||
*
|
||||
* @deprecated 2.0.26
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function um_requesting_password_reset() {
|
||||
//um_deprecated_function( 'um_requesting_password_reset', '2.0.26', 'UM()->password()->is_reset_request' );
|
||||
|
||||
if ( um_is_core_page( 'password-reset' ) && isset( $_POST['_um_password_reset'] ) == 1 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a legitimate password change request is in action
|
||||
*
|
||||
* @deprecated 2.0.26
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function um_requesting_password_change() {
|
||||
//um_deprecated_function( 'um_requesting_password_change', '2.0.26', 'UM()->password()->is_change_request' );
|
||||
|
||||
if ( um_is_core_page( 'account' ) && isset( $_POST['_um_account'] ) == 1 & isset( $_POST['_um_account_tab'] ) == 'password' ) {
|
||||
return true;
|
||||
} elseif ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
+71
-129
@@ -555,7 +555,12 @@ function um_user_submitted_registration( $style = false ) {
|
||||
|
||||
if ( UM()->fields()->get_field_type( $k ) == 'image' || UM()->fields()->get_field_type( $k ) == 'file' ) {
|
||||
$file = basename( $v );
|
||||
$v = um_user_uploads_uri() . $file;
|
||||
$filedata = get_user_meta( um_user( 'ID' ), $k . "_metadata", true );
|
||||
if ( ! empty( $filedata['original_name'] ) ) {
|
||||
$v = '<a href="' . esc_attr( UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . '/' . $file ) . '">' . $filedata['original_name'] . '</a>';
|
||||
} else {
|
||||
$v = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . '/' . $file;
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_array( $v ) ) {
|
||||
@@ -776,40 +781,30 @@ function um_is_temp_image( $url ) {
|
||||
|
||||
/**
|
||||
* Check user's file ownership
|
||||
* @param string $url
|
||||
* @param integer $user_id
|
||||
* @return bool
|
||||
* @param string $url
|
||||
* @param int|null $user_id
|
||||
* @param string|bool $image_path
|
||||
* @return bool
|
||||
*/
|
||||
function um_is_file_owner( $url, $user_id = null, $image_path = false ){
|
||||
|
||||
if( strpos( $url, "/uploads/ultimatemember/{$user_id}/" ) !== false && is_user_logged_in() ){
|
||||
|
||||
function um_is_file_owner( $url, $user_id = null, $image_path = false ) {
|
||||
|
||||
if ( strpos( $url, UM()->uploader()->get_upload_base_url() . $user_id . '/' ) !== false && is_user_logged_in() ) {
|
||||
$user_basedir = UM()->uploader()->get_upload_user_base_dir( $user_id );
|
||||
|
||||
$filename = wp_basename( parse_url( $url, PHP_URL_PATH ) );
|
||||
|
||||
$file = $user_basedir . '/' . $filename;
|
||||
if( file_exists( $file ) ){
|
||||
if( $image_path ){
|
||||
return $file;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$user_basedir = UM()->uploader()->get_upload_user_base_dir( 'temp' );
|
||||
|
||||
$filename = wp_basename( parse_url( $url, PHP_URL_PATH ) );
|
||||
|
||||
$file = $user_basedir . '/' . $filename;
|
||||
if( file_exists( $file ) ){
|
||||
if( $image_path ){
|
||||
return $file;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$filename = wp_basename( parse_url( $url, PHP_URL_PATH ) );
|
||||
|
||||
$file = $user_basedir . DIRECTORY_SEPARATOR . $filename;
|
||||
if ( file_exists( $file ) ) {
|
||||
if ( $image_path ) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -819,12 +814,12 @@ function um_is_file_owner( $url, $user_id = null, $image_path = false ){
|
||||
* @param string $filename
|
||||
* @return bool
|
||||
*/
|
||||
function um_is_temp_file( $filename ){
|
||||
function um_is_temp_file( $filename ) {
|
||||
$user_basedir = UM()->uploader()->get_upload_user_base_dir( 'temp' );
|
||||
|
||||
$file = $user_basedir . '/' . $filename;
|
||||
|
||||
if( file_exists( $file ) ){
|
||||
if ( file_exists( $file ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1101,36 +1096,6 @@ function um_get_metadefault( $id ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a legitimate password reset request is in action
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function um_requesting_password_reset() {
|
||||
if (um_is_core_page( 'password-reset' ) && isset( $_POST['_um_password_reset'] ) == 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a legitimate password change request is in action
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function um_requesting_password_change() {
|
||||
if ( um_is_core_page( 'account' ) && isset( $_POST['_um_account'] ) == 1 & isset( $_POST['_um_account_tab'] ) == 'password' ) {
|
||||
return true;
|
||||
} elseif ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* boolean for account page editing
|
||||
*
|
||||
@@ -1666,32 +1631,6 @@ function um_youtube_id_from_url( $url ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* user uploads uri
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function um_user_uploads_uri() {
|
||||
UM()->files()->upload_baseurl = set_url_scheme( UM()->files()->upload_baseurl );
|
||||
|
||||
$uri = UM()->files()->upload_baseurl . um_user( 'ID' ) . '/';
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* user uploads directory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function um_user_uploads_dir() {
|
||||
$uri = UM()->files()->upload_basedir . um_user( 'ID' ) . '/';
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find closest number in an array
|
||||
*
|
||||
@@ -1721,14 +1660,15 @@ function um_closest_num( $array, $number ) {
|
||||
function um_get_cover_uri( $image, $attrs ) {
|
||||
$uri = false;
|
||||
$ext = '.' . pathinfo( $image, PATHINFO_EXTENSION );
|
||||
if (file_exists( UM()->files()->upload_basedir . um_user( 'ID' ) . "/cover_photo{$ext}" ) ) {
|
||||
$uri = um_user_uploads_uri() . "/cover_photo{$ext}?" . current_time( 'timestamp' );
|
||||
|
||||
if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo{$ext}" ) ) {
|
||||
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo{$ext}?" . current_time( 'timestamp' );
|
||||
}
|
||||
|
||||
if ( file_exists( UM()->files()->upload_basedir . um_user( 'ID' ) . "/cover_photo-{$attrs}x{$attrs}{$ext}" ) ) {
|
||||
$uri = um_user_uploads_uri() . "/cover_photo-{$attrs}x{$attrs}{$ext}?". current_time( 'timestamp' );
|
||||
}else if ( file_exists( UM()->files()->upload_basedir . um_user( 'ID' ) . "/cover_photo-{$attrs}{$ext}" ) ) {
|
||||
$uri = um_user_uploads_uri() . "/cover_photo-{$attrs}{$ext}?" . current_time( 'timestamp' );
|
||||
|
||||
if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}x{$attrs}{$ext}" ) ) {
|
||||
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo-{$attrs}x{$attrs}{$ext}?". current_time( 'timestamp' );
|
||||
} elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}{$ext}" ) ) {
|
||||
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo-{$attrs}{$ext}?" . current_time( 'timestamp' );
|
||||
}
|
||||
return $uri;
|
||||
}
|
||||
@@ -1753,7 +1693,7 @@ function um_get_avatar_url( $get_avatar ) {
|
||||
* get avatar uri
|
||||
*
|
||||
* @param $image
|
||||
* @param $attrs
|
||||
* @param string|array $attrs
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
@@ -1783,24 +1723,28 @@ function um_get_avatar_uri( $image, $attrs ) {
|
||||
* ?>
|
||||
*/
|
||||
$cache_time = apply_filters( 'um_filter_avatar_cache_time', current_time( 'timestamp' ), um_user( 'ID' ) );
|
||||
if( $attrs == 'original' && file_exists( um_user_uploads_dir() . "profile_photo{$ext}" ) ) {
|
||||
$uri = um_user_uploads_uri() . "profile_photo{$ext}";
|
||||
} else if ( file_exists( um_user_uploads_dir() . "profile_photo-{$attrs}x{$attrs}{$ext}" ) ) {
|
||||
$uri = um_user_uploads_uri() . "profile_photo-{$attrs}x{$attrs}{$ext}";
|
||||
} else if ( file_exists( um_user_uploads_dir() . "profile_photo-{$attrs}{$ext}" ) ) {
|
||||
$uri = um_user_uploads_uri() . "profile_photo-{$attrs}{$ext}";
|
||||
if ( $attrs == 'original' && file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) {
|
||||
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo{$ext}";
|
||||
} elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}x{$attrs}{$ext}" ) ) {
|
||||
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$attrs}x{$attrs}{$ext}";
|
||||
} elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}{$ext}" ) ) {
|
||||
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$attrs}{$ext}";
|
||||
} else {
|
||||
$sizes = UM()->options()->get( 'photo_thumb_sizes' );
|
||||
if ( is_array( $sizes ) ) $find = um_closest_num( $sizes, $attrs );
|
||||
if ( file_exists( um_user_uploads_dir() . "profile_photo-{$find}x{$find}{$ext}" ) ) {
|
||||
$uri = um_user_uploads_uri() . "profile_photo-{$find}x{$find}{$ext}";
|
||||
}else if ( file_exists( um_user_uploads_dir() . "profile_photo-{$find}{$ext}" ) ) {
|
||||
$uri = um_user_uploads_uri() . "profile_photo-{$find}{$ext}";
|
||||
} else if ( file_exists( um_user_uploads_dir() . "profile_photo{$ext}" ) ) {
|
||||
$uri = um_user_uploads_uri() . "profile_photo{$ext}";
|
||||
if ( is_array( $sizes ) ) {
|
||||
$find = um_closest_num( $sizes, $attrs );
|
||||
}
|
||||
|
||||
if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}x{$find}{$ext}" ) ) {
|
||||
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$find}x{$find}{$ext}";
|
||||
} elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}{$ext}" ) ) {
|
||||
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$find}{$ext}";
|
||||
} elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) {
|
||||
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo{$ext}";
|
||||
}
|
||||
}
|
||||
if ( !empty( $cache_time ) ) {
|
||||
|
||||
if ( ! empty( $cache_time ) ) {
|
||||
$uri .= "?{$cache_time}";
|
||||
}
|
||||
return $uri;
|
||||
@@ -2218,8 +2162,10 @@ function um_user( $data, $attrs = null ) {
|
||||
|
||||
case 'submitted':
|
||||
$array = um_profile( $data );
|
||||
if (empty( $array )) return '';
|
||||
$array = unserialize( $array );
|
||||
if ( empty( $array ) ) {
|
||||
return '';
|
||||
}
|
||||
$array = maybe_unserialize( $array );
|
||||
|
||||
return $array;
|
||||
break;
|
||||
@@ -2235,23 +2181,24 @@ function um_user( $data, $attrs = null ) {
|
||||
case 'profile_photo':
|
||||
$data = um_get_user_avatar_data( um_user( 'ID' ), $attrs );
|
||||
|
||||
return '<img src="' . esc_attr($data['url']) . '"
|
||||
class="' . esc_attr($data['class']) . '"
|
||||
width="' . esc_attr($data['size']) . '"
|
||||
height="' . esc_attr($data['size']) . '"
|
||||
alt="' . esc_attr($data['alt']) . '"
|
||||
data-default="' . esc_attr($data['default']) . '"
|
||||
onerror="if(!this.getAttribute(\'data-load-error\')){this.setAttribute(\'data-load-error\', \'1\');this.setAttribute(\'src\', this.getAttribute(\'data-default\'));}" />'; //don't move attribute before src
|
||||
|
||||
return sprintf( '<img src="%s" class="%s" width="%s" height="%s" alt="%s" data-default="%s" onerror="%s" />',
|
||||
esc_attr( $data['url'] ),
|
||||
esc_attr( $data['class'] ),
|
||||
esc_attr( $data['size'] ),
|
||||
esc_attr( $data['size'] ),
|
||||
esc_attr( $data['alt'] ),
|
||||
esc_attr( $data['default'] ),
|
||||
'if ( ! this.getAttribute(\'data-load-error\') ){ this.setAttribute(\'data-load-error\', \'1\');this.setAttribute(\'src\', this.getAttribute(\'data-default\'));}'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'cover_photo':
|
||||
|
||||
$is_default = false;
|
||||
|
||||
if (um_profile( 'cover_photo' )) {
|
||||
if ( um_profile( 'cover_photo' ) ) {
|
||||
$cover_uri = um_get_cover_uri( um_profile( 'cover_photo' ), $attrs );
|
||||
} else if (um_profile( 'synced_cover_photo' )) {
|
||||
} elseif ( um_profile( 'synced_cover_photo' ) ) {
|
||||
$cover_uri = um_profile( 'synced_cover_photo' );
|
||||
} else {
|
||||
$cover_uri = um_get_default_cover_uri();
|
||||
@@ -2282,12 +2229,7 @@ function um_user( $data, $attrs = null ) {
|
||||
*/
|
||||
$cover_uri = apply_filters( 'um_user_cover_photo_uri__filter', $cover_uri, $is_default, $attrs );
|
||||
|
||||
if ( $cover_uri )
|
||||
return '<img src="' . $cover_uri . '" alt="" />';
|
||||
|
||||
if ( ! $cover_uri )
|
||||
return '';
|
||||
|
||||
return $cover_uri ? '<img src="' . esc_attr( $cover_uri ) . '" alt="" />' : '';
|
||||
break;
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace um\widgets;
|
||||
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+8
-2
@@ -6,7 +6,7 @@ Donate link:
|
||||
Tags: community, member, membership, user-profile, user-registration
|
||||
Requires at least: 4.7
|
||||
Tested up to: 4.9
|
||||
Stable tag: 2.0.25
|
||||
Stable tag: 2.0.26
|
||||
License: GNU Version 2 or Any Later Version
|
||||
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
|
||||
@@ -131,11 +131,17 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
|
||||
|
||||
= Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin =
|
||||
|
||||
= 2.0.26: August 29, 2018 =
|
||||
= 2.0.26: September 18, 2018 =
|
||||
|
||||
* Enhancements:
|
||||
- New files/images downloading process
|
||||
|
||||
* Bugfixes:
|
||||
- File/Image email placeholders after registration form submitting
|
||||
- File/Image forms fields values on submit/edit
|
||||
- Fixed multisite file/image upload process
|
||||
- Fixed clearing old user sessions after the changing a password
|
||||
- Made reset password process via WP native functions
|
||||
|
||||
= 2.0.25: August 20, 2018 =
|
||||
|
||||
|
||||
@@ -3,74 +3,93 @@
|
||||
<div class="um-form">
|
||||
|
||||
<form method="post" action="">
|
||||
|
||||
<?php if ( !isset( UM()->password()->reset_request ) ) {
|
||||
<input type="hidden" name="_um_password_change" id="_um_password_change" value="1" />
|
||||
<input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $args['user_id'] ); ?>" />
|
||||
<input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>">
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_change_password_page_hidden_fields
|
||||
* @description Password change hidden fields
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Password change shortcode arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_change_password_page_hidden_fields', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_change_password_page_hidden_fields', 'my_change_password_page_hidden_fields', 10, 1 );
|
||||
* function my_change_password_page_hidden_fields( $args ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_change_password_page_hidden_fields', $args );
|
||||
<?php
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_change_password_page_hidden_fields
|
||||
* @description Password change hidden fields
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Password change shortcode arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_change_password_page_hidden_fields', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_change_password_page_hidden_fields', 'my_change_password_page_hidden_fields', 10, 1 );
|
||||
* function my_change_password_page_hidden_fields( $args ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_change_password_page_hidden_fields', $args );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_change_password_form
|
||||
* @description Password change form content
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Password change shortcode arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_change_password_form', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_change_password_form', 'my_change_password_form', 10, 1 );
|
||||
* function my_change_password_form( $args ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_change_password_form', $args );
|
||||
$fields = UM()->builtin()->get_specific_fields( 'user_password' );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_after_form_fields
|
||||
* @description Password change after form content
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Password change shortcode arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_after_form_fields', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_after_form_fields', 'my_after_form_fields', 10, 1 );
|
||||
* function my_after_form_fields( $args ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( "um_after_form_fields", $args );
|
||||
|
||||
} ?>
|
||||
$output = null;
|
||||
foreach ( $fields as $key => $data ) {
|
||||
$output .= UM()->fields()->edit_field( $key, $data );
|
||||
}
|
||||
echo $output; ?>
|
||||
|
||||
<div class="um-col-alt um-col-alt-b">
|
||||
|
||||
<div class="um-center">
|
||||
<input type="submit" value="<?php esc_attr_e( 'Change my password', 'ultimate-member' ); ?>" class="um-button" id="um-submit-btn" />
|
||||
</div>
|
||||
|
||||
<div class="um-clear"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_change_password_form
|
||||
* @description Password change form content
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Password change shortcode arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_change_password_form', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_change_password_form', 'my_change_password_form', 10, 1 );
|
||||
* function my_change_password_form( $args ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_change_password_form', $args );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_after_form_fields
|
||||
* @description Password change after form content
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Password change shortcode arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_after_form_fields', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_after_form_fields', 'my_after_form_fields', 10, 1 );
|
||||
* function my_after_form_fields( $args ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( "um_after_form_fields", $args ); ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,13 +1,19 @@
|
||||
<div class="um <?php echo $this->get_class( $mode ); ?> um-<?php echo esc_attr( $form_id ); ?>">
|
||||
|
||||
<div class="um-form">
|
||||
|
||||
<form method="post" action="">
|
||||
|
||||
<?php
|
||||
|
||||
if ( ! isset( UM()->password()->reset_request ) ) {
|
||||
<?php if ( isset( $_GET['updated'] ) && 'checkemail' == $_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' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
|
||||
<input type="hidden" name="_um_password_reset" id="_um_password_reset" value="1" />
|
||||
|
||||
<?php
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
@@ -29,6 +35,68 @@
|
||||
*/
|
||||
do_action( 'um_reset_password_page_hidden_fields', $args );
|
||||
|
||||
if ( ! empty( $_GET['updated'] ) ) { ?>
|
||||
<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'] ) {
|
||||
_e( 'Your password reset link has expired. Please request a new link below.', 'ultimate-member' );
|
||||
} elseif ( 'invalidkey' == $_GET['updated'] ) {
|
||||
_e( 'Your password reset link appears to be invalid. Please request a new link below.', 'ultimate-member' );
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<div class="um-field um-field-block um-field-type_block">
|
||||
<div class="um-field-block">
|
||||
<div style="text-align:center;">
|
||||
<?php _e('To reset your password, please enter your email address or username below','ultimate-member'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
|
||||
$fields = UM()->builtin()->get_specific_fields( 'username_b' );
|
||||
|
||||
$output = null;
|
||||
foreach ( $fields as $key => $data ) {
|
||||
$output .= UM()->fields()->edit_field( $key, $data );
|
||||
}
|
||||
echo $output;
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_after_password_reset_fields
|
||||
* @description Hook that runs after user reset their password
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Form data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_after_password_reset_fields', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_after_password_reset_fields', 'my_after_password_reset_fields', 10, 1 );
|
||||
* function my_after_password_reset_fields( $args ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_after_password_reset_fields', $args ); ?>
|
||||
|
||||
<div class="um-col-alt um-col-alt-b">
|
||||
|
||||
<div class="um-center">
|
||||
<input type="submit" value="<?php esc_attr_e('Reset my password','ultimate-member' ); ?>" class="um-button" id="um-submit-btn" />
|
||||
</div>
|
||||
|
||||
<div class="um-clear"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
@@ -70,15 +138,7 @@
|
||||
* ?>
|
||||
*/
|
||||
do_action( "um_after_form_fields", $args );
|
||||
|
||||
} else { ?>
|
||||
|
||||
<div class="um-field-block">
|
||||
<p><?php _e( 'We have sent you a password reset link to your e-mail. Please check your inbox.', 'ultimate-member' ) ?></p>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
} ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user