Version Description
Download this release
Release Info
Developer | nsinelnikov |
Plugin | Ultimate Member – User Profile & Membership Plugin |
Version | 2.3.0 |
Comparing to | |
See all releases |
Code changes from version 2.2.5 to 2.3.0
- assets/js/um-account.js +2 -2
- assets/js/um-account.min.js +1 -1
- assets/js/um-members.js +1 -0
- assets/js/um-members.min.js +1 -1
- assets/js/um-scripts.js +716 -706
- assets/js/um-scripts.min.js +1 -1
- includes/admin/class-admin.php +1980 -1980
- includes/admin/core/class-admin-metabox.php +1 -1
- includes/admin/core/class-admin-settings.php +3466 -3475
- includes/admin/core/packages/2.3.0/functions.php +152 -0
- includes/admin/core/packages/2.3.0/hooks.php +8 -0
- includes/admin/core/packages/2.3.0/init.php +133 -0
- includes/class-config.php +808 -809
- includes/class-functions.php +410 -410
- includes/core/class-builtin.php +64 -5
- includes/core/class-fields.php +45 -0
- includes/core/class-form.php +13 -4
- includes/core/class-member-directory.php +2 -1
- includes/core/class-password.php +719 -721
- includes/core/class-profile.php +1 -1
- includes/core/class-roles-capabilities.php +17 -0
- includes/core/class-user.php +2185 -2185
- includes/core/class-validation.php +22 -1
- includes/core/um-actions-account.php +768 -764
- includes/core/um-actions-form.php +936 -924
- includes/core/um-actions-login.php +2 -2
- includes/core/um-actions-profile.php +1605 -1754
assets/js/um-account.js
CHANGED
@@ -4,8 +4,8 @@ jQuery(document).ready(function() {
|
|
4 |
|
5 |
if ( current_tab ) {
|
6 |
jQuery('.um-account-tab[data-tab="'+current_tab+'"]').show();
|
7 |
-
|
8 |
jQuery('.um-account-tab:not(:visible)').find( 'input, select, textarea' ).not( ':disabled' ).addClass('um_account_inactive').prop( 'disabled', true ).attr( 'disabled', true );
|
|
|
9 |
}
|
10 |
|
11 |
jQuery( document.body ).on( 'click', '.um-account-side li a', function(e) {
|
@@ -103,4 +103,4 @@ jQuery(document).ready(function() {
|
|
103 |
|
104 |
});
|
105 |
|
106 |
-
});
|
4 |
|
5 |
if ( current_tab ) {
|
6 |
jQuery('.um-account-tab[data-tab="'+current_tab+'"]').show();
|
|
|
7 |
jQuery('.um-account-tab:not(:visible)').find( 'input, select, textarea' ).not( ':disabled' ).addClass('um_account_inactive').prop( 'disabled', true ).attr( 'disabled', true );
|
8 |
+
wp.hooks.doAction( 'um_account_active_tab_inited', current_tab );
|
9 |
}
|
10 |
|
11 |
jQuery( document.body ).on( 'click', '.um-account-side li a', function(e) {
|
103 |
|
104 |
});
|
105 |
|
106 |
+
});
|
assets/js/um-account.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(document).ready(function(){var a=jQuery(".um-account-main").attr("data-current_tab");a&&(jQuery('.um-account-tab[data-tab="'+a+'"]').show(),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0)),jQuery(document.body).on("click",".um-account-side li a",function(a){a.preventDefault();var
|
1 |
+
jQuery(document).ready(function(){var a=jQuery(".um-account-main").attr("data-current_tab");a&&(jQuery('.um-account-tab[data-tab="'+a+'"]').show(),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),wp.hooks.doAction("um_account_active_tab_inited",a)),jQuery(document.body).on("click",".um-account-side li a",function(a){a.preventDefault();var t=jQuery(this);t.parents("ul").find("li a").removeClass("current"),t.addClass("current");var e=jQuery(this).attr("href"),u=jQuery(this).attr("data-tab");return jQuery('input[id="_um_account_tab"]:hidden').val(u),window.history.pushState("","",e),jQuery(".um-account-tab").hide(),jQuery('.um-account-tab[data-tab="'+u+'"]').fadeIn(),jQuery(".um-account-tab:visible").find("input, select, textarea").filter(".um_account_inactive:disabled").removeClass("um_account_inactive").prop("disabled",!1).attr("disabled",!1),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),jQuery(".um-account-nav a").removeClass("current"),jQuery('.um-account-nav a[data-tab="'+u+'"]').addClass("current"),wp.hooks.doAction("um_after_account_tab_changed",u),!1}),jQuery(document.body).on("click",".um-account-nav a",function(a){a.preventDefault();var t=jQuery(this).attr("data-tab"),e=jQuery(this).parents("div"),u=jQuery(this);return jQuery('input[id="_um_account_tab"]:hidden').val(t),jQuery(".um-account-tab").hide(),u.hasClass("current")?(e.next(".um-account-tab").slideUp(),u.removeClass("current")):(e.next(".um-account-tab").slideDown(),u.parents("div").find("a").removeClass("current"),u.addClass("current")),jQuery(".um-account-tab:visible").find("input, select, textarea").filter(".um_account_inactive:disabled").removeClass("um_account_inactive").prop("disabled",!1).attr("disabled",!1),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),jQuery(".um-account-side li a").removeClass("current"),jQuery('.um-account-side li a[data-tab="'+t+'"]').addClass("current"),wp.hooks.doAction("um_after_account_tab_changed",t),!1}),jQuery(document.body).on("click",".um-request-button",function(a){a.preventDefault();var t=jQuery(this).data("action"),e=jQuery("#"+t).val();if(jQuery(".um-field-area-response."+t).hide(),jQuery("#"+t).length&&""===e)jQuery(".um-field-error."+t).show();else{jQuery(".um-field-error."+t).hide();var u={request_action:t,nonce:um_scripts.nonce};jQuery("#"+t).length&&(u.password=e),wp.ajax.send("um_request_user_data",{data:u,success:function(a){jQuery(".um-field-area-response."+t).text(a.answer).show()},error:function(a){console.log(a)}})}})});
|
assets/js/um-members.js
CHANGED
@@ -1253,6 +1253,7 @@ jQuery(document.body).ready( function() {
|
|
1253 |
if ( typeof current_value == 'undefined' ) {
|
1254 |
current_value = [];
|
1255 |
} else {
|
|
|
1256 |
current_value = current_value.split( '||' );
|
1257 |
}
|
1258 |
|
1253 |
if ( typeof current_value == 'undefined' ) {
|
1254 |
current_value = [];
|
1255 |
} else {
|
1256 |
+
current_value = um_unsanitize_value( current_value );
|
1257 |
current_value = current_value.split( '||' );
|
1258 |
}
|
1259 |
|
assets/js/um-members.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var um_members_directory_busy=[],um_member_directories=[],um_member_directory_last_data=[];function um_parse_current_url(){var t={},a=window.location.search.substring(1).split("&");return jQuery.each(a,function(e){var r=a[e].split("=");t[r[0]]=r[1]}),t}function um_get_data_for_directory(e,r){var t=um_members_get_hash(e),a={},i=um_parse_current_url();if(jQuery.each(i,function(e){-1!==e.indexOf("_"+t)&&""!==i[e]&&(a[e.replace("_"+t,"")]=i[e])}),r){if(void 0!==a[r])try{a[r]=decodeURIComponent(a[r])}catch(e){console.error(e)}return a[r]}return a}function um_set_url_from_data(e,r,t){var a=um_members_get_hash(e),i=um_get_data_for_directory(e),m={};Array.isArray(t)?(jQuery.each(t,function(e){t[e]=encodeURIComponent(t[e])}),t=t.join("||")):jQuery.isNumeric(t)||(t=t.split("||"),jQuery.each(t,function(e){t[e]=encodeURIComponent(t[e])}),t=t.join("||")),""!==t&&(m[r+"_"+a]=t),jQuery.each(i,function(e){r===e?""!==t&&(m[e+"_"+a]=t):m[e+"_"+a]=i[e]}),jQuery.each(um_member_directories,function(e){var r=um_member_directories[e];if(r!==a){var t=um_get_data_for_directory(jQuery('.um-directory[data-hash="'+r+'"]'));jQuery.each(t,function(e){m[e+"_"+r]=t[e]})}});var d=[];jQuery.each(m,function(e){d.push(e+"="+m[e])});var s="?"+(d=wp.hooks.applyFilters("um_member_directory_url_attrs",d)).join("&");"?"===s&&(s=""),window.history.pushState("string","UM Member Directory",window.location.origin+window.location.pathname+s)}function um_members_get_hash(e){return e.data("hash")}function um_is_directory_busy(e){var r=um_members_get_hash(e);return void 0!==um_members_directory_busy[r]&&um_members_directory_busy[r]}function um_members_show_preloader(e){um_members_directory_busy[um_members_get_hash(e)]=!0,e.find(".um-members-overlay").show()}function um_members_hide_preloader(e){um_members_directory_busy[um_members_get_hash(e)]=!1,e.find(".um-members-overlay").hide()}function um_set_range_label(e,r){var t,a,i="",m=e.siblings(".um-slider-range").data("placeholder-s"),d=e.siblings(".um-slider-range").data("placeholder-p");a=r?(i=r.values[0]===r.values[1]?m.replace("{value}",r.values[0]).replace("{field_label}",e.siblings(".um-slider-range").data("label")):d.replace("{min_range}",r.values[0]).replace("{max_range}",r.values[1]).replace("{field_label}",e.siblings(".um-slider-range").data("label")),t=r.values[0],r.values[1]):(i=e.slider("values",0)===e.slider("values",1)?m.replace("{value}",e.slider("values",0)).replace("{field_label}",e.siblings(".um-slider-range").data("label")):d.replace("{min_range}",e.slider("values",0)).replace("{max_range}",e.slider("values",1)).replace("{field_label}",e.siblings(".um-slider-range").data("label")),t=e.slider("values",0),e.slider("values",1)),e.siblings(".um-slider-range").html(i),e.siblings(".um_range_min").val(t),e.siblings(".um_range_max").val(a)}function um_get_search(e){return e.find(".um-search-line").length?e.find(".um-search-line").val():""}function um_get_sort(e){return e.data("sorting")}function um_get_current_page(e){var r=e.data("page");return r&&void 0!==r||(r=1),r}function um_time_convert(e,r){var t=Math.floor(e/60),a=e%60;return 60<=a&&(a=0,24<=(t+=1)&&(t=0)),a<10&&(a="0"+a),t+":"+a}function um_ajax_get_members(u,e){var t=um_members_get_hash(u);if(wp.hooks.applyFilters("um_member_directory_get_members_allow",!0,t,u)){var r=um_get_current_page(u),a=um_get_search(u),i=um_get_sort(u),m=-(new Date).getTimezoneOffset()/60,_={directory_id:t,page:r,search:a,sorting:i,gmt_offset:m,post_refferer:u.data("base-post"),nonce:um_scripts.nonce};u.find(".um-search-filter").length&&u.find(".um-search-filter").each(function(){var e=jQuery(this);if(e.find(".um-slider").length){var r=e.find(".um-slider").data("field_name"),t=um_get_data_for_directory(u,"filter_"+r+"_from"),a=um_get_data_for_directory(u,"filter_"+r+"_to");void 0===t&&void 0===a||(_[r]=[t,a])}else if(e.find(".um-datepicker-filter").length){r=e.find(".um-datepicker-filter").data("filter_name"),t=um_get_data_for_directory(u,"filter_"+r+"_from"),a=um_get_data_for_directory(u,"filter_"+r+"_to");void 0===t&&void 0===a||(_[r]=[t,a])}else if(e.find(".um-timepicker-filter").length){r=e.find(".um-timepicker-filter").data("filter_name"),t=um_get_data_for_directory(u,"filter_"+r+"_from"),a=um_get_data_for_directory(u,"filter_"+r+"_to");if(void 0!==t)(i=1*(t=t.split(":"))[0])<10&&(i="0"+i),(d=1*t[1])<10&&(d="0"+d),t=i+":"+d+":00";if(void 0!==a){var i,m=a.split(":"),d=1*m[1];(i=1*m[0])<10&&(i="0"+i),d<10&&(d="0"+d),a=i+":"+d+":59"}void 0===t&&void 0===a||(_[r]=[t,a])}else if(e.find("select").length){r=e.find("select").attr("name");void 0!==(s=um_get_data_for_directory(u,"filter_"+r))&&(s=um_unsanitize_value(s),_[r]=s.split("||"))}else if(e.hasClass("um-text-filter-type")&&e.find('input[type="text"]').length){var s;r=e.find('input[type="text"]').attr("name");void 0!==(s=um_get_data_for_directory(u,"filter_"+r))&&(s=um_unsanitize_value(s),_[r]=s)}else _=wp.hooks.applyFilters("um_member_directory_custom_filter_handler",_,e,u)}),_=wp.hooks.applyFilters("um_member_directory_filter_request",_),wp.ajax.send("um_get_members",{data:_,success:function(e){um_member_directory_last_data[t]=e,um_build_template(u,e);var r=wp.template("um-members-pagination");u.find(".um-members-pagination-box").html(r(e)),u.data("total_pages",e.pagination.total_pages),e.pagination.total_pages?(u.find(".um-member-directory-sorting-options").prop("disabled",!1),u.find(".um-member-directory-view-type").removeClass("um-disabled")):(u.find(".um-member-directory-sorting-options").prop("disabled",!0),u.find(".um-member-directory-view-type").addClass("um-disabled")),wp.hooks.doAction("um_member_directory_loaded",u,e),um_init_new_dropdown(),um_members_hide_preloader(u)},error:function(e){console.log(e),um_members_hide_preloader(u)}})}else setTimeout(um_ajax_get_members,600,u,e)}function um_build_template(e,r){var t=e.data("view_type"),a=wp.template("um-member-"+t+"-"+um_members_get_hash(e));e.find(".um-members-grid, .um-members-list").remove(),e.find(".um-members-wrapper").prepend(a(r.users));var i=wp.template("um-members-header");e.find(".um-members-intro").remove();var m=wp.hooks.applyFilters("um_member_directory_generate_header",!1,e);(void 0!==r.is_search&&r.is_search||m)&&e.find(".um-members-wrapper").prepend(i(r)),e.addClass("um-loaded"),e.find(".um-members.um-members-grid").length&&UM_Member_Grid(e.find(".um-members.um-members-grid")),jQuery(document).trigger("um_build_template",[e,r]),jQuery(window).trigger("resize"),init_tipsy()}function UM_Member_Grid(r){r.find(".um-member").length&&r.imagesLoaded(function(){var e=wp.hooks.applyFilters("um_member_directory_grid_masonry_attrs",{itemSelector:".um-member",columnWidth:".um-member",gutter:".um-gutter-sizer"},r);r.masonry(e).on("layoutComplete",function(e,r){jQuery(document).trigger("um_grid_initialized",[e,r])})})}function um_get_filters_data(u){var _=[];return u.find(".um-search-filter").each(function(){var t,a,d,i=jQuery(this);if(i.find("input.um-datepicker-filter").length)d="datepicker",i.find("input.um-datepicker-filter").each(function(){if("to"!==jQuery(this).data("range")){var e=jQuery(this).data("filter_name"),r=um_get_data_for_directory(u,"filter_"+e+"_from"),t=um_get_data_for_directory(u,"filter_"+e+"_to");if(void 0!==r||void 0!==t){var a,i=jQuery(this).val(),m=u.find('input.um-datepicker-filter[data-range="to"][data-filter_name="'+e+'"]').val();i===m?a=m:""!==i&&""!==m?a=i+" - "+m:""===i?a="before "+m:""===m&&(a="since "+i),_.push({name:e,label:jQuery(this).data("filter-label"),value_label:a,value:[r,t],type:d})}}});else if(i.find("input.um-timepicker-filter").length)d="timepicker",i.find("input.um-timepicker-filter").each(function(){if("to"!==jQuery(this).data("range")){var e=jQuery(this).data("filter_name"),r=um_get_data_for_directory(u,"filter_"+e+"_from"),t=um_get_data_for_directory(u,"filter_"+e+"_to");if(void 0!==r||void 0!==t){var a,i=jQuery(this).val(),m=u.find('input.um-timepicker-filter[data-range="to"][data-filter_name="'+e+'"]').val();i===m?a=m:""!==i&&""!==m?a=i+" - "+m:""===i?a="before "+m:""===m&&(a="since "+i),_.push({name:e,label:jQuery(this).data("filter-label"),value_label:a,value:[r,t],type:d})}}});else if(i.find("select").length){d="select",t=i.find("select").attr("name"),a=i.find("select").data("placeholder"),m=void 0===(m=um_get_data_for_directory(u,"filter_"+t))?[]:(m=um_unsanitize_value(m)).split("||"),jQuery.each(m,function(e){var r=i.find('select option[value="'+m[e]+'"]').data("value_label");_.push({name:t,label:a,value_label:r,value:m[e],type:d})})}else if(i.hasClass("um-text-filter-type")&&i.find('input[type="text"]').length){var m;d="text",t=i.find('input[type="text"]').attr("name"),a=i.find('input[type="text"]').attr("placeholder"),void 0===(m=um_get_data_for_directory(u,"filter_"+t))&&(m=""),""!=m&&_.push({name:t,label:a,value_label:m,value:m,type:d})}else if(i.find("div.ui-slider").length){d="slider",t=i.find("div.ui-slider").data("field_name");var e,r=um_get_data_for_directory(u,"filter_"+t+"_from"),s=um_get_data_for_directory(u,"filter_"+t+"_to");if(void 0===r&&void 0===s)return;e=r===s?i.find("div.um-slider-range").data("placeholder-s").replace("{value}",r).replace("{field_label}",i.find("div.um-slider-range").data("label")):i.find("div.um-slider-range").data("placeholder-p").replace("{min_range}",r).replace("{max_range}",s).replace("{field_label}",i.find("div.um-slider-range").data("label")),a=i.find("div.um-slider-range").data("label"),_.push({name:t,label:a,value_label:e,value:[r,s],type:d})}else _=wp.hooks.applyFilters("um_member_directory_get_filter_data",_,u,i)}),_}function um_change_tag(e){var r=um_get_filters_data(e);e.find(".um-members-filter-tag").remove();var t=e.find(".um-filtered-line");if(t.length){var a=wp.template("um-members-filtered-line");t.prepend(a({filters:r})),0===e.find(".um-members-filter-remove").length?(e.find(".um-clear-filters").hide(),e.find(".um-clear-filters").parents(".um-member-directory-header-row").addClass("um-header-row-invisible")):(e.find(".um-clear-filters").show(),e.find(".um-clear-filters").parents(".um-member-directory-header-row").removeClass("um-header-row-invisible"))}}function um_run_search(e){if(!um_is_directory_busy(e)){um_members_show_preloader(e);var r=um_get_data_for_directory(e,"search"),t=um_sanitize_value(e.find(".um-search-line").val());if(t===r||""===t&&void 0===r)um_members_hide_preloader(e);else{e.data("general_search",t),um_set_url_from_data(e,"search",t),e.data("page",1),um_set_url_from_data(e,"page","");var a=!1;if(!(a=wp.hooks.applyFilters("um_member_directory_ignore_after_search",a,e)))if(1===e.data("must-search")&&(t=um_get_search(e),0===e.find(".um-members-filter-remove").length&&!t))return e.data("searched",0),e.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),e.find(".um-member-directory-sorting-options").prop("disabled",!0),e.find(".um-member-directory-view-type").addClass("um-disabled"),wp.hooks.doAction("um_member_directory_clear_not_searched",e),void um_members_hide_preloader(e);e.data("searched",1),e.find(".um-member-directory-sorting-options").prop("disabled",!1),e.find(".um-member-directory-view-type").removeClass("um-disabled"),um_ajax_get_members(e)}}}jQuery(document.body).ready(function(){jQuery(".um-directory .um-search-filter select").each(function(){1===jQuery(this).find("option:not(:disabled)").length&&jQuery(this).prop("disabled",!0);var e=jQuery(this);e.select2("destroy").select2({dropdownParent:e.parent()})}),jQuery(document.body).on("mouseover",".um-directory .um-member-directory-view-type",function(){if(!jQuery(this).hasClass("um-disabled")){var e=jQuery(this).find(".um-member-directory-view-type-a:visible");e.hide(),e.next().length?e.next().show().tipsy("show"):jQuery(this).find(".um-member-directory-view-type-a:first").show().tipsy("show")}}).on("mouseout",".um-directory .um-member-directory-view-type",function(){jQuery(this).hasClass("um-disabled")||(jQuery(this).find(".um-member-directory-view-type-a").hide().tipsy("hide"),jQuery(this).find('.um-member-directory-view-type-a[data-type="'+jQuery(this).parents(".um-directory").data("view_type")+'"]').show())}),jQuery(document.body).on("click",".um-directory .um-member-directory-view-type-a",function(){var e=jQuery(this).parents(".um-directory");if(um_is_directory_busy(e))return!1;var r=jQuery(this),t=r.parents(".um-member-directory-view-type");if(!t.hasClass("um-disabled")){um_members_show_preloader(e);var a=t.find(".um-member-directory-view-type-a:visible");a.hide(),a.next().length?a.next().show().tipsy("show"):t.find(".um-member-directory-view-type-a:first").show().tipsy("show");var i=um_member_directory_last_data[um_members_get_hash(e)];if(null!==i){var m=r.data("type");um_set_url_from_data(e,"view_type",m),e.data("view_type",m),um_build_template(e,i),um_init_new_dropdown()}um_members_hide_preloader(e)}}),jQuery(document.body).on("click",".um-directory .um-do-search",function(){um_run_search(jQuery(this).parents(".um-directory"))}),jQuery(document.body).on("keypress",".um-directory .um-search-line",function(e){13===e.which&&um_run_search(jQuery(this).parents(".um-directory"))}),jQuery(document.body).on("click",'.um-new-dropdown[data-element=".um-member-directory-sorting-a"] li a',function(){if(1!==jQuery(this).data("selected")){var e=jQuery(this).data("directory-hash"),r=jQuery('.um-directory[data-hash="'+e+'"]');if(!um_is_directory_busy(r)){um_members_show_preloader(r);var t=jQuery(this).html(),a=jQuery(this).data("value");r.data("sorting",a),um_set_url_from_data(r,"sort",a),um_ajax_get_members(r),r.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"]').find("a").data("selected",0).prop("data-selected",0).attr("data-selected",0),r.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"] a[data-value="'+a+'"]').data("selected",1).prop("data-selected",1).attr("data-selected",1),r.find(".um-member-directory-sorting-a").find("> a").html(t)}}}),jQuery(document.body).on("click",".um-directory .pagi:not(.current)",function(){if(!jQuery(this).hasClass("disabled")){var e,r=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(r))um_members_show_preloader(r),1===(e="first"===jQuery(this).data("page")?1:"prev"===jQuery(this).data("page")?1*r.data("page")-1:"next"===jQuery(this).data("page")?1*r.data("page")+1:"last"===jQuery(this).data("page")?parseInt(r.data("total_pages")):parseInt(jQuery(this).data("page")))?(r.find('.pagi[data-page="first"], .pagi[data-page="prev"]').addClass("disabled"),r.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass("disabled")):(e===parseInt(r.data("total_pages"))?r.find('.pagi[data-page="prev"], .pagi[data-page="last"]').addClass("disabled"):r.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass("disabled"),r.find('.pagi[data-page="first"], .pagi[data-page="prev"]').removeClass("disabled")),r.find(".pagi").removeClass("current"),r.find('.pagi[data-page="'+e+'"]').addClass("current"),r.data("page",e),um_set_url_from_data(r,"page",1===e?"":e),um_ajax_get_members(r)}}),jQuery(document.body).on("change",".um-directory .um-members-pagi-dropdown",function(){var e=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(e)){um_members_show_preloader(e);var r=jQuery(this).val();e.find(".pagi").removeClass("current"),e.find('.pagi[data-page="'+r+'"]').addClass("current"),e.data("page",r),um_set_url_from_data(e,"page",1===r?"":r),um_ajax_get_members(e)}}),jQuery(document.body).on("click",".um-directory .um-members.um-members-list .um-member-more a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member");return r.find(".um-member-more").hide(),r.find(".um-member-meta-main").slideDown(),r.find(".um-member-less").fadeIn(),!1}),jQuery(document.body).on("click",".um-directory .um-members.um-members-list .um-member-less a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member");return r.find(".um-member-less").hide(),r.find(".um-member-meta-main").slideUp(),r.find(".um-member-more").fadeIn(),!1}),jQuery(document.body).on("click",".um-directory .um-members.um-members-grid .um-member-more a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member"),t=jQuery(this).parents(".um-members");return r.find(".um-member-more").hide(),r.find(".um-member-meta").slideDown(function(){UM_Member_Grid(t)}),r.find(".um-member-less").fadeIn(),setTimeout(function(){UM_Member_Grid(t)},100),!1}),jQuery(document.body).on("click",".um-directory .um-members.um-members-grid .um-member-less a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member"),t=jQuery(this).parents(".um-members");return r.find(".um-member-less").hide(),r.find(".um-member-meta").slideUp(function(){r.find(".um-member-more").fadeIn(),UM_Member_Grid(t)}),!1}),jQuery(".um-member-directory-filters-a").on("click",function(){var e=jQuery(this),r=e.parents(".um-directory").find(".um-search");r.is(":visible")?r.slideUp(250,function(){e.toggleClass("um-member-directory-filters-visible"),r.parents(".um-member-directory-header-row").toggleClass("um-header-row-invisible")}):r.slideDown({duration:250,start:function(){jQuery(this).css({display:"grid"}),e.toggleClass("um-member-directory-filters-visible"),r.parents(".um-member-directory-header-row").toggleClass("um-header-row-invisible")}})}),jQuery(document.body).on("change",".um-directory .um-search-filter select",function(){var e=jQuery(this).val(),r=um_sanitize_value(e);if(""!==r){var t=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(t)){um_members_show_preloader(t);var a=jQuery(this).prop("name"),i=um_get_data_for_directory(t,"filter_"+a);i=void 0===i?[]:i.split("||"),-1===jQuery.inArray(r,i)&&(i.push(r),um_set_url_from_data(t,"filter_"+a,i=i.join("||")),t.data("page",1),um_set_url_from_data(t,"page","")),jQuery(this).find('option[value="'+e+'"]').prop("disabled",!0).hide(),1===jQuery(this).find("option:not(:disabled)").length&&jQuery(this).prop("disabled",!0);var m=jQuery(this);m.select2("destroy").select2({dropdownParent:m.parent()}),m.val("").trigger("change"),um_ajax_get_members(t),um_change_tag(t),t.data("searched",1),t.find(".um-member-directory-sorting-options").prop("disabled",!1),t.find(".um-member-directory-view-type").removeClass("um-disabled")}}}),jQuery(document.body).on("blur",'.um-directory .um-search-filter.um-text-filter-type input[type="text"]',function(){var e=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(e)){var r=um_sanitize_value(jQuery(this).val()),t=jQuery(this).prop("name"),a=um_get_data_for_directory(e,"filter_"+t);void 0===a&&(a=""),r!==a&&(um_members_show_preloader(e),um_set_url_from_data(e,"filter_"+t,r),e.data("page",1),um_set_url_from_data(e,"page",""),um_ajax_get_members(e),um_change_tag(e),e.data("searched",1),e.find(".um-member-directory-sorting-options").prop("disabled",!1),e.find(".um-member-directory-view-type").removeClass("um-disabled"))}}),jQuery(document.body).on("keypress",'.um-directory .um-search-filter.um-text-filter-type input[type="text"]',function(e){if(13===e.which){var r=jQuery(this).parents(".um-directory");if(um_is_directory_busy(r))return;var t=um_sanitize_value(jQuery(this).val()),a=jQuery(this).prop("name"),i=um_get_data_for_directory(r,"filter_"+a);if(void 0===i&&(i=""),t===i)return;um_members_show_preloader(r),um_set_url_from_data(r,"filter_"+a,t),r.data("page",1),um_set_url_from_data(r,"page",""),um_ajax_get_members(r),um_change_tag(r),r.data("searched",1),r.find(".um-member-directory-sorting-options").prop("disabled",!1),r.find(".um-member-directory-view-type").removeClass("um-disabled")}}),jQuery(document.body).on("click",".um-directory .um-members-filter-remove",function(){var e=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(e)&&e){um_members_show_preloader(e);var r=jQuery(this).data("value"),t=jQuery(this).data("name"),a=jQuery(this).data("type");if("text"===a)um_set_url_from_data(e,"filter_"+t,""),jQuery('.um-search-filter input[name="'+t+'"]').val("");else if("select"===a){var i=um_get_data_for_directory(e,"filter_"+t);i=void 0===i?[]:(i=um_unsanitize_value(i)).split("||"),-1!==jQuery.inArray(r.toString(),i)&&(i=jQuery.grep(i,function(e){return e!==r.toString()})),i.length||(i=""),um_set_url_from_data(e,"filter_"+t,i);var m=jQuery('.um-search-filter select[name="'+t+'"]');m.find('option[value="'+r+'"]').prop("disabled",!1).show(),1<m.find("option:not(:disabled)").length&&m.prop("disabled",!1),m.select2("destroy").select2({dropdownParent:m.parent()}),0<e.find('.um-search-filter select[data-um-parent="'+t+'"]').length&&m.trigger("change")}else if("slider"===a){um_set_url_from_data(e,"filter_"+t+"_from",""),um_set_url_from_data(e,"filter_"+t+"_to","");var d=jQuery(".um-search-filter #"+t+"_min").siblings(".um-slider"),s=d.slider("option");d.slider("values",[s.min,s.max]),jQuery(".um-search-filter #"+t+"_min").val(""),jQuery(".um-search-filter #"+t+"_max").val(""),um_set_range_label(d)}else"datepicker"===a?(um_set_url_from_data(e,"filter_"+t+"_from",""),um_set_url_from_data(e,"filter_"+t+"_to",""),jQuery(".um-search-filter #"+t+"_from").val(""),jQuery(".um-search-filter #"+t+"_to").val("")):"timepicker"===a?(um_set_url_from_data(e,"filter_"+t+"_from",""),um_set_url_from_data(e,"filter_"+t+"_to",""),jQuery(".um-search-filter #"+t+"_from").val(""),jQuery(".um-search-filter #"+t+"_to").val("")):wp.hooks.doAction("um_member_directory_filter_remove",a,e,t,r);e.data("page",1),um_set_url_from_data(e,"page",""),jQuery(this).tipsy("hide"),jQuery(this).parents(".um-members-filter-tag").remove(),0===e.find(".um-members-filter-remove").length?e.find(".um-clear-filters").hide():e.find(".um-clear-filters").show();var u=!1;if(!(u=wp.hooks.applyFilters("um_member_directory_ignore_after_search",u,e)))if(1===e.data("must-search")){var _=um_get_search(e);if(0===e.find(".um-members-filter-remove").length&&!_)return e.data("searched",0),e.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),e.find(".um-member-directory-sorting-options").prop("disabled",!0),e.find(".um-member-directory-view-type").addClass("um-disabled"),wp.hooks.doAction("um_member_directory_clear_not_searched",e),void um_members_hide_preloader(e)}e.find(".um-member-directory-sorting-options").prop("disabled",!1),e.find(".um-member-directory-view-type").removeClass("um-disabled"),um_ajax_get_members(e)}}),jQuery(document.body).on("click",".um-directory .um-clear-filters-a",function(){var s=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(s)){um_members_show_preloader(s),s.find(".um-members-filter-remove").each(function(){var r=jQuery(this).data("value"),e=jQuery(this).data("name"),t=jQuery(this).data("type");if("text"===t)um_set_url_from_data(s,"filter_"+e,""),jQuery('.um-search-filter input[name="'+e+'"]').val("");else if("select"===t){var a=um_get_data_for_directory(s,"filter_"+e);a=void 0===a?[]:a.split("||"),-1!==jQuery.inArray(r.toString(),a)&&(a=jQuery.grep(a,function(e){return e!==r.toString()})),a.length||(a=""),um_set_url_from_data(s,"filter_"+e,a);var i=jQuery('.um-search-filter select[name="'+e+'"]');i.find('option[value="'+r+'"]').prop("disabled",!1).show(),1<i.find("option:not(:disabled)").length&&i.prop("disabled",!1),i.select2("destroy").select2({dropdownParent:i.parent()}),0<s.find('.um-search-filter select[data-um-parent="'+e+'"]').length&&i.trigger("change")}else if("slider"===t){um_set_url_from_data(s,"filter_"+e+"_from",""),um_set_url_from_data(s,"filter_"+e+"_to","");var m=jQuery(".um-search-filter #"+e+"_min").siblings(".um-slider"),d=m.slider("option");m.slider("values",[d.min,d.max]),jQuery(".um-search-filter #"+e+"_min").val(""),jQuery(".um-search-filter #"+e+"_max").val(""),um_set_range_label(m)}else"datepicker"===t?(um_set_url_from_data(s,"filter_"+e+"_from",""),um_set_url_from_data(s,"filter_"+e+"_to",""),jQuery(".um-search-filter #"+e+"_from").val(""),jQuery(".um-search-filter #"+e+"_to").val("")):"timepicker"===t?(um_set_url_from_data(s,"filter_"+e+"_from",""),um_set_url_from_data(s,"filter_"+e+"_to",""),jQuery(".um-search-filter #"+e+"_from").val(""),jQuery(".um-search-filter #"+e+"_to").val("")):wp.hooks.doAction("um_member_directory_clear_filters",t,s,e,r)}),s.data("page",1),um_set_url_from_data(s,"page",""),s.find(".um-members-filter-tag").remove(),0===s.find(".um-members-filter-remove").length?(s.find(".um-clear-filters").hide(),s.find(".um-clear-filters").parents(".um-member-directory-header-row").addClass("um-header-row-invisible")):(s.find(".um-clear-filters").show(),s.find(".um-clear-filters").parents(".um-member-directory-header-row").removeClass("um-header-row-invisible"));var e=!1;if(!(e=wp.hooks.applyFilters("um_member_directory_ignore_after_search",e,s)))if(1===s.data("must-search"))if(!um_get_search(s))return s.data("searched",0),s.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),s.find(".um-member-directory-sorting-options").prop("disabled",!0),s.find(".um-member-directory-view-type").addClass("um-disabled"),wp.hooks.doAction("um_member_directory_clear_not_searched",s),void um_members_hide_preloader(s);s.find(".um-member-directory-sorting-options").prop("disabled",!1),s.find(".um-member-directory-view-type").removeClass("um-disabled"),um_ajax_get_members(s)}}),wp.hooks.doAction("um_member_directory_on_first_pages_loading"),jQuery(".um-directory").each(function(){var e=jQuery(this),r=um_members_get_hash(e);um_member_directories.push(r),e.find(".um-search").length&&(e.find(".um-search").is(":visible")||e.find(".um-search").css({display:"grid"}).slideUp(1)),e.find(".um-slider").each(function(){var e=jQuery(this),t=e.parents(".um-directory"),a=e.data("field_name"),r=um_get_data_for_directory(t,"filter_"+a+"_from"),i=um_get_data_for_directory(t,"filter_"+a+"_to");void 0===r&&(r=parseInt(e.data("min"))),void 0===i&&(i=parseInt(e.data("max")));var m=[r,i];e.slider({range:!0,min:parseInt(e.data("min")),max:parseInt(e.data("max")),values:m,create:function(e,r){},step:1,slide:function(e,r){um_set_range_label(jQuery(this),r)},stop:function(e,r){um_is_directory_busy(t)||(um_members_show_preloader(t),um_set_url_from_data(t,"filter_"+a+"_from",r.values[0]),um_set_url_from_data(t,"filter_"+a+"_to",r.values[1]),t.data("page",1),um_set_url_from_data(t,"page",""),um_ajax_get_members(t),um_change_tag(t),t.data("searched",1),t.find(".um-member-directory-sorting-options").prop("disabled",!1),t.find(".um-member-directory-view-type").removeClass("um-disabled"))}}),um_set_range_label(e)}),e.find(".um-datepicker-filter").each(function(){var s=jQuery(this),u=new Date(1e3*s.data("date_min")),_=new Date(1e3*s.data("date_max")),e=s.pickadate({selectYears:!0,min:u,max:_,formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){s.blur()},onClose:function(){s.blur()},onSet:function(e){if(e.select){var r=s.parents(".um-directory");if(!um_is_directory_busy(r)){um_members_show_preloader(r);var t=s.data("filter_name"),a=s.data("range"),i=um_get_data_for_directory(r,"filter_"+t+"_from"),m=um_get_data_for_directory(r,"filter_"+t+"_to");void 0===i&&(i=u/1e3),void 0===m&&(m=_/1e3);var d=e.select/1e3;s.val();"from"===a?i=d:"to"===a&&(m=d),um_set_url_from_data(r,"filter_"+t+"_from",i),um_set_url_from_data(r,"filter_"+t+"_to",m),r.data("page",1),um_set_url_from_data(r,"page",""),um_ajax_get_members(r),um_change_tag(r),r.data("searched",1),r.find(".um-member-directory-sorting-options").prop("disabled",!1),r.find(".um-member-directory-view-type").removeClass("um-disabled")}}}}).pickadate("picker"),r=s.data("filter_name"),t=s.data("range"),a=um_get_data_for_directory(s.parents(".um-directory"),"filter_"+r+"_"+t);void 0!==a&&e.set("select",1e3*a)}),e.find(".um-timepicker-filter").each(function(){var u=jQuery(this),_=u.attr("id"),o=u.data("filter_name"),n=u.attr("data-min"),l=u.attr("data-max"),e=n.split(":"),r=l.split(":"),t=u.pickatime({format:u.data("format"),interval:parseInt(u.data("intervals")),min:[e[0],e[1]],max:[r[0],r[1]],formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){u.blur()},onClose:function(){u.blur()},onSet:function(e){if(e.select){var r=u.parents(".um-directory");if(!um_is_directory_busy(r)){um_members_show_preloader(r);var t=u.data("filter_name"),a=u.data("range"),i=um_get_data_for_directory(r,"filter_"+t+"_from"),m=um_get_data_for_directory(r,"filter_"+t+"_to");if(void 0===i&&(i=n),void 0===m&&(m=l),void 0!==e.select){var d=um_time_convert(e.select,a);"from"===a?i=d:"to"===a&&(m=d)}else"from"===a?i=n:"to"===a&&(m=l);var s=jQuery("#"+_).val();"from"===u.data("range")?jQuery("#"+o+"_to").pickatime("picker").set("min",s):jQuery("#"+o+"_from").pickatime("picker").set("max",s),um_set_url_from_data(r,"filter_"+t+"_from",i),um_set_url_from_data(r,"filter_"+t+"_to",m),r.data("page",1),um_set_url_from_data(r,"page",""),um_ajax_get_members(r),um_change_tag(r),r.data("searched",1),r.find(".um-member-directory-sorting-options").prop("disabled",!1),r.find(".um-member-directory-view-type").removeClass("um-disabled")}}}}).pickatime("picker"),a=u.data("filter_name"),i=u.data("range"),m=um_get_data_for_directory(u.parents(".um-directory"),"filter_"+a+"_"+i);if(void 0!==m){var d=m.split(":");t.set("select",60*d[0]+1*d[1])}}),wp.hooks.doAction("um_member_directory_on_init",e,r);var t=!1;if(!(t=wp.hooks.applyFilters("um_member_directory_ignore_after_search",t,e))&&1===e.data("must-search")){var a=um_get_search(e);if(!um_get_filters_data(e).length&&!a)return}wp.hooks.applyFilters("um_member_directory_prevent_default_first_loading",!1,e,r)||(um_members_show_preloader(e),um_ajax_get_members(e,{first_load:!0}),um_change_tag(e))}),window.addEventListener("popstate",function(e){jQuery(".um-directory").each(function(){var d=jQuery(this),e=um_members_get_hash(d);(um_member_directories.push(e),um_members_show_preloader(d),d.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),d.find(".um-member-directory-search-line").length)&&(void 0===(s=um_get_data_for_directory(d,"search"))&&(s=""),d.data("general_search",s),d.find(".um-search-line").val(s));var r=um_get_data_for_directory(d,"page");if(void 0===r?r=1:r>d.data("total_pages")&&(r=d.data("total_pages")),d.data("page",r).attr("data-page",r),d.find(".um-member-directory-sorting").length){var t=um_get_data_for_directory(d,"sort");void 0===t&&(t=d.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"]').find('a[data-default="1"]').data("value")),d.data("sorting",t);var a=d.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"]');a.find("a").data("selected",0).prop("data-selected",0).attr("data-selected",0),a.find('a[data-value="'+t+'"]').data("selected",1).prop("data-selected",1).attr("data-selected",1),d.find(".um-member-directory-sorting-a").find("> a").html(a.find('a[data-value="'+t+'"]').html())}if(d.find(".um-member-directory-view-type").length){var i=um_get_data_for_directory(d,"view_type");void 0===i&&(i=d.find('.um-member-directory-view-type-a[data-default="1"]').data("type")),d.data("view_type",i),d.find(".um-member-directory-view-type .um-member-directory-view-type-a").hide(),d.find('.um-member-directory-view-type .um-member-directory-view-type-a[data-type="'+i+'"]').show()}d.find(".um-datepicker-filter").each(function(){var e=jQuery(this),r=e.pickadate("picker"),t=e.data("filter_name"),a=e.data("range"),i=um_get_data_for_directory(d,"filter_"+t+"_"+a);void 0!==i?r.set("select",1e3*i):r.clear()}),d.find(".um-slider").each(function(){var e=jQuery(this),r=e.data("field_name"),t=um_get_data_for_directory(d,"filter_"+r+"_from"),a=um_get_data_for_directory(d,"filter_"+r+"_to");void 0===t&&(t=e.data("min")),t=parseInt(t),void 0===a&&(a=e.data("max")),a=parseInt(a),e.slider("values",[t,a]),um_set_range_label(e)}),d.find(".um-timepicker-filter").each(function(){var e=jQuery(this),r=e.pickatime("picker"),t=e.data("filter_name"),a=e.data("range"),i=um_get_data_for_directory(d,"filter_"+t+"_"+a);if(void 0!==i){var m=i.split(":");r.set("select",60*m[0])}else r.clear()});var m=!1;if(!(m=wp.hooks.applyFilters("um_member_directory_ignore_after_search",m,d))&&1===d.data("must-search")){var s=um_get_search(d);if(!um_get_filters_data(d).length&&!s)return d.data("searched",0),void um_members_hide_preloader(d);d.data("searched",1)}wp.hooks.applyFilters("um_member_directory_prevent_default_first_loading",!1,d,e)||(um_ajax_get_members(d),um_change_tag(d))})})});
|
1 |
+
var um_members_directory_busy=[],um_member_directories=[],um_member_directory_last_data=[];function um_parse_current_url(){var t={},a=window.location.search.substring(1).split("&");return jQuery.each(a,function(e){var r=a[e].split("=");t[r[0]]=r[1]}),t}function um_get_data_for_directory(e,r){var t=um_members_get_hash(e),a={},i=um_parse_current_url();if(jQuery.each(i,function(e){-1!==e.indexOf("_"+t)&&""!==i[e]&&(a[e.replace("_"+t,"")]=i[e])}),r){if(void 0!==a[r])try{a[r]=decodeURIComponent(a[r])}catch(e){console.error(e)}return a[r]}return a}function um_set_url_from_data(e,r,t){var a=um_members_get_hash(e),i=um_get_data_for_directory(e),m={};Array.isArray(t)?(jQuery.each(t,function(e){t[e]=encodeURIComponent(t[e])}),t=t.join("||")):jQuery.isNumeric(t)||(t=t.split("||"),jQuery.each(t,function(e){t[e]=encodeURIComponent(t[e])}),t=t.join("||")),""!==t&&(m[r+"_"+a]=t),jQuery.each(i,function(e){r===e?""!==t&&(m[e+"_"+a]=t):m[e+"_"+a]=i[e]}),jQuery.each(um_member_directories,function(e){var r=um_member_directories[e];if(r!==a){var t=um_get_data_for_directory(jQuery('.um-directory[data-hash="'+r+'"]'));jQuery.each(t,function(e){m[e+"_"+r]=t[e]})}});var d=[];jQuery.each(m,function(e){d.push(e+"="+m[e])});var s="?"+(d=wp.hooks.applyFilters("um_member_directory_url_attrs",d)).join("&");"?"===s&&(s=""),window.history.pushState("string","UM Member Directory",window.location.origin+window.location.pathname+s)}function um_members_get_hash(e){return e.data("hash")}function um_is_directory_busy(e){var r=um_members_get_hash(e);return void 0!==um_members_directory_busy[r]&&um_members_directory_busy[r]}function um_members_show_preloader(e){um_members_directory_busy[um_members_get_hash(e)]=!0,e.find(".um-members-overlay").show()}function um_members_hide_preloader(e){um_members_directory_busy[um_members_get_hash(e)]=!1,e.find(".um-members-overlay").hide()}function um_set_range_label(e,r){var t,a,i="",m=e.siblings(".um-slider-range").data("placeholder-s"),d=e.siblings(".um-slider-range").data("placeholder-p");a=r?(i=r.values[0]===r.values[1]?m.replace("{value}",r.values[0]).replace("{field_label}",e.siblings(".um-slider-range").data("label")):d.replace("{min_range}",r.values[0]).replace("{max_range}",r.values[1]).replace("{field_label}",e.siblings(".um-slider-range").data("label")),t=r.values[0],r.values[1]):(i=e.slider("values",0)===e.slider("values",1)?m.replace("{value}",e.slider("values",0)).replace("{field_label}",e.siblings(".um-slider-range").data("label")):d.replace("{min_range}",e.slider("values",0)).replace("{max_range}",e.slider("values",1)).replace("{field_label}",e.siblings(".um-slider-range").data("label")),t=e.slider("values",0),e.slider("values",1)),e.siblings(".um-slider-range").html(i),e.siblings(".um_range_min").val(t),e.siblings(".um_range_max").val(a)}function um_get_search(e){return e.find(".um-search-line").length?e.find(".um-search-line").val():""}function um_get_sort(e){return e.data("sorting")}function um_get_current_page(e){var r=e.data("page");return r&&void 0!==r||(r=1),r}function um_time_convert(e,r){var t=Math.floor(e/60),a=e%60;return 60<=a&&(a=0,24<=(t+=1)&&(t=0)),a<10&&(a="0"+a),t+":"+a}function um_ajax_get_members(u,e){var t=um_members_get_hash(u);if(wp.hooks.applyFilters("um_member_directory_get_members_allow",!0,t,u)){var r=um_get_current_page(u),a=um_get_search(u),i=um_get_sort(u),m=-(new Date).getTimezoneOffset()/60,_={directory_id:t,page:r,search:a,sorting:i,gmt_offset:m,post_refferer:u.data("base-post"),nonce:um_scripts.nonce};u.find(".um-search-filter").length&&u.find(".um-search-filter").each(function(){var e=jQuery(this);if(e.find(".um-slider").length){var r=e.find(".um-slider").data("field_name"),t=um_get_data_for_directory(u,"filter_"+r+"_from"),a=um_get_data_for_directory(u,"filter_"+r+"_to");void 0===t&&void 0===a||(_[r]=[t,a])}else if(e.find(".um-datepicker-filter").length){r=e.find(".um-datepicker-filter").data("filter_name"),t=um_get_data_for_directory(u,"filter_"+r+"_from"),a=um_get_data_for_directory(u,"filter_"+r+"_to");void 0===t&&void 0===a||(_[r]=[t,a])}else if(e.find(".um-timepicker-filter").length){r=e.find(".um-timepicker-filter").data("filter_name"),t=um_get_data_for_directory(u,"filter_"+r+"_from"),a=um_get_data_for_directory(u,"filter_"+r+"_to");if(void 0!==t)(i=1*(t=t.split(":"))[0])<10&&(i="0"+i),(d=1*t[1])<10&&(d="0"+d),t=i+":"+d+":00";if(void 0!==a){var i,m=a.split(":"),d=1*m[1];(i=1*m[0])<10&&(i="0"+i),d<10&&(d="0"+d),a=i+":"+d+":59"}void 0===t&&void 0===a||(_[r]=[t,a])}else if(e.find("select").length){r=e.find("select").attr("name");void 0!==(s=um_get_data_for_directory(u,"filter_"+r))&&(s=um_unsanitize_value(s),_[r]=s.split("||"))}else if(e.hasClass("um-text-filter-type")&&e.find('input[type="text"]').length){var s;r=e.find('input[type="text"]').attr("name");void 0!==(s=um_get_data_for_directory(u,"filter_"+r))&&(s=um_unsanitize_value(s),_[r]=s)}else _=wp.hooks.applyFilters("um_member_directory_custom_filter_handler",_,e,u)}),_=wp.hooks.applyFilters("um_member_directory_filter_request",_),wp.ajax.send("um_get_members",{data:_,success:function(e){um_member_directory_last_data[t]=e,um_build_template(u,e);var r=wp.template("um-members-pagination");u.find(".um-members-pagination-box").html(r(e)),u.data("total_pages",e.pagination.total_pages),e.pagination.total_pages?(u.find(".um-member-directory-sorting-options").prop("disabled",!1),u.find(".um-member-directory-view-type").removeClass("um-disabled")):(u.find(".um-member-directory-sorting-options").prop("disabled",!0),u.find(".um-member-directory-view-type").addClass("um-disabled")),wp.hooks.doAction("um_member_directory_loaded",u,e),um_init_new_dropdown(),um_members_hide_preloader(u)},error:function(e){console.log(e),um_members_hide_preloader(u)}})}else setTimeout(um_ajax_get_members,600,u,e)}function um_build_template(e,r){var t=e.data("view_type"),a=wp.template("um-member-"+t+"-"+um_members_get_hash(e));e.find(".um-members-grid, .um-members-list").remove(),e.find(".um-members-wrapper").prepend(a(r.users));var i=wp.template("um-members-header");e.find(".um-members-intro").remove();var m=wp.hooks.applyFilters("um_member_directory_generate_header",!1,e);(void 0!==r.is_search&&r.is_search||m)&&e.find(".um-members-wrapper").prepend(i(r)),e.addClass("um-loaded"),e.find(".um-members.um-members-grid").length&&UM_Member_Grid(e.find(".um-members.um-members-grid")),jQuery(document).trigger("um_build_template",[e,r]),jQuery(window).trigger("resize"),init_tipsy()}function UM_Member_Grid(r){r.find(".um-member").length&&r.imagesLoaded(function(){var e=wp.hooks.applyFilters("um_member_directory_grid_masonry_attrs",{itemSelector:".um-member",columnWidth:".um-member",gutter:".um-gutter-sizer"},r);r.masonry(e).on("layoutComplete",function(e,r){jQuery(document).trigger("um_grid_initialized",[e,r])})})}function um_get_filters_data(u){var _=[];return u.find(".um-search-filter").each(function(){var t,a,d,i=jQuery(this);if(i.find("input.um-datepicker-filter").length)d="datepicker",i.find("input.um-datepicker-filter").each(function(){if("to"!==jQuery(this).data("range")){var e=jQuery(this).data("filter_name"),r=um_get_data_for_directory(u,"filter_"+e+"_from"),t=um_get_data_for_directory(u,"filter_"+e+"_to");if(void 0!==r||void 0!==t){var a,i=jQuery(this).val(),m=u.find('input.um-datepicker-filter[data-range="to"][data-filter_name="'+e+'"]').val();i===m?a=m:""!==i&&""!==m?a=i+" - "+m:""===i?a="before "+m:""===m&&(a="since "+i),_.push({name:e,label:jQuery(this).data("filter-label"),value_label:a,value:[r,t],type:d})}}});else if(i.find("input.um-timepicker-filter").length)d="timepicker",i.find("input.um-timepicker-filter").each(function(){if("to"!==jQuery(this).data("range")){var e=jQuery(this).data("filter_name"),r=um_get_data_for_directory(u,"filter_"+e+"_from"),t=um_get_data_for_directory(u,"filter_"+e+"_to");if(void 0!==r||void 0!==t){var a,i=jQuery(this).val(),m=u.find('input.um-timepicker-filter[data-range="to"][data-filter_name="'+e+'"]').val();i===m?a=m:""!==i&&""!==m?a=i+" - "+m:""===i?a="before "+m:""===m&&(a="since "+i),_.push({name:e,label:jQuery(this).data("filter-label"),value_label:a,value:[r,t],type:d})}}});else if(i.find("select").length){d="select",t=i.find("select").attr("name"),a=i.find("select").data("placeholder"),m=void 0===(m=um_get_data_for_directory(u,"filter_"+t))?[]:(m=um_unsanitize_value(m)).split("||"),jQuery.each(m,function(e){var r=i.find('select option[value="'+m[e]+'"]').data("value_label");_.push({name:t,label:a,value_label:r,value:m[e],type:d})})}else if(i.hasClass("um-text-filter-type")&&i.find('input[type="text"]').length){var m;d="text",t=i.find('input[type="text"]').attr("name"),a=i.find('input[type="text"]').attr("placeholder"),void 0===(m=um_get_data_for_directory(u,"filter_"+t))&&(m=""),""!=m&&_.push({name:t,label:a,value_label:m,value:m,type:d})}else if(i.find("div.ui-slider").length){d="slider",t=i.find("div.ui-slider").data("field_name");var e,r=um_get_data_for_directory(u,"filter_"+t+"_from"),s=um_get_data_for_directory(u,"filter_"+t+"_to");if(void 0===r&&void 0===s)return;e=r===s?i.find("div.um-slider-range").data("placeholder-s").replace("{value}",r).replace("{field_label}",i.find("div.um-slider-range").data("label")):i.find("div.um-slider-range").data("placeholder-p").replace("{min_range}",r).replace("{max_range}",s).replace("{field_label}",i.find("div.um-slider-range").data("label")),a=i.find("div.um-slider-range").data("label"),_.push({name:t,label:a,value_label:e,value:[r,s],type:d})}else _=wp.hooks.applyFilters("um_member_directory_get_filter_data",_,u,i)}),_}function um_change_tag(e){var r=um_get_filters_data(e);e.find(".um-members-filter-tag").remove();var t=e.find(".um-filtered-line");if(t.length){var a=wp.template("um-members-filtered-line");t.prepend(a({filters:r})),0===e.find(".um-members-filter-remove").length?(e.find(".um-clear-filters").hide(),e.find(".um-clear-filters").parents(".um-member-directory-header-row").addClass("um-header-row-invisible")):(e.find(".um-clear-filters").show(),e.find(".um-clear-filters").parents(".um-member-directory-header-row").removeClass("um-header-row-invisible"))}}function um_run_search(e){if(!um_is_directory_busy(e)){um_members_show_preloader(e);var r=um_get_data_for_directory(e,"search"),t=um_sanitize_value(e.find(".um-search-line").val());if(t===r||""===t&&void 0===r)um_members_hide_preloader(e);else{e.data("general_search",t),um_set_url_from_data(e,"search",t),e.data("page",1),um_set_url_from_data(e,"page","");var a=!1;if(!(a=wp.hooks.applyFilters("um_member_directory_ignore_after_search",a,e)))if(1===e.data("must-search")&&(t=um_get_search(e),0===e.find(".um-members-filter-remove").length&&!t))return e.data("searched",0),e.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),e.find(".um-member-directory-sorting-options").prop("disabled",!0),e.find(".um-member-directory-view-type").addClass("um-disabled"),wp.hooks.doAction("um_member_directory_clear_not_searched",e),void um_members_hide_preloader(e);e.data("searched",1),e.find(".um-member-directory-sorting-options").prop("disabled",!1),e.find(".um-member-directory-view-type").removeClass("um-disabled"),um_ajax_get_members(e)}}}jQuery(document.body).ready(function(){jQuery(".um-directory .um-search-filter select").each(function(){1===jQuery(this).find("option:not(:disabled)").length&&jQuery(this).prop("disabled",!0);var e=jQuery(this);e.select2("destroy").select2({dropdownParent:e.parent()})}),jQuery(document.body).on("mouseover",".um-directory .um-member-directory-view-type",function(){if(!jQuery(this).hasClass("um-disabled")){var e=jQuery(this).find(".um-member-directory-view-type-a:visible");e.hide(),e.next().length?e.next().show().tipsy("show"):jQuery(this).find(".um-member-directory-view-type-a:first").show().tipsy("show")}}).on("mouseout",".um-directory .um-member-directory-view-type",function(){jQuery(this).hasClass("um-disabled")||(jQuery(this).find(".um-member-directory-view-type-a").hide().tipsy("hide"),jQuery(this).find('.um-member-directory-view-type-a[data-type="'+jQuery(this).parents(".um-directory").data("view_type")+'"]').show())}),jQuery(document.body).on("click",".um-directory .um-member-directory-view-type-a",function(){var e=jQuery(this).parents(".um-directory");if(um_is_directory_busy(e))return!1;var r=jQuery(this),t=r.parents(".um-member-directory-view-type");if(!t.hasClass("um-disabled")){um_members_show_preloader(e);var a=t.find(".um-member-directory-view-type-a:visible");a.hide(),a.next().length?a.next().show().tipsy("show"):t.find(".um-member-directory-view-type-a:first").show().tipsy("show");var i=um_member_directory_last_data[um_members_get_hash(e)];if(null!==i){var m=r.data("type");um_set_url_from_data(e,"view_type",m),e.data("view_type",m),um_build_template(e,i),um_init_new_dropdown()}um_members_hide_preloader(e)}}),jQuery(document.body).on("click",".um-directory .um-do-search",function(){um_run_search(jQuery(this).parents(".um-directory"))}),jQuery(document.body).on("keypress",".um-directory .um-search-line",function(e){13===e.which&&um_run_search(jQuery(this).parents(".um-directory"))}),jQuery(document.body).on("click",'.um-new-dropdown[data-element=".um-member-directory-sorting-a"] li a',function(){if(1!==jQuery(this).data("selected")){var e=jQuery(this).data("directory-hash"),r=jQuery('.um-directory[data-hash="'+e+'"]');if(!um_is_directory_busy(r)){um_members_show_preloader(r);var t=jQuery(this).html(),a=jQuery(this).data("value");r.data("sorting",a),um_set_url_from_data(r,"sort",a),um_ajax_get_members(r),r.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"]').find("a").data("selected",0).prop("data-selected",0).attr("data-selected",0),r.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"] a[data-value="'+a+'"]').data("selected",1).prop("data-selected",1).attr("data-selected",1),r.find(".um-member-directory-sorting-a").find("> a").html(t)}}}),jQuery(document.body).on("click",".um-directory .pagi:not(.current)",function(){if(!jQuery(this).hasClass("disabled")){var e,r=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(r))um_members_show_preloader(r),1===(e="first"===jQuery(this).data("page")?1:"prev"===jQuery(this).data("page")?1*r.data("page")-1:"next"===jQuery(this).data("page")?1*r.data("page")+1:"last"===jQuery(this).data("page")?parseInt(r.data("total_pages")):parseInt(jQuery(this).data("page")))?(r.find('.pagi[data-page="first"], .pagi[data-page="prev"]').addClass("disabled"),r.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass("disabled")):(e===parseInt(r.data("total_pages"))?r.find('.pagi[data-page="prev"], .pagi[data-page="last"]').addClass("disabled"):r.find('.pagi[data-page="prev"], .pagi[data-page="last"]').removeClass("disabled"),r.find('.pagi[data-page="first"], .pagi[data-page="prev"]').removeClass("disabled")),r.find(".pagi").removeClass("current"),r.find('.pagi[data-page="'+e+'"]').addClass("current"),r.data("page",e),um_set_url_from_data(r,"page",1===e?"":e),um_ajax_get_members(r)}}),jQuery(document.body).on("change",".um-directory .um-members-pagi-dropdown",function(){var e=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(e)){um_members_show_preloader(e);var r=jQuery(this).val();e.find(".pagi").removeClass("current"),e.find('.pagi[data-page="'+r+'"]').addClass("current"),e.data("page",r),um_set_url_from_data(e,"page",1===r?"":r),um_ajax_get_members(e)}}),jQuery(document.body).on("click",".um-directory .um-members.um-members-list .um-member-more a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member");return r.find(".um-member-more").hide(),r.find(".um-member-meta-main").slideDown(),r.find(".um-member-less").fadeIn(),!1}),jQuery(document.body).on("click",".um-directory .um-members.um-members-list .um-member-less a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member");return r.find(".um-member-less").hide(),r.find(".um-member-meta-main").slideUp(),r.find(".um-member-more").fadeIn(),!1}),jQuery(document.body).on("click",".um-directory .um-members.um-members-grid .um-member-more a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member"),t=jQuery(this).parents(".um-members");return r.find(".um-member-more").hide(),r.find(".um-member-meta").slideDown(function(){UM_Member_Grid(t)}),r.find(".um-member-less").fadeIn(),setTimeout(function(){UM_Member_Grid(t)},100),!1}),jQuery(document.body).on("click",".um-directory .um-members.um-members-grid .um-member-less a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member"),t=jQuery(this).parents(".um-members");return r.find(".um-member-less").hide(),r.find(".um-member-meta").slideUp(function(){r.find(".um-member-more").fadeIn(),UM_Member_Grid(t)}),!1}),jQuery(".um-member-directory-filters-a").on("click",function(){var e=jQuery(this),r=e.parents(".um-directory").find(".um-search");r.is(":visible")?r.slideUp(250,function(){e.toggleClass("um-member-directory-filters-visible"),r.parents(".um-member-directory-header-row").toggleClass("um-header-row-invisible")}):r.slideDown({duration:250,start:function(){jQuery(this).css({display:"grid"}),e.toggleClass("um-member-directory-filters-visible"),r.parents(".um-member-directory-header-row").toggleClass("um-header-row-invisible")}})}),jQuery(document.body).on("change",".um-directory .um-search-filter select",function(){var e=jQuery(this).val(),r=um_sanitize_value(e);if(""!==r){var t=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(t)){um_members_show_preloader(t);var a=jQuery(this).prop("name"),i=um_get_data_for_directory(t,"filter_"+a);i=void 0===i?[]:i.split("||"),-1===jQuery.inArray(r,i)&&(i.push(r),um_set_url_from_data(t,"filter_"+a,i=i.join("||")),t.data("page",1),um_set_url_from_data(t,"page","")),jQuery(this).find('option[value="'+e+'"]').prop("disabled",!0).hide(),1===jQuery(this).find("option:not(:disabled)").length&&jQuery(this).prop("disabled",!0);var m=jQuery(this);m.select2("destroy").select2({dropdownParent:m.parent()}),m.val("").trigger("change"),um_ajax_get_members(t),um_change_tag(t),t.data("searched",1),t.find(".um-member-directory-sorting-options").prop("disabled",!1),t.find(".um-member-directory-view-type").removeClass("um-disabled")}}}),jQuery(document.body).on("blur",'.um-directory .um-search-filter.um-text-filter-type input[type="text"]',function(){var e=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(e)){var r=um_sanitize_value(jQuery(this).val()),t=jQuery(this).prop("name"),a=um_get_data_for_directory(e,"filter_"+t);void 0===a&&(a=""),r!==a&&(um_members_show_preloader(e),um_set_url_from_data(e,"filter_"+t,r),e.data("page",1),um_set_url_from_data(e,"page",""),um_ajax_get_members(e),um_change_tag(e),e.data("searched",1),e.find(".um-member-directory-sorting-options").prop("disabled",!1),e.find(".um-member-directory-view-type").removeClass("um-disabled"))}}),jQuery(document.body).on("keypress",'.um-directory .um-search-filter.um-text-filter-type input[type="text"]',function(e){if(13===e.which){var r=jQuery(this).parents(".um-directory");if(um_is_directory_busy(r))return;var t=um_sanitize_value(jQuery(this).val()),a=jQuery(this).prop("name"),i=um_get_data_for_directory(r,"filter_"+a);if(void 0===i&&(i=""),t===i)return;um_members_show_preloader(r),um_set_url_from_data(r,"filter_"+a,t),r.data("page",1),um_set_url_from_data(r,"page",""),um_ajax_get_members(r),um_change_tag(r),r.data("searched",1),r.find(".um-member-directory-sorting-options").prop("disabled",!1),r.find(".um-member-directory-view-type").removeClass("um-disabled")}}),jQuery(document.body).on("click",".um-directory .um-members-filter-remove",function(){var e=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(e)&&e){um_members_show_preloader(e);var r=jQuery(this).data("value"),t=jQuery(this).data("name"),a=jQuery(this).data("type");if("text"===a)um_set_url_from_data(e,"filter_"+t,""),jQuery('.um-search-filter input[name="'+t+'"]').val("");else if("select"===a){var i=um_get_data_for_directory(e,"filter_"+t);i=void 0===i?[]:(i=um_unsanitize_value(i)).split("||"),-1!==jQuery.inArray(r.toString(),i)&&(i=jQuery.grep(i,function(e){return e!==r.toString()})),i.length||(i=""),um_set_url_from_data(e,"filter_"+t,i);var m=jQuery('.um-search-filter select[name="'+t+'"]');m.find('option[value="'+r+'"]').prop("disabled",!1).show(),1<m.find("option:not(:disabled)").length&&m.prop("disabled",!1),m.select2("destroy").select2({dropdownParent:m.parent()}),0<e.find('.um-search-filter select[data-um-parent="'+t+'"]').length&&m.trigger("change")}else if("slider"===a){um_set_url_from_data(e,"filter_"+t+"_from",""),um_set_url_from_data(e,"filter_"+t+"_to","");var d=jQuery(".um-search-filter #"+t+"_min").siblings(".um-slider"),s=d.slider("option");d.slider("values",[s.min,s.max]),jQuery(".um-search-filter #"+t+"_min").val(""),jQuery(".um-search-filter #"+t+"_max").val(""),um_set_range_label(d)}else"datepicker"===a?(um_set_url_from_data(e,"filter_"+t+"_from",""),um_set_url_from_data(e,"filter_"+t+"_to",""),jQuery(".um-search-filter #"+t+"_from").val(""),jQuery(".um-search-filter #"+t+"_to").val("")):"timepicker"===a?(um_set_url_from_data(e,"filter_"+t+"_from",""),um_set_url_from_data(e,"filter_"+t+"_to",""),jQuery(".um-search-filter #"+t+"_from").val(""),jQuery(".um-search-filter #"+t+"_to").val("")):wp.hooks.doAction("um_member_directory_filter_remove",a,e,t,r);e.data("page",1),um_set_url_from_data(e,"page",""),jQuery(this).tipsy("hide"),jQuery(this).parents(".um-members-filter-tag").remove(),0===e.find(".um-members-filter-remove").length?e.find(".um-clear-filters").hide():e.find(".um-clear-filters").show();var u=!1;if(!(u=wp.hooks.applyFilters("um_member_directory_ignore_after_search",u,e)))if(1===e.data("must-search")){var _=um_get_search(e);if(0===e.find(".um-members-filter-remove").length&&!_)return e.data("searched",0),e.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),e.find(".um-member-directory-sorting-options").prop("disabled",!0),e.find(".um-member-directory-view-type").addClass("um-disabled"),wp.hooks.doAction("um_member_directory_clear_not_searched",e),void um_members_hide_preloader(e)}e.find(".um-member-directory-sorting-options").prop("disabled",!1),e.find(".um-member-directory-view-type").removeClass("um-disabled"),um_ajax_get_members(e)}}),jQuery(document.body).on("click",".um-directory .um-clear-filters-a",function(){var s=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(s)){um_members_show_preloader(s),s.find(".um-members-filter-remove").each(function(){var r=jQuery(this).data("value"),e=jQuery(this).data("name"),t=jQuery(this).data("type");if("text"===t)um_set_url_from_data(s,"filter_"+e,""),jQuery('.um-search-filter input[name="'+e+'"]').val("");else if("select"===t){var a=um_get_data_for_directory(s,"filter_"+e);a=void 0===a?[]:(a=um_unsanitize_value(a)).split("||"),-1!==jQuery.inArray(r.toString(),a)&&(a=jQuery.grep(a,function(e){return e!==r.toString()})),a.length||(a=""),um_set_url_from_data(s,"filter_"+e,a);var i=jQuery('.um-search-filter select[name="'+e+'"]');i.find('option[value="'+r+'"]').prop("disabled",!1).show(),1<i.find("option:not(:disabled)").length&&i.prop("disabled",!1),i.select2("destroy").select2({dropdownParent:i.parent()}),0<s.find('.um-search-filter select[data-um-parent="'+e+'"]').length&&i.trigger("change")}else if("slider"===t){um_set_url_from_data(s,"filter_"+e+"_from",""),um_set_url_from_data(s,"filter_"+e+"_to","");var m=jQuery(".um-search-filter #"+e+"_min").siblings(".um-slider"),d=m.slider("option");m.slider("values",[d.min,d.max]),jQuery(".um-search-filter #"+e+"_min").val(""),jQuery(".um-search-filter #"+e+"_max").val(""),um_set_range_label(m)}else"datepicker"===t?(um_set_url_from_data(s,"filter_"+e+"_from",""),um_set_url_from_data(s,"filter_"+e+"_to",""),jQuery(".um-search-filter #"+e+"_from").val(""),jQuery(".um-search-filter #"+e+"_to").val("")):"timepicker"===t?(um_set_url_from_data(s,"filter_"+e+"_from",""),um_set_url_from_data(s,"filter_"+e+"_to",""),jQuery(".um-search-filter #"+e+"_from").val(""),jQuery(".um-search-filter #"+e+"_to").val("")):wp.hooks.doAction("um_member_directory_clear_filters",t,s,e,r)}),s.data("page",1),um_set_url_from_data(s,"page",""),s.find(".um-members-filter-tag").remove(),0===s.find(".um-members-filter-remove").length?(s.find(".um-clear-filters").hide(),s.find(".um-clear-filters").parents(".um-member-directory-header-row").addClass("um-header-row-invisible")):(s.find(".um-clear-filters").show(),s.find(".um-clear-filters").parents(".um-member-directory-header-row").removeClass("um-header-row-invisible"));var e=!1;if(!(e=wp.hooks.applyFilters("um_member_directory_ignore_after_search",e,s)))if(1===s.data("must-search"))if(!um_get_search(s))return s.data("searched",0),s.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),s.find(".um-member-directory-sorting-options").prop("disabled",!0),s.find(".um-member-directory-view-type").addClass("um-disabled"),wp.hooks.doAction("um_member_directory_clear_not_searched",s),void um_members_hide_preloader(s);s.find(".um-member-directory-sorting-options").prop("disabled",!1),s.find(".um-member-directory-view-type").removeClass("um-disabled"),um_ajax_get_members(s)}}),wp.hooks.doAction("um_member_directory_on_first_pages_loading"),jQuery(".um-directory").each(function(){var e=jQuery(this),r=um_members_get_hash(e);um_member_directories.push(r),e.find(".um-search").length&&(e.find(".um-search").is(":visible")||e.find(".um-search").css({display:"grid"}).slideUp(1)),e.find(".um-slider").each(function(){var e=jQuery(this),t=e.parents(".um-directory"),a=e.data("field_name"),r=um_get_data_for_directory(t,"filter_"+a+"_from"),i=um_get_data_for_directory(t,"filter_"+a+"_to");void 0===r&&(r=parseInt(e.data("min"))),void 0===i&&(i=parseInt(e.data("max")));var m=[r,i];e.slider({range:!0,min:parseInt(e.data("min")),max:parseInt(e.data("max")),values:m,create:function(e,r){},step:1,slide:function(e,r){um_set_range_label(jQuery(this),r)},stop:function(e,r){um_is_directory_busy(t)||(um_members_show_preloader(t),um_set_url_from_data(t,"filter_"+a+"_from",r.values[0]),um_set_url_from_data(t,"filter_"+a+"_to",r.values[1]),t.data("page",1),um_set_url_from_data(t,"page",""),um_ajax_get_members(t),um_change_tag(t),t.data("searched",1),t.find(".um-member-directory-sorting-options").prop("disabled",!1),t.find(".um-member-directory-view-type").removeClass("um-disabled"))}}),um_set_range_label(e)}),e.find(".um-datepicker-filter").each(function(){var s=jQuery(this),u=new Date(1e3*s.data("date_min")),_=new Date(1e3*s.data("date_max")),e=s.pickadate({selectYears:!0,min:u,max:_,formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){s.blur()},onClose:function(){s.blur()},onSet:function(e){if(e.select){var r=s.parents(".um-directory");if(!um_is_directory_busy(r)){um_members_show_preloader(r);var t=s.data("filter_name"),a=s.data("range"),i=um_get_data_for_directory(r,"filter_"+t+"_from"),m=um_get_data_for_directory(r,"filter_"+t+"_to");void 0===i&&(i=u/1e3),void 0===m&&(m=_/1e3);var d=e.select/1e3;s.val();"from"===a?i=d:"to"===a&&(m=d),um_set_url_from_data(r,"filter_"+t+"_from",i),um_set_url_from_data(r,"filter_"+t+"_to",m),r.data("page",1),um_set_url_from_data(r,"page",""),um_ajax_get_members(r),um_change_tag(r),r.data("searched",1),r.find(".um-member-directory-sorting-options").prop("disabled",!1),r.find(".um-member-directory-view-type").removeClass("um-disabled")}}}}).pickadate("picker"),r=s.data("filter_name"),t=s.data("range"),a=um_get_data_for_directory(s.parents(".um-directory"),"filter_"+r+"_"+t);void 0!==a&&e.set("select",1e3*a)}),e.find(".um-timepicker-filter").each(function(){var u=jQuery(this),_=u.attr("id"),o=u.data("filter_name"),n=u.attr("data-min"),l=u.attr("data-max"),e=n.split(":"),r=l.split(":"),t=u.pickatime({format:u.data("format"),interval:parseInt(u.data("intervals")),min:[e[0],e[1]],max:[r[0],r[1]],formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){u.blur()},onClose:function(){u.blur()},onSet:function(e){if(e.select){var r=u.parents(".um-directory");if(!um_is_directory_busy(r)){um_members_show_preloader(r);var t=u.data("filter_name"),a=u.data("range"),i=um_get_data_for_directory(r,"filter_"+t+"_from"),m=um_get_data_for_directory(r,"filter_"+t+"_to");if(void 0===i&&(i=n),void 0===m&&(m=l),void 0!==e.select){var d=um_time_convert(e.select,a);"from"===a?i=d:"to"===a&&(m=d)}else"from"===a?i=n:"to"===a&&(m=l);var s=jQuery("#"+_).val();"from"===u.data("range")?jQuery("#"+o+"_to").pickatime("picker").set("min",s):jQuery("#"+o+"_from").pickatime("picker").set("max",s),um_set_url_from_data(r,"filter_"+t+"_from",i),um_set_url_from_data(r,"filter_"+t+"_to",m),r.data("page",1),um_set_url_from_data(r,"page",""),um_ajax_get_members(r),um_change_tag(r),r.data("searched",1),r.find(".um-member-directory-sorting-options").prop("disabled",!1),r.find(".um-member-directory-view-type").removeClass("um-disabled")}}}}).pickatime("picker"),a=u.data("filter_name"),i=u.data("range"),m=um_get_data_for_directory(u.parents(".um-directory"),"filter_"+a+"_"+i);if(void 0!==m){var d=m.split(":");t.set("select",60*d[0]+1*d[1])}}),wp.hooks.doAction("um_member_directory_on_init",e,r);var t=!1;if(!(t=wp.hooks.applyFilters("um_member_directory_ignore_after_search",t,e))&&1===e.data("must-search")){var a=um_get_search(e);if(!um_get_filters_data(e).length&&!a)return}wp.hooks.applyFilters("um_member_directory_prevent_default_first_loading",!1,e,r)||(um_members_show_preloader(e),um_ajax_get_members(e,{first_load:!0}),um_change_tag(e))}),window.addEventListener("popstate",function(e){jQuery(".um-directory").each(function(){var d=jQuery(this),e=um_members_get_hash(d);(um_member_directories.push(e),um_members_show_preloader(d),d.find(".um-members-grid, .um-members-list, .um-members-intro").remove(),d.find(".um-member-directory-search-line").length)&&(void 0===(s=um_get_data_for_directory(d,"search"))&&(s=""),d.data("general_search",s),d.find(".um-search-line").val(s));var r=um_get_data_for_directory(d,"page");if(void 0===r?r=1:r>d.data("total_pages")&&(r=d.data("total_pages")),d.data("page",r).attr("data-page",r),d.find(".um-member-directory-sorting").length){var t=um_get_data_for_directory(d,"sort");void 0===t&&(t=d.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"]').find('a[data-default="1"]').data("value")),d.data("sorting",t);var a=d.find('.um-new-dropdown[data-element=".um-member-directory-sorting-a"]');a.find("a").data("selected",0).prop("data-selected",0).attr("data-selected",0),a.find('a[data-value="'+t+'"]').data("selected",1).prop("data-selected",1).attr("data-selected",1),d.find(".um-member-directory-sorting-a").find("> a").html(a.find('a[data-value="'+t+'"]').html())}if(d.find(".um-member-directory-view-type").length){var i=um_get_data_for_directory(d,"view_type");void 0===i&&(i=d.find('.um-member-directory-view-type-a[data-default="1"]').data("type")),d.data("view_type",i),d.find(".um-member-directory-view-type .um-member-directory-view-type-a").hide(),d.find('.um-member-directory-view-type .um-member-directory-view-type-a[data-type="'+i+'"]').show()}d.find(".um-datepicker-filter").each(function(){var e=jQuery(this),r=e.pickadate("picker"),t=e.data("filter_name"),a=e.data("range"),i=um_get_data_for_directory(d,"filter_"+t+"_"+a);void 0!==i?r.set("select",1e3*i):r.clear()}),d.find(".um-slider").each(function(){var e=jQuery(this),r=e.data("field_name"),t=um_get_data_for_directory(d,"filter_"+r+"_from"),a=um_get_data_for_directory(d,"filter_"+r+"_to");void 0===t&&(t=e.data("min")),t=parseInt(t),void 0===a&&(a=e.data("max")),a=parseInt(a),e.slider("values",[t,a]),um_set_range_label(e)}),d.find(".um-timepicker-filter").each(function(){var e=jQuery(this),r=e.pickatime("picker"),t=e.data("filter_name"),a=e.data("range"),i=um_get_data_for_directory(d,"filter_"+t+"_"+a);if(void 0!==i){var m=i.split(":");r.set("select",60*m[0])}else r.clear()});var m=!1;if(!(m=wp.hooks.applyFilters("um_member_directory_ignore_after_search",m,d))&&1===d.data("must-search")){var s=um_get_search(d);if(!um_get_filters_data(d).length&&!s)return d.data("searched",0),void um_members_hide_preloader(d);d.data("searched",1)}wp.hooks.applyFilters("um_member_directory_prevent_default_first_loading",!1,d,e)||(um_ajax_get_members(d),um_change_tag(d))})})});
|
assets/js/um-scripts.js
CHANGED
@@ -1,706 +1,716 @@
|
|
1 |
-
function um_sanitize_value( value, el ) {
|
2 |
-
var element = document.createElement( 'div' );
|
3 |
-
element.innerText = value;
|
4 |
-
var sanitized_value = element.innerHTML;
|
5 |
-
if ( el ) {
|
6 |
-
jQuery( el ).val( sanitized_value );
|
7 |
-
}
|
8 |
-
|
9 |
-
return sanitized_value;
|
10 |
-
}
|
11 |
-
|
12 |
-
function um_unsanitize_value( input ) {
|
13 |
-
var e = document.createElement( 'textarea' );
|
14 |
-
e.innerHTML = input;
|
15 |
-
// handle case of empty input
|
16 |
-
return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
|
17 |
-
}
|
18 |
-
|
19 |
-
|
20 |
-
function um_init_datetimepicker() {
|
21 |
-
jQuery('.um-datepicker:not(.picker__input)').each(function(){
|
22 |
-
var elem = jQuery(this);
|
23 |
-
|
24 |
-
var disable = false;
|
25 |
-
if ( typeof elem.attr('data-disabled_weekdays') != 'undefined' && elem.attr('data-disabled_weekdays') !== '' ) {
|
26 |
-
disable = JSON.parse( elem.attr('data-disabled_weekdays') );
|
27 |
-
}
|
28 |
-
|
29 |
-
var years_n = null;
|
30 |
-
if ( typeof elem.attr('data-years') != 'undefined' ) {
|
31 |
-
years_n = elem.attr('data-years');
|
32 |
-
}
|
33 |
-
|
34 |
-
var minRange = elem.attr('data-date_min');
|
35 |
-
var maxRange = elem.attr('data-date_max');
|
36 |
-
|
37 |
-
var minSplit = [], maxSplit = [];
|
38 |
-
if ( typeof minRange != 'undefined' ) {
|
39 |
-
minSplit = minRange.split(",");
|
40 |
-
}
|
41 |
-
if ( typeof maxRange != 'undefined' ) {
|
42 |
-
maxSplit = maxRange.split(",");
|
43 |
-
}
|
44 |
-
|
45 |
-
var min = minSplit.length ? new Date(minSplit) : null;
|
46 |
-
var max = minSplit.length ? new Date(maxSplit) : null;
|
47 |
-
|
48 |
-
// fix min date for safari
|
49 |
-
if ( min && min.toString() == 'Invalid Date' && minSplit.length == 3 ) {
|
50 |
-
var minDateString = minSplit[1] + '/' + minSplit[2] + '/' + minSplit[0];
|
51 |
-
min = new Date(Date.parse(minDateString));
|
52 |
-
}
|
53 |
-
|
54 |
-
// fix max date for safari
|
55 |
-
if ( max && max.toString() == 'Invalid Date' && maxSplit.length == 3 ) {
|
56 |
-
var maxDateString = maxSplit[1] + '/' + maxSplit[2] + '/' + maxSplit[0];
|
57 |
-
max = new Date(Date.parse(maxDateString));
|
58 |
-
}
|
59 |
-
|
60 |
-
var data = {
|
61 |
-
disable: disable,
|
62 |
-
format: elem.attr( 'data-format' ),
|
63 |
-
formatSubmit: 'yyyy/mm/dd',
|
64 |
-
hiddenName: true,
|
65 |
-
onOpen: function() { elem.blur(); },
|
66 |
-
onClose: function() { elem.blur(); }
|
67 |
-
};
|
68 |
-
|
69 |
-
if ( years_n !== null ) {
|
70 |
-
data.selectYears = years_n;
|
71 |
-
}
|
72 |
-
|
73 |
-
if ( min !== null ) {
|
74 |
-
data.min = min;
|
75 |
-
}
|
76 |
-
|
77 |
-
if ( max !== null ) {
|
78 |
-
data.max = max;
|
79 |
-
}
|
80 |
-
|
81 |
-
elem.pickadate( data );
|
82 |
-
});
|
83 |
-
|
84 |
-
jQuery('.um-timepicker:not(.picker__input)').each(function(){
|
85 |
-
var elem = jQuery(this);
|
86 |
-
|
87 |
-
elem.pickatime({
|
88 |
-
format: elem.attr('data-format'),
|
89 |
-
interval: parseInt( elem.attr('data-intervals') ),
|
90 |
-
formatSubmit: 'HH:i',
|
91 |
-
hiddenName: true,
|
92 |
-
onOpen: function() { elem.blur(); },
|
93 |
-
onClose: function() { elem.blur(); }
|
94 |
-
});
|
95 |
-
});
|
96 |
-
}
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
function init_tipsy() {
|
101 |
-
if ( typeof( jQuery.fn.tipsy ) === 'function' ) {
|
102 |
-
jQuery('.um-tip-n').tipsy({gravity: 'n', opacity: 1, live: 'a.live', offset: 3 });
|
103 |
-
jQuery('.um-tip-w').tipsy({gravity: 'w', opacity: 1, live: 'a.live', offset: 3 });
|
104 |
-
jQuery('.um-tip-e').tipsy({gravity: 'e', opacity: 1, live: 'a.live', offset: 3 });
|
105 |
-
jQuery('.um-tip-s').tipsy({gravity: 's', opacity: 1, live: 'a.live', offset: 3 });
|
106 |
-
}
|
107 |
-
}
|
108 |
-
|
109 |
-
jQuery(document).ready(function() {
|
110 |
-
|
111 |
-
jQuery( document.body ).on('click', '.um-dropdown a.real_url', function() {
|
112 |
-
window.location = jQuery(this).attr('href');
|
113 |
-
});
|
114 |
-
|
115 |
-
jQuery( document.body ).on( 'click', '.um-trigger-menu-on-click', function() {
|
116 |
-
var menu = jQuery(this).find('.um-dropdown');
|
117 |
-
UM.dropdown.show( menu );
|
118 |
-
return false;
|
119 |
-
});
|
120 |
-
|
121 |
-
jQuery( document.body ).on('click', '.um-dropdown-hide', function() {
|
122 |
-
UM.dropdown.hideAll();
|
123 |
-
return false;
|
124 |
-
});
|
125 |
-
|
126 |
-
jQuery( document.body ).on('click', 'a.um-manual-trigger', function() {
|
127 |
-
var child = jQuery(this).attr('data-child');
|
128 |
-
var parent = jQuery(this).attr('data-parent');
|
129 |
-
jQuery(this).parents( parent ).find( child ).trigger('click');
|
130 |
-
UM.dropdown.hideAll();
|
131 |
-
return false;
|
132 |
-
});
|
133 |
-
|
134 |
-
jQuery('.um-s1,.um-s2').css({'display':'block'});
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Unselect empty option if something is selected
|
138 |
-
*
|
139 |
-
* @since 2.1.16
|
140 |
-
* @param {object} e
|
141 |
-
* @returns {undefined}
|
142 |
-
*/
|
143 |
-
function unselectEmptyOption( e ) {
|
144 |
-
var $element = jQuery( e.currentTarget );
|
145 |
-
var $selected = $element.find(':selected');
|
146 |
-
|
147 |
-
if ( $selected.length > 1 ) {
|
148 |
-
$selected.each( function ( i, option ) {
|
149 |
-
if ( option.value === '' ) {
|
150 |
-
option.selected = false;
|
151 |
-
$element.trigger( 'change' );
|
152 |
-
}
|
153 |
-
});
|
154 |
-
}
|
155 |
-
}
|
156 |
-
|
157 |
-
if ( typeof( jQuery.fn.select2 ) === 'function' ) {
|
158 |
-
jQuery(".um-s1").each( function( e ) {
|
159 |
-
var obj = jQuery(this);
|
160 |
-
|
161 |
-
obj.select2({
|
162 |
-
allowClear: true,
|
163 |
-
dropdownParent: obj.parent()
|
164 |
-
}).on( 'change', unselectEmptyOption );
|
165 |
-
} );
|
166 |
-
|
167 |
-
jQuery(".um-s2").each( function( e ) {
|
168 |
-
var obj = jQuery(this);
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
} );
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
field.
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
jQuery(this).
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
});
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
url = action
|
495 |
-
}
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
url = action
|
524 |
-
}
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
}
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
}
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
jQuery.
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
}
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function um_sanitize_value( value, el ) {
|
2 |
+
var element = document.createElement( 'div' );
|
3 |
+
element.innerText = value;
|
4 |
+
var sanitized_value = element.innerHTML;
|
5 |
+
if ( el ) {
|
6 |
+
jQuery( el ).val( sanitized_value );
|
7 |
+
}
|
8 |
+
|
9 |
+
return sanitized_value;
|
10 |
+
}
|
11 |
+
|
12 |
+
function um_unsanitize_value( input ) {
|
13 |
+
var e = document.createElement( 'textarea' );
|
14 |
+
e.innerHTML = input;
|
15 |
+
// handle case of empty input
|
16 |
+
return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
|
17 |
+
}
|
18 |
+
|
19 |
+
|
20 |
+
function um_init_datetimepicker() {
|
21 |
+
jQuery('.um-datepicker:not(.picker__input)').each(function(){
|
22 |
+
var elem = jQuery(this);
|
23 |
+
|
24 |
+
var disable = false;
|
25 |
+
if ( typeof elem.attr('data-disabled_weekdays') != 'undefined' && elem.attr('data-disabled_weekdays') !== '' ) {
|
26 |
+
disable = JSON.parse( elem.attr('data-disabled_weekdays') );
|
27 |
+
}
|
28 |
+
|
29 |
+
var years_n = null;
|
30 |
+
if ( typeof elem.attr('data-years') != 'undefined' ) {
|
31 |
+
years_n = elem.attr('data-years');
|
32 |
+
}
|
33 |
+
|
34 |
+
var minRange = elem.attr('data-date_min');
|
35 |
+
var maxRange = elem.attr('data-date_max');
|
36 |
+
|
37 |
+
var minSplit = [], maxSplit = [];
|
38 |
+
if ( typeof minRange != 'undefined' ) {
|
39 |
+
minSplit = minRange.split(",");
|
40 |
+
}
|
41 |
+
if ( typeof maxRange != 'undefined' ) {
|
42 |
+
maxSplit = maxRange.split(",");
|
43 |
+
}
|
44 |
+
|
45 |
+
var min = minSplit.length ? new Date(minSplit) : null;
|
46 |
+
var max = minSplit.length ? new Date(maxSplit) : null;
|
47 |
+
|
48 |
+
// fix min date for safari
|
49 |
+
if ( min && min.toString() == 'Invalid Date' && minSplit.length == 3 ) {
|
50 |
+
var minDateString = minSplit[1] + '/' + minSplit[2] + '/' + minSplit[0];
|
51 |
+
min = new Date(Date.parse(minDateString));
|
52 |
+
}
|
53 |
+
|
54 |
+
// fix max date for safari
|
55 |
+
if ( max && max.toString() == 'Invalid Date' && maxSplit.length == 3 ) {
|
56 |
+
var maxDateString = maxSplit[1] + '/' + maxSplit[2] + '/' + maxSplit[0];
|
57 |
+
max = new Date(Date.parse(maxDateString));
|
58 |
+
}
|
59 |
+
|
60 |
+
var data = {
|
61 |
+
disable: disable,
|
62 |
+
format: elem.attr( 'data-format' ),
|
63 |
+
formatSubmit: 'yyyy/mm/dd',
|
64 |
+
hiddenName: true,
|
65 |
+
onOpen: function() { elem.blur(); },
|
66 |
+
onClose: function() { elem.blur(); }
|
67 |
+
};
|
68 |
+
|
69 |
+
if ( years_n !== null ) {
|
70 |
+
data.selectYears = years_n;
|
71 |
+
}
|
72 |
+
|
73 |
+
if ( min !== null ) {
|
74 |
+
data.min = min;
|
75 |
+
}
|
76 |
+
|
77 |
+
if ( max !== null ) {
|
78 |
+
data.max = max;
|
79 |
+
}
|
80 |
+
|
81 |
+
elem.pickadate( data );
|
82 |
+
});
|
83 |
+
|
84 |
+
jQuery('.um-timepicker:not(.picker__input)').each(function(){
|
85 |
+
var elem = jQuery(this);
|
86 |
+
|
87 |
+
elem.pickatime({
|
88 |
+
format: elem.attr('data-format'),
|
89 |
+
interval: parseInt( elem.attr('data-intervals') ),
|
90 |
+
formatSubmit: 'HH:i',
|
91 |
+
hiddenName: true,
|
92 |
+
onOpen: function() { elem.blur(); },
|
93 |
+
onClose: function() { elem.blur(); }
|
94 |
+
});
|
95 |
+
});
|
96 |
+
}
|
97 |
+
|
98 |
+
|
99 |
+
|
100 |
+
function init_tipsy() {
|
101 |
+
if ( typeof( jQuery.fn.tipsy ) === 'function' ) {
|
102 |
+
jQuery('.um-tip-n').tipsy({gravity: 'n', opacity: 1, live: 'a.live', offset: 3 });
|
103 |
+
jQuery('.um-tip-w').tipsy({gravity: 'w', opacity: 1, live: 'a.live', offset: 3 });
|
104 |
+
jQuery('.um-tip-e').tipsy({gravity: 'e', opacity: 1, live: 'a.live', offset: 3 });
|
105 |
+
jQuery('.um-tip-s').tipsy({gravity: 's', opacity: 1, live: 'a.live', offset: 3 });
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
jQuery(document).ready(function() {
|
110 |
+
|
111 |
+
jQuery( document.body ).on('click', '.um-dropdown a.real_url', function() {
|
112 |
+
window.location = jQuery(this).attr('href');
|
113 |
+
});
|
114 |
+
|
115 |
+
jQuery( document.body ).on( 'click', '.um-trigger-menu-on-click', function() {
|
116 |
+
var menu = jQuery(this).find('.um-dropdown');
|
117 |
+
UM.dropdown.show( menu );
|
118 |
+
return false;
|
119 |
+
});
|
120 |
+
|
121 |
+
jQuery( document.body ).on('click', '.um-dropdown-hide', function() {
|
122 |
+
UM.dropdown.hideAll();
|
123 |
+
return false;
|
124 |
+
});
|
125 |
+
|
126 |
+
jQuery( document.body ).on('click', 'a.um-manual-trigger', function() {
|
127 |
+
var child = jQuery(this).attr('data-child');
|
128 |
+
var parent = jQuery(this).attr('data-parent');
|
129 |
+
jQuery(this).parents( parent ).find( child ).trigger('click');
|
130 |
+
UM.dropdown.hideAll();
|
131 |
+
return false;
|
132 |
+
});
|
133 |
+
|
134 |
+
jQuery('.um-s1,.um-s2').css({'display':'block'});
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Unselect empty option if something is selected
|
138 |
+
*
|
139 |
+
* @since 2.1.16
|
140 |
+
* @param {object} e
|
141 |
+
* @returns {undefined}
|
142 |
+
*/
|
143 |
+
function unselectEmptyOption( e ) {
|
144 |
+
var $element = jQuery( e.currentTarget );
|
145 |
+
var $selected = $element.find(':selected');
|
146 |
+
|
147 |
+
if ( $selected.length > 1 ) {
|
148 |
+
$selected.each( function ( i, option ) {
|
149 |
+
if ( option.value === '' ) {
|
150 |
+
option.selected = false;
|
151 |
+
$element.trigger( 'change' );
|
152 |
+
}
|
153 |
+
});
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
if ( typeof( jQuery.fn.select2 ) === 'function' ) {
|
158 |
+
jQuery(".um-s1").each( function( e ) {
|
159 |
+
var obj = jQuery(this);
|
160 |
+
|
161 |
+
obj.select2({
|
162 |
+
allowClear: true,
|
163 |
+
dropdownParent: obj.parent()
|
164 |
+
}).on( 'change', unselectEmptyOption );
|
165 |
+
} );
|
166 |
+
|
167 |
+
jQuery(".um-s2").each( function( e ) {
|
168 |
+
var obj = jQuery(this);
|
169 |
+
|
170 |
+
// fix https://github.com/ultimatemember/ultimatemember/issues/941
|
171 |
+
// using .um-custom-shortcode-tab class as temporarily solution
|
172 |
+
var atts = {};
|
173 |
+
if ( obj.parents('.um-custom-shortcode-tab').length ) {
|
174 |
+
atts = {
|
175 |
+
allowClear: false
|
176 |
+
};
|
177 |
+
} else {
|
178 |
+
atts = {
|
179 |
+
allowClear: false,
|
180 |
+
minimumResultsForSearch: 10,
|
181 |
+
dropdownParent: obj.parent()
|
182 |
+
};
|
183 |
+
}
|
184 |
+
obj.select2( atts ).on( 'change', unselectEmptyOption );
|
185 |
+
} );
|
186 |
+
|
187 |
+
jQuery(".um-s3").each( function( e ) {
|
188 |
+
var obj = jQuery(this);
|
189 |
+
|
190 |
+
obj.select2({
|
191 |
+
allowClear: false,
|
192 |
+
minimumResultsForSearch: -1,
|
193 |
+
dropdownParent: obj.parent()
|
194 |
+
}).on( 'change', unselectEmptyOption );
|
195 |
+
} );
|
196 |
+
}
|
197 |
+
|
198 |
+
init_tipsy();
|
199 |
+
|
200 |
+
if ( typeof( jQuery.fn.um_raty ) === 'function' ) {
|
201 |
+
jQuery('.um-rating').um_raty({
|
202 |
+
half: false,
|
203 |
+
starType: 'i',
|
204 |
+
number: function() {
|
205 |
+
return jQuery(this).attr('data-number');
|
206 |
+
},
|
207 |
+
score: function() {
|
208 |
+
return jQuery(this).attr('data-score');
|
209 |
+
},
|
210 |
+
scoreName: function() {
|
211 |
+
return jQuery(this).attr('data-key');
|
212 |
+
},
|
213 |
+
hints: false,
|
214 |
+
click: function( score, evt ) {
|
215 |
+
um_live_field = this.id;
|
216 |
+
um_live_value = score;
|
217 |
+
um_apply_conditions( jQuery(this), false );
|
218 |
+
}
|
219 |
+
});
|
220 |
+
|
221 |
+
jQuery('.um-rating-readonly').um_raty({
|
222 |
+
half: false,
|
223 |
+
starType: 'i',
|
224 |
+
number: function() {
|
225 |
+
return jQuery(this).attr('data-number');
|
226 |
+
},
|
227 |
+
score: function() {
|
228 |
+
return jQuery(this).attr('data-score');
|
229 |
+
},
|
230 |
+
scoreName: function() {
|
231 |
+
return jQuery(this).attr('data-key');
|
232 |
+
},
|
233 |
+
hints: false,
|
234 |
+
readOnly: true
|
235 |
+
});
|
236 |
+
}
|
237 |
+
|
238 |
+
jQuery(document).on('change', '.um-field-area input[type="radio"]', function() {
|
239 |
+
var field = jQuery(this).parents('.um-field-area');
|
240 |
+
var this_field = jQuery(this).parents('label');
|
241 |
+
field.find('.um-field-radio').removeClass('active');
|
242 |
+
field.find('.um-field-radio').find('i').removeAttr('class').addClass('um-icon-android-radio-button-off');
|
243 |
+
this_field.addClass('active');
|
244 |
+
this_field.find('i').removeAttr('class').addClass('um-icon-android-radio-button-on');
|
245 |
+
});
|
246 |
+
|
247 |
+
jQuery(document).on('change', '.um-field-area input[type="checkbox"]', function() {
|
248 |
+
var this_field = jQuery(this).parents('label');
|
249 |
+
if ( this_field.hasClass('active') ) {
|
250 |
+
this_field.removeClass('active');
|
251 |
+
this_field.find('i').removeAttr('class').addClass('um-icon-android-checkbox-outline-blank');
|
252 |
+
} else {
|
253 |
+
this_field.addClass('active');
|
254 |
+
this_field.find('i').removeAttr('class').addClass('um-icon-android-checkbox-outline');
|
255 |
+
}
|
256 |
+
});
|
257 |
+
|
258 |
+
|
259 |
+
um_init_datetimepicker();
|
260 |
+
|
261 |
+
jQuery(document).on('click', '.um .um-single-image-preview a.cancel', function( e ) {
|
262 |
+
e.preventDefault();
|
263 |
+
var parent = jQuery(this).parents('.um-field');
|
264 |
+
|
265 |
+
var filename = parent.find( 'input[type="hidden"]#' + parent.data('key') + '-' + jQuery(this).parents('form').find('input[type="hidden"][name="form_id"]').val() ).val();
|
266 |
+
|
267 |
+
var src = jQuery(this).parents('.um-field').find('.um-single-image-preview img').attr('src');
|
268 |
+
var mode = parent.data('mode');
|
269 |
+
|
270 |
+
var args = {
|
271 |
+
data: {
|
272 |
+
mode: mode,
|
273 |
+
filename: filename,
|
274 |
+
src: src,
|
275 |
+
nonce: um_scripts.nonce
|
276 |
+
},
|
277 |
+
success: function() {
|
278 |
+
parent.find('.um-single-image-preview img').attr( 'src', '' );
|
279 |
+
parent.find('.um-single-image-preview').hide();
|
280 |
+
parent.find('.um-btn-auto-width').html( parent.data('upload-label') );
|
281 |
+
parent.find('input[type="hidden"]').val( 'empty_file' );
|
282 |
+
}
|
283 |
+
};
|
284 |
+
|
285 |
+
if ( mode !== 'register' ) {
|
286 |
+
args.data.user_id = jQuery(this).parents('form' ).find( '#user_id' ).val();
|
287 |
+
}
|
288 |
+
|
289 |
+
wp.ajax.send( 'um_remove_file', args );
|
290 |
+
|
291 |
+
return false;
|
292 |
+
});
|
293 |
+
|
294 |
+
jQuery(document).on('click', '.um .um-single-file-preview a.cancel', function( e ) {
|
295 |
+
e.preventDefault();
|
296 |
+
var parent = jQuery(this).parents('.um-field');
|
297 |
+
var filename = parent.find( 'input[type="hidden"]#' + parent.data('key') + '-' + jQuery(this).parents('form').find('input[type="hidden"][name="form_id"]').val() ).val();
|
298 |
+
var src = jQuery(this).parents('.um-field').find('.um-single-fileinfo a').attr('href');
|
299 |
+
var mode = parent.data('mode');
|
300 |
+
|
301 |
+
var args = {
|
302 |
+
data: {
|
303 |
+
mode: mode,
|
304 |
+
filename: filename,
|
305 |
+
src: src,
|
306 |
+
nonce: um_scripts.nonce
|
307 |
+
},
|
308 |
+
success: function() {
|
309 |
+
parent.find('.um-single-file-preview').hide();
|
310 |
+
parent.find('.um-btn-auto-width').html( parent.data('upload-label') );
|
311 |
+
parent.find('input[type=hidden]').val( 'empty_file' );
|
312 |
+
}
|
313 |
+
};
|
314 |
+
|
315 |
+
if ( mode !== 'register' ) {
|
316 |
+
args.data.user_id = jQuery(this).parents('form' ).find( '#user_id' ).val();
|
317 |
+
}
|
318 |
+
|
319 |
+
wp.ajax.send( 'um_remove_file', args );
|
320 |
+
|
321 |
+
return false;
|
322 |
+
});
|
323 |
+
|
324 |
+
jQuery(document).on('click', '.um-field-group-head:not(.disabled)', function() {
|
325 |
+
var field = jQuery(this).parents('.um-field-group');
|
326 |
+
var limit = field.data('max_entries');
|
327 |
+
|
328 |
+
if ( field.find('.um-field-group-body').is(':hidden')){
|
329 |
+
field.find('.um-field-group-body').show();
|
330 |
+
} else {
|
331 |
+
field.find('.um-field-group-body:first').clone().appendTo( field );
|
332 |
+
}
|
333 |
+
|
334 |
+
var increase_id = 0;
|
335 |
+
field.find('.um-field-group-body').each(function(){
|
336 |
+
increase_id++;
|
337 |
+
jQuery(this).find('input').each(function(){
|
338 |
+
var input = jQuery(this);
|
339 |
+
input.attr('id', input.data('key') + '-' + increase_id );
|
340 |
+
input.attr('name', input.data('key') + '-' + increase_id );
|
341 |
+
input.parent().parent().find('label').attr('for', input.data('key') + '-' + increase_id );
|
342 |
+
});
|
343 |
+
});
|
344 |
+
|
345 |
+
if ( limit > 0 && field.find('.um-field-group-body').length == limit ) {
|
346 |
+
|
347 |
+
jQuery(this).addClass('disabled');
|
348 |
+
|
349 |
+
}
|
350 |
+
});
|
351 |
+
|
352 |
+
jQuery(document).on('click', '.um-field-group-cancel', function( e ) {
|
353 |
+
e.preventDefault();
|
354 |
+
var field = jQuery(this).parents('.um-field-group');
|
355 |
+
|
356 |
+
var limit = field.data('max_entries');
|
357 |
+
|
358 |
+
if ( field.find('.um-field-group-body').length > 1 ) {
|
359 |
+
jQuery(this).parents('.um-field-group-body').remove();
|
360 |
+
} else {
|
361 |
+
jQuery(this).parents('.um-field-group-body').hide();
|
362 |
+
}
|
363 |
+
|
364 |
+
if ( limit > 0 && field.find('.um-field-group-body').length < limit ) {
|
365 |
+
field.find('.um-field-group-head').removeClass('disabled');
|
366 |
+
}
|
367 |
+
|
368 |
+
return false;
|
369 |
+
});
|
370 |
+
|
371 |
+
|
372 |
+
jQuery( document.body ).on( 'click', '.um-ajax-paginate', function( e ) {
|
373 |
+
e.preventDefault();
|
374 |
+
|
375 |
+
var obj = jQuery(this);
|
376 |
+
var parent = obj.parent();
|
377 |
+
parent.addClass( 'loading' );
|
378 |
+
|
379 |
+
var pages = obj.data('pages')*1;
|
380 |
+
var next_page = obj.data('page')*1 + 1;
|
381 |
+
|
382 |
+
var hook = obj.data('hook');
|
383 |
+
|
384 |
+
if ( 'um_load_posts' === hook ) {
|
385 |
+
|
386 |
+
jQuery.ajax({
|
387 |
+
url: wp.ajax.settings.url,
|
388 |
+
type: 'post',
|
389 |
+
data: {
|
390 |
+
action: 'um_ajax_paginate_posts',
|
391 |
+
author: jQuery(this).data('author'),
|
392 |
+
page: next_page,
|
393 |
+
nonce: um_scripts.nonce
|
394 |
+
},
|
395 |
+
complete: function() {
|
396 |
+
parent.removeClass( 'loading' );
|
397 |
+
},
|
398 |
+
success: function( data ) {
|
399 |
+
parent.before( data );
|
400 |
+
if ( next_page === pages ) {
|
401 |
+
parent.remove();
|
402 |
+
} else {
|
403 |
+
obj.data( 'page', next_page );
|
404 |
+
}
|
405 |
+
}
|
406 |
+
});
|
407 |
+
} else if ( 'um_load_comments' === hook ) {
|
408 |
+
|
409 |
+
jQuery.ajax({
|
410 |
+
url: wp.ajax.settings.url,
|
411 |
+
type: 'post',
|
412 |
+
data: {
|
413 |
+
action: 'um_ajax_paginate_comments',
|
414 |
+
user_id: jQuery(this).data('user_id'),
|
415 |
+
page: next_page,
|
416 |
+
nonce: um_scripts.nonce
|
417 |
+
},
|
418 |
+
complete: function() {
|
419 |
+
parent.removeClass( 'loading' );
|
420 |
+
},
|
421 |
+
success: function( data ) {
|
422 |
+
parent.before( data );
|
423 |
+
if ( next_page === pages ) {
|
424 |
+
parent.remove();
|
425 |
+
} else {
|
426 |
+
obj.data( 'page', next_page );
|
427 |
+
}
|
428 |
+
}
|
429 |
+
});
|
430 |
+
} else {
|
431 |
+
var args = jQuery(this).data('args');
|
432 |
+
var container = jQuery(this).parents('.um').find('.um-ajax-items');
|
433 |
+
|
434 |
+
jQuery.ajax({
|
435 |
+
url: wp.ajax.settings.url,
|
436 |
+
type: 'post',
|
437 |
+
data: {
|
438 |
+
action: 'um_ajax_paginate',
|
439 |
+
hook: hook,
|
440 |
+
args: args,
|
441 |
+
nonce: um_scripts.nonce
|
442 |
+
},
|
443 |
+
complete: function() {
|
444 |
+
parent.removeClass( 'loading' );
|
445 |
+
},
|
446 |
+
success: function(data){
|
447 |
+
parent.remove();
|
448 |
+
container.append( data );
|
449 |
+
}
|
450 |
+
});
|
451 |
+
}
|
452 |
+
});
|
453 |
+
|
454 |
+
|
455 |
+
jQuery(document).on('click', '.um-ajax-action', function( e ) {
|
456 |
+
e.preventDefault();
|
457 |
+
var hook = jQuery(this).data('hook');
|
458 |
+
var user_id = jQuery(this).data('user_id');
|
459 |
+
var arguments = jQuery(this).data('arguments');
|
460 |
+
|
461 |
+
if ( jQuery(this).data('js-remove') ){
|
462 |
+
jQuery(this).parents('.'+jQuery(this).data('js-remove')).fadeOut('fast');
|
463 |
+
}
|
464 |
+
|
465 |
+
jQuery.ajax({
|
466 |
+
url: wp.ajax.settings.url,
|
467 |
+
type: 'post',
|
468 |
+
data: {
|
469 |
+
action: 'um_muted_action',
|
470 |
+
hook: hook,
|
471 |
+
user_id: user_id,
|
472 |
+
arguments: arguments,
|
473 |
+
nonce: um_scripts.nonce
|
474 |
+
},
|
475 |
+
success: function(data){
|
476 |
+
|
477 |
+
}
|
478 |
+
});
|
479 |
+
return false;
|
480 |
+
});
|
481 |
+
|
482 |
+
jQuery( document.body ).on('click', '#um-search-button', function() {
|
483 |
+
var action = jQuery(this).parents('.um-search-form').data('members_page');
|
484 |
+
|
485 |
+
var search_keys = [];
|
486 |
+
jQuery(this).parents('.um-search-form').find('input[name="um-search-keys[]"]').each( function() {
|
487 |
+
search_keys.push( jQuery(this).val() );
|
488 |
+
});
|
489 |
+
|
490 |
+
var search = jQuery(this).parents('.um-search-form').find('.um-search-field').val();
|
491 |
+
|
492 |
+
var url;
|
493 |
+
if ( search === '' ) {
|
494 |
+
url = action;
|
495 |
+
} else {
|
496 |
+
var query = '?';
|
497 |
+
for ( var i = 0; i < search_keys.length; i++ ) {
|
498 |
+
query += search_keys[i] + '=' + search;
|
499 |
+
if ( i !== search_keys.length - 1 ) {
|
500 |
+
query += '&';
|
501 |
+
}
|
502 |
+
}
|
503 |
+
|
504 |
+
url = action + query;
|
505 |
+
}
|
506 |
+
window.location = url;
|
507 |
+
});
|
508 |
+
|
509 |
+
//make search on Enter click
|
510 |
+
jQuery( document.body ).on( 'keypress', '.um-search-field', function(e) {
|
511 |
+
if ( e.which === 13 ) {
|
512 |
+
var action = jQuery(this).parents('.um-search-form').data('members_page');
|
513 |
+
|
514 |
+
var search_keys = [];
|
515 |
+
jQuery(this).parents('.um-search-form').find('input[name="um-search-keys[]"]').each( function() {
|
516 |
+
search_keys.push( jQuery(this).val() );
|
517 |
+
});
|
518 |
+
|
519 |
+
var search = jQuery(this).val();
|
520 |
+
|
521 |
+
var url;
|
522 |
+
if ( search === '' ) {
|
523 |
+
url = action;
|
524 |
+
} else {
|
525 |
+
var query = '?';
|
526 |
+
for ( var i = 0; i < search_keys.length; i++ ) {
|
527 |
+
query += search_keys[i] + '=' + search;
|
528 |
+
if ( i !== search_keys.length - 1 ) {
|
529 |
+
query += '&';
|
530 |
+
}
|
531 |
+
}
|
532 |
+
|
533 |
+
url = action + query;
|
534 |
+
}
|
535 |
+
window.location = url;
|
536 |
+
}
|
537 |
+
});
|
538 |
+
|
539 |
+
jQuery('.um-form input[class="um-button"][type="submit"]').prop('disabled', false);
|
540 |
+
|
541 |
+
jQuery(document).one('click', '.um:not(.um-account) .um-form input[class="um-button"][type="submit"]:not(.um-has-recaptcha)', function() {
|
542 |
+
jQuery(this).attr('disabled','disabled');
|
543 |
+
jQuery(this).parents('form').trigger('submit');
|
544 |
+
});
|
545 |
+
|
546 |
+
|
547 |
+
var um_select_options_cache = {};
|
548 |
+
|
549 |
+
/**
|
550 |
+
* Find all select fields with parent select fields
|
551 |
+
*/
|
552 |
+
jQuery('select[data-um-parent]').each( function() {
|
553 |
+
|
554 |
+
var me = jQuery(this);
|
555 |
+
var parent_option = me.data('um-parent');
|
556 |
+
var um_ajax_source = me.data('um-ajax-source');
|
557 |
+
|
558 |
+
me.attr('data-um-init-field', true );
|
559 |
+
|
560 |
+
jQuery(document).on('change','select[name="' + parent_option + '"]',function() {
|
561 |
+
var parent = jQuery(this);
|
562 |
+
var form_id = parent.closest( 'form' ).find( 'input[type="hidden"][name="form_id"]' ).val();
|
563 |
+
|
564 |
+
var arr_key;
|
565 |
+
if ( me.attr( 'data-member-directory' ) === 'yes' ) {
|
566 |
+
var directory = parent.parents('.um-directory');
|
567 |
+
arr_key = um_get_data_for_directory( directory, 'filter_' + parent_option );
|
568 |
+
if ( typeof arr_key != 'undefined' ) {
|
569 |
+
arr_key = arr_key.split('||');
|
570 |
+
} else {
|
571 |
+
arr_key = '';
|
572 |
+
}
|
573 |
+
} else {
|
574 |
+
arr_key = parent.val();
|
575 |
+
}
|
576 |
+
|
577 |
+
if ( typeof arr_key != 'undefined' && arr_key !== '' && typeof um_select_options_cache[ arr_key ] !== 'object' ) {
|
578 |
+
|
579 |
+
if ( typeof( me.um_wait ) === 'undefined' || me.um_wait === false ) {
|
580 |
+
me.um_wait = true;
|
581 |
+
} else {
|
582 |
+
return;
|
583 |
+
}
|
584 |
+
|
585 |
+
jQuery.ajax({
|
586 |
+
url: wp.ajax.settings.url,
|
587 |
+
type: 'post',
|
588 |
+
data: {
|
589 |
+
action: 'um_select_options',
|
590 |
+
parent_option_name: parent_option,
|
591 |
+
parent_option: arr_key,
|
592 |
+
child_callback: um_ajax_source,
|
593 |
+
child_name: me.attr('name'),
|
594 |
+
members_directory: me.attr('data-member-directory'),
|
595 |
+
form_id: form_id,
|
596 |
+
nonce: um_scripts.nonce
|
597 |
+
},
|
598 |
+
success: function( data ) {
|
599 |
+
if ( data.status === 'success' && arr_key !== '' ) {
|
600 |
+
um_select_options_cache[ arr_key ] = data;
|
601 |
+
um_field_populate_child_options( me, data, arr_key );
|
602 |
+
}
|
603 |
+
|
604 |
+
if ( typeof data.debug !== 'undefined' ) {
|
605 |
+
console.log( data );
|
606 |
+
}
|
607 |
+
|
608 |
+
me.um_wait = false;
|
609 |
+
},
|
610 |
+
error: function( e ) {
|
611 |
+
console.log( e );
|
612 |
+
me.um_wait = false;
|
613 |
+
}
|
614 |
+
});
|
615 |
+
|
616 |
+
}
|
617 |
+
|
618 |
+
if ( typeof arr_key != 'undefined' && arr_key !== '' && typeof um_select_options_cache[ arr_key ] == 'object' ) {
|
619 |
+
setTimeout( um_field_populate_child_options, 10, me, um_select_options_cache[ arr_key ], arr_key );
|
620 |
+
}
|
621 |
+
|
622 |
+
if ( typeof arr_key != 'undefined' || arr_key === '' ) {
|
623 |
+
me.find('option[value!=""]').remove();
|
624 |
+
me.val('').trigger('change');
|
625 |
+
}
|
626 |
+
|
627 |
+
});
|
628 |
+
|
629 |
+
jQuery('select[name="' + parent_option + '"]').trigger('change');
|
630 |
+
|
631 |
+
});
|
632 |
+
|
633 |
+
|
634 |
+
/**
|
635 |
+
* Populates child options and cache ajax response
|
636 |
+
*
|
637 |
+
* @param me
|
638 |
+
* @param data
|
639 |
+
* @param arr_key
|
640 |
+
*/
|
641 |
+
function um_field_populate_child_options( me, data, arr_key ) {
|
642 |
+
var directory = me.parents('.um-directory');
|
643 |
+
var child_name = me.attr('name');
|
644 |
+
me.find('option[value!=""]').remove();
|
645 |
+
|
646 |
+
if ( ! me.hasClass('um-child-option-disabled') ) {
|
647 |
+
me.prop('disabled', false);
|
648 |
+
}
|
649 |
+
|
650 |
+
var arr_items = [],
|
651 |
+
search_get = '';
|
652 |
+
|
653 |
+
if ( data.post.members_directory === 'yes' ) {
|
654 |
+
arr_items.push({id: '', text: '', selected: 1});
|
655 |
+
}
|
656 |
+
jQuery.each( data.items, function(k,v){
|
657 |
+
arr_items.push({id: k, text: v, selected: (v === search_get)});
|
658 |
+
});
|
659 |
+
|
660 |
+
me.select2('destroy');
|
661 |
+
me.select2({
|
662 |
+
data: arr_items,
|
663 |
+
allowClear: true,
|
664 |
+
minimumResultsForSearch: 10
|
665 |
+
});
|
666 |
+
|
667 |
+
if ( data.post.members_directory === 'yes' ) {
|
668 |
+
me.find('option').each( function() {
|
669 |
+
if ( jQuery(this).html() !== '' ) {
|
670 |
+
jQuery(this).data( 'value_label', jQuery(this).html() ).attr( 'data-value_label', jQuery(this).html() );
|
671 |
+
}
|
672 |
+
});
|
673 |
+
|
674 |
+
var current_filter_val = um_get_data_for_directory( directory, 'filter_' + child_name );
|
675 |
+
if ( typeof current_filter_val !== 'undefined' ) {
|
676 |
+
current_filter_val = current_filter_val.split('||');
|
677 |
+
|
678 |
+
var temp_filter_val = [];
|
679 |
+
jQuery.each( current_filter_val, function(i) {
|
680 |
+
if ( me.find('option[value="' + current_filter_val[ i ] + '"]').length ) {
|
681 |
+
temp_filter_val.push( current_filter_val[ i ] );
|
682 |
+
}
|
683 |
+
me.find('option[value="' + current_filter_val[ i ] + '"]').prop('disabled', true).hide();
|
684 |
+
if ( me.find('option:not(:disabled)').length === 1 ) {
|
685 |
+
me.prop('disabled', true);
|
686 |
+
}
|
687 |
+
|
688 |
+
me.select2('destroy').select2();
|
689 |
+
me.val('').trigger( 'change' );
|
690 |
+
});
|
691 |
+
|
692 |
+
temp_filter_val = temp_filter_val.join('||');
|
693 |
+
if ( current_filter_val !== temp_filter_val ) {
|
694 |
+
um_set_url_from_data( directory, 'filter_' + child_name, temp_filter_val );
|
695 |
+
um_ajax_get_members( directory );
|
696 |
+
}
|
697 |
+
}
|
698 |
+
|
699 |
+
um_change_tag( directory );
|
700 |
+
}
|
701 |
+
|
702 |
+
if ( data.post.members_directory !== 'yes' ) {
|
703 |
+
if ( typeof data.field.default !== 'undefined' && ! me.data('um-original-value') ) {
|
704 |
+
me.val( data.field.default ).trigger('change');
|
705 |
+
} else if ( me.data('um-original-value') !== '' ) {
|
706 |
+
me.val( me.data('um-original-value') ).trigger('change');
|
707 |
+
}
|
708 |
+
|
709 |
+
if ( data.field.editable == 0 ) {
|
710 |
+
me.addClass('um-child-option-disabled');
|
711 |
+
me.attr('disabled','disabled');
|
712 |
+
}
|
713 |
+
}
|
714 |
+
}
|
715 |
+
|
716 |
+
});
|
assets/js/um-scripts.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function um_sanitize_value(e,t){var a=document.createElement("div");a.innerText=e;var i=a.innerHTML;return t&&jQuery(t).val(i),i}function um_unsanitize_value(e){var t=document.createElement("textarea");return t.innerHTML=e,0===t.childNodes.length?"":t.childNodes[0].nodeValue}function um_init_datetimepicker(){jQuery(".um-datepicker:not(.picker__input)").each(function(){var e=jQuery(this),t=!1;void 0!==e.attr("data-disabled_weekdays")&&""!==e.attr("data-disabled_weekdays")&&(t=JSON.parse(e.attr("data-disabled_weekdays")));var a=null;void 0!==e.attr("data-years")&&(a=e.attr("data-years"));var i=e.attr("data-date_min"),r=e.attr("data-date_max"),n=[],u=[];void 0!==i&&(n=i.split(",")),void 0!==r&&(u=r.split(","));var o=n.length?new Date(n):null,d=n.length?new Date(u):null;if(o&&"Invalid Date"==o.toString()&&3==n.length){var s=n[1]+"/"+n[2]+"/"+n[0];o=new Date(Date.parse(s))}if(d&&"Invalid Date"==d.toString()&&3==u.length){var l=u[1]+"/"+u[2]+"/"+u[0];d=new Date(Date.parse(l))}var c={disable:t,format:e.attr("data-format"),formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()}};null!==a&&(c.selectYears=a),null!==o&&(c.min=o),null!==d&&(c.max=d),e.pickadate(c)}),jQuery(".um-timepicker:not(.picker__input)").each(function(){var e=jQuery(this);e.pickatime({format:e.attr("data-format"),interval:parseInt(e.attr("data-intervals")),formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()}})})}function init_tipsy(){"function"==typeof jQuery.fn.tipsy&&(jQuery(".um-tip-n").tipsy({gravity:"n",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-w").tipsy({gravity:"w",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-e").tipsy({gravity:"e",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-s").tipsy({gravity:"s",opacity:1,live:"a.live",offset:3}))}jQuery(document).ready(function(){function a(e){var a=jQuery(e.currentTarget),t=a.find(":selected");1<t.length&&t.each(function(e,t){""===t.value&&(t.selected=!1,a.trigger("change"))})}jQuery(document.body).on("click",".um-dropdown a.real_url",function(){window.location=jQuery(this).attr("href")}),jQuery(document.body).on("click",".um-trigger-menu-on-click",function(){var e=jQuery(this).find(".um-dropdown");return UM.dropdown.show(e),!1}),jQuery(document.body).on("click",".um-dropdown-hide",function(){return UM.dropdown.hideAll(),!1}),jQuery(document.body).on("click","a.um-manual-trigger",function(){var e=jQuery(this).attr("data-child"),t=jQuery(this).attr("data-parent");return jQuery(this).parents(t).find(e).trigger("click"),UM.dropdown.hideAll(),!1}),jQuery(".um-s1,.um-s2").css({display:"block"}),"function"==typeof jQuery.fn.select2&&(jQuery(".um-s1").each(function(e){var t=jQuery(this);t.select2({allowClear:!0,dropdownParent:t.parent()}).on("change",a)}),jQuery(".um-s2").each(function(e){var t=jQuery(this);t.select2({allowClear:!1,minimumResultsForSearch:10,dropdownParent:t.parent()}).on("change",a)}),jQuery(".um-s3").each(function(e){var t=jQuery(this);t.select2({allowClear:!1,minimumResultsForSearch:-1,dropdownParent:t.parent()}).on("change",a)})),init_tipsy(),"function"==typeof jQuery.fn.um_raty&&(jQuery(".um-rating").um_raty({half:!1,starType:"i",number:function(){return jQuery(this).attr("data-number")},score:function(){return jQuery(this).attr("data-score")},scoreName:function(){return jQuery(this).attr("data-key")},hints:!1,click:function(e,t){um_live_field=this.id,um_live_value=e,um_apply_conditions(jQuery(this),!1)}}),jQuery(".um-rating-readonly").um_raty({half:!1,starType:"i",number:function(){return jQuery(this).attr("data-number")},score:function(){return jQuery(this).attr("data-score")},scoreName:function(){return jQuery(this).attr("data-key")},hints:!1,readOnly:!0})),jQuery(document).on("change",'.um-field-area input[type="radio"]',function(){var e=jQuery(this).parents(".um-field-area"),t=jQuery(this).parents("label");e.find(".um-field-radio").removeClass("active"),e.find(".um-field-radio").find("i").removeAttr("class").addClass("um-icon-android-radio-button-off"),t.addClass("active"),t.find("i").removeAttr("class").addClass("um-icon-android-radio-button-on")}),jQuery(document).on("change",'.um-field-area input[type="checkbox"]',function(){var e=jQuery(this).parents("label");e.hasClass("active")?(e.removeClass("active"),e.find("i").removeAttr("class").addClass("um-icon-android-checkbox-outline-blank")):(e.addClass("active"),e.find("i").removeAttr("class").addClass("um-icon-android-checkbox-outline"))}),um_init_datetimepicker(),jQuery(document).on("click",".um .um-single-image-preview a.cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field"),a=t.find('input[type="hidden"]#'+t.data("key")+"-"+jQuery(this).parents("form").find('input[type="hidden"][name="form_id"]').val()).val(),i=jQuery(this).parents(".um-field").find(".um-single-image-preview img").attr("src"),r=t.data("mode"),n={data:{mode:r,filename:a,src:i,nonce:um_scripts.nonce},success:function(){t.find(".um-single-image-preview img").attr("src",""),t.find(".um-single-image-preview").hide(),t.find(".um-btn-auto-width").html(t.data("upload-label")),t.find('input[type="hidden"]').val("empty_file")}};return"register"!==r&&(n.data.user_id=jQuery(this).parents("form").find("#user_id").val()),wp.ajax.send("um_remove_file",n),!1}),jQuery(document).on("click",".um .um-single-file-preview a.cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field"),a=t.find('input[type="hidden"]#'+t.data("key")+"-"+jQuery(this).parents("form").find('input[type="hidden"][name="form_id"]').val()).val(),i=jQuery(this).parents(".um-field").find(".um-single-fileinfo a").attr("href"),r=t.data("mode"),n={data:{mode:r,filename:a,src:i,nonce:um_scripts.nonce},success:function(){t.find(".um-single-file-preview").hide(),t.find(".um-btn-auto-width").html(t.data("upload-label")),t.find("input[type=hidden]").val("empty_file")}};return"register"!==r&&(n.data.user_id=jQuery(this).parents("form").find("#user_id").val()),wp.ajax.send("um_remove_file",n),!1}),jQuery(document).on("click",".um-field-group-head:not(.disabled)",function(){var e=jQuery(this).parents(".um-field-group"),t=e.data("max_entries");e.find(".um-field-group-body").is(":hidden")?e.find(".um-field-group-body").show():e.find(".um-field-group-body:first").clone().appendTo(e);var a=0;e.find(".um-field-group-body").each(function(){a++,jQuery(this).find("input").each(function(){var e=jQuery(this);e.attr("id",e.data("key")+"-"+a),e.attr("name",e.data("key")+"-"+a),e.parent().parent().find("label").attr("for",e.data("key")+"-"+a)})}),0<t&&e.find(".um-field-group-body").length==t&&jQuery(this).addClass("disabled")}),jQuery(document).on("click",".um-field-group-cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field-group"),a=t.data("max_entries");return 1<t.find(".um-field-group-body").length?jQuery(this).parents(".um-field-group-body").remove():jQuery(this).parents(".um-field-group-body").hide(),0<a&&t.find(".um-field-group-body").length<a&&t.find(".um-field-group-head").removeClass("disabled"),!1}),jQuery(document.body).on("click",".um-ajax-paginate",function(e){e.preventDefault();var t=jQuery(this),a=t.parent();a.addClass("loading");var i=1*t.data("pages"),r=1*t.data("page")+1,n=t.data("hook");if("um_load_posts"===n)jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate_posts",author:jQuery(this).data("author"),page:r,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.before(e),r==i?a.remove():t.data("page",r)}});else if("um_load_comments"===n)jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate_comments",user_id:jQuery(this).data("user_id"),page:r,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.before(e),r==i?a.remove():t.data("page",r)}});else{var u=jQuery(this).data("args"),o=jQuery(this).parents(".um").find(".um-ajax-items");jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate",hook:n,args:u,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.remove(),o.append(e)}})}}),jQuery(document).on("click",".um-ajax-action",function(e){e.preventDefault();var t=jQuery(this).data("hook"),a=jQuery(this).data("user_id"),arguments=jQuery(this).data("arguments");return jQuery(this).data("js-remove")&&jQuery(this).parents("."+jQuery(this).data("js-remove")).fadeOut("fast"),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_muted_action",hook:t,user_id:a,arguments:arguments,nonce:um_scripts.nonce},success:function(e){}}),!1}),jQuery(document.body).on("click","#um-search-button",function(){var e=jQuery(this).parents(".um-search-form").data("members_page"),t=[];jQuery(this).parents(".um-search-form").find('input[name="um-search-keys[]"]').each(function(){t.push(jQuery(this).val())});var a,i=jQuery(this).parents(".um-search-form").find(".um-search-field").val();if(""===i)a=e;else{for(var r="?",n=0;n<t.length;n++)r+=t[n]+"="+i,n!==t.length-1&&(r+="&");a=e+r}window.location=a}),jQuery(document.body).on("keypress",".um-search-field",function(e){if(13===e.which){var t=jQuery(this).parents(".um-search-form").data("members_page"),a=[];jQuery(this).parents(".um-search-form").find('input[name="um-search-keys[]"]').each(function(){a.push(jQuery(this).val())});var i,r=jQuery(this).val();if(""===r)i=t;else{for(var n="?",u=0;u<a.length;u++)n+=a[u]+"="+r,u!==a.length-1&&(n+="&");i=t+n}window.location=i}}),jQuery('.um-form input[class="um-button"][type="submit"]').prop("disabled",!1),jQuery(document).one("click",'.um:not(.um-account) .um-form input[class="um-button"][type="submit"]:not(.um-has-recaptcha)',function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parents("form").trigger("submit")});var o={};function d(t,e,a){var i=t.parents(".um-directory"),r=t.attr("name");t.find('option[value!=""]').remove(),t.hasClass("um-child-option-disabled")||t.prop("disabled",!1);var n=[];if("yes"===e.post.members_directory&&n.push({id:"",text:"",selected:1}),jQuery.each(e.items,function(e,t){n.push({id:e,text:t,selected:""===t})}),t.select2("destroy"),t.select2({data:n,allowClear:!0,minimumResultsForSearch:10}),"yes"===e.post.members_directory){t.find("option").each(function(){""!==jQuery(this).html()&&jQuery(this).data("value_label",jQuery(this).html()).attr("data-value_label",jQuery(this).html())});var u=um_get_data_for_directory(i,"filter_"+r);if(void 0!==u){u=u.split("||");var o=[];jQuery.each(u,function(e){t.find('option[value="'+u[e]+'"]').length&&o.push(u[e]),t.find('option[value="'+u[e]+'"]').prop("disabled",!0).hide(),1===t.find("option:not(:disabled)").length&&t.prop("disabled",!0),t.select2("destroy").select2(),t.val("").trigger("change")}),o=o.join("||"),u!==o&&(um_set_url_from_data(i,"filter_"+r,o),um_ajax_get_members(i))}um_change_tag(i)}"yes"!==e.post.members_directory&&(void 0===e.field.default||t.data("um-original-value")?""!==t.data("um-original-value")&&t.val(t.data("um-original-value")).trigger("change"):t.val(e.field.default).trigger("change"),0==e.field.editable&&(t.addClass("um-child-option-disabled"),t.attr("disabled","disabled")))}jQuery("select[data-um-parent]").each(function(){var r=jQuery(this),n=r.data("um-parent"),u=r.data("um-ajax-source");r.attr("data-um-init-field",!0),jQuery(document).on("change",'select[name="'+n+'"]',function(){var t,e=jQuery(this),a=e.closest("form").find('input[type="hidden"][name="form_id"]').val();if("yes"===r.attr("data-member-directory")){var i=e.parents(".um-directory");t=void 0!==(t=um_get_data_for_directory(i,"filter_"+n))?t.split("||"):""}else t=e.val();if(void 0!==t&&""!==t&&"object"!=typeof o[t]){if(void 0!==r.um_wait&&!1!==r.um_wait)return;r.um_wait=!0,jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_select_options",parent_option_name:n,parent_option:t,child_callback:u,child_name:r.attr("name"),members_directory:r.attr("data-member-directory"),form_id:a,nonce:um_scripts.nonce},success:function(e){"success"===e.status&&""!==t&&(o[t]=e,d(r,e,t)),void 0!==e.debug&&console.log(e),r.um_wait=!1},error:function(e){console.log(e),r.um_wait=!1}})}void 0!==t&&""!==t&&"object"==typeof o[t]&&setTimeout(d,10,r,o[t],t),void 0===t&&""!==t||(r.find('option[value!=""]').remove(),r.val("").trigger("change"))}),jQuery('select[name="'+n+'"]').trigger("change")})});
|
1 |
+
function um_sanitize_value(e,t){var a=document.createElement("div");a.innerText=e;var i=a.innerHTML;return t&&jQuery(t).val(i),i}function um_unsanitize_value(e){var t=document.createElement("textarea");return t.innerHTML=e,0===t.childNodes.length?"":t.childNodes[0].nodeValue}function um_init_datetimepicker(){jQuery(".um-datepicker:not(.picker__input)").each(function(){var e=jQuery(this),t=!1;void 0!==e.attr("data-disabled_weekdays")&&""!==e.attr("data-disabled_weekdays")&&(t=JSON.parse(e.attr("data-disabled_weekdays")));var a=null;void 0!==e.attr("data-years")&&(a=e.attr("data-years"));var i=e.attr("data-date_min"),r=e.attr("data-date_max"),n=[],u=[];void 0!==i&&(n=i.split(",")),void 0!==r&&(u=r.split(","));var o=n.length?new Date(n):null,d=n.length?new Date(u):null;if(o&&"Invalid Date"==o.toString()&&3==n.length){var s=n[1]+"/"+n[2]+"/"+n[0];o=new Date(Date.parse(s))}if(d&&"Invalid Date"==d.toString()&&3==u.length){var l=u[1]+"/"+u[2]+"/"+u[0];d=new Date(Date.parse(l))}var c={disable:t,format:e.attr("data-format"),formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()}};null!==a&&(c.selectYears=a),null!==o&&(c.min=o),null!==d&&(c.max=d),e.pickadate(c)}),jQuery(".um-timepicker:not(.picker__input)").each(function(){var e=jQuery(this);e.pickatime({format:e.attr("data-format"),interval:parseInt(e.attr("data-intervals")),formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()}})})}function init_tipsy(){"function"==typeof jQuery.fn.tipsy&&(jQuery(".um-tip-n").tipsy({gravity:"n",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-w").tipsy({gravity:"w",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-e").tipsy({gravity:"e",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-s").tipsy({gravity:"s",opacity:1,live:"a.live",offset:3}))}jQuery(document).ready(function(){function i(e){var a=jQuery(e.currentTarget),t=a.find(":selected");1<t.length&&t.each(function(e,t){""===t.value&&(t.selected=!1,a.trigger("change"))})}jQuery(document.body).on("click",".um-dropdown a.real_url",function(){window.location=jQuery(this).attr("href")}),jQuery(document.body).on("click",".um-trigger-menu-on-click",function(){var e=jQuery(this).find(".um-dropdown");return UM.dropdown.show(e),!1}),jQuery(document.body).on("click",".um-dropdown-hide",function(){return UM.dropdown.hideAll(),!1}),jQuery(document.body).on("click","a.um-manual-trigger",function(){var e=jQuery(this).attr("data-child"),t=jQuery(this).attr("data-parent");return jQuery(this).parents(t).find(e).trigger("click"),UM.dropdown.hideAll(),!1}),jQuery(".um-s1,.um-s2").css({display:"block"}),"function"==typeof jQuery.fn.select2&&(jQuery(".um-s1").each(function(e){var t=jQuery(this);t.select2({allowClear:!0,dropdownParent:t.parent()}).on("change",i)}),jQuery(".um-s2").each(function(e){var t=jQuery(this),a={};a=t.parents(".um-custom-shortcode-tab").length?{allowClear:!1}:{allowClear:!1,minimumResultsForSearch:10,dropdownParent:t.parent()},t.select2(a).on("change",i)}),jQuery(".um-s3").each(function(e){var t=jQuery(this);t.select2({allowClear:!1,minimumResultsForSearch:-1,dropdownParent:t.parent()}).on("change",i)})),init_tipsy(),"function"==typeof jQuery.fn.um_raty&&(jQuery(".um-rating").um_raty({half:!1,starType:"i",number:function(){return jQuery(this).attr("data-number")},score:function(){return jQuery(this).attr("data-score")},scoreName:function(){return jQuery(this).attr("data-key")},hints:!1,click:function(e,t){um_live_field=this.id,um_live_value=e,um_apply_conditions(jQuery(this),!1)}}),jQuery(".um-rating-readonly").um_raty({half:!1,starType:"i",number:function(){return jQuery(this).attr("data-number")},score:function(){return jQuery(this).attr("data-score")},scoreName:function(){return jQuery(this).attr("data-key")},hints:!1,readOnly:!0})),jQuery(document).on("change",'.um-field-area input[type="radio"]',function(){var e=jQuery(this).parents(".um-field-area"),t=jQuery(this).parents("label");e.find(".um-field-radio").removeClass("active"),e.find(".um-field-radio").find("i").removeAttr("class").addClass("um-icon-android-radio-button-off"),t.addClass("active"),t.find("i").removeAttr("class").addClass("um-icon-android-radio-button-on")}),jQuery(document).on("change",'.um-field-area input[type="checkbox"]',function(){var e=jQuery(this).parents("label");e.hasClass("active")?(e.removeClass("active"),e.find("i").removeAttr("class").addClass("um-icon-android-checkbox-outline-blank")):(e.addClass("active"),e.find("i").removeAttr("class").addClass("um-icon-android-checkbox-outline"))}),um_init_datetimepicker(),jQuery(document).on("click",".um .um-single-image-preview a.cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field"),a=t.find('input[type="hidden"]#'+t.data("key")+"-"+jQuery(this).parents("form").find('input[type="hidden"][name="form_id"]').val()).val(),i=jQuery(this).parents(".um-field").find(".um-single-image-preview img").attr("src"),r=t.data("mode"),n={data:{mode:r,filename:a,src:i,nonce:um_scripts.nonce},success:function(){t.find(".um-single-image-preview img").attr("src",""),t.find(".um-single-image-preview").hide(),t.find(".um-btn-auto-width").html(t.data("upload-label")),t.find('input[type="hidden"]').val("empty_file")}};return"register"!==r&&(n.data.user_id=jQuery(this).parents("form").find("#user_id").val()),wp.ajax.send("um_remove_file",n),!1}),jQuery(document).on("click",".um .um-single-file-preview a.cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field"),a=t.find('input[type="hidden"]#'+t.data("key")+"-"+jQuery(this).parents("form").find('input[type="hidden"][name="form_id"]').val()).val(),i=jQuery(this).parents(".um-field").find(".um-single-fileinfo a").attr("href"),r=t.data("mode"),n={data:{mode:r,filename:a,src:i,nonce:um_scripts.nonce},success:function(){t.find(".um-single-file-preview").hide(),t.find(".um-btn-auto-width").html(t.data("upload-label")),t.find("input[type=hidden]").val("empty_file")}};return"register"!==r&&(n.data.user_id=jQuery(this).parents("form").find("#user_id").val()),wp.ajax.send("um_remove_file",n),!1}),jQuery(document).on("click",".um-field-group-head:not(.disabled)",function(){var e=jQuery(this).parents(".um-field-group"),t=e.data("max_entries");e.find(".um-field-group-body").is(":hidden")?e.find(".um-field-group-body").show():e.find(".um-field-group-body:first").clone().appendTo(e);var a=0;e.find(".um-field-group-body").each(function(){a++,jQuery(this).find("input").each(function(){var e=jQuery(this);e.attr("id",e.data("key")+"-"+a),e.attr("name",e.data("key")+"-"+a),e.parent().parent().find("label").attr("for",e.data("key")+"-"+a)})}),0<t&&e.find(".um-field-group-body").length==t&&jQuery(this).addClass("disabled")}),jQuery(document).on("click",".um-field-group-cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field-group"),a=t.data("max_entries");return 1<t.find(".um-field-group-body").length?jQuery(this).parents(".um-field-group-body").remove():jQuery(this).parents(".um-field-group-body").hide(),0<a&&t.find(".um-field-group-body").length<a&&t.find(".um-field-group-head").removeClass("disabled"),!1}),jQuery(document.body).on("click",".um-ajax-paginate",function(e){e.preventDefault();var t=jQuery(this),a=t.parent();a.addClass("loading");var i=1*t.data("pages"),r=1*t.data("page")+1,n=t.data("hook");if("um_load_posts"===n)jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate_posts",author:jQuery(this).data("author"),page:r,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.before(e),r==i?a.remove():t.data("page",r)}});else if("um_load_comments"===n)jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate_comments",user_id:jQuery(this).data("user_id"),page:r,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.before(e),r==i?a.remove():t.data("page",r)}});else{var u=jQuery(this).data("args"),o=jQuery(this).parents(".um").find(".um-ajax-items");jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate",hook:n,args:u,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.remove(),o.append(e)}})}}),jQuery(document).on("click",".um-ajax-action",function(e){e.preventDefault();var t=jQuery(this).data("hook"),a=jQuery(this).data("user_id"),arguments=jQuery(this).data("arguments");return jQuery(this).data("js-remove")&&jQuery(this).parents("."+jQuery(this).data("js-remove")).fadeOut("fast"),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_muted_action",hook:t,user_id:a,arguments:arguments,nonce:um_scripts.nonce},success:function(e){}}),!1}),jQuery(document.body).on("click","#um-search-button",function(){var e=jQuery(this).parents(".um-search-form").data("members_page"),t=[];jQuery(this).parents(".um-search-form").find('input[name="um-search-keys[]"]').each(function(){t.push(jQuery(this).val())});var a,i=jQuery(this).parents(".um-search-form").find(".um-search-field").val();if(""===i)a=e;else{for(var r="?",n=0;n<t.length;n++)r+=t[n]+"="+i,n!==t.length-1&&(r+="&");a=e+r}window.location=a}),jQuery(document.body).on("keypress",".um-search-field",function(e){if(13===e.which){var t=jQuery(this).parents(".um-search-form").data("members_page"),a=[];jQuery(this).parents(".um-search-form").find('input[name="um-search-keys[]"]').each(function(){a.push(jQuery(this).val())});var i,r=jQuery(this).val();if(""===r)i=t;else{for(var n="?",u=0;u<a.length;u++)n+=a[u]+"="+r,u!==a.length-1&&(n+="&");i=t+n}window.location=i}}),jQuery('.um-form input[class="um-button"][type="submit"]').prop("disabled",!1),jQuery(document).one("click",'.um:not(.um-account) .um-form input[class="um-button"][type="submit"]:not(.um-has-recaptcha)',function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parents("form").trigger("submit")});var o={};function d(t,e,a){var i=t.parents(".um-directory"),r=t.attr("name");t.find('option[value!=""]').remove(),t.hasClass("um-child-option-disabled")||t.prop("disabled",!1);var n=[];if("yes"===e.post.members_directory&&n.push({id:"",text:"",selected:1}),jQuery.each(e.items,function(e,t){n.push({id:e,text:t,selected:""===t})}),t.select2("destroy"),t.select2({data:n,allowClear:!0,minimumResultsForSearch:10}),"yes"===e.post.members_directory){t.find("option").each(function(){""!==jQuery(this).html()&&jQuery(this).data("value_label",jQuery(this).html()).attr("data-value_label",jQuery(this).html())});var u=um_get_data_for_directory(i,"filter_"+r);if(void 0!==u){u=u.split("||");var o=[];jQuery.each(u,function(e){t.find('option[value="'+u[e]+'"]').length&&o.push(u[e]),t.find('option[value="'+u[e]+'"]').prop("disabled",!0).hide(),1===t.find("option:not(:disabled)").length&&t.prop("disabled",!0),t.select2("destroy").select2(),t.val("").trigger("change")}),o=o.join("||"),u!==o&&(um_set_url_from_data(i,"filter_"+r,o),um_ajax_get_members(i))}um_change_tag(i)}"yes"!==e.post.members_directory&&(void 0===e.field.default||t.data("um-original-value")?""!==t.data("um-original-value")&&t.val(t.data("um-original-value")).trigger("change"):t.val(e.field.default).trigger("change"),0==e.field.editable&&(t.addClass("um-child-option-disabled"),t.attr("disabled","disabled")))}jQuery("select[data-um-parent]").each(function(){var r=jQuery(this),n=r.data("um-parent"),u=r.data("um-ajax-source");r.attr("data-um-init-field",!0),jQuery(document).on("change",'select[name="'+n+'"]',function(){var t,e=jQuery(this),a=e.closest("form").find('input[type="hidden"][name="form_id"]').val();if("yes"===r.attr("data-member-directory")){var i=e.parents(".um-directory");t=void 0!==(t=um_get_data_for_directory(i,"filter_"+n))?t.split("||"):""}else t=e.val();if(void 0!==t&&""!==t&&"object"!=typeof o[t]){if(void 0!==r.um_wait&&!1!==r.um_wait)return;r.um_wait=!0,jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_select_options",parent_option_name:n,parent_option:t,child_callback:u,child_name:r.attr("name"),members_directory:r.attr("data-member-directory"),form_id:a,nonce:um_scripts.nonce},success:function(e){"success"===e.status&&""!==t&&(o[t]=e,d(r,e,t)),void 0!==e.debug&&console.log(e),r.um_wait=!1},error:function(e){console.log(e),r.um_wait=!1}})}void 0!==t&&""!==t&&"object"==typeof o[t]&&setTimeout(d,10,r,o[t],t),void 0===t&&""!==t||(r.find('option[value!=""]').remove(),r.val("").trigger("change"))}),jQuery('select[name="'+n+'"]').trigger("change")})});
|
includes/admin/class-admin.php
CHANGED
@@ -1,1980 +1,1980 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\admin;
|
3 |
-
|
4 |
-
// Exit if accessed directly.
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
6 |
-
exit;
|
7 |
-
}
|
8 |
-
|
9 |
-
if ( ! class_exists( 'um\admin\Admin' ) ) {
|
10 |
-
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class Admin
|
14 |
-
* @package um\admin
|
15 |
-
*/
|
16 |
-
class Admin extends Admin_Functions {
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @var string
|
21 |
-
*/
|
22 |
-
public $templates_path;
|
23 |
-
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @var array
|
27 |
-
*/
|
28 |
-
public $role_meta;
|
29 |
-
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @var array
|
33 |
-
*/
|
34 |
-
public $restriction_term_meta;
|
35 |
-
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @var array
|
39 |
-
*/
|
40 |
-
public $member_directory_meta;
|
41 |
-
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @var array
|
45 |
-
*/
|
46 |
-
public $form_meta;
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
* @var array
|
51 |
-
*/
|
52 |
-
public $builder_input;
|
53 |
-
|
54 |
-
|
55 |
-
/**
|
56 |
-
* @var array
|
57 |
-
*/
|
58 |
-
public $restriction_post_meta;
|
59 |
-
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Admin constructor.
|
63 |
-
*/
|
64 |
-
public function __construct() {
|
65 |
-
parent::__construct();
|
66 |
-
|
67 |
-
$this->templates_path = um_path . 'includes/admin/templates/';
|
68 |
-
|
69 |
-
add_action( 'admin_init', array( &$this, 'admin_init' ), 0 );
|
70 |
-
|
71 |
-
$prefix = is_network_admin() ? 'network_admin_' : '';
|
72 |
-
add_filter( "{$prefix}plugin_action_links_" . um_plugin, array( &$this, 'plugin_links' ) );
|
73 |
-
|
74 |
-
add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) );
|
75 |
-
add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) );
|
76 |
-
add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) );
|
77 |
-
add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) );
|
78 |
-
add_action( 'um_admin_do_action__um_hide_locale_notice', array( &$this, 'um_hide_notice' ) );
|
79 |
-
add_action( 'um_admin_do_action__um_can_register_notice', array( &$this, 'um_hide_notice' ) );
|
80 |
-
add_action( 'um_admin_do_action__um_hide_exif_notice', array( &$this, 'um_hide_notice' ) );
|
81 |
-
add_action( 'um_admin_do_action__user_action', array( &$this, 'user_action' ) );
|
82 |
-
|
83 |
-
add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) );
|
84 |
-
|
85 |
-
add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ), 999 );
|
86 |
-
|
87 |
-
add_action( 'parent_file', array( &$this, 'parent_file' ), 9 );
|
88 |
-
add_filter( 'gettext', array( &$this, 'gettext' ), 10, 4 );
|
89 |
-
add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
function init_variables() {
|
94 |
-
$this->role_meta = apply_filters(
|
95 |
-
'um_role_meta_map',
|
96 |
-
array(
|
97 |
-
'_um_priority' => array(
|
98 |
-
'sanitize' => 'int',
|
99 |
-
),
|
100 |
-
'_um_can_access_wpadmin' => array(
|
101 |
-
'sanitize' => 'bool',
|
102 |
-
),
|
103 |
-
'_um_can_not_see_adminbar' => array(
|
104 |
-
'sanitize' => 'bool',
|
105 |
-
),
|
106 |
-
'_um_can_edit_everyone' => array(
|
107 |
-
'sanitize' => 'bool',
|
108 |
-
),
|
109 |
-
'_um_can_edit_roles' => array(
|
110 |
-
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
111 |
-
),
|
112 |
-
'_um_can_delete_everyone' => array(
|
113 |
-
'sanitize' => 'bool',
|
114 |
-
),
|
115 |
-
'_um_can_delete_roles' => array(
|
116 |
-
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
117 |
-
),
|
118 |
-
'_um_can_edit_profile' => array(
|
119 |
-
'sanitize' => 'bool',
|
120 |
-
),
|
121 |
-
'_um_can_delete_profile' => array(
|
122 |
-
'sanitize' => 'bool',
|
123 |
-
),
|
124 |
-
'_um_can_view_all' => array(
|
125 |
-
'sanitize' => 'bool',
|
126 |
-
),
|
127 |
-
'_um_can_view_roles' => array(
|
128 |
-
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
129 |
-
),
|
130 |
-
'_um_can_make_private_profile' => array(
|
131 |
-
'sanitize' => 'bool',
|
132 |
-
),
|
133 |
-
'_um_can_access_private_profile' => array(
|
134 |
-
'sanitize' => 'bool',
|
135 |
-
),
|
136 |
-
'_um_profile_noindex' => array(
|
137 |
-
'sanitize' => array( $this, 'sanitize_profile_noindex' ),
|
138 |
-
),
|
139 |
-
'_um_default_homepage' => array(
|
140 |
-
'sanitize' => 'bool',
|
141 |
-
),
|
142 |
-
'_um_redirect_homepage' => array(
|
143 |
-
'sanitize' => 'url',
|
144 |
-
),
|
145 |
-
'_um_status' => array(
|
146 |
-
'sanitize' => 'sanitize_array_key',
|
147 |
-
'default' => 'approved',
|
148 |
-
'array' => array( 'approved', 'checkmail', 'pending' ),
|
149 |
-
),
|
150 |
-
'_um_auto_approve_act' => array(
|
151 |
-
'sanitize' => 'sanitize_array_key',
|
152 |
-
'default' => 'redirect_profile',
|
153 |
-
'array' => array( 'redirect_profile', 'redirect_url' ),
|
154 |
-
),
|
155 |
-
'_um_auto_approve_url' => array(
|
156 |
-
'sanitize' => 'url',
|
157 |
-
),
|
158 |
-
'_um_login_email_activate' => array(
|
159 |
-
'sanitize' => 'bool',
|
160 |
-
),
|
161 |
-
'_um_checkmail_action' => array(
|
162 |
-
'sanitize' => 'sanitize_array_key',
|
163 |
-
'default' => 'show_message',
|
164 |
-
'array' => array( 'show_message', 'redirect_url' ),
|
165 |
-
),
|
166 |
-
'_um_checkmail_message' => array(
|
167 |
-
'sanitize' => 'textarea',
|
168 |
-
),
|
169 |
-
'_um_checkmail_url' => array(
|
170 |
-
'sanitize' => 'url',
|
171 |
-
),
|
172 |
-
'_um_url_email_activate' => array(
|
173 |
-
'sanitize' => 'url',
|
174 |
-
),
|
175 |
-
'_um_pending_action' => array(
|
176 |
-
'sanitize' => 'sanitize_array_key',
|
177 |
-
'default' => 'show_message',
|
178 |
-
'array' => array( 'show_message', 'redirect_url' ),
|
179 |
-
),
|
180 |
-
'_um_pending_message' => array(
|
181 |
-
'sanitize' => 'textarea',
|
182 |
-
),
|
183 |
-
'_um_pending_url' => array(
|
184 |
-
'sanitize' => 'url',
|
185 |
-
),
|
186 |
-
'_um_after_login' => array(
|
187 |
-
'sanitize' => 'sanitize_array_key',
|
188 |
-
'default' => 'redirect_profile',
|
189 |
-
'array' => array( 'redirect_profile', 'redirect_url', 'refresh', 'redirect_admin' ),
|
190 |
-
),
|
191 |
-
'_um_login_redirect_url' => array(
|
192 |
-
'sanitize' => 'url',
|
193 |
-
),
|
194 |
-
'_um_after_logout' => array(
|
195 |
-
'sanitize' => 'sanitize_array_key',
|
196 |
-
'default' => 'redirect_home',
|
197 |
-
'array' => array( 'redirect_home', 'redirect_url' ),
|
198 |
-
),
|
199 |
-
'_um_logout_redirect_url' => array(
|
200 |
-
'sanitize' => 'url',
|
201 |
-
),
|
202 |
-
'_um_after_delete' => array(
|
203 |
-
'sanitize' => 'sanitize_array_key',
|
204 |
-
'default' => 'redirect_home',
|
205 |
-
'array' => array( 'redirect_home', 'redirect_url' ),
|
206 |
-
),
|
207 |
-
'_um_delete_redirect_url' => array(
|
208 |
-
'sanitize' => 'url',
|
209 |
-
),
|
210 |
-
'wp_capabilities' => array(
|
211 |
-
'sanitize' => array( $this, 'sanitize_wp_capabilities' ),
|
212 |
-
),
|
213 |
-
)
|
214 |
-
);
|
215 |
-
|
216 |
-
$this->restriction_post_meta = apply_filters(
|
217 |
-
'um_restriction_post_meta_map',
|
218 |
-
array(
|
219 |
-
'_um_custom_access_settings' => array(
|
220 |
-
'sanitize' => 'bool',
|
221 |
-
),
|
222 |
-
'_um_accessible' => array(
|
223 |
-
'sanitize' => 'int',
|
224 |
-
),
|
225 |
-
'_um_access_roles' => array(
|
226 |
-
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
227 |
-
),
|
228 |
-
'_um_noaccess_action' => array(
|
229 |
-
'sanitize' => 'int',
|
230 |
-
),
|
231 |
-
'_um_restrict_by_custom_message' => array(
|
232 |
-
'sanitize' => 'int',
|
233 |
-
),
|
234 |
-
'_um_restrict_custom_message' => array(
|
235 |
-
'sanitize' => 'wp_kses',
|
236 |
-
),
|
237 |
-
'_um_access_redirect' => array(
|
238 |
-
'sanitize' => 'int',
|
239 |
-
),
|
240 |
-
'_um_access_redirect_url' => array(
|
241 |
-
'sanitize' => 'url',
|
242 |
-
),
|
243 |
-
'_um_access_hide_from_queries' => array(
|
244 |
-
'sanitize' => 'bool',
|
245 |
-
),
|
246 |
-
)
|
247 |
-
);
|
248 |
-
|
249 |
-
$this->restriction_term_meta = apply_filters(
|
250 |
-
'um_restriction_term_meta_map',
|
251 |
-
array(
|
252 |
-
'_um_custom_access_settings' => array(
|
253 |
-
'sanitize' => 'bool',
|
254 |
-
),
|
255 |
-
'_um_accessible' => array(
|
256 |
-
'sanitize' => 'int',
|
257 |
-
),
|
258 |
-
'_um_access_roles' => array(
|
259 |
-
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
260 |
-
),
|
261 |
-
'_um_noaccess_action' => array(
|
262 |
-
'sanitize' => 'int',
|
263 |
-
),
|
264 |
-
'_um_restrict_by_custom_message' => array(
|
265 |
-
'sanitize' => 'int',
|
266 |
-
),
|
267 |
-
'_um_restrict_custom_message' => array(
|
268 |
-
'sanitize' => 'wp_kses',
|
269 |
-
),
|
270 |
-
'_um_access_redirect' => array(
|
271 |
-
'sanitize' => 'int',
|
272 |
-
),
|
273 |
-
'_um_access_redirect_url' => array(
|
274 |
-
'sanitize' => 'url',
|
275 |
-
),
|
276 |
-
'_um_access_hide_from_queries' => array(
|
277 |
-
'sanitize' => 'bool',
|
278 |
-
),
|
279 |
-
)
|
280 |
-
);
|
281 |
-
|
282 |
-
$this->member_directory_meta = apply_filters(
|
283 |
-
'um_member_directory_meta_map',
|
284 |
-
array(
|
285 |
-
'_um_directory_template' => array(
|
286 |
-
'sanitize' => 'text',
|
287 |
-
),
|
288 |
-
'_um_mode' => array(
|
289 |
-
'sanitize' => 'key',
|
290 |
-
),
|
291 |
-
'_um_view_types' => array(
|
292 |
-
'sanitize' => array( $this, 'sanitize_md_view_types' ),
|
293 |
-
),
|
294 |
-
'_um_default_view' => array(
|
295 |
-
'sanitize' => 'key',
|
296 |
-
),
|
297 |
-
'_um_roles' => array(
|
298 |
-
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
299 |
-
),
|
300 |
-
'_um_has_profile_photo' => array(
|
301 |
-
'sanitize' => 'bool',
|
302 |
-
),
|
303 |
-
'_um_show_these_users' => array(
|
304 |
-
'sanitize' => 'textarea',
|
305 |
-
),
|
306 |
-
'_um_exclude_these_users' => array(
|
307 |
-
'sanitize' => 'textarea',
|
308 |
-
),
|
309 |
-
'_um_must_search' => array(
|
310 |
-
'sanitize' => 'bool',
|
311 |
-
),
|
312 |
-
'_um_max_users' => array(
|
313 |
-
'sanitize' => 'absint',
|
314 |
-
),
|
315 |
-
'_um_profiles_per_page' => array(
|
316 |
-
'sanitize' => 'absint',
|
317 |
-
),
|
318 |
-
'_um_profiles_per_page_mobile' => array(
|
319 |
-
'sanitize' => 'absint',
|
320 |
-
),
|
321 |
-
'_um_directory_header' => array(
|
322 |
-
'sanitize' => 'text',
|
323 |
-
),
|
324 |
-
'_um_directory_header_single' => array(
|
325 |
-
'sanitize' => 'text',
|
326 |
-
),
|
327 |
-
'_um_directory_no_users' => array(
|
328 |
-
'sanitize' => 'text',
|
329 |
-
),
|
330 |
-
'_um_profile_photo' => array(
|
331 |
-
'sanitize' => 'bool',
|
332 |
-
),
|
333 |
-
'_um_cover_photos' => array(
|
334 |
-
'sanitize' => 'bool',
|
335 |
-
),
|
336 |
-
'_um_show_name' => array(
|
337 |
-
'sanitize' => 'bool',
|
338 |
-
),
|
339 |
-
'_um_show_tagline' => array(
|
340 |
-
'sanitize' => 'bool',
|
341 |
-
),
|
342 |
-
'_um_tagline_fields' => array(
|
343 |
-
'sanitize' => array( $this, 'sanitize_user_field' ),
|
344 |
-
),
|
345 |
-
'_um_show_userinfo' => array(
|
346 |
-
'sanitize' => 'bool',
|
347 |
-
),
|
348 |
-
'_um_reveal_fields' => array(
|
349 |
-
'sanitize' => array( $this, 'sanitize_user_field' ),
|
350 |
-
),
|
351 |
-
'_um_show_social' => array(
|
352 |
-
'sanitize' => 'bool',
|
353 |
-
),
|
354 |
-
'_um_userinfo_animate' => array(
|
355 |
-
'sanitize' => 'bool',
|
356 |
-
),
|
357 |
-
'_um_search' => array(
|
358 |
-
'sanitize' => 'bool',
|
359 |
-
),
|
360 |
-
'_um_roles_can_search' => array(
|
361 |
-
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
362 |
-
),
|
363 |
-
'_um_filters' => array(
|
364 |
-
'sanitize' => 'bool',
|
365 |
-
),
|
366 |
-
'_um_roles_can_filter' => array(
|
367 |
-
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
368 |
-
),
|
369 |
-
'_um_search_fields' => array(
|
370 |
-
'sanitize' => array( $this, 'sanitize_filter_fields' ),
|
371 |
-
),
|
372 |
-
'_um_filters_expanded' => array(
|
373 |
-
'sanitize' => 'bool',
|
374 |
-
),
|
375 |
-
'_um_filters_is_collapsible' => array(
|
376 |
-
'sanitize' => 'bool',
|
377 |
-
),
|
378 |
-
'_um_search_filters' => array(
|
379 |
-
'sanitize' => array( $this, 'sanitize_filter_fields' ),
|
380 |
-
),
|
381 |
-
'_um_sortby' => array(
|
382 |
-
'sanitize' => 'text',
|
383 |
-
),
|
384 |
-
'_um_sortby_custom' => array(
|
385 |
-
'sanitize' => 'text',
|
386 |
-
),
|
387 |
-
'_um_sortby_custom_label' => array(
|
388 |
-
'sanitize' => 'text',
|
389 |
-
),
|
390 |
-
'_um_enable_sorting' => array(
|
391 |
-
'sanitize' => 'bool',
|
392 |
-
),
|
393 |
-
'_um_sorting_fields' => array(
|
394 |
-
'sanitize' => array( $this, 'sanitize_md_sorting_fields' ),
|
395 |
-
),
|
396 |
-
)
|
397 |
-
);
|
398 |
-
|
399 |
-
$this->form_meta = apply_filters(
|
400 |
-
'um_form_meta_map',
|
401 |
-
array(
|
402 |
-
'_um_mode' => array(
|
403 |
-
'sanitize' => 'key',
|
404 |
-
),
|
405 |
-
'_um_register_use_gdpr' => array(
|
406 |
-
'sanitize' => 'bool',
|
407 |
-
),
|
408 |
-
'_um_register_use_gdpr_content_id' => array(
|
409 |
-
'sanitize' => 'absint',
|
410 |
-
),
|
411 |
-
'_um_register_use_gdpr_toggle_show' => array(
|
412 |
-
'sanitize' => 'text',
|
413 |
-
),
|
414 |
-
'_um_register_use_gdpr_toggle_hide' => array(
|
415 |
-
'sanitize' => 'text',
|
416 |
-
),
|
417 |
-
'_um_register_use_gdpr_agreement' => array(
|
418 |
-
'sanitize' => 'text',
|
419 |
-
),
|
420 |
-
'_um_register_use_gdpr_error_text' => array(
|
421 |
-
'sanitize' => 'text',
|
422 |
-
),
|
423 |
-
'_um_register_use_custom_settings' => array(
|
424 |
-
'sanitize' => 'bool',
|
425 |
-
),
|
426 |
-
'_um_register_role' => array(
|
427 |
-
'sanitize' => 'key',
|
428 |
-
),
|
429 |
-
'_um_register_template' => array(
|
430 |
-
'sanitize' => 'text',
|
431 |
-
),
|
432 |
-
'_um_register_max_width' => array(
|
433 |
-
'sanitize' => 'text',
|
434 |
-
),
|
435 |
-
'_um_register_icons' => array(
|
436 |
-
'sanitize' => 'key',
|
437 |
-
),
|
438 |
-
'_um_register_primary_btn_word' => array(
|
439 |
-
'sanitize' => 'text',
|
440 |
-
),
|
441 |
-
'_um_register_secondary_btn' => array(
|
442 |
-
'sanitize' => 'bool',
|
443 |
-
),
|
444 |
-
'_um_register_secondary_btn_word' => array(
|
445 |
-
'sanitize' => 'text',
|
446 |
-
),
|
447 |
-
'_um_login_after_login' => array(
|
448 |
-
'sanitize' => 'key',
|
449 |
-
),
|
450 |
-
'_um_login_redirect_url' => array(
|
451 |
-
'sanitize' => 'url',
|
452 |
-
),
|
453 |
-
'_um_login_use_custom_settings' => array(
|
454 |
-
'sanitize' => 'bool',
|
455 |
-
),
|
456 |
-
'_um_login_template' => array(
|
457 |
-
'sanitize' => 'text',
|
458 |
-
),
|
459 |
-
'_um_login_max_width' => array(
|
460 |
-
'sanitize' => 'text',
|
461 |
-
),
|
462 |
-
'_um_login_icons' => array(
|
463 |
-
'sanitize' => 'key',
|
464 |
-
),
|
465 |
-
'_um_login_primary_btn_word' => array(
|
466 |
-
'sanitize' => 'text',
|
467 |
-
),
|
468 |
-
'_um_login_secondary_btn' => array(
|
469 |
-
'sanitize' => 'bool',
|
470 |
-
),
|
471 |
-
'_um_login_secondary_btn_word' => array(
|
472 |
-
'sanitize' => 'text',
|
473 |
-
),
|
474 |
-
'_um_login_forgot_pass_link' => array(
|
475 |
-
'sanitize' => 'bool',
|
476 |
-
),
|
477 |
-
'_um_login_show_rememberme' => array(
|
478 |
-
'sanitize' => 'bool',
|
479 |
-
),
|
480 |
-
'_um_profile_metafields' => array(
|
481 |
-
'sanitize' => array( $this, 'sanitize_user_field' ),
|
482 |
-
),
|
483 |
-
'_um_profile_use_custom_settings' => array(
|
484 |
-
'sanitize' => 'bool',
|
485 |
-
),
|
486 |
-
'_um_profile_role' => array(
|
487 |
-
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
488 |
-
),
|
489 |
-
'_um_profile_template' => array(
|
490 |
-
'sanitize' => 'text',
|
491 |
-
),
|
492 |
-
'_um_profile_max_width' => array(
|
493 |
-
'sanitize' => 'text',
|
494 |
-
),
|
495 |
-
'_um_profile_area_max_width' => array(
|
496 |
-
'sanitize' => 'text',
|
497 |
-
),
|
498 |
-
'_um_profile_icons' => array(
|
499 |
-
'sanitize' => 'key',
|
500 |
-
),
|
501 |
-
'_um_profile_primary_btn_word' => array(
|
502 |
-
'sanitize' => 'text',
|
503 |
-
),
|
504 |
-
'_um_profile_secondary_btn' => array(
|
505 |
-
'sanitize' => 'bool',
|
506 |
-
),
|
507 |
-
'_um_profile_secondary_btn_word' => array(
|
508 |
-
'sanitize' => 'text',
|
509 |
-
),
|
510 |
-
'_um_profile_cover_enabled' => array(
|
511 |
-
'sanitize' => 'bool',
|
512 |
-
),
|
513 |
-
'_um_profile_coversize' => array(
|
514 |
-
'sanitize' => 'absint',
|
515 |
-
),
|
516 |
-
'_um_profile_cover_ratio' => array(
|
517 |
-
'sanitize' => 'text',
|
518 |
-
),
|
519 |
-
'_um_profile_disable_photo_upload' => array(
|
520 |
-
'sanitize' => 'bool',
|
521 |
-
),
|
522 |
-
'_um_profile_photosize' => array(
|
523 |
-
'sanitize' => array( $this, 'sanitize_photosize' ),
|
524 |
-
),
|
525 |
-
'_um_profile_photo_required' => array(
|
526 |
-
'sanitize' => 'bool',
|
527 |
-
),
|
528 |
-
'_um_profile_show_name' => array(
|
529 |
-
'sanitize' => 'bool',
|
530 |
-
),
|
531 |
-
'_um_profile_show_social_links' => array(
|
532 |
-
'sanitize' => 'bool',
|
533 |
-
),
|
534 |
-
'_um_profile_show_bio' => array(
|
535 |
-
'sanitize' => 'bool',
|
536 |
-
),
|
537 |
-
|
538 |
-
)
|
539 |
-
);
|
540 |
-
|
541 |
-
$this->builder_input = apply_filters(
|
542 |
-
'um_builder_input_map',
|
543 |
-
array(
|
544 |
-
'_in_row' => array(
|
545 |
-
'sanitize' => 'key',
|
546 |
-
),
|
547 |
-
'_in_sub_row' => array(
|
548 |
-
'sanitize' => 'absint',
|
549 |
-
),
|
550 |
-
'_in_column' => array(
|
551 |
-
'sanitize' => 'absint',
|
552 |
-
),
|
553 |
-
'_in_group' => array(
|
554 |
-
'sanitize' => 'absint',
|
555 |
-
),
|
556 |
-
'_visibility' => array(
|
557 |
-
'sanitize' => 'key',
|
558 |
-
),
|
559 |
-
'_conditional_action' => array(
|
560 |
-
'sanitize' => 'key',
|
561 |
-
),
|
562 |
-
'_conditional_action1' => array(
|
563 |
-
'sanitize' => 'key',
|
564 |
-
),
|
565 |
-
'_conditional_action2' => array(
|
566 |
-
'sanitize' => 'key',
|
567 |
-
),
|
568 |
-
'_conditional_action3' => array(
|
569 |
-
'sanitize' => 'key',
|
570 |
-
),
|
571 |
-
'_conditional_action4' => array(
|
572 |
-
'sanitize' => 'key',
|
573 |
-
),
|
574 |
-
'_conditional_field' => array(
|
575 |
-
'sanitize' => 'text',
|
576 |
-
),
|
577 |
-
'_conditional_field1' => array(
|
578 |
-
'sanitize' => 'text',
|
579 |
-
),
|
580 |
-
'_conditional_field2' => array(
|
581 |
-
'sanitize' => 'text',
|
582 |
-
),
|
583 |
-
'_conditional_field3' => array(
|
584 |
-
'sanitize' => 'text',
|
585 |
-
),
|
586 |
-
'_conditional_field4' => array(
|
587 |
-
'sanitize' => 'text',
|
588 |
-
),
|
589 |
-
'_conditional_operator' => array(
|
590 |
-
'sanitize' => 'text',
|
591 |
-
),
|
592 |
-
'_conditional_operator1' => array(
|
593 |
-
'sanitize' => 'text',
|
594 |
-
),
|
595 |
-
'_conditional_operator2' => array(
|
596 |
-
'sanitize' => 'text',
|
597 |
-
),
|
598 |
-
'_conditional_operator3' => array(
|
599 |
-
'sanitize' => 'text',
|
600 |
-
),
|
601 |
-
'_conditional_operator4' => array(
|
602 |
-
'sanitize' => 'text',
|
603 |
-
),
|
604 |
-
'_conditional_value' => array(
|
605 |
-
'sanitize' => 'text',
|
606 |
-
),
|
607 |
-
'_conditional_value1' => array(
|
608 |
-
'sanitize' => 'text',
|
609 |
-
),
|
610 |
-
'_conditional_value2' => array(
|
611 |
-
'sanitize' => 'text',
|
612 |
-
),
|
613 |
-
'_conditional_value3' => array(
|
614 |
-
'sanitize' => 'text',
|
615 |
-
),
|
616 |
-
'_conditional_value4' => array(
|
617 |
-
'sanitize' => 'text',
|
618 |
-
),
|
619 |
-
'_validate' => array(
|
620 |
-
'sanitize' => 'key',
|
621 |
-
),
|
622 |
-
'_custom_validate' => array(
|
623 |
-
'sanitize' => 'text',
|
624 |
-
),
|
625 |
-
'_icon' => array(
|
626 |
-
'sanitize' => 'key',
|
627 |
-
),
|
628 |
-
'_css_class' => array(
|
629 |
-
'sanitize' => 'text',
|
630 |
-
),
|
631 |
-
'_width' => array(
|
632 |
-
'sanitize' => 'absint',
|
633 |
-
),
|
634 |
-
'_divider_text' => array(
|
635 |
-
'sanitize' => 'text',
|
636 |
-
),
|
637 |
-
'_padding' => array(
|
638 |
-
'sanitize' => 'text',
|
639 |
-
),
|
640 |
-
'_margin' => array(
|
641 |
-
'sanitize' => 'text',
|
642 |
-
),
|
643 |
-
'_border' => array(
|
644 |
-
'sanitize' => 'text',
|
645 |
-
),
|
646 |
-
'_borderstyle' => array(
|
647 |
-
'sanitize' => 'key',
|
648 |
-
),
|
649 |
-
'_borderradius' => array(
|
650 |
-
'sanitize' => 'text',
|
651 |
-
),
|
652 |
-
'_bordercolor' => array(
|
653 |
-
'sanitize' => 'text',
|
654 |
-
),
|
655 |
-
'_heading' => array(
|
656 |
-
'sanitize' => 'bool',
|
657 |
-
),
|
658 |
-
'_heading_text' => array(
|
659 |
-
'sanitize' => 'text',
|
660 |
-
),
|
661 |
-
'_background' => array(
|
662 |
-
'sanitize' => 'text',
|
663 |
-
),
|
664 |
-
'_heading_background_color' => array(
|
665 |
-
'sanitize' => 'text',
|
666 |
-
),
|
667 |
-
'_heading_text_color' => array(
|
668 |
-
'sanitize' => 'text',
|
669 |
-
),
|
670 |
-
'_text_color' => array(
|
671 |
-
'sanitize' => 'text',
|
672 |
-
),
|
673 |
-
'_icon_color' => array(
|
674 |
-
'sanitize' => 'text',
|
675 |
-
),
|
676 |
-
'_color' => array(
|
677 |
-
'sanitize' => 'text',
|
678 |
-
),
|
679 |
-
'_url_text' => array(
|
680 |
-
'sanitize' => 'text',
|
681 |
-
),
|
682 |
-
'_url_target' => array(
|
683 |
-
'sanitize' => 'key',
|
684 |
-
),
|
685 |
-
'_url_rel' => array(
|
686 |
-
'sanitize' => 'key',
|
687 |
-
),
|
688 |
-
'_force_good_pass' => array(
|
689 |
-
'sanitize' => 'bool',
|
690 |
-
),
|
691 |
-
'_force_confirm_pass' => array(
|
692 |
-
'sanitize' => 'bool',
|
693 |
-
),
|
694 |
-
'_style' => array(
|
695 |
-
'sanitize' => 'key',
|
696 |
-
),
|
697 |
-
'_intervals' => array(
|
698 |
-
'sanitize' => 'absint',
|
699 |
-
),
|
700 |
-
'_format' => array(
|
701 |
-
'sanitize' => 'text',
|
702 |
-
),
|
703 |
-
'_format_custom' => array(
|
704 |
-
'sanitize' => 'text',
|
705 |
-
),
|
706 |
-
'_pretty_format' => array(
|
707 |
-
'sanitize' => 'bool',
|
708 |
-
),
|
709 |
-
'_disabled_weekdays' => array(
|
710 |
-
'sanitize' => 'absint',
|
711 |
-
),
|
712 |
-
'_years' => array(
|
713 |
-
'sanitize' => 'absint',
|
714 |
-
),
|
715 |
-
'_years_x' => array(
|
716 |
-
'sanitize' => 'key',
|
717 |
-
),
|
718 |
-
'_range_start' => array(
|
719 |
-
'sanitize' => 'text',
|
720 |
-
),
|
721 |
-
'_range_end' => array(
|
722 |
-
'sanitize' => 'text',
|
723 |
-
),
|
724 |
-
'_range' => array(
|
725 |
-
'sanitize' => 'key',
|
726 |
-
),
|
727 |
-
'_content' => array(
|
728 |
-
'sanitize' => 'textarea',
|
729 |
-
),
|
730 |
-
'_crop' => array(
|
731 |
-
'sanitize' => 'int',
|
732 |
-
),
|
733 |
-
'_allowed_types' => array(
|
734 |
-
'sanitize' => 'key',
|
735 |
-
),
|
736 |
-
'_upload_text' => array(
|
737 |
-
'sanitize' => 'text',
|
738 |
-
),
|
739 |
-
'_upload_help_text' => array(
|
740 |
-
'sanitize' => 'text',
|
741 |
-
),
|
742 |
-
'_button_text' => array(
|
743 |
-
'sanitize' => 'text',
|
744 |
-
),
|
745 |
-
'_max_size' => array(
|
746 |
-
'sanitize' => 'absint',
|
747 |
-
),
|
748 |
-
'_height' => array(
|
749 |
-
'sanitize' => 'text',
|
750 |
-
),
|
751 |
-
'_spacing' => array(
|
752 |
-
'sanitize' => 'text',
|
753 |
-
),
|
754 |
-
'_is_multi' => array(
|
755 |
-
'sanitize' => 'bool',
|
756 |
-
),
|
757 |
-
'_max_selections' => array(
|
758 |
-
'sanitize' => 'absint',
|
759 |
-
),
|
760 |
-
'_min_selections' => array(
|
761 |
-
'sanitize' => 'absint',
|
762 |
-
),
|
763 |
-
'_max_entries' => array(
|
764 |
-
'sanitize' => 'absint',
|
765 |
-
),
|
766 |
-
'_max_words' => array(
|
767 |
-
'sanitize' => 'absint',
|
768 |
-
),
|
769 |
-
'_min' => array(
|
770 |
-
'sanitize' => 'empty_int',
|
771 |
-
),
|
772 |
-
'_max' => array(
|
773 |
-
'sanitize' => 'empty_int',
|
774 |
-
),
|
775 |
-
'_min_chars' => array(
|
776 |
-
'sanitize' => 'absint',
|
777 |
-
),
|
778 |
-
'_max_chars' => array(
|
779 |
-
'sanitize' => 'absint',
|
780 |
-
),
|
781 |
-
'_html' => array(
|
782 |
-
'sanitize' => 'bool',
|
783 |
-
),
|
784 |
-
'_options' => array(
|
785 |
-
'sanitize' => 'textarea',
|
786 |
-
),
|
787 |
-
'_title' => array(
|
788 |
-
'sanitize' => 'text',
|
789 |
-
),
|
790 |
-
'_id' => array(
|
791 |
-
'sanitize' => 'text',
|
792 |
-
),
|
793 |
-
'_metakey' => array(
|
794 |
-
'sanitize' => 'text',
|
795 |
-
),
|
796 |
-
'_help' => array(
|
797 |
-
'sanitize' => 'text',
|
798 |
-
),
|
799 |
-
'_default' => array(
|
800 |
-
'sanitize' => 'text',
|
801 |
-
),
|
802 |
-
'_label' => array(
|
803 |
-
'sanitize' => 'text',
|
804 |
-
),
|
805 |
-
'_label_confirm_pass' => array(
|
806 |
-
'sanitize' => 'text',
|
807 |
-
),
|
808 |
-
'_placeholder' => array(
|
809 |
-
'sanitize' => 'text',
|
810 |
-
),
|
811 |
-
'_public' => array(
|
812 |
-
'sanitize' => 'text',
|
813 |
-
),
|
814 |
-
'_roles' => array(
|
815 |
-
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
816 |
-
),
|
817 |
-
'_required' => array(
|
818 |
-
'sanitize' => 'bool',
|
819 |
-
),
|
820 |
-
'_editable' => array(
|
821 |
-
'sanitize' => 'bool',
|
822 |
-
),
|
823 |
-
'_number' => array(
|
824 |
-
'sanitize' => 'absint',
|
825 |
-
),
|
826 |
-
'_custom_dropdown_options_source' => array(
|
827 |
-
'sanitize' => 'text',
|
828 |
-
),
|
829 |
-
'_parent_dropdown_relationship' => array(
|
830 |
-
'sanitize' => 'text',
|
831 |
-
),
|
832 |
-
)
|
833 |
-
);
|
834 |
-
}
|
835 |
-
|
836 |
-
|
837 |
-
/**
|
838 |
-
* @param array|string $value
|
839 |
-
*
|
840 |
-
* @return array|string
|
841 |
-
*/
|
842 |
-
public function sanitize_md_sorting_fields( $value ) {
|
843 |
-
$filter_fields = array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) );
|
844 |
-
$filter_fields = array_keys( $filter_fields );
|
845 |
-
|
846 |
-
if ( '' !== $value ) {
|
847 |
-
$value = array_filter(
|
848 |
-
$value,
|
849 |
-
function( $v, $k ) use ( $filter_fields ) {
|
850 |
-
if ( 'other_data' === $k ) {
|
851 |
-
return true;
|
852 |
-
} else {
|
853 |
-
return in_array( sanitize_text_field( $v ), $filter_fields, true );
|
854 |
-
}
|
855 |
-
},
|
856 |
-
ARRAY_FILTER_USE_BOTH
|
857 |
-
);
|
858 |
-
|
859 |
-
$value = array_map(
|
860 |
-
function( $item ) {
|
861 |
-
if ( is_array( $item ) ) {
|
862 |
-
if ( isset( $item['meta_key'] ) ) {
|
863 |
-
$item['meta_key'] = sanitize_text_field( $item['meta_key'] );
|
864 |
-
}
|
865 |
-
if ( isset( $item['label'] ) ) {
|
866 |
-
$item['label'] = sanitize_text_field( $item['label'] );
|
867 |
-
}
|
868 |
-
|
869 |
-
return $item;
|
870 |
-
} else {
|
871 |
-
return sanitize_text_field( $item );
|
872 |
-
}
|
873 |
-
},
|
874 |
-
$value
|
875 |
-
);
|
876 |
-
}
|
877 |
-
|
878 |
-
return $value;
|
879 |
-
}
|
880 |
-
|
881 |
-
|
882 |
-
/**
|
883 |
-
* @param array|string $value
|
884 |
-
*
|
885 |
-
* @return array|string
|
886 |
-
*/
|
887 |
-
public function sanitize_filter_fields( $value ) {
|
888 |
-
$filter_fields = array_keys( UM()->member_directory()->filter_fields );
|
889 |
-
|
890 |
-
if ( '' !== $value ) {
|
891 |
-
$value = array_filter(
|
892 |
-
$value,
|
893 |
-
function( $v, $k ) use ( $filter_fields ) {
|
894 |
-
return in_array( sanitize_text_field( $v ), $filter_fields, true );
|
895 |
-
},
|
896 |
-
ARRAY_FILTER_USE_BOTH
|
897 |
-
);
|
898 |
-
|
899 |
-
$value = array_map( 'sanitize_text_field', $value );
|
900 |
-
}
|
901 |
-
|
902 |
-
return $value;
|
903 |
-
}
|
904 |
-
|
905 |
-
|
906 |
-
/**
|
907 |
-
* @param array|string $value
|
908 |
-
*
|
909 |
-
* @return array|string
|
910 |
-
*/
|
911 |
-
public function sanitize_user_field( $value ) {
|
912 |
-
$user_fields = array_keys( UM()->builtin()->all_user_fields() );
|
913 |
-
|
914 |
-
if ( '' !== $value ) {
|
915 |
-
$value = array_filter(
|
916 |
-
$value,
|
917 |
-
function( $v, $k ) use ( $user_fields ) {
|
918 |
-
return in_array( sanitize_text_field( $v ), $user_fields, true );
|
919 |
-
},
|
920 |
-
ARRAY_FILTER_USE_BOTH
|
921 |
-
);
|
922 |
-
|
923 |
-
$value = array_map( 'sanitize_text_field', $value );
|
924 |
-
}
|
925 |
-
|
926 |
-
return $value;
|
927 |
-
}
|
928 |
-
|
929 |
-
|
930 |
-
/**
|
931 |
-
* @param array|string $value
|
932 |
-
*
|
933 |
-
* @return array|string
|
934 |
-
*/
|
935 |
-
public function sanitize_md_view_types( $value ) {
|
936 |
-
$view_types = array_map(
|
937 |
-
function ( $item ) {
|
938 |
-
return $item['title'];
|
939 |
-
},
|
940 |
-
UM()->member_directory()->view_types
|
941 |
-
);
|
942 |
-
$view_types = array_keys( $view_types );
|
943 |
-
|
944 |
-
if ( '' !== $value ) {
|
945 |
-
$value = array_filter(
|
946 |
-
$value,
|
947 |
-
function( $v, $k ) use ( $view_types ) {
|
948 |
-
return in_array( sanitize_key( $k ), $view_types, true ) && 1 === (int) $v;
|
949 |
-
},
|
950 |
-
ARRAY_FILTER_USE_BOTH
|
951 |
-
);
|
952 |
-
|
953 |
-
$value = array_map( 'sanitize_key', $value );
|
954 |
-
}
|
955 |
-
|
956 |
-
return $value;
|
957 |
-
}
|
958 |
-
|
959 |
-
|
960 |
-
/**
|
961 |
-
* @param array|string $value
|
962 |
-
*
|
963 |
-
* @return array|string
|
964 |
-
*/
|
965 |
-
public function sanitize_photosize( $value ) {
|
966 |
-
$sizes = UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' );
|
967 |
-
$sizes = array_keys( $sizes );
|
968 |
-
|
969 |
-
if ( '' !== $value ) {
|
970 |
-
$value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
|
971 |
-
}
|
972 |
-
|
973 |
-
return $value;
|
974 |
-
}
|
975 |
-
|
976 |
-
|
977 |
-
/**
|
978 |
-
* @param array|string $value
|
979 |
-
*
|
980 |
-
* @return array|string
|
981 |
-
*/
|
982 |
-
public function sanitize_cover_photosize( $value ) {
|
983 |
-
$sizes = UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' );
|
984 |
-
$sizes = array_keys( $sizes );
|
985 |
-
|
986 |
-
if ( '' !== $value ) {
|
987 |
-
$value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
|
988 |
-
}
|
989 |
-
|
990 |
-
return $value;
|
991 |
-
}
|
992 |
-
|
993 |
-
|
994 |
-
/**
|
995 |
-
* @param array|string $value
|
996 |
-
*
|
997 |
-
* @return array|string
|
998 |
-
*/
|
999 |
-
public function sanitize_restriction_existed_role( $value ) {
|
1000 |
-
$all_roles = array_keys( UM()->roles()->get_roles() );
|
1001 |
-
|
1002 |
-
if ( '' !== $value ) {
|
1003 |
-
$value = array_filter(
|
1004 |
-
$value,
|
1005 |
-
function( $v, $k ) use ( $all_roles ) {
|
1006 |
-
return in_array( sanitize_key( $k ), $all_roles, true ) && 1 === (int) $v;
|
1007 |
-
},
|
1008 |
-
ARRAY_FILTER_USE_BOTH
|
1009 |
-
);
|
1010 |
-
|
1011 |
-
$value = array_map( 'sanitize_key', $value );
|
1012 |
-
}
|
1013 |
-
|
1014 |
-
return $value;
|
1015 |
-
}
|
1016 |
-
|
1017 |
-
|
1018 |
-
/**
|
1019 |
-
* @param array|string $value
|
1020 |
-
*
|
1021 |
-
* @return array|string
|
1022 |
-
*/
|
1023 |
-
public function sanitize_existed_role( $value ) {
|
1024 |
-
$all_roles = array_keys( UM()->roles()->get_roles() );
|
1025 |
-
|
1026 |
-
if ( '' !== $value ) {
|
1027 |
-
$value = array_filter(
|
1028 |
-
$value,
|
1029 |
-
function( $v, $k ) use ( $all_roles ) {
|
1030 |
-
return in_array( sanitize_key( $v ), $all_roles, true );
|
1031 |
-
},
|
1032 |
-
ARRAY_FILTER_USE_BOTH
|
1033 |
-
);
|
1034 |
-
|
1035 |
-
$value = array_map( 'sanitize_key', $value );
|
1036 |
-
}
|
1037 |
-
|
1038 |
-
return $value;
|
1039 |
-
}
|
1040 |
-
|
1041 |
-
|
1042 |
-
/**
|
1043 |
-
* @param array|string $value
|
1044 |
-
*
|
1045 |
-
* @return array|string
|
1046 |
-
*/
|
1047 |
-
public function sanitize_tabs_privacy( $value ) {
|
1048 |
-
$all_privacy = array_keys( UM()->profile()->tabs_privacy() );
|
1049 |
-
|
1050 |
-
if ( '' !== $value ) {
|
1051 |
-
$value = in_array( absint( $value ), $all_privacy, true ) ? absint( $value ) : '';
|
1052 |
-
}
|
1053 |
-
|
1054 |
-
return $value;
|
1055 |
-
}
|
1056 |
-
|
1057 |
-
|
1058 |
-
/**
|
1059 |
-
* @param $value
|
1060 |
-
*
|
1061 |
-
* @return bool|string
|
1062 |
-
*/
|
1063 |
-
public function sanitize_profile_noindex( $value ) {
|
1064 |
-
$value = '' !== $value ? (bool) $value : $value;
|
1065 |
-
return $value;
|
1066 |
-
}
|
1067 |
-
|
1068 |
-
|
1069 |
-
/**
|
1070 |
-
* @param $value
|
1071 |
-
*
|
1072 |
-
* @return array
|
1073 |
-
*/
|
1074 |
-
public function sanitize_wp_capabilities( $value ) {
|
1075 |
-
$value = array_map( 'boolval', array_filter( $value ) );
|
1076 |
-
return $value;
|
1077 |
-
}
|
1078 |
-
|
1079 |
-
|
1080 |
-
/**
|
1081 |
-
* Sanitize role meta fields when wp-admin form has been submitted
|
1082 |
-
*
|
1083 |
-
* @param array $data
|
1084 |
-
*
|
1085 |
-
* @return array
|
1086 |
-
*/
|
1087 |
-
public function sanitize_role_meta( $data ) {
|
1088 |
-
$sanitized = array();
|
1089 |
-
foreach ( $data as $k => $v ) {
|
1090 |
-
if ( ! array_key_exists( $k, $this->role_meta ) ) {
|
1091 |
-
// @todo remove since 2.2.x and leave only continue
|
1092 |
-
$sanitized[ $k ] = $v;
|
1093 |
-
continue;
|
1094 |
-
}
|
1095 |
-
|
1096 |
-
if ( ! array_key_exists( 'sanitize', $this->role_meta[ $k ] ) ) {
|
1097 |
-
// @todo remove since 2.2.x and leave only continue
|
1098 |
-
$sanitized[ $k ] = $v;
|
1099 |
-
continue;
|
1100 |
-
}
|
1101 |
-
|
1102 |
-
if ( is_callable( $this->role_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1103 |
-
add_filter( 'um_role_meta_sanitize_' . $k, $this->role_meta[ $k ]['sanitize'], 10, 1 );
|
1104 |
-
}
|
1105 |
-
|
1106 |
-
switch ( $this->role_meta[ $k ]['sanitize'] ) {
|
1107 |
-
default:
|
1108 |
-
$sanitized[ $k ] = apply_filters( 'um_role_meta_sanitize_' . $k, $data[ $k ] );
|
1109 |
-
break;
|
1110 |
-
case 'int':
|
1111 |
-
$sanitized[ $k ] = (int) $v;
|
1112 |
-
break;
|
1113 |
-
case 'bool':
|
1114 |
-
$sanitized[ $k ] = (bool) $v;
|
1115 |
-
break;
|
1116 |
-
case 'url':
|
1117 |
-
$sanitized[ $k ] = esc_url_raw( $v );
|
1118 |
-
break;
|
1119 |
-
case 'textarea':
|
1120 |
-
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1121 |
-
break;
|
1122 |
-
case 'sanitize_array_key':
|
1123 |
-
if ( ! array_key_exists( 'default', $this->role_meta[ $k ] ) || ! array_key_exists( 'array', $this->role_meta[ $k ] ) ) {
|
1124 |
-
continue 2;
|
1125 |
-
}
|
1126 |
-
|
1127 |
-
$sanitized[ $k ] = ! in_array( sanitize_key( $v ), $this->role_meta[ $k ]['array'], true ) ? $this->role_meta[ $k ]['default'] : sanitize_key( $v );
|
1128 |
-
break;
|
1129 |
-
}
|
1130 |
-
}
|
1131 |
-
|
1132 |
-
$data = $sanitized;
|
1133 |
-
|
1134 |
-
$data = apply_filters( 'um_save_role_meta_sanitize', $data );
|
1135 |
-
|
1136 |
-
return $data;
|
1137 |
-
}
|
1138 |
-
|
1139 |
-
|
1140 |
-
/**
|
1141 |
-
* Sanitize post restriction meta fields when wp-admin form has been submitted
|
1142 |
-
*
|
1143 |
-
* @param array $data
|
1144 |
-
*
|
1145 |
-
* @return array
|
1146 |
-
*/
|
1147 |
-
public function sanitize_post_restriction_meta( $data ) {
|
1148 |
-
$sanitized = array();
|
1149 |
-
foreach ( $data as $k => $v ) {
|
1150 |
-
if ( ! array_key_exists( $k, $this->restriction_post_meta ) ) {
|
1151 |
-
// @todo remove since 2.2.x and leave only continue
|
1152 |
-
$sanitized[ $k ] = $v;
|
1153 |
-
continue;
|
1154 |
-
}
|
1155 |
-
|
1156 |
-
if ( ! array_key_exists( 'sanitize', $this->restriction_post_meta[ $k ] ) ) {
|
1157 |
-
// @todo remove since 2.2.x and leave only continue
|
1158 |
-
$sanitized[ $k ] = $v;
|
1159 |
-
continue;
|
1160 |
-
}
|
1161 |
-
|
1162 |
-
if ( is_callable( $this->restriction_post_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1163 |
-
add_filter( 'um_restriction_post_meta_sanitize_' . $k, $this->restriction_post_meta[ $k ]['sanitize'], 10, 1 );
|
1164 |
-
}
|
1165 |
-
|
1166 |
-
switch ( $this->restriction_post_meta[ $k ]['sanitize'] ) {
|
1167 |
-
default:
|
1168 |
-
$sanitized[ $k ] = apply_filters( 'um_restriction_post_meta_sanitize_' . $k, $data[ $k ] );
|
1169 |
-
break;
|
1170 |
-
case 'int':
|
1171 |
-
$sanitized[ $k ] = (int) $v;
|
1172 |
-
break;
|
1173 |
-
case 'bool':
|
1174 |
-
$sanitized[ $k ] = (bool) $v;
|
1175 |
-
break;
|
1176 |
-
case 'url':
|
1177 |
-
$sanitized[ $k ] = esc_url_raw( $v );
|
1178 |
-
break;
|
1179 |
-
case 'textarea':
|
1180 |
-
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1181 |
-
break;
|
1182 |
-
case 'wp_kses':
|
1183 |
-
$sanitized[ $k ] = wp_kses_post( $v );
|
1184 |
-
break;
|
1185 |
-
}
|
1186 |
-
}
|
1187 |
-
|
1188 |
-
$data = $sanitized;
|
1189 |
-
|
1190 |
-
$data = apply_filters( 'um_save_restriction_post_meta_sanitize', $data );
|
1191 |
-
|
1192 |
-
return $data;
|
1193 |
-
}
|
1194 |
-
|
1195 |
-
|
1196 |
-
/**
|
1197 |
-
* Sanitize term restriction meta fields when wp-admin form has been submitted
|
1198 |
-
*
|
1199 |
-
* @param array $data
|
1200 |
-
*
|
1201 |
-
* @return array
|
1202 |
-
*/
|
1203 |
-
public function sanitize_term_restriction_meta( $data ) {
|
1204 |
-
$sanitized = array();
|
1205 |
-
foreach ( $data as $k => $v ) {
|
1206 |
-
if ( ! array_key_exists( $k, $this->restriction_term_meta ) ) {
|
1207 |
-
// @todo remove since 2.2.x and leave only continue
|
1208 |
-
$sanitized[ $k ] = $v;
|
1209 |
-
continue;
|
1210 |
-
}
|
1211 |
-
|
1212 |
-
if ( ! array_key_exists( 'sanitize', $this->restriction_term_meta[ $k ] ) ) {
|
1213 |
-
// @todo remove since 2.2.x and leave only continue
|
1214 |
-
$sanitized[ $k ] = $v;
|
1215 |
-
continue;
|
1216 |
-
}
|
1217 |
-
|
1218 |
-
if ( is_callable( $this->restriction_term_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1219 |
-
add_filter( 'um_restriction_term_meta_sanitize_' . $k, $this->restriction_term_meta[ $k ]['sanitize'], 10, 1 );
|
1220 |
-
}
|
1221 |
-
|
1222 |
-
switch ( $this->restriction_term_meta[ $k ]['sanitize'] ) {
|
1223 |
-
default:
|
1224 |
-
$sanitized[ $k ] = apply_filters( 'um_restriction_term_meta_sanitize_' . $k, $data[ $k ] );
|
1225 |
-
break;
|
1226 |
-
case 'int':
|
1227 |
-
$sanitized[ $k ] = (int) $v;
|
1228 |
-
break;
|
1229 |
-
case 'bool':
|
1230 |
-
$sanitized[ $k ] = (bool) $v;
|
1231 |
-
break;
|
1232 |
-
case 'url':
|
1233 |
-
$sanitized[ $k ] = esc_url_raw( $v );
|
1234 |
-
break;
|
1235 |
-
case 'textarea':
|
1236 |
-
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1237 |
-
break;
|
1238 |
-
case 'wp_kses':
|
1239 |
-
$sanitized[ $k ] = wp_kses_post( $v );
|
1240 |
-
break;
|
1241 |
-
}
|
1242 |
-
}
|
1243 |
-
|
1244 |
-
$data = $sanitized;
|
1245 |
-
|
1246 |
-
$data = apply_filters( 'um_save_restriction_term_meta_sanitize', $data );
|
1247 |
-
|
1248 |
-
return $data;
|
1249 |
-
}
|
1250 |
-
|
1251 |
-
|
1252 |
-
/**
|
1253 |
-
* Sanitize member directory meta when wp-admin form has been submitted
|
1254 |
-
*
|
1255 |
-
* @todo checking all sanitize types
|
1256 |
-
*
|
1257 |
-
* @param array $data
|
1258 |
-
*
|
1259 |
-
* @return array
|
1260 |
-
*/
|
1261 |
-
public function sanitize_member_directory_meta( $data ) {
|
1262 |
-
$sanitized = array();
|
1263 |
-
foreach ( $data as $k => $v ) {
|
1264 |
-
if ( ! array_key_exists( $k, $this->member_directory_meta ) ) {
|
1265 |
-
// @todo remove since 2.2.x and leave only continue
|
1266 |
-
$sanitized[ $k ] = $v;
|
1267 |
-
continue;
|
1268 |
-
}
|
1269 |
-
|
1270 |
-
if ( ! array_key_exists( 'sanitize', $this->member_directory_meta[ $k ] ) ) {
|
1271 |
-
// @todo remove since 2.2.x and leave only continue
|
1272 |
-
$sanitized[ $k ] = $v;
|
1273 |
-
continue;
|
1274 |
-
}
|
1275 |
-
|
1276 |
-
if ( is_callable( $this->member_directory_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1277 |
-
add_filter( 'um_member_directory_meta_sanitize_' . $k, $this->member_directory_meta[ $k ]['sanitize'], 10, 1 );
|
1278 |
-
}
|
1279 |
-
|
1280 |
-
switch ( $this->member_directory_meta[ $k ]['sanitize'] ) {
|
1281 |
-
default:
|
1282 |
-
$sanitized[ $k ] = apply_filters( 'um_member_directory_meta_sanitize_' . $k, $data[ $k ] );
|
1283 |
-
break;
|
1284 |
-
case 'int':
|
1285 |
-
$sanitized[ $k ] = (int) $v;
|
1286 |
-
break;
|
1287 |
-
case 'bool':
|
1288 |
-
$sanitized[ $k ] = (bool) $v;
|
1289 |
-
break;
|
1290 |
-
case 'url':
|
1291 |
-
if ( is_array( $v ) ) {
|
1292 |
-
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1293 |
-
} else {
|
1294 |
-
$sanitized[ $k ] = esc_url_raw( $v );
|
1295 |
-
}
|
1296 |
-
break;
|
1297 |
-
case 'text':
|
1298 |
-
$sanitized[ $k ] = sanitize_text_field( $v );
|
1299 |
-
break;
|
1300 |
-
case 'textarea':
|
1301 |
-
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1302 |
-
break;
|
1303 |
-
case 'key':
|
1304 |
-
if ( is_array( $v ) ) {
|
1305 |
-
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1306 |
-
} else {
|
1307 |
-
$sanitized[ $k ] = sanitize_key( $v );
|
1308 |
-
}
|
1309 |
-
break;
|
1310 |
-
case 'absint':
|
1311 |
-
if ( is_array( $v ) ) {
|
1312 |
-
$sanitized[ $k ] = array_map( 'absint', $v );
|
1313 |
-
} else {
|
1314 |
-
$sanitized[ $k ] = absint( $v );
|
1315 |
-
}
|
1316 |
-
break;
|
1317 |
-
}
|
1318 |
-
}
|
1319 |
-
|
1320 |
-
$data = $sanitized;
|
1321 |
-
|
1322 |
-
$data = apply_filters( 'um_save_member_directory_meta_sanitize', $data );
|
1323 |
-
|
1324 |
-
return $data;
|
1325 |
-
}
|
1326 |
-
|
1327 |
-
|
1328 |
-
/**
|
1329 |
-
* Sanitize builder field meta when wp-admin form has been submitted
|
1330 |
-
*
|
1331 |
-
* @todo checking all sanitize types
|
1332 |
-
*
|
1333 |
-
* @param array $data
|
1334 |
-
*
|
1335 |
-
* @return array
|
1336 |
-
*/
|
1337 |
-
public function sanitize_builder_field_meta( $data ) {
|
1338 |
-
$sanitized = array();
|
1339 |
-
foreach ( $data as $k => $v ) {
|
1340 |
-
if ( ! array_key_exists( $k, $this->builder_input ) ) {
|
1341 |
-
// @todo remove since 2.2.x and leave only continue
|
1342 |
-
$sanitized[ $k ] = $v;
|
1343 |
-
continue;
|
1344 |
-
}
|
1345 |
-
|
1346 |
-
if ( ! array_key_exists( 'sanitize', $this->builder_input[ $k ] ) ) {
|
1347 |
-
// @todo remove since 2.2.x and leave only continue
|
1348 |
-
$sanitized[ $k ] = $v;
|
1349 |
-
continue;
|
1350 |
-
}
|
1351 |
-
|
1352 |
-
if ( is_callable( $this->builder_input[ $k ]['sanitize'], true, $callable_name ) ) {
|
1353 |
-
add_filter( 'um_builder_input_sanitize_' . $k, $this->builder_input[ $k ]['sanitize'], 10, 1 );
|
1354 |
-
}
|
1355 |
-
|
1356 |
-
switch ( $this->builder_input[ $k ]['sanitize'] ) {
|
1357 |
-
default:
|
1358 |
-
$sanitized[ $k ] = apply_filters( 'um_builder_input_sanitize_' . $k, $data[ $k ] );
|
1359 |
-
break;
|
1360 |
-
case 'int':
|
1361 |
-
$sanitized[ $k ] = (int) $v;
|
1362 |
-
break;
|
1363 |
-
case 'empty_int':
|
1364 |
-
$sanitized[ $k ] = ( '' !== $v ) ? (int) $v : '';
|
1365 |
-
break;
|
1366 |
-
case 'bool':
|
1367 |
-
$sanitized[ $k ] = (bool) $v;
|
1368 |
-
break;
|
1369 |
-
case 'url':
|
1370 |
-
if ( is_array( $v ) ) {
|
1371 |
-
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1372 |
-
} else {
|
1373 |
-
$sanitized[ $k ] = esc_url_raw( $v );
|
1374 |
-
}
|
1375 |
-
break;
|
1376 |
-
case 'text':
|
1377 |
-
$sanitized[ $k ] = sanitize_text_field( $v );
|
1378 |
-
break;
|
1379 |
-
case 'textarea':
|
1380 |
-
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1381 |
-
break;
|
1382 |
-
case 'wp_kses':
|
1383 |
-
$sanitized[ $k ] = wp_kses_post( $v );
|
1384 |
-
break;
|
1385 |
-
case 'key':
|
1386 |
-
if ( is_array( $v ) ) {
|
1387 |
-
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1388 |
-
} else {
|
1389 |
-
$sanitized[ $k ] = sanitize_key( $v );
|
1390 |
-
}
|
1391 |
-
break;
|
1392 |
-
case 'absint':
|
1393 |
-
if ( is_array( $v ) ) {
|
1394 |
-
$sanitized[ $k ] = array_map( 'absint', $v );
|
1395 |
-
} else {
|
1396 |
-
$sanitized[ $k ] = absint( $v );
|
1397 |
-
}
|
1398 |
-
break;
|
1399 |
-
case 'empty_absint':
|
1400 |
-
if ( is_array( $v ) ) {
|
1401 |
-
$sanitized[ $k ] = array_map( 'absint', $v );
|
1402 |
-
} else {
|
1403 |
-
$sanitized[ $k ] = ( '' !== $v ) ? absint( $v ) : '';
|
1404 |
-
}
|
1405 |
-
break;
|
1406 |
-
}
|
1407 |
-
}
|
1408 |
-
|
1409 |
-
$data = $sanitized;
|
1410 |
-
|
1411 |
-
$data = apply_filters( 'um_save_builder_input_sanitize', $data );
|
1412 |
-
|
1413 |
-
return $data;
|
1414 |
-
}
|
1415 |
-
|
1416 |
-
|
1417 |
-
/**
|
1418 |
-
* Sanitize form meta when wp-admin form has been submitted
|
1419 |
-
*
|
1420 |
-
* @todo checking all sanitize types
|
1421 |
-
*
|
1422 |
-
* @param array $data
|
1423 |
-
*
|
1424 |
-
* @return array
|
1425 |
-
*/
|
1426 |
-
public function sanitize_form_meta( $data ) {
|
1427 |
-
$sanitized = array();
|
1428 |
-
foreach ( $data as $k => $v ) {
|
1429 |
-
if ( ! array_key_exists( $k, $this->form_meta ) ) {
|
1430 |
-
// @todo remove since 2.2.x and leave only continue
|
1431 |
-
$sanitized[ $k ] = $v;
|
1432 |
-
continue;
|
1433 |
-
}
|
1434 |
-
|
1435 |
-
if ( ! array_key_exists( 'sanitize', $this->form_meta[ $k ] ) ) {
|
1436 |
-
// @todo remove since 2.2.x and leave only continue
|
1437 |
-
$sanitized[ $k ] = $v;
|
1438 |
-
continue;
|
1439 |
-
}
|
1440 |
-
|
1441 |
-
if ( is_callable( $this->form_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1442 |
-
add_filter( 'um_form_meta_sanitize_' . $k, $this->form_meta[ $k ]['sanitize'], 10, 1 );
|
1443 |
-
}
|
1444 |
-
|
1445 |
-
switch ( $this->form_meta[ $k ]['sanitize'] ) {
|
1446 |
-
default:
|
1447 |
-
$sanitized[ $k ] = apply_filters( 'um_form_meta_sanitize_' . $k, $data[ $k ] );
|
1448 |
-
break;
|
1449 |
-
case 'int':
|
1450 |
-
$sanitized[ $k ] = (int) $v;
|
1451 |
-
break;
|
1452 |
-
case 'bool':
|
1453 |
-
$sanitized[ $k ] = (bool) $v;
|
1454 |
-
break;
|
1455 |
-
case 'url':
|
1456 |
-
if ( is_array( $v ) ) {
|
1457 |
-
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1458 |
-
} else {
|
1459 |
-
$sanitized[ $k ] = esc_url_raw( $v );
|
1460 |
-
}
|
1461 |
-
break;
|
1462 |
-
case 'text':
|
1463 |
-
$sanitized[ $k ] = sanitize_text_field( $v );
|
1464 |
-
break;
|
1465 |
-
case 'textarea':
|
1466 |
-
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1467 |
-
break;
|
1468 |
-
case 'key':
|
1469 |
-
if ( is_array( $v ) ) {
|
1470 |
-
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1471 |
-
} else {
|
1472 |
-
$sanitized[ $k ] = sanitize_key( $v );
|
1473 |
-
}
|
1474 |
-
break;
|
1475 |
-
case 'absint':
|
1476 |
-
if ( is_array( $v ) ) {
|
1477 |
-
$sanitized[ $k ] = array_map( 'absint', $v );
|
1478 |
-
} else {
|
1479 |
-
$sanitized[ $k ] = absint( $v );
|
1480 |
-
}
|
1481 |
-
break;
|
1482 |
-
}
|
1483 |
-
}
|
1484 |
-
|
1485 |
-
$data = $sanitized;
|
1486 |
-
|
1487 |
-
$data = apply_filters( 'um_save_form_meta_sanitize', $data );
|
1488 |
-
|
1489 |
-
return $data;
|
1490 |
-
}
|
1491 |
-
|
1492 |
-
|
1493 |
-
/**
|
1494 |
-
* Sanitize options when wp-admin form has been submitted
|
1495 |
-
*
|
1496 |
-
* @todo checking all sanitize types
|
1497 |
-
*
|
1498 |
-
* @param array $data
|
1499 |
-
*
|
1500 |
-
* @return array
|
1501 |
-
*/
|
1502 |
-
public function sanitize_options( $data ) {
|
1503 |
-
$sanitized = array();
|
1504 |
-
foreach ( $data as $k => $v ) {
|
1505 |
-
if ( ! array_key_exists( $k, UM()->admin_settings()->settings_map ) ) {
|
1506 |
-
// @todo remove since 2.2.x and leave only continue
|
1507 |
-
$sanitized[ $k ] = $v;
|
1508 |
-
continue;
|
1509 |
-
}
|
1510 |
-
|
1511 |
-
if ( ! array_key_exists( 'sanitize', UM()->admin_settings()->settings_map[ $k ] ) ) {
|
1512 |
-
// @todo remove since 2.2.x and leave only continue
|
1513 |
-
$sanitized[ $k ] = $v;
|
1514 |
-
continue;
|
1515 |
-
}
|
1516 |
-
|
1517 |
-
if ( is_callable( UM()->admin_settings()->settings_map[ $k ]['sanitize'], true, $callable_name ) ) {
|
1518 |
-
add_filter( 'um_settings_sanitize_' . $k, UM()->admin_settings()->settings_map[ $k ]['sanitize'], 10, 1 );
|
1519 |
-
}
|
1520 |
-
|
1521 |
-
switch ( UM()->admin_settings()->settings_map[ $k ]['sanitize'] ) {
|
1522 |
-
default:
|
1523 |
-
$sanitized[ $k ] = apply_filters( 'um_settings_sanitize_' . $k, $v );
|
1524 |
-
break;
|
1525 |
-
case 'int':
|
1526 |
-
$sanitized[ $k ] = (int) $v;
|
1527 |
-
break;
|
1528 |
-
case 'absint':
|
1529 |
-
if ( is_array( $v ) ) {
|
1530 |
-
$sanitized[ $k ] = array_map( 'absint', $v );
|
1531 |
-
} else {
|
1532 |
-
$sanitized[ $k ] = absint( $v );
|
1533 |
-
}
|
1534 |
-
break;
|
1535 |
-
case 'key':
|
1536 |
-
if ( is_array( $v ) ) {
|
1537 |
-
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1538 |
-
} else {
|
1539 |
-
$sanitized[ $k ] = sanitize_key( $v );
|
1540 |
-
}
|
1541 |
-
break;
|
1542 |
-
case 'bool':
|
1543 |
-
$sanitized[ $k ] = (bool) $v;
|
1544 |
-
break;
|
1545 |
-
case 'url':
|
1546 |
-
if ( is_array( $v ) ) {
|
1547 |
-
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1548 |
-
} else {
|
1549 |
-
$sanitized[ $k ] = esc_url_raw( $v );
|
1550 |
-
}
|
1551 |
-
break;
|
1552 |
-
case 'wp_kses':
|
1553 |
-
$sanitized[ $k ] = wp_kses_post( $v );
|
1554 |
-
break;
|
1555 |
-
case 'textarea':
|
1556 |
-
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1557 |
-
break;
|
1558 |
-
case 'text':
|
1559 |
-
$sanitized[ $k ] = sanitize_text_field( $v );
|
1560 |
-
break;
|
1561 |
-
}
|
1562 |
-
}
|
1563 |
-
|
1564 |
-
$data = $sanitized;
|
1565 |
-
|
1566 |
-
$data = apply_filters( 'um_save_settings_sanitize', $data );
|
1567 |
-
|
1568 |
-
return $data;
|
1569 |
-
}
|
1570 |
-
|
1571 |
-
|
1572 |
-
/**
|
1573 |
-
* Adds class to our admin pages
|
1574 |
-
*
|
1575 |
-
* @param $classes
|
1576 |
-
*
|
1577 |
-
* @return string
|
1578 |
-
*/
|
1579 |
-
public function admin_body_class( $classes ) {
|
1580 |
-
if ( $this->is_um_screen() ) {
|
1581 |
-
return "$classes um-admin";
|
1582 |
-
}
|
1583 |
-
return $classes;
|
1584 |
-
}
|
1585 |
-
|
1586 |
-
|
1587 |
-
/**
|
1588 |
-
*
|
1589 |
-
*/
|
1590 |
-
public function manual_upgrades_request() {
|
1591 |
-
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1592 |
-
die();
|
1593 |
-
}
|
1594 |
-
|
1595 |
-
$last_request = get_option( 'um_last_manual_upgrades_request', false );
|
1596 |
-
|
1597 |
-
if ( empty( $last_request ) || time() > $last_request + DAY_IN_SECONDS ) {
|
1598 |
-
|
1599 |
-
if ( is_multisite() ) {
|
1600 |
-
$blogs_ids = get_sites();
|
1601 |
-
foreach( $blogs_ids as $b ) {
|
1602 |
-
switch_to_blog( $b->blog_id );
|
1603 |
-
wp_clean_update_cache();
|
1604 |
-
|
1605 |
-
UM()->plugin_updater()->um_checklicenses();
|
1606 |
-
|
1607 |
-
update_option( 'um_last_manual_upgrades_request', time() );
|
1608 |
-
restore_current_blog();
|
1609 |
-
}
|
1610 |
-
} else {
|
1611 |
-
wp_clean_update_cache();
|
1612 |
-
|
1613 |
-
UM()->plugin_updater()->um_checklicenses();
|
1614 |
-
|
1615 |
-
update_option( 'um_last_manual_upgrades_request', time() );
|
1616 |
-
}
|
1617 |
-
|
1618 |
-
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'got_updates' ), admin_url( 'admin.php' ) );
|
1619 |
-
} else {
|
1620 |
-
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'often_updates' ), admin_url( 'admin.php' ) );
|
1621 |
-
}
|
1622 |
-
exit( wp_redirect( $url ) );
|
1623 |
-
}
|
1624 |
-
|
1625 |
-
|
1626 |
-
/**
|
1627 |
-
* Core pages installation
|
1628 |
-
*/
|
1629 |
-
function install_core_pages() {
|
1630 |
-
if ( ! is_admin() ) {
|
1631 |
-
die();
|
1632 |
-
}
|
1633 |
-
|
1634 |
-
UM()->setup()->install_default_pages();
|
1635 |
-
|
1636 |
-
//check empty pages in settings
|
1637 |
-
$empty_pages = array();
|
1638 |
-
|
1639 |
-
$pages = UM()->config()->permalinks;
|
1640 |
-
if ( $pages && is_array( $pages ) ) {
|
1641 |
-
foreach ( $pages as $slug => $page_id ) {
|
1642 |
-
$page = get_post( $page_id );
|
1643 |
-
|
1644 |
-
if ( ! isset( $page->ID ) && in_array( $slug, array_keys( UM()->config()->core_pages ) ) ) {
|
1645 |
-
$empty_pages[] = $slug;
|
1646 |
-
}
|
1647 |
-
}
|
1648 |
-
}
|
1649 |
-
|
1650 |
-
//if there aren't empty pages - then hide pages notice
|
1651 |
-
if ( empty( $empty_pages ) ) {
|
1652 |
-
$hidden_notices = get_option( 'um_hidden_admin_notices', array() );
|
1653 |
-
$hidden_notices[] = 'wrong_pages';
|
1654 |
-
|
1655 |
-
update_option( 'um_hidden_admin_notices', $hidden_notices );
|
1656 |
-
}
|
1657 |
-
|
1658 |
-
$url = add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) );
|
1659 |
-
exit( wp_redirect( $url ) );
|
1660 |
-
}
|
1661 |
-
|
1662 |
-
|
1663 |
-
/**
|
1664 |
-
* Clear all users cache
|
1665 |
-
*
|
1666 |
-
* @param $action
|
1667 |
-
*/
|
1668 |
-
function user_cache( $action ) {
|
1669 |
-
global $wpdb;
|
1670 |
-
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1671 |
-
die();
|
1672 |
-
}
|
1673 |
-
|
1674 |
-
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
|
1675 |
-
|
1676 |
-
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) );
|
1677 |
-
exit( wp_redirect( $url ) );
|
1678 |
-
}
|
1679 |
-
|
1680 |
-
|
1681 |
-
/**
|
1682 |
-
* Purge temp uploads dir
|
1683 |
-
* @param $action
|
1684 |
-
*/
|
1685 |
-
function purge_temp( $action ) {
|
1686 |
-
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1687 |
-
die();
|
1688 |
-
}
|
1689 |
-
|
1690 |
-
UM()->files()->remove_dir( UM()->files()->upload_temp );
|
1691 |
-
|
1692 |
-
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'purged_temp' ), admin_url( 'admin.php' ) );
|
1693 |
-
exit( wp_redirect( $url ) );
|
1694 |
-
}
|
1695 |
-
|
1696 |
-
|
1697 |
-
/**
|
1698 |
-
* Duplicate form
|
1699 |
-
*
|
1700 |
-
* @param $action
|
1701 |
-
*/
|
1702 |
-
function duplicate_form( $action ) {
|
1703 |
-
if ( ! is_admin() || ! current_user_can('manage_options') ) {
|
1704 |
-
die();
|
1705 |
-
}
|
1706 |
-
if ( ! isset( $_REQUEST['post_id'] ) || ! is_numeric( $_REQUEST['post_id'] ) ) {
|
1707 |
-
die();
|
1708 |
-
}
|
1709 |
-
|
1710 |
-
$post_id = absint( $_REQUEST['post_id'] );
|
1711 |
-
|
1712 |
-
$n = array(
|
1713 |
-
'post_type' => 'um_form',
|
1714 |
-
'post_title' => sprintf( __( 'Duplicate of %s', 'ultimate-member' ), get_the_title( $post_id ) ),
|
1715 |
-
'post_status' => 'publish',
|
1716 |
-
'post_author' => get_current_user_id(),
|
1717 |
-
);
|
1718 |
-
|
1719 |
-
$n_id = wp_insert_post( $n );
|
1720 |
-
|
1721 |
-
$n_fields = get_post_custom( $post_id );
|
1722 |
-
foreach ( $n_fields as $key => $value ) {
|
1723 |
-
|
1724 |
-
if ( $key == '_um_custom_fields' ) {
|
1725 |
-
$the_value = unserialize( $value[0] );
|
1726 |
-
} else {
|
1727 |
-
$the_value = $value[0];
|
1728 |
-
}
|
1729 |
-
|
1730 |
-
update_post_meta( $n_id, $key, $the_value );
|
1731 |
-
|
1732 |
-
}
|
1733 |
-
|
1734 |
-
delete_post_meta( $n_id, '_um_core' );
|
1735 |
-
|
1736 |
-
$url = admin_url( 'edit.php?post_type=um_form' );
|
1737 |
-
$url = add_query_arg( 'update', 'form_duplicated', $url );
|
1738 |
-
|
1739 |
-
exit( wp_redirect( $url ) );
|
1740 |
-
|
1741 |
-
}
|
1742 |
-
|
1743 |
-
|
1744 |
-
/**
|
1745 |
-
* Action to hide notices in admin
|
1746 |
-
*
|
1747 |
-
* @param $action
|
1748 |
-
*/
|
1749 |
-
function um_hide_notice( $action ) {
|
1750 |
-
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1751 |
-
die();
|
1752 |
-
}
|
1753 |
-
|
1754 |
-
update_option( $action, 1 );
|
1755 |
-
exit( wp_redirect( remove_query_arg( 'um_adm_action' ) ) );
|
1756 |
-
}
|
1757 |
-
|
1758 |
-
|
1759 |
-
/**
|
1760 |
-
* Various user actions
|
1761 |
-
*
|
1762 |
-
* @param $action
|
1763 |
-
*/
|
1764 |
-
function user_action( $action ) {
|
1765 |
-
if ( ! is_admin() || ! current_user_can( 'edit_users' ) ) {
|
1766 |
-
die();
|
1767 |
-
}
|
1768 |
-
if ( ! isset( $_REQUEST['sub'] ) ) {
|
1769 |
-
die();
|
1770 |
-
}
|
1771 |
-
if ( ! isset( $_REQUEST['user_id'] ) ) {
|
1772 |
-
die();
|
1773 |
-
}
|
1774 |
-
|
1775 |
-
um_fetch_user( absint( $_REQUEST['user_id'] ) );
|
1776 |
-
|
1777 |
-
$subaction = sanitize_key( $_REQUEST['sub'] );
|
1778 |
-
|
1779 |
-
/**
|
1780 |
-
* UM hook
|
1781 |
-
*
|
1782 |
-
* @type action
|
1783 |
-
* @title um_admin_user_action_hook
|
1784 |
-
* @description Action on bulk user subaction
|
1785 |
-
* @input_vars
|
1786 |
-
* [{"var":"$subaction","type":"string","desc":"Bulk Subaction"}]
|
1787 |
-
* @change_log
|
1788 |
-
* ["Since: 2.0"]
|
1789 |
-
* @usage add_action( 'um_admin_user_action_hook', 'function_name', 10, 1 );
|
1790 |
-
* @example
|
1791 |
-
* <?php
|
1792 |
-
* add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
|
1793 |
-
* function my_admin_user_action( $subaction ) {
|
1794 |
-
* // your code here
|
1795 |
-
* }
|
1796 |
-
* ?>
|
1797 |
-
*/
|
1798 |
-
do_action( 'um_admin_user_action_hook', $subaction );
|
1799 |
-
/**
|
1800 |
-
* UM hook
|
1801 |
-
*
|
1802 |
-
* @type action
|
1803 |
-
* @title um_admin_user_action_{$subaction}_hook
|
1804 |
-
* @description Action on bulk user subaction
|
1805 |
-
* @change_log
|
1806 |
-
* ["Since: 2.0"]
|
1807 |
-
* @usage add_action( 'um_admin_user_action_{$subaction}_hook', 'function_name', 10 );
|
1808 |
-
* @example
|
1809 |
-
* <?php
|
1810 |
-
* add_action( 'um_admin_user_action_{$subaction}_hook', 'my_admin_user_action', 10 );
|
1811 |
-
* function my_admin_user_action() {
|
1812 |
-
* // your code here
|
1813 |
-
* }
|
1814 |
-
* ?>
|
1815 |
-
*/
|
1816 |
-
do_action( "um_admin_user_action_{$subaction}_hook" );
|
1817 |
-
|
1818 |
-
um_reset_user();
|
1819 |
-
|
1820 |
-
wp_redirect( add_query_arg( 'update', 'user_updated', admin_url( '?page=ultimatemember' ) ) );
|
1821 |
-
exit;
|
1822 |
-
|
1823 |
-
}
|
1824 |
-
|
1825 |
-
|
1826 |
-
/**
|
1827 |
-
* Add any custom links to plugin page
|
1828 |
-
*
|
1829 |
-
* @param array $links
|
1830 |
-
*
|
1831 |
-
* @return array
|
1832 |
-
*/
|
1833 |
-
function plugin_links( $links ) {
|
1834 |
-
$more_links[] = '<a href="http://docs.ultimatemember.com/">' . __( 'Docs', 'ultimate-member' ) . '</a>';
|
1835 |
-
$more_links[] = '<a href="'.admin_url().'admin.php?page=um_options">' . __( 'Settings', 'ultimate-member' ) . '</a>';
|
1836 |
-
|
1837 |
-
$links = $more_links + $links;
|
1838 |
-
return $links;
|
1839 |
-
}
|
1840 |
-
|
1841 |
-
|
1842 |
-
/**
|
1843 |
-
* Init admin action/filters + request handlers
|
1844 |
-
*/
|
1845 |
-
function admin_init() {
|
1846 |
-
$this->init_variables();
|
1847 |
-
|
1848 |
-
if ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_REQUEST['um_adm_action'] ) ) {
|
1849 |
-
$action = sanitize_key( $_REQUEST['um_adm_action'] );
|
1850 |
-
|
1851 |
-
/**
|
1852 |
-
* UM hook
|
1853 |
-
*
|
1854 |
-
* @type action
|
1855 |
-
* @title um_admin_do_action__
|
1856 |
-
* @description Make some action on custom admin action
|
1857 |
-
* @input_vars
|
1858 |
-
* [{"var":"$action","type":"string","desc":"Admin Action"}]
|
1859 |
-
* @change_log
|
1860 |
-
* ["Since: 2.0"]
|
1861 |
-
* @usage add_action( 'um_admin_do_action__', 'function_name', 10, 1 );
|
1862 |
-
* @example
|
1863 |
-
* <?php
|
1864 |
-
* add_action( 'um_admin_do_action__', 'my_admin_do_action', 10, 1 );
|
1865 |
-
* function my_admin_do_action( $action ) {
|
1866 |
-
* // your code here
|
1867 |
-
* }
|
1868 |
-
* ?>
|
1869 |
-
*/
|
1870 |
-
do_action( 'um_admin_do_action__', $action );
|
1871 |
-
/**
|
1872 |
-
* UM hook
|
1873 |
-
*
|
1874 |
-
* @type action
|
1875 |
-
* @title um_admin_do_action__{$action}
|
1876 |
-
* @description Make some action on custom admin $action
|
1877 |
-
* @input_vars
|
1878 |
-
* [{"var":"$action","type":"string","desc":"Admin Action"}]
|
1879 |
-
* @change_log
|
1880 |
-
* ["Since: 2.0"]
|
1881 |
-
* @usage add_action( 'um_admin_do_action__{$action}', 'function_name', 10, 1 );
|
1882 |
-
* @example
|
1883 |
-
* <?php
|
1884 |
-
* add_action( 'um_admin_do_action__{$action}', 'my_admin_do_action', 10, 1 );
|
1885 |
-
* function my_admin_do_action( $action ) {
|
1886 |
-
* // your code here
|
1887 |
-
* }
|
1888 |
-
* ?>
|
1889 |
-
*/
|
1890 |
-
do_action( "um_admin_do_action__{$action}", $action );
|
1891 |
-
}
|
1892 |
-
}
|
1893 |
-
|
1894 |
-
|
1895 |
-
/**
|
1896 |
-
* Updated post messages
|
1897 |
-
*
|
1898 |
-
* @param array $messages
|
1899 |
-
*
|
1900 |
-
* @return array
|
1901 |
-
*/
|
1902 |
-
function post_updated_messages( $messages ) {
|
1903 |
-
global $post_ID;
|
1904 |
-
|
1905 |
-
$post_type = get_post_type( $post_ID );
|
1906 |
-
|
1907 |
-
if ( $post_type == 'um_form' ) {
|
1908 |
-
$messages['um_form'] = array(
|
1909 |
-
0 => '',
|
1910 |
-
1 => __( 'Form updated.', 'ultimate-member' ),
|
1911 |
-
2 => __( 'Custom field updated.', 'ultimate-member' ),
|
1912 |
-
3 => __( 'Custom field deleted.', 'ultimate-member' ),
|
1913 |
-
4 => __( 'Form updated.', 'ultimate-member' ),
|
1914 |
-
5 => isset( $_GET['revision'] ) ? __( 'Form restored to revision.', 'ultimate-member' ) : false,
|
1915 |
-
6 => __( 'Form created.', 'ultimate-member' ),
|
1916 |
-
7 => __( 'Form saved.', 'ultimate-member' ),
|
1917 |
-
8 => __( 'Form submitted.', 'ultimate-member' ),
|
1918 |
-
9 => __( 'Form scheduled.', 'ultimate-member' ),
|
1919 |
-
10 => __( 'Form draft updated.', 'ultimate-member' ),
|
1920 |
-
);
|
1921 |
-
}
|
1922 |
-
|
1923 |
-
return $messages;
|
1924 |
-
}
|
1925 |
-
|
1926 |
-
|
1927 |
-
/**
|
1928 |
-
* Gettext filters
|
1929 |
-
*
|
1930 |
-
* @param $translation
|
1931 |
-
* @param $text
|
1932 |
-
* @param $domain
|
1933 |
-
*
|
1934 |
-
* @return string
|
1935 |
-
*/
|
1936 |
-
function gettext( $translation, $text, $domain ) {
|
1937 |
-
global $post;
|
1938 |
-
if ( isset( $post->post_type ) && $this->is_plugin_post_type() ) {
|
1939 |
-
$translations = get_translations_for_domain( $domain );
|
1940 |
-
if ( $text == 'Publish' ) {
|
1941 |
-
return $translations->translate( 'Create' );
|
1942 |
-
} elseif ( $text == 'Move to Trash' ) {
|
1943 |
-
return $translations->translate( 'Delete' );
|
1944 |
-
}
|
1945 |
-
}
|
1946 |
-
|
1947 |
-
return $translation;
|
1948 |
-
}
|
1949 |
-
|
1950 |
-
|
1951 |
-
/**
|
1952 |
-
* Fix parent file for correct highlighting
|
1953 |
-
*
|
1954 |
-
* @param $parent_file
|
1955 |
-
*
|
1956 |
-
* @return string
|
1957 |
-
*/
|
1958 |
-
function parent_file( $parent_file ) {
|
1959 |
-
global $current_screen;
|
1960 |
-
$screen_id = $current_screen->id;
|
1961 |
-
if ( strstr( $screen_id, 'um_' ) ) {
|
1962 |
-
$parent_file = 'ultimatemember';
|
1963 |
-
}
|
1964 |
-
return $parent_file;
|
1965 |
-
}
|
1966 |
-
|
1967 |
-
|
1968 |
-
/**
|
1969 |
-
* @since 2.0
|
1970 |
-
*
|
1971 |
-
* @return core\Admin_Notices()
|
1972 |
-
*/
|
1973 |
-
function notices() {
|
1974 |
-
if ( empty( UM()->classes['admin_notices'] ) ) {
|
1975 |
-
UM()->classes['admin_notices'] = new core\Admin_Notices();
|
1976 |
-
}
|
1977 |
-
return UM()->classes['admin_notices'];
|
1978 |
-
}
|
1979 |
-
}
|
1980 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\admin;
|
3 |
+
|
4 |
+
// Exit if accessed directly.
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
|
9 |
+
if ( ! class_exists( 'um\admin\Admin' ) ) {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class Admin
|
14 |
+
* @package um\admin
|
15 |
+
*/
|
16 |
+
class Admin extends Admin_Functions {
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
public $templates_path;
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var array
|
27 |
+
*/
|
28 |
+
public $role_meta;
|
29 |
+
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @var array
|
33 |
+
*/
|
34 |
+
public $restriction_term_meta;
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @var array
|
39 |
+
*/
|
40 |
+
public $member_directory_meta;
|
41 |
+
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @var array
|
45 |
+
*/
|
46 |
+
public $form_meta;
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @var array
|
51 |
+
*/
|
52 |
+
public $builder_input;
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @var array
|
57 |
+
*/
|
58 |
+
public $restriction_post_meta;
|
59 |
+
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Admin constructor.
|
63 |
+
*/
|
64 |
+
public function __construct() {
|
65 |
+
parent::__construct();
|
66 |
+
|
67 |
+
$this->templates_path = um_path . 'includes/admin/templates/';
|
68 |
+
|
69 |
+
add_action( 'admin_init', array( &$this, 'admin_init' ), 0 );
|
70 |
+
|
71 |
+
$prefix = is_network_admin() ? 'network_admin_' : '';
|
72 |
+
add_filter( "{$prefix}plugin_action_links_" . um_plugin, array( &$this, 'plugin_links' ) );
|
73 |
+
|
74 |
+
add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) );
|
75 |
+
add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) );
|
76 |
+
add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) );
|
77 |
+
add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) );
|
78 |
+
add_action( 'um_admin_do_action__um_hide_locale_notice', array( &$this, 'um_hide_notice' ) );
|
79 |
+
add_action( 'um_admin_do_action__um_can_register_notice', array( &$this, 'um_hide_notice' ) );
|
80 |
+
add_action( 'um_admin_do_action__um_hide_exif_notice', array( &$this, 'um_hide_notice' ) );
|
81 |
+
add_action( 'um_admin_do_action__user_action', array( &$this, 'user_action' ) );
|
82 |
+
|
83 |
+
add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) );
|
84 |
+
|
85 |
+
add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ), 999 );
|
86 |
+
|
87 |
+
add_action( 'parent_file', array( &$this, 'parent_file' ), 9 );
|
88 |
+
add_filter( 'gettext', array( &$this, 'gettext' ), 10, 4 );
|
89 |
+
add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
function init_variables() {
|
94 |
+
$this->role_meta = apply_filters(
|
95 |
+
'um_role_meta_map',
|
96 |
+
array(
|
97 |
+
'_um_priority' => array(
|
98 |
+
'sanitize' => 'int',
|
99 |
+
),
|
100 |
+
'_um_can_access_wpadmin' => array(
|
101 |
+
'sanitize' => 'bool',
|
102 |
+
),
|
103 |
+
'_um_can_not_see_adminbar' => array(
|
104 |
+
'sanitize' => 'bool',
|
105 |
+
),
|
106 |
+
'_um_can_edit_everyone' => array(
|
107 |
+
'sanitize' => 'bool',
|
108 |
+
),
|
109 |
+
'_um_can_edit_roles' => array(
|
110 |
+
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
111 |
+
),
|
112 |
+
'_um_can_delete_everyone' => array(
|
113 |
+
'sanitize' => 'bool',
|
114 |
+
),
|
115 |
+
'_um_can_delete_roles' => array(
|
116 |
+
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
117 |
+
),
|
118 |
+
'_um_can_edit_profile' => array(
|
119 |
+
'sanitize' => 'bool',
|
120 |
+
),
|
121 |
+
'_um_can_delete_profile' => array(
|
122 |
+
'sanitize' => 'bool',
|
123 |
+
),
|
124 |
+
'_um_can_view_all' => array(
|
125 |
+
'sanitize' => 'bool',
|
126 |
+
),
|
127 |
+
'_um_can_view_roles' => array(
|
128 |
+
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
129 |
+
),
|
130 |
+
'_um_can_make_private_profile' => array(
|
131 |
+
'sanitize' => 'bool',
|
132 |
+
),
|
133 |
+
'_um_can_access_private_profile' => array(
|
134 |
+
'sanitize' => 'bool',
|
135 |
+
),
|
136 |
+
'_um_profile_noindex' => array(
|
137 |
+
'sanitize' => array( $this, 'sanitize_profile_noindex' ),
|
138 |
+
),
|
139 |
+
'_um_default_homepage' => array(
|
140 |
+
'sanitize' => 'bool',
|
141 |
+
),
|
142 |
+
'_um_redirect_homepage' => array(
|
143 |
+
'sanitize' => 'url',
|
144 |
+
),
|
145 |
+
'_um_status' => array(
|
146 |
+
'sanitize' => 'sanitize_array_key',
|
147 |
+
'default' => 'approved',
|
148 |
+
'array' => array( 'approved', 'checkmail', 'pending' ),
|
149 |
+
),
|
150 |
+
'_um_auto_approve_act' => array(
|
151 |
+
'sanitize' => 'sanitize_array_key',
|
152 |
+
'default' => 'redirect_profile',
|
153 |
+
'array' => array( 'redirect_profile', 'redirect_url' ),
|
154 |
+
),
|
155 |
+
'_um_auto_approve_url' => array(
|
156 |
+
'sanitize' => 'url',
|
157 |
+
),
|
158 |
+
'_um_login_email_activate' => array(
|
159 |
+
'sanitize' => 'bool',
|
160 |
+
),
|
161 |
+
'_um_checkmail_action' => array(
|
162 |
+
'sanitize' => 'sanitize_array_key',
|
163 |
+
'default' => 'show_message',
|
164 |
+
'array' => array( 'show_message', 'redirect_url' ),
|
165 |
+
),
|
166 |
+
'_um_checkmail_message' => array(
|
167 |
+
'sanitize' => 'textarea',
|
168 |
+
),
|
169 |
+
'_um_checkmail_url' => array(
|
170 |
+
'sanitize' => 'url',
|
171 |
+
),
|
172 |
+
'_um_url_email_activate' => array(
|
173 |
+
'sanitize' => 'url',
|
174 |
+
),
|
175 |
+
'_um_pending_action' => array(
|
176 |
+
'sanitize' => 'sanitize_array_key',
|
177 |
+
'default' => 'show_message',
|
178 |
+
'array' => array( 'show_message', 'redirect_url' ),
|
179 |
+
),
|
180 |
+
'_um_pending_message' => array(
|
181 |
+
'sanitize' => 'textarea',
|
182 |
+
),
|
183 |
+
'_um_pending_url' => array(
|
184 |
+
'sanitize' => 'url',
|
185 |
+
),
|
186 |
+
'_um_after_login' => array(
|
187 |
+
'sanitize' => 'sanitize_array_key',
|
188 |
+
'default' => 'redirect_profile',
|
189 |
+
'array' => array( 'redirect_profile', 'redirect_url', 'refresh', 'redirect_admin' ),
|
190 |
+
),
|
191 |
+
'_um_login_redirect_url' => array(
|
192 |
+
'sanitize' => 'url',
|
193 |
+
),
|
194 |
+
'_um_after_logout' => array(
|
195 |
+
'sanitize' => 'sanitize_array_key',
|
196 |
+
'default' => 'redirect_home',
|
197 |
+
'array' => array( 'redirect_home', 'redirect_url' ),
|
198 |
+
),
|
199 |
+
'_um_logout_redirect_url' => array(
|
200 |
+
'sanitize' => 'url',
|
201 |
+
),
|
202 |
+
'_um_after_delete' => array(
|
203 |
+
'sanitize' => 'sanitize_array_key',
|
204 |
+
'default' => 'redirect_home',
|
205 |
+
'array' => array( 'redirect_home', 'redirect_url' ),
|
206 |
+
),
|
207 |
+
'_um_delete_redirect_url' => array(
|
208 |
+
'sanitize' => 'url',
|
209 |
+
),
|
210 |
+
'wp_capabilities' => array(
|
211 |
+
'sanitize' => array( $this, 'sanitize_wp_capabilities' ),
|
212 |
+
),
|
213 |
+
)
|
214 |
+
);
|
215 |
+
|
216 |
+
$this->restriction_post_meta = apply_filters(
|
217 |
+
'um_restriction_post_meta_map',
|
218 |
+
array(
|
219 |
+
'_um_custom_access_settings' => array(
|
220 |
+
'sanitize' => 'bool',
|
221 |
+
),
|
222 |
+
'_um_accessible' => array(
|
223 |
+
'sanitize' => 'int',
|
224 |
+
),
|
225 |
+
'_um_access_roles' => array(
|
226 |
+
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
227 |
+
),
|
228 |
+
'_um_noaccess_action' => array(
|
229 |
+
'sanitize' => 'int',
|
230 |
+
),
|
231 |
+
'_um_restrict_by_custom_message' => array(
|
232 |
+
'sanitize' => 'int',
|
233 |
+
),
|
234 |
+
'_um_restrict_custom_message' => array(
|
235 |
+
'sanitize' => 'wp_kses',
|
236 |
+
),
|
237 |
+
'_um_access_redirect' => array(
|
238 |
+
'sanitize' => 'int',
|
239 |
+
),
|
240 |
+
'_um_access_redirect_url' => array(
|
241 |
+
'sanitize' => 'url',
|
242 |
+
),
|
243 |
+
'_um_access_hide_from_queries' => array(
|
244 |
+
'sanitize' => 'bool',
|
245 |
+
),
|
246 |
+
)
|
247 |
+
);
|
248 |
+
|
249 |
+
$this->restriction_term_meta = apply_filters(
|
250 |
+
'um_restriction_term_meta_map',
|
251 |
+
array(
|
252 |
+
'_um_custom_access_settings' => array(
|
253 |
+
'sanitize' => 'bool',
|
254 |
+
),
|
255 |
+
'_um_accessible' => array(
|
256 |
+
'sanitize' => 'int',
|
257 |
+
),
|
258 |
+
'_um_access_roles' => array(
|
259 |
+
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
260 |
+
),
|
261 |
+
'_um_noaccess_action' => array(
|
262 |
+
'sanitize' => 'int',
|
263 |
+
),
|
264 |
+
'_um_restrict_by_custom_message' => array(
|
265 |
+
'sanitize' => 'int',
|
266 |
+
),
|
267 |
+
'_um_restrict_custom_message' => array(
|
268 |
+
'sanitize' => 'wp_kses',
|
269 |
+
),
|
270 |
+
'_um_access_redirect' => array(
|
271 |
+
'sanitize' => 'int',
|
272 |
+
),
|
273 |
+
'_um_access_redirect_url' => array(
|
274 |
+
'sanitize' => 'url',
|
275 |
+
),
|
276 |
+
'_um_access_hide_from_queries' => array(
|
277 |
+
'sanitize' => 'bool',
|
278 |
+
),
|
279 |
+
)
|
280 |
+
);
|
281 |
+
|
282 |
+
$this->member_directory_meta = apply_filters(
|
283 |
+
'um_member_directory_meta_map',
|
284 |
+
array(
|
285 |
+
'_um_directory_template' => array(
|
286 |
+
'sanitize' => 'text',
|
287 |
+
),
|
288 |
+
'_um_mode' => array(
|
289 |
+
'sanitize' => 'key',
|
290 |
+
),
|
291 |
+
'_um_view_types' => array(
|
292 |
+
'sanitize' => array( $this, 'sanitize_md_view_types' ),
|
293 |
+
),
|
294 |
+
'_um_default_view' => array(
|
295 |
+
'sanitize' => 'key',
|
296 |
+
),
|
297 |
+
'_um_roles' => array(
|
298 |
+
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
299 |
+
),
|
300 |
+
'_um_has_profile_photo' => array(
|
301 |
+
'sanitize' => 'bool',
|
302 |
+
),
|
303 |
+
'_um_show_these_users' => array(
|
304 |
+
'sanitize' => 'textarea',
|
305 |
+
),
|
306 |
+
'_um_exclude_these_users' => array(
|
307 |
+
'sanitize' => 'textarea',
|
308 |
+
),
|
309 |
+
'_um_must_search' => array(
|
310 |
+
'sanitize' => 'bool',
|
311 |
+
),
|
312 |
+
'_um_max_users' => array(
|
313 |
+
'sanitize' => 'absint',
|
314 |
+
),
|
315 |
+
'_um_profiles_per_page' => array(
|
316 |
+
'sanitize' => 'absint',
|
317 |
+
),
|
318 |
+
'_um_profiles_per_page_mobile' => array(
|
319 |
+
'sanitize' => 'absint',
|
320 |
+
),
|
321 |
+
'_um_directory_header' => array(
|
322 |
+
'sanitize' => 'text',
|
323 |
+
),
|
324 |
+
'_um_directory_header_single' => array(
|
325 |
+
'sanitize' => 'text',
|
326 |
+
),
|
327 |
+
'_um_directory_no_users' => array(
|
328 |
+
'sanitize' => 'text',
|
329 |
+
),
|
330 |
+
'_um_profile_photo' => array(
|
331 |
+
'sanitize' => 'bool',
|
332 |
+
),
|
333 |
+
'_um_cover_photos' => array(
|
334 |
+
'sanitize' => 'bool',
|
335 |
+
),
|
336 |
+
'_um_show_name' => array(
|
337 |
+
'sanitize' => 'bool',
|
338 |
+
),
|
339 |
+
'_um_show_tagline' => array(
|
340 |
+
'sanitize' => 'bool',
|
341 |
+
),
|
342 |
+
'_um_tagline_fields' => array(
|
343 |
+
'sanitize' => array( $this, 'sanitize_user_field' ),
|
344 |
+
),
|
345 |
+
'_um_show_userinfo' => array(
|
346 |
+
'sanitize' => 'bool',
|
347 |
+
),
|
348 |
+
'_um_reveal_fields' => array(
|
349 |
+
'sanitize' => array( $this, 'sanitize_user_field' ),
|
350 |
+
),
|
351 |
+
'_um_show_social' => array(
|
352 |
+
'sanitize' => 'bool',
|
353 |
+
),
|
354 |
+
'_um_userinfo_animate' => array(
|
355 |
+
'sanitize' => 'bool',
|
356 |
+
),
|
357 |
+
'_um_search' => array(
|
358 |
+
'sanitize' => 'bool',
|
359 |
+
),
|
360 |
+
'_um_roles_can_search' => array(
|
361 |
+
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
362 |
+
),
|
363 |
+
'_um_filters' => array(
|
364 |
+
'sanitize' => 'bool',
|
365 |
+
),
|
366 |
+
'_um_roles_can_filter' => array(
|
367 |
+
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
368 |
+
),
|
369 |
+
'_um_search_fields' => array(
|
370 |
+
'sanitize' => array( $this, 'sanitize_filter_fields' ),
|
371 |
+
),
|
372 |
+
'_um_filters_expanded' => array(
|
373 |
+
'sanitize' => 'bool',
|
374 |
+
),
|
375 |
+
'_um_filters_is_collapsible' => array(
|
376 |
+
'sanitize' => 'bool',
|
377 |
+
),
|
378 |
+
'_um_search_filters' => array(
|
379 |
+
'sanitize' => array( $this, 'sanitize_filter_fields' ),
|
380 |
+
),
|
381 |
+
'_um_sortby' => array(
|
382 |
+
'sanitize' => 'text',
|
383 |
+
),
|
384 |
+
'_um_sortby_custom' => array(
|
385 |
+
'sanitize' => 'text',
|
386 |
+
),
|
387 |
+
'_um_sortby_custom_label' => array(
|
388 |
+
'sanitize' => 'text',
|
389 |
+
),
|
390 |
+
'_um_enable_sorting' => array(
|
391 |
+
'sanitize' => 'bool',
|
392 |
+
),
|
393 |
+
'_um_sorting_fields' => array(
|
394 |
+
'sanitize' => array( $this, 'sanitize_md_sorting_fields' ),
|
395 |
+
),
|
396 |
+
)
|
397 |
+
);
|
398 |
+
|
399 |
+
$this->form_meta = apply_filters(
|
400 |
+
'um_form_meta_map',
|
401 |
+
array(
|
402 |
+
'_um_mode' => array(
|
403 |
+
'sanitize' => 'key',
|
404 |
+
),
|
405 |
+
'_um_register_use_gdpr' => array(
|
406 |
+
'sanitize' => 'bool',
|
407 |
+
),
|
408 |
+
'_um_register_use_gdpr_content_id' => array(
|
409 |
+
'sanitize' => 'absint',
|
410 |
+
),
|
411 |
+
'_um_register_use_gdpr_toggle_show' => array(
|
412 |
+
'sanitize' => 'text',
|
413 |
+
),
|
414 |
+
'_um_register_use_gdpr_toggle_hide' => array(
|
415 |
+
'sanitize' => 'text',
|
416 |
+
),
|
417 |
+
'_um_register_use_gdpr_agreement' => array(
|
418 |
+
'sanitize' => 'text',
|
419 |
+
),
|
420 |
+
'_um_register_use_gdpr_error_text' => array(
|
421 |
+
'sanitize' => 'text',
|
422 |
+
),
|
423 |
+
'_um_register_use_custom_settings' => array(
|
424 |
+
'sanitize' => 'bool',
|
425 |
+
),
|
426 |
+
'_um_register_role' => array(
|
427 |
+
'sanitize' => 'key',
|
428 |
+
),
|
429 |
+
'_um_register_template' => array(
|
430 |
+
'sanitize' => 'text',
|
431 |
+
),
|
432 |
+
'_um_register_max_width' => array(
|
433 |
+
'sanitize' => 'text',
|
434 |
+
),
|
435 |
+
'_um_register_icons' => array(
|
436 |
+
'sanitize' => 'key',
|
437 |
+
),
|
438 |
+
'_um_register_primary_btn_word' => array(
|
439 |
+
'sanitize' => 'text',
|
440 |
+
),
|
441 |
+
'_um_register_secondary_btn' => array(
|
442 |
+
'sanitize' => 'bool',
|
443 |
+
),
|
444 |
+
'_um_register_secondary_btn_word' => array(
|
445 |
+
'sanitize' => 'text',
|
446 |
+
),
|
447 |
+
'_um_login_after_login' => array(
|
448 |
+
'sanitize' => 'key',
|
449 |
+
),
|
450 |
+
'_um_login_redirect_url' => array(
|
451 |
+
'sanitize' => 'url',
|
452 |
+
),
|
453 |
+
'_um_login_use_custom_settings' => array(
|
454 |
+
'sanitize' => 'bool',
|
455 |
+
),
|
456 |
+
'_um_login_template' => array(
|
457 |
+
'sanitize' => 'text',
|
458 |
+
),
|
459 |
+
'_um_login_max_width' => array(
|
460 |
+
'sanitize' => 'text',
|
461 |
+
),
|
462 |
+
'_um_login_icons' => array(
|
463 |
+
'sanitize' => 'key',
|
464 |
+
),
|
465 |
+
'_um_login_primary_btn_word' => array(
|
466 |
+
'sanitize' => 'text',
|
467 |
+
),
|
468 |
+
'_um_login_secondary_btn' => array(
|
469 |
+
'sanitize' => 'bool',
|
470 |
+
),
|
471 |
+
'_um_login_secondary_btn_word' => array(
|
472 |
+
'sanitize' => 'text',
|
473 |
+
),
|
474 |
+
'_um_login_forgot_pass_link' => array(
|
475 |
+
'sanitize' => 'bool',
|
476 |
+
),
|
477 |
+
'_um_login_show_rememberme' => array(
|
478 |
+
'sanitize' => 'bool',
|
479 |
+
),
|
480 |
+
'_um_profile_metafields' => array(
|
481 |
+
'sanitize' => array( $this, 'sanitize_user_field' ),
|
482 |
+
),
|
483 |
+
'_um_profile_use_custom_settings' => array(
|
484 |
+
'sanitize' => 'bool',
|
485 |
+
),
|
486 |
+
'_um_profile_role' => array(
|
487 |
+
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
488 |
+
),
|
489 |
+
'_um_profile_template' => array(
|
490 |
+
'sanitize' => 'text',
|
491 |
+
),
|
492 |
+
'_um_profile_max_width' => array(
|
493 |
+
'sanitize' => 'text',
|
494 |
+
),
|
495 |
+
'_um_profile_area_max_width' => array(
|
496 |
+
'sanitize' => 'text',
|
497 |
+
),
|
498 |
+
'_um_profile_icons' => array(
|
499 |
+
'sanitize' => 'key',
|
500 |
+
),
|
501 |
+
'_um_profile_primary_btn_word' => array(
|
502 |
+
'sanitize' => 'text',
|
503 |
+
),
|
504 |
+
'_um_profile_secondary_btn' => array(
|
505 |
+
'sanitize' => 'bool',
|
506 |
+
),
|
507 |
+
'_um_profile_secondary_btn_word' => array(
|
508 |
+
'sanitize' => 'text',
|
509 |
+
),
|
510 |
+
'_um_profile_cover_enabled' => array(
|
511 |
+
'sanitize' => 'bool',
|
512 |
+
),
|
513 |
+
'_um_profile_coversize' => array(
|
514 |
+
'sanitize' => 'absint',
|
515 |
+
),
|
516 |
+
'_um_profile_cover_ratio' => array(
|
517 |
+
'sanitize' => 'text',
|
518 |
+
),
|
519 |
+
'_um_profile_disable_photo_upload' => array(
|
520 |
+
'sanitize' => 'bool',
|
521 |
+
),
|
522 |
+
'_um_profile_photosize' => array(
|
523 |
+
'sanitize' => array( $this, 'sanitize_photosize' ),
|
524 |
+
),
|
525 |
+
'_um_profile_photo_required' => array(
|
526 |
+
'sanitize' => 'bool',
|
527 |
+
),
|
528 |
+
'_um_profile_show_name' => array(
|
529 |
+
'sanitize' => 'bool',
|
530 |
+
),
|
531 |
+
'_um_profile_show_social_links' => array(
|
532 |
+
'sanitize' => 'bool',
|
533 |
+
),
|
534 |
+
'_um_profile_show_bio' => array(
|
535 |
+
'sanitize' => 'bool',
|
536 |
+
),
|
537 |
+
|
538 |
+
)
|
539 |
+
);
|
540 |
+
|
541 |
+
$this->builder_input = apply_filters(
|
542 |
+
'um_builder_input_map',
|
543 |
+
array(
|
544 |
+
'_in_row' => array(
|
545 |
+
'sanitize' => 'key',
|
546 |
+
),
|
547 |
+
'_in_sub_row' => array(
|
548 |
+
'sanitize' => 'absint',
|
549 |
+
),
|
550 |
+
'_in_column' => array(
|
551 |
+
'sanitize' => 'absint',
|
552 |
+
),
|
553 |
+
'_in_group' => array(
|
554 |
+
'sanitize' => 'absint',
|
555 |
+
),
|
556 |
+
'_visibility' => array(
|
557 |
+
'sanitize' => 'key',
|
558 |
+
),
|
559 |
+
'_conditional_action' => array(
|
560 |
+
'sanitize' => 'key',
|
561 |
+
),
|
562 |
+
'_conditional_action1' => array(
|
563 |
+
'sanitize' => 'key',
|
564 |
+
),
|
565 |
+
'_conditional_action2' => array(
|
566 |
+
'sanitize' => 'key',
|
567 |
+
),
|
568 |
+
'_conditional_action3' => array(
|
569 |
+
'sanitize' => 'key',
|
570 |
+
),
|
571 |
+
'_conditional_action4' => array(
|
572 |
+
'sanitize' => 'key',
|
573 |
+
),
|
574 |
+
'_conditional_field' => array(
|
575 |
+
'sanitize' => 'text',
|
576 |
+
),
|
577 |
+
'_conditional_field1' => array(
|
578 |
+
'sanitize' => 'text',
|
579 |
+
),
|
580 |
+
'_conditional_field2' => array(
|
581 |
+
'sanitize' => 'text',
|
582 |
+
),
|
583 |
+
'_conditional_field3' => array(
|
584 |
+
'sanitize' => 'text',
|
585 |
+
),
|
586 |
+
'_conditional_field4' => array(
|
587 |
+
'sanitize' => 'text',
|
588 |
+
),
|
589 |
+
'_conditional_operator' => array(
|
590 |
+
'sanitize' => 'text',
|
591 |
+
),
|
592 |
+
'_conditional_operator1' => array(
|
593 |
+
'sanitize' => 'text',
|
594 |
+
),
|
595 |
+
'_conditional_operator2' => array(
|
596 |
+
'sanitize' => 'text',
|
597 |
+
),
|
598 |
+
'_conditional_operator3' => array(
|
599 |
+
'sanitize' => 'text',
|
600 |
+
),
|
601 |
+
'_conditional_operator4' => array(
|
602 |
+
'sanitize' => 'text',
|
603 |
+
),
|
604 |
+
'_conditional_value' => array(
|
605 |
+
'sanitize' => 'text',
|
606 |
+
),
|
607 |
+
'_conditional_value1' => array(
|
608 |
+
'sanitize' => 'text',
|
609 |
+
),
|
610 |
+
'_conditional_value2' => array(
|
611 |
+
'sanitize' => 'text',
|
612 |
+
),
|
613 |
+
'_conditional_value3' => array(
|
614 |
+
'sanitize' => 'text',
|
615 |
+
),
|
616 |
+
'_conditional_value4' => array(
|
617 |
+
'sanitize' => 'text',
|
618 |
+
),
|
619 |
+
'_validate' => array(
|
620 |
+
'sanitize' => 'key',
|
621 |
+
),
|
622 |
+
'_custom_validate' => array(
|
623 |
+
'sanitize' => 'text',
|
624 |
+
),
|
625 |
+
'_icon' => array(
|
626 |
+
'sanitize' => 'key',
|
627 |
+
),
|
628 |
+
'_css_class' => array(
|
629 |
+
'sanitize' => 'text',
|
630 |
+
),
|
631 |
+
'_width' => array(
|
632 |
+
'sanitize' => 'absint',
|
633 |
+
),
|
634 |
+
'_divider_text' => array(
|
635 |
+
'sanitize' => 'text',
|
636 |
+
),
|
637 |
+
'_padding' => array(
|
638 |
+
'sanitize' => 'text',
|
639 |
+
),
|
640 |
+
'_margin' => array(
|
641 |
+
'sanitize' => 'text',
|
642 |
+
),
|
643 |
+
'_border' => array(
|
644 |
+
'sanitize' => 'text',
|
645 |
+
),
|
646 |
+
'_borderstyle' => array(
|
647 |
+
'sanitize' => 'key',
|
648 |
+
),
|
649 |
+
'_borderradius' => array(
|
650 |
+
'sanitize' => 'text',
|
651 |
+
),
|
652 |
+
'_bordercolor' => array(
|
653 |
+
'sanitize' => 'text',
|
654 |
+
),
|
655 |
+
'_heading' => array(
|
656 |
+
'sanitize' => 'bool',
|
657 |
+
),
|
658 |
+
'_heading_text' => array(
|
659 |
+
'sanitize' => 'text',
|
660 |
+
),
|
661 |
+
'_background' => array(
|
662 |
+
'sanitize' => 'text',
|
663 |
+
),
|
664 |
+
'_heading_background_color' => array(
|
665 |
+
'sanitize' => 'text',
|
666 |
+
),
|
667 |
+
'_heading_text_color' => array(
|
668 |
+
'sanitize' => 'text',
|
669 |
+
),
|
670 |
+
'_text_color' => array(
|
671 |
+
'sanitize' => 'text',
|
672 |
+
),
|
673 |
+
'_icon_color' => array(
|
674 |
+
'sanitize' => 'text',
|
675 |
+
),
|
676 |
+
'_color' => array(
|
677 |
+
'sanitize' => 'text',
|
678 |
+
),
|
679 |
+
'_url_text' => array(
|
680 |
+
'sanitize' => 'text',
|
681 |
+
),
|
682 |
+
'_url_target' => array(
|
683 |
+
'sanitize' => 'key',
|
684 |
+
),
|
685 |
+
'_url_rel' => array(
|
686 |
+
'sanitize' => 'key',
|
687 |
+
),
|
688 |
+
'_force_good_pass' => array(
|
689 |
+
'sanitize' => 'bool',
|
690 |
+
),
|
691 |
+
'_force_confirm_pass' => array(
|
692 |
+
'sanitize' => 'bool',
|
693 |
+
),
|
694 |
+
'_style' => array(
|
695 |
+
'sanitize' => 'key',
|
696 |
+
),
|
697 |
+
'_intervals' => array(
|
698 |
+
'sanitize' => 'absint',
|
699 |
+
),
|
700 |
+
'_format' => array(
|
701 |
+
'sanitize' => 'text',
|
702 |
+
),
|
703 |
+
'_format_custom' => array(
|
704 |
+
'sanitize' => 'text',
|
705 |
+
),
|
706 |
+
'_pretty_format' => array(
|
707 |
+
'sanitize' => 'bool',
|
708 |
+
),
|
709 |
+
'_disabled_weekdays' => array(
|
710 |
+
'sanitize' => 'absint',
|
711 |
+
),
|
712 |
+
'_years' => array(
|
713 |
+
'sanitize' => 'absint',
|
714 |
+
),
|
715 |
+
'_years_x' => array(
|
716 |
+
'sanitize' => 'key',
|
717 |
+
),
|
718 |
+
'_range_start' => array(
|
719 |
+
'sanitize' => 'text',
|
720 |
+
),
|
721 |
+
'_range_end' => array(
|
722 |
+
'sanitize' => 'text',
|
723 |
+
),
|
724 |
+
'_range' => array(
|
725 |
+
'sanitize' => 'key',
|
726 |
+
),
|
727 |
+
'_content' => array(
|
728 |
+
'sanitize' => 'textarea',
|
729 |
+
),
|
730 |
+
'_crop' => array(
|
731 |
+
'sanitize' => 'int',
|
732 |
+
),
|
733 |
+
'_allowed_types' => array(
|
734 |
+
'sanitize' => 'key',
|
735 |
+
),
|
736 |
+
'_upload_text' => array(
|
737 |
+
'sanitize' => 'text',
|
738 |
+
),
|
739 |
+
'_upload_help_text' => array(
|
740 |
+
'sanitize' => 'text',
|
741 |
+
),
|
742 |
+
'_button_text' => array(
|
743 |
+
'sanitize' => 'text',
|
744 |
+
),
|
745 |
+
'_max_size' => array(
|
746 |
+
'sanitize' => 'absint',
|
747 |
+
),
|
748 |
+
'_height' => array(
|
749 |
+
'sanitize' => 'text',
|
750 |
+
),
|
751 |
+
'_spacing' => array(
|
752 |
+
'sanitize' => 'text',
|
753 |
+
),
|
754 |
+
'_is_multi' => array(
|
755 |
+
'sanitize' => 'bool',
|
756 |
+
),
|
757 |
+
'_max_selections' => array(
|
758 |
+
'sanitize' => 'absint',
|
759 |
+
),
|
760 |
+
'_min_selections' => array(
|
761 |
+
'sanitize' => 'absint',
|
762 |
+
),
|
763 |
+
'_max_entries' => array(
|
764 |
+
'sanitize' => 'absint',
|
765 |
+
),
|
766 |
+
'_max_words' => array(
|
767 |
+
'sanitize' => 'absint',
|
768 |
+
),
|
769 |
+
'_min' => array(
|
770 |
+
'sanitize' => 'empty_int',
|
771 |
+
),
|
772 |
+
'_max' => array(
|
773 |
+
'sanitize' => 'empty_int',
|
774 |
+
),
|
775 |
+
'_min_chars' => array(
|
776 |
+
'sanitize' => 'absint',
|
777 |
+
),
|
778 |
+
'_max_chars' => array(
|
779 |
+
'sanitize' => 'absint',
|
780 |
+
),
|
781 |
+
'_html' => array(
|
782 |
+
'sanitize' => 'bool',
|
783 |
+
),
|
784 |
+
'_options' => array(
|
785 |
+
'sanitize' => 'textarea',
|
786 |
+
),
|
787 |
+
'_title' => array(
|
788 |
+
'sanitize' => 'text',
|
789 |
+
),
|
790 |
+
'_id' => array(
|
791 |
+
'sanitize' => 'text',
|
792 |
+
),
|
793 |
+
'_metakey' => array(
|
794 |
+
'sanitize' => 'text',
|
795 |
+
),
|
796 |
+
'_help' => array(
|
797 |
+
'sanitize' => 'text',
|
798 |
+
),
|
799 |
+
'_default' => array(
|
800 |
+
'sanitize' => 'text',
|
801 |
+
),
|
802 |
+
'_label' => array(
|
803 |
+
'sanitize' => 'text',
|
804 |
+
),
|
805 |
+
'_label_confirm_pass' => array(
|
806 |
+
'sanitize' => 'text',
|
807 |
+
),
|
808 |
+
'_placeholder' => array(
|
809 |
+
'sanitize' => 'text',
|
810 |
+
),
|
811 |
+
'_public' => array(
|
812 |
+
'sanitize' => 'text',
|
813 |
+
),
|
814 |
+
'_roles' => array(
|
815 |
+
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
816 |
+
),
|
817 |
+
'_required' => array(
|
818 |
+
'sanitize' => 'bool',
|
819 |
+
),
|
820 |
+
'_editable' => array(
|
821 |
+
'sanitize' => 'bool',
|
822 |
+
),
|
823 |
+
'_number' => array(
|
824 |
+
'sanitize' => 'absint',
|
825 |
+
),
|
826 |
+
'_custom_dropdown_options_source' => array(
|
827 |
+
'sanitize' => 'text',
|
828 |
+
),
|
829 |
+
'_parent_dropdown_relationship' => array(
|
830 |
+
'sanitize' => 'text',
|
831 |
+
),
|
832 |
+
)
|
833 |
+
);
|
834 |
+
}
|
835 |
+
|
836 |
+
|
837 |
+
/**
|
838 |
+
* @param array|string $value
|
839 |
+
*
|
840 |
+
* @return array|string
|
841 |
+
*/
|
842 |
+
public function sanitize_md_sorting_fields( $value ) {
|
843 |
+
$filter_fields = array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) );
|
844 |
+
$filter_fields = array_keys( $filter_fields );
|
845 |
+
|
846 |
+
if ( '' !== $value ) {
|
847 |
+
$value = array_filter(
|
848 |
+
$value,
|
849 |
+
function( $v, $k ) use ( $filter_fields ) {
|
850 |
+
if ( 'other_data' === $k ) {
|
851 |
+
return true;
|
852 |
+
} else {
|
853 |
+
return in_array( sanitize_text_field( $v ), $filter_fields, true );
|
854 |
+
}
|
855 |
+
},
|
856 |
+
ARRAY_FILTER_USE_BOTH
|
857 |
+
);
|
858 |
+
|
859 |
+
$value = array_map(
|
860 |
+
function( $item ) {
|
861 |
+
if ( is_array( $item ) ) {
|
862 |
+
if ( isset( $item['meta_key'] ) ) {
|
863 |
+
$item['meta_key'] = sanitize_text_field( $item['meta_key'] );
|
864 |
+
}
|
865 |
+
if ( isset( $item['label'] ) ) {
|
866 |
+
$item['label'] = sanitize_text_field( $item['label'] );
|
867 |
+
}
|
868 |
+
|
869 |
+
return $item;
|
870 |
+
} else {
|
871 |
+
return sanitize_text_field( $item );
|
872 |
+
}
|
873 |
+
},
|
874 |
+
$value
|
875 |
+
);
|
876 |
+
}
|
877 |
+
|
878 |
+
return $value;
|
879 |
+
}
|
880 |
+
|
881 |
+
|
882 |
+
/**
|
883 |
+
* @param array|string $value
|
884 |
+
*
|
885 |
+
* @return array|string
|
886 |
+
*/
|
887 |
+
public function sanitize_filter_fields( $value ) {
|
888 |
+
$filter_fields = array_keys( UM()->member_directory()->filter_fields );
|
889 |
+
|
890 |
+
if ( '' !== $value ) {
|
891 |
+
$value = array_filter(
|
892 |
+
$value,
|
893 |
+
function( $v, $k ) use ( $filter_fields ) {
|
894 |
+
return in_array( sanitize_text_field( $v ), $filter_fields, true );
|
895 |
+
},
|
896 |
+
ARRAY_FILTER_USE_BOTH
|
897 |
+
);
|
898 |
+
|
899 |
+
$value = array_map( 'sanitize_text_field', $value );
|
900 |
+
}
|
901 |
+
|
902 |
+
return $value;
|
903 |
+
}
|
904 |
+
|
905 |
+
|
906 |
+
/**
|
907 |
+
* @param array|string $value
|
908 |
+
*
|
909 |
+
* @return array|string
|
910 |
+
*/
|
911 |
+
public function sanitize_user_field( $value ) {
|
912 |
+
$user_fields = array_keys( UM()->builtin()->all_user_fields() );
|
913 |
+
|
914 |
+
if ( '' !== $value ) {
|
915 |
+
$value = array_filter(
|
916 |
+
$value,
|
917 |
+
function( $v, $k ) use ( $user_fields ) {
|
918 |
+
return in_array( sanitize_text_field( $v ), $user_fields, true );
|
919 |
+
},
|
920 |
+
ARRAY_FILTER_USE_BOTH
|
921 |
+
);
|
922 |
+
|
923 |
+
$value = array_map( 'sanitize_text_field', $value );
|
924 |
+
}
|
925 |
+
|
926 |
+
return $value;
|
927 |
+
}
|
928 |
+
|
929 |
+
|
930 |
+
/**
|
931 |
+
* @param array|string $value
|
932 |
+
*
|
933 |
+
* @return array|string
|
934 |
+
*/
|
935 |
+
public function sanitize_md_view_types( $value ) {
|
936 |
+
$view_types = array_map(
|
937 |
+
function ( $item ) {
|
938 |
+
return $item['title'];
|
939 |
+
},
|
940 |
+
UM()->member_directory()->view_types
|
941 |
+
);
|
942 |
+
$view_types = array_keys( $view_types );
|
943 |
+
|
944 |
+
if ( '' !== $value ) {
|
945 |
+
$value = array_filter(
|
946 |
+
$value,
|
947 |
+
function( $v, $k ) use ( $view_types ) {
|
948 |
+
return in_array( sanitize_key( $k ), $view_types, true ) && 1 === (int) $v;
|
949 |
+
},
|
950 |
+
ARRAY_FILTER_USE_BOTH
|
951 |
+
);
|
952 |
+
|
953 |
+
$value = array_map( 'sanitize_key', $value );
|
954 |
+
}
|
955 |
+
|
956 |
+
return $value;
|
957 |
+
}
|
958 |
+
|
959 |
+
|
960 |
+
/**
|
961 |
+
* @param array|string $value
|
962 |
+
*
|
963 |
+
* @return array|string
|
964 |
+
*/
|
965 |
+
public function sanitize_photosize( $value ) {
|
966 |
+
$sizes = UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' );
|
967 |
+
$sizes = array_keys( $sizes );
|
968 |
+
|
969 |
+
if ( '' !== $value ) {
|
970 |
+
$value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
|
971 |
+
}
|
972 |
+
|
973 |
+
return $value;
|
974 |
+
}
|
975 |
+
|
976 |
+
|
977 |
+
/**
|
978 |
+
* @param array|string $value
|
979 |
+
*
|
980 |
+
* @return array|string
|
981 |
+
*/
|
982 |
+
public function sanitize_cover_photosize( $value ) {
|
983 |
+
$sizes = UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' );
|
984 |
+
$sizes = array_keys( $sizes );
|
985 |
+
|
986 |
+
if ( '' !== $value ) {
|
987 |
+
$value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
|
988 |
+
}
|
989 |
+
|
990 |
+
return $value;
|
991 |
+
}
|
992 |
+
|
993 |
+
|
994 |
+
/**
|
995 |
+
* @param array|string $value
|
996 |
+
*
|
997 |
+
* @return array|string
|
998 |
+
*/
|
999 |
+
public function sanitize_restriction_existed_role( $value ) {
|
1000 |
+
$all_roles = array_keys( UM()->roles()->get_roles() );
|
1001 |
+
|
1002 |
+
if ( '' !== $value ) {
|
1003 |
+
$value = array_filter(
|
1004 |
+
$value,
|
1005 |
+
function( $v, $k ) use ( $all_roles ) {
|
1006 |
+
return in_array( sanitize_key( $k ), $all_roles, true ) && 1 === (int) $v;
|
1007 |
+
},
|
1008 |
+
ARRAY_FILTER_USE_BOTH
|
1009 |
+
);
|
1010 |
+
|
1011 |
+
$value = array_map( 'sanitize_key', $value );
|
1012 |
+
}
|
1013 |
+
|
1014 |
+
return $value;
|
1015 |
+
}
|
1016 |
+
|
1017 |
+
|
1018 |
+
/**
|
1019 |
+
* @param array|string $value
|
1020 |
+
*
|
1021 |
+
* @return array|string
|
1022 |
+
*/
|
1023 |
+
public function sanitize_existed_role( $value ) {
|
1024 |
+
$all_roles = array_keys( UM()->roles()->get_roles() );
|
1025 |
+
|
1026 |
+
if ( '' !== $value ) {
|
1027 |
+
$value = array_filter(
|
1028 |
+
$value,
|
1029 |
+
function( $v, $k ) use ( $all_roles ) {
|
1030 |
+
return in_array( sanitize_key( $v ), $all_roles, true );
|
1031 |
+
},
|
1032 |
+
ARRAY_FILTER_USE_BOTH
|
1033 |
+
);
|
1034 |
+
|
1035 |
+
$value = array_map( 'sanitize_key', $value );
|
1036 |
+
}
|
1037 |
+
|
1038 |
+
return $value;
|
1039 |
+
}
|
1040 |
+
|
1041 |
+
|
1042 |
+
/**
|
1043 |
+
* @param array|string $value
|
1044 |
+
*
|
1045 |
+
* @return array|string
|
1046 |
+
*/
|
1047 |
+
public function sanitize_tabs_privacy( $value ) {
|
1048 |
+
$all_privacy = array_keys( UM()->profile()->tabs_privacy() );
|
1049 |
+
|
1050 |
+
if ( '' !== $value ) {
|
1051 |
+
$value = in_array( absint( $value ), $all_privacy, true ) ? absint( $value ) : '';
|
1052 |
+
}
|
1053 |
+
|
1054 |
+
return $value;
|
1055 |
+
}
|
1056 |
+
|
1057 |
+
|
1058 |
+
/**
|
1059 |
+
* @param $value
|
1060 |
+
*
|
1061 |
+
* @return bool|string
|
1062 |
+
*/
|
1063 |
+
public function sanitize_profile_noindex( $value ) {
|
1064 |
+
$value = '' !== $value ? (bool) $value : $value;
|
1065 |
+
return $value;
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
|
1069 |
+
/**
|
1070 |
+
* @param $value
|
1071 |
+
*
|
1072 |
+
* @return array
|
1073 |
+
*/
|
1074 |
+
public function sanitize_wp_capabilities( $value ) {
|
1075 |
+
$value = array_map( 'boolval', array_filter( $value ) );
|
1076 |
+
return $value;
|
1077 |
+
}
|
1078 |
+
|
1079 |
+
|
1080 |
+
/**
|
1081 |
+
* Sanitize role meta fields when wp-admin form has been submitted
|
1082 |
+
*
|
1083 |
+
* @param array $data
|
1084 |
+
*
|
1085 |
+
* @return array
|
1086 |
+
*/
|
1087 |
+
public function sanitize_role_meta( $data ) {
|
1088 |
+
$sanitized = array();
|
1089 |
+
foreach ( $data as $k => $v ) {
|
1090 |
+
if ( ! array_key_exists( $k, $this->role_meta ) ) {
|
1091 |
+
// @todo remove since 2.2.x and leave only continue
|
1092 |
+
$sanitized[ $k ] = $v;
|
1093 |
+
continue;
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
if ( ! array_key_exists( 'sanitize', $this->role_meta[ $k ] ) ) {
|
1097 |
+
// @todo remove since 2.2.x and leave only continue
|
1098 |
+
$sanitized[ $k ] = $v;
|
1099 |
+
continue;
|
1100 |
+
}
|
1101 |
+
|
1102 |
+
if ( is_callable( $this->role_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1103 |
+
add_filter( 'um_role_meta_sanitize_' . $k, $this->role_meta[ $k ]['sanitize'], 10, 1 );
|
1104 |
+
}
|
1105 |
+
|
1106 |
+
switch ( $this->role_meta[ $k ]['sanitize'] ) {
|
1107 |
+
default:
|
1108 |
+
$sanitized[ $k ] = apply_filters( 'um_role_meta_sanitize_' . $k, $data[ $k ] );
|
1109 |
+
break;
|
1110 |
+
case 'int':
|
1111 |
+
$sanitized[ $k ] = (int) $v;
|
1112 |
+
break;
|
1113 |
+
case 'bool':
|
1114 |
+
$sanitized[ $k ] = (bool) $v;
|
1115 |
+
break;
|
1116 |
+
case 'url':
|
1117 |
+
$sanitized[ $k ] = esc_url_raw( $v );
|
1118 |
+
break;
|
1119 |
+
case 'textarea':
|
1120 |
+
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1121 |
+
break;
|
1122 |
+
case 'sanitize_array_key':
|
1123 |
+
if ( ! array_key_exists( 'default', $this->role_meta[ $k ] ) || ! array_key_exists( 'array', $this->role_meta[ $k ] ) ) {
|
1124 |
+
continue 2;
|
1125 |
+
}
|
1126 |
+
|
1127 |
+
$sanitized[ $k ] = ! in_array( sanitize_key( $v ), $this->role_meta[ $k ]['array'], true ) ? $this->role_meta[ $k ]['default'] : sanitize_key( $v );
|
1128 |
+
break;
|
1129 |
+
}
|
1130 |
+
}
|
1131 |
+
|
1132 |
+
$data = $sanitized;
|
1133 |
+
|
1134 |
+
$data = apply_filters( 'um_save_role_meta_sanitize', $data );
|
1135 |
+
|
1136 |
+
return $data;
|
1137 |
+
}
|
1138 |
+
|
1139 |
+
|
1140 |
+
/**
|
1141 |
+
* Sanitize post restriction meta fields when wp-admin form has been submitted
|
1142 |
+
*
|
1143 |
+
* @param array $data
|
1144 |
+
*
|
1145 |
+
* @return array
|
1146 |
+
*/
|
1147 |
+
public function sanitize_post_restriction_meta( $data ) {
|
1148 |
+
$sanitized = array();
|
1149 |
+
foreach ( $data as $k => $v ) {
|
1150 |
+
if ( ! array_key_exists( $k, $this->restriction_post_meta ) ) {
|
1151 |
+
// @todo remove since 2.2.x and leave only continue
|
1152 |
+
$sanitized[ $k ] = $v;
|
1153 |
+
continue;
|
1154 |
+
}
|
1155 |
+
|
1156 |
+
if ( ! array_key_exists( 'sanitize', $this->restriction_post_meta[ $k ] ) ) {
|
1157 |
+
// @todo remove since 2.2.x and leave only continue
|
1158 |
+
$sanitized[ $k ] = $v;
|
1159 |
+
continue;
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
if ( is_callable( $this->restriction_post_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1163 |
+
add_filter( 'um_restriction_post_meta_sanitize_' . $k, $this->restriction_post_meta[ $k ]['sanitize'], 10, 1 );
|
1164 |
+
}
|
1165 |
+
|
1166 |
+
switch ( $this->restriction_post_meta[ $k ]['sanitize'] ) {
|
1167 |
+
default:
|
1168 |
+
$sanitized[ $k ] = apply_filters( 'um_restriction_post_meta_sanitize_' . $k, $data[ $k ] );
|
1169 |
+
break;
|
1170 |
+
case 'int':
|
1171 |
+
$sanitized[ $k ] = (int) $v;
|
1172 |
+
break;
|
1173 |
+
case 'bool':
|
1174 |
+
$sanitized[ $k ] = (bool) $v;
|
1175 |
+
break;
|
1176 |
+
case 'url':
|
1177 |
+
$sanitized[ $k ] = esc_url_raw( $v );
|
1178 |
+
break;
|
1179 |
+
case 'textarea':
|
1180 |
+
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1181 |
+
break;
|
1182 |
+
case 'wp_kses':
|
1183 |
+
$sanitized[ $k ] = wp_kses_post( $v );
|
1184 |
+
break;
|
1185 |
+
}
|
1186 |
+
}
|
1187 |
+
|
1188 |
+
$data = $sanitized;
|
1189 |
+
|
1190 |
+
$data = apply_filters( 'um_save_restriction_post_meta_sanitize', $data );
|
1191 |
+
|
1192 |
+
return $data;
|
1193 |
+
}
|
1194 |
+
|
1195 |
+
|
1196 |
+
/**
|
1197 |
+
* Sanitize term restriction meta fields when wp-admin form has been submitted
|
1198 |
+
*
|
1199 |
+
* @param array $data
|
1200 |
+
*
|
1201 |
+
* @return array
|
1202 |
+
*/
|
1203 |
+
public function sanitize_term_restriction_meta( $data ) {
|
1204 |
+
$sanitized = array();
|
1205 |
+
foreach ( $data as $k => $v ) {
|
1206 |
+
if ( ! array_key_exists( $k, $this->restriction_term_meta ) ) {
|
1207 |
+
// @todo remove since 2.2.x and leave only continue
|
1208 |
+
$sanitized[ $k ] = $v;
|
1209 |
+
continue;
|
1210 |
+
}
|
1211 |
+
|
1212 |
+
if ( ! array_key_exists( 'sanitize', $this->restriction_term_meta[ $k ] ) ) {
|
1213 |
+
// @todo remove since 2.2.x and leave only continue
|
1214 |
+
$sanitized[ $k ] = $v;
|
1215 |
+
continue;
|
1216 |
+
}
|
1217 |
+
|
1218 |
+
if ( is_callable( $this->restriction_term_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1219 |
+
add_filter( 'um_restriction_term_meta_sanitize_' . $k, $this->restriction_term_meta[ $k ]['sanitize'], 10, 1 );
|
1220 |
+
}
|
1221 |
+
|
1222 |
+
switch ( $this->restriction_term_meta[ $k ]['sanitize'] ) {
|
1223 |
+
default:
|
1224 |
+
$sanitized[ $k ] = apply_filters( 'um_restriction_term_meta_sanitize_' . $k, $data[ $k ] );
|
1225 |
+
break;
|
1226 |
+
case 'int':
|
1227 |
+
$sanitized[ $k ] = (int) $v;
|
1228 |
+
break;
|
1229 |
+
case 'bool':
|
1230 |
+
$sanitized[ $k ] = (bool) $v;
|
1231 |
+
break;
|
1232 |
+
case 'url':
|
1233 |
+
$sanitized[ $k ] = esc_url_raw( $v );
|
1234 |
+
break;
|
1235 |
+
case 'textarea':
|
1236 |
+
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1237 |
+
break;
|
1238 |
+
case 'wp_kses':
|
1239 |
+
$sanitized[ $k ] = wp_kses_post( $v );
|
1240 |
+
break;
|
1241 |
+
}
|
1242 |
+
}
|
1243 |
+
|
1244 |
+
$data = $sanitized;
|
1245 |
+
|
1246 |
+
$data = apply_filters( 'um_save_restriction_term_meta_sanitize', $data );
|
1247 |
+
|
1248 |
+
return $data;
|
1249 |
+
}
|
1250 |
+
|
1251 |
+
|
1252 |
+
/**
|
1253 |
+
* Sanitize member directory meta when wp-admin form has been submitted
|
1254 |
+
*
|
1255 |
+
* @todo checking all sanitize types
|
1256 |
+
*
|
1257 |
+
* @param array $data
|
1258 |
+
*
|
1259 |
+
* @return array
|
1260 |
+
*/
|
1261 |
+
public function sanitize_member_directory_meta( $data ) {
|
1262 |
+
$sanitized = array();
|
1263 |
+
foreach ( $data as $k => $v ) {
|
1264 |
+
if ( ! array_key_exists( $k, $this->member_directory_meta ) ) {
|
1265 |
+
// @todo remove since 2.2.x and leave only continue
|
1266 |
+
$sanitized[ $k ] = $v;
|
1267 |
+
continue;
|
1268 |
+
}
|
1269 |
+
|
1270 |
+
if ( ! array_key_exists( 'sanitize', $this->member_directory_meta[ $k ] ) ) {
|
1271 |
+
// @todo remove since 2.2.x and leave only continue
|
1272 |
+
$sanitized[ $k ] = $v;
|
1273 |
+
continue;
|
1274 |
+
}
|
1275 |
+
|
1276 |
+
if ( is_callable( $this->member_directory_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1277 |
+
add_filter( 'um_member_directory_meta_sanitize_' . $k, $this->member_directory_meta[ $k ]['sanitize'], 10, 1 );
|
1278 |
+
}
|
1279 |
+
|
1280 |
+
switch ( $this->member_directory_meta[ $k ]['sanitize'] ) {
|
1281 |
+
default:
|
1282 |
+
$sanitized[ $k ] = apply_filters( 'um_member_directory_meta_sanitize_' . $k, $data[ $k ] );
|
1283 |
+
break;
|
1284 |
+
case 'int':
|
1285 |
+
$sanitized[ $k ] = (int) $v;
|
1286 |
+
break;
|
1287 |
+
case 'bool':
|
1288 |
+
$sanitized[ $k ] = (bool) $v;
|
1289 |
+
break;
|
1290 |
+
case 'url':
|
1291 |
+
if ( is_array( $v ) ) {
|
1292 |
+
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1293 |
+
} else {
|
1294 |
+
$sanitized[ $k ] = esc_url_raw( $v );
|
1295 |
+
}
|
1296 |
+
break;
|
1297 |
+
case 'text':
|
1298 |
+
$sanitized[ $k ] = sanitize_text_field( $v );
|
1299 |
+
break;
|
1300 |
+
case 'textarea':
|
1301 |
+
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1302 |
+
break;
|
1303 |
+
case 'key':
|
1304 |
+
if ( is_array( $v ) ) {
|
1305 |
+
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1306 |
+
} else {
|
1307 |
+
$sanitized[ $k ] = sanitize_key( $v );
|
1308 |
+
}
|
1309 |
+
break;
|
1310 |
+
case 'absint':
|
1311 |
+
if ( is_array( $v ) ) {
|
1312 |
+
$sanitized[ $k ] = array_map( 'absint', $v );
|
1313 |
+
} else {
|
1314 |
+
$sanitized[ $k ] = absint( $v );
|
1315 |
+
}
|
1316 |
+
break;
|
1317 |
+
}
|
1318 |
+
}
|
1319 |
+
|
1320 |
+
$data = $sanitized;
|
1321 |
+
|
1322 |
+
$data = apply_filters( 'um_save_member_directory_meta_sanitize', $data );
|
1323 |
+
|
1324 |
+
return $data;
|
1325 |
+
}
|
1326 |
+
|
1327 |
+
|
1328 |
+
/**
|
1329 |
+
* Sanitize builder field meta when wp-admin form has been submitted
|
1330 |
+
*
|
1331 |
+
* @todo checking all sanitize types
|
1332 |
+
*
|
1333 |
+
* @param array $data
|
1334 |
+
*
|
1335 |
+
* @return array
|
1336 |
+
*/
|
1337 |
+
public function sanitize_builder_field_meta( $data ) {
|
1338 |
+
$sanitized = array();
|
1339 |
+
foreach ( $data as $k => $v ) {
|
1340 |
+
if ( ! array_key_exists( $k, $this->builder_input ) ) {
|
1341 |
+
// @todo remove since 2.2.x and leave only continue
|
1342 |
+
$sanitized[ $k ] = $v;
|
1343 |
+
continue;
|
1344 |
+
}
|
1345 |
+
|
1346 |
+
if ( ! array_key_exists( 'sanitize', $this->builder_input[ $k ] ) ) {
|
1347 |
+
// @todo remove since 2.2.x and leave only continue
|
1348 |
+
$sanitized[ $k ] = $v;
|
1349 |
+
continue;
|
1350 |
+
}
|
1351 |
+
|
1352 |
+
if ( is_callable( $this->builder_input[ $k ]['sanitize'], true, $callable_name ) ) {
|
1353 |
+
add_filter( 'um_builder_input_sanitize_' . $k, $this->builder_input[ $k ]['sanitize'], 10, 1 );
|
1354 |
+
}
|
1355 |
+
|
1356 |
+
switch ( $this->builder_input[ $k ]['sanitize'] ) {
|
1357 |
+
default:
|
1358 |
+
$sanitized[ $k ] = apply_filters( 'um_builder_input_sanitize_' . $k, $data[ $k ] );
|
1359 |
+
break;
|
1360 |
+
case 'int':
|
1361 |
+
$sanitized[ $k ] = (int) $v;
|
1362 |
+
break;
|
1363 |
+
case 'empty_int':
|
1364 |
+
$sanitized[ $k ] = ( '' !== $v ) ? (int) $v : '';
|
1365 |
+
break;
|
1366 |
+
case 'bool':
|
1367 |
+
$sanitized[ $k ] = (bool) $v;
|
1368 |
+
break;
|
1369 |
+
case 'url':
|
1370 |
+
if ( is_array( $v ) ) {
|
1371 |
+
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1372 |
+
} else {
|
1373 |
+
$sanitized[ $k ] = esc_url_raw( $v );
|
1374 |
+
}
|
1375 |
+
break;
|
1376 |
+
case 'text':
|
1377 |
+
$sanitized[ $k ] = sanitize_text_field( $v );
|
1378 |
+
break;
|
1379 |
+
case 'textarea':
|
1380 |
+
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1381 |
+
break;
|
1382 |
+
case 'wp_kses':
|
1383 |
+
$sanitized[ $k ] = wp_kses_post( $v );
|
1384 |
+
break;
|
1385 |
+
case 'key':
|
1386 |
+
if ( is_array( $v ) ) {
|
1387 |
+
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1388 |
+
} else {
|
1389 |
+
$sanitized[ $k ] = sanitize_key( $v );
|
1390 |
+
}
|
1391 |
+
break;
|
1392 |
+
case 'absint':
|
1393 |
+
if ( is_array( $v ) ) {
|
1394 |
+
$sanitized[ $k ] = array_map( 'absint', $v );
|
1395 |
+
} else {
|
1396 |
+
$sanitized[ $k ] = absint( $v );
|
1397 |
+
}
|
1398 |
+
break;
|
1399 |
+
case 'empty_absint':
|
1400 |
+
if ( is_array( $v ) ) {
|
1401 |
+
$sanitized[ $k ] = array_map( 'absint', $v );
|
1402 |
+
} else {
|
1403 |
+
$sanitized[ $k ] = ( '' !== $v ) ? absint( $v ) : '';
|
1404 |
+
}
|
1405 |
+
break;
|
1406 |
+
}
|
1407 |
+
}
|
1408 |
+
|
1409 |
+
$data = $sanitized;
|
1410 |
+
|
1411 |
+
$data = apply_filters( 'um_save_builder_input_sanitize', $data );
|
1412 |
+
|
1413 |
+
return $data;
|
1414 |
+
}
|
1415 |
+
|
1416 |
+
|
1417 |
+
/**
|
1418 |
+
* Sanitize form meta when wp-admin form has been submitted
|
1419 |
+
*
|
1420 |
+
* @todo checking all sanitize types
|
1421 |
+
*
|
1422 |
+
* @param array $data
|
1423 |
+
*
|
1424 |
+
* @return array
|
1425 |
+
*/
|
1426 |
+
public function sanitize_form_meta( $data ) {
|
1427 |
+
$sanitized = array();
|
1428 |
+
foreach ( $data as $k => $v ) {
|
1429 |
+
if ( ! array_key_exists( $k, $this->form_meta ) ) {
|
1430 |
+
// @todo remove since 2.2.x and leave only continue
|
1431 |
+
$sanitized[ $k ] = $v;
|
1432 |
+
continue;
|
1433 |
+
}
|
1434 |
+
|
1435 |
+
if ( ! array_key_exists( 'sanitize', $this->form_meta[ $k ] ) ) {
|
1436 |
+
// @todo remove since 2.2.x and leave only continue
|
1437 |
+
$sanitized[ $k ] = $v;
|
1438 |
+
continue;
|
1439 |
+
}
|
1440 |
+
|
1441 |
+
if ( is_callable( $this->form_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1442 |
+
add_filter( 'um_form_meta_sanitize_' . $k, $this->form_meta[ $k ]['sanitize'], 10, 1 );
|
1443 |
+
}
|
1444 |
+
|
1445 |
+
switch ( $this->form_meta[ $k ]['sanitize'] ) {
|
1446 |
+
default:
|
1447 |
+
$sanitized[ $k ] = apply_filters( 'um_form_meta_sanitize_' . $k, $data[ $k ] );
|
1448 |
+
break;
|
1449 |
+
case 'int':
|
1450 |
+
$sanitized[ $k ] = (int) $v;
|
1451 |
+
break;
|
1452 |
+
case 'bool':
|
1453 |
+
$sanitized[ $k ] = (bool) $v;
|
1454 |
+
break;
|
1455 |
+
case 'url':
|
1456 |
+
if ( is_array( $v ) ) {
|
1457 |
+
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1458 |
+
} else {
|
1459 |
+
$sanitized[ $k ] = esc_url_raw( $v );
|
1460 |
+
}
|
1461 |
+
break;
|
1462 |
+
case 'text':
|
1463 |
+
$sanitized[ $k ] = sanitize_text_field( $v );
|
1464 |
+
break;
|
1465 |
+
case 'textarea':
|
1466 |
+
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1467 |
+
break;
|
1468 |
+
case 'key':
|
1469 |
+
if ( is_array( $v ) ) {
|
1470 |
+
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1471 |
+
} else {
|
1472 |
+
$sanitized[ $k ] = sanitize_key( $v );
|
1473 |
+
}
|
1474 |
+
break;
|
1475 |
+
case 'absint':
|
1476 |
+
if ( is_array( $v ) ) {
|
1477 |
+
$sanitized[ $k ] = array_map( 'absint', $v );
|
1478 |
+
} else {
|
1479 |
+
$sanitized[ $k ] = absint( $v );
|
1480 |
+
}
|
1481 |
+
break;
|
1482 |
+
}
|
1483 |
+
}
|
1484 |
+
|
1485 |
+
$data = $sanitized;
|
1486 |
+
|
1487 |
+
$data = apply_filters( 'um_save_form_meta_sanitize', $data );
|
1488 |
+
|
1489 |
+
return $data;
|
1490 |
+
}
|
1491 |
+
|
1492 |
+
|
1493 |
+
/**
|
1494 |
+
* Sanitize options when wp-admin form has been submitted
|
1495 |
+
*
|
1496 |
+
* @todo checking all sanitize types
|
1497 |
+
*
|
1498 |
+
* @param array $data
|
1499 |
+
*
|
1500 |
+
* @return array
|
1501 |
+
*/
|
1502 |
+
public function sanitize_options( $data ) {
|
1503 |
+
$sanitized = array();
|
1504 |
+
foreach ( $data as $k => $v ) {
|
1505 |
+
if ( ! array_key_exists( $k, UM()->admin_settings()->settings_map ) ) {
|
1506 |
+
// @todo remove since 2.2.x and leave only continue
|
1507 |
+
$sanitized[ $k ] = $v;
|
1508 |
+
continue;
|
1509 |
+
}
|
1510 |
+
|
1511 |
+
if ( ! array_key_exists( 'sanitize', UM()->admin_settings()->settings_map[ $k ] ) ) {
|
1512 |
+
// @todo remove since 2.2.x and leave only continue
|
1513 |
+
$sanitized[ $k ] = $v;
|
1514 |
+
continue;
|
1515 |
+
}
|
1516 |
+
|
1517 |
+
if ( is_callable( UM()->admin_settings()->settings_map[ $k ]['sanitize'], true, $callable_name ) ) {
|
1518 |
+
add_filter( 'um_settings_sanitize_' . $k, UM()->admin_settings()->settings_map[ $k ]['sanitize'], 10, 1 );
|
1519 |
+
}
|
1520 |
+
|
1521 |
+
switch ( UM()->admin_settings()->settings_map[ $k ]['sanitize'] ) {
|
1522 |
+
default:
|
1523 |
+
$sanitized[ $k ] = apply_filters( 'um_settings_sanitize_' . $k, $v );
|
1524 |
+
break;
|
1525 |
+
case 'int':
|
1526 |
+
$sanitized[ $k ] = (int) $v;
|
1527 |
+
break;
|
1528 |
+
case 'absint':
|
1529 |
+
if ( is_array( $v ) ) {
|
1530 |
+
$sanitized[ $k ] = array_map( 'absint', $v );
|
1531 |
+
} else {
|
1532 |
+
$sanitized[ $k ] = absint( $v );
|
1533 |
+
}
|
1534 |
+
break;
|
1535 |
+
case 'key':
|
1536 |
+
if ( is_array( $v ) ) {
|
1537 |
+
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1538 |
+
} else {
|
1539 |
+
$sanitized[ $k ] = sanitize_key( $v );
|
1540 |
+
}
|
1541 |
+
break;
|
1542 |
+
case 'bool':
|
1543 |
+
$sanitized[ $k ] = (bool) $v;
|
1544 |
+
break;
|
1545 |
+
case 'url':
|
1546 |
+
if ( is_array( $v ) ) {
|
1547 |
+
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1548 |
+
} else {
|
1549 |
+
$sanitized[ $k ] = esc_url_raw( $v );
|
1550 |
+
}
|
1551 |
+
break;
|
1552 |
+
case 'wp_kses':
|
1553 |
+
$sanitized[ $k ] = wp_kses_post( $v );
|
1554 |
+
break;
|
1555 |
+
case 'textarea':
|
1556 |
+
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1557 |
+
break;
|
1558 |
+
case 'text':
|
1559 |
+
$sanitized[ $k ] = sanitize_text_field( $v );
|
1560 |
+
break;
|
1561 |
+
}
|
1562 |
+
}
|
1563 |
+
|
1564 |
+
$data = $sanitized;
|
1565 |
+
|
1566 |
+
$data = apply_filters( 'um_save_settings_sanitize', $data );
|
1567 |
+
|
1568 |
+
return $data;
|
1569 |
+
}
|
1570 |
+
|
1571 |
+
|
1572 |
+
/**
|
1573 |
+
* Adds class to our admin pages
|
1574 |
+
*
|
1575 |
+
* @param $classes
|
1576 |
+
*
|
1577 |
+
* @return string
|
1578 |
+
*/
|
1579 |
+
public function admin_body_class( $classes ) {
|
1580 |
+
if ( $this->is_um_screen() ) {
|
1581 |
+
return "$classes um-admin";
|
1582 |
+
}
|
1583 |
+
return $classes;
|
1584 |
+
}
|
1585 |
+
|
1586 |
+
|
1587 |
+
/**
|
1588 |
+
*
|
1589 |
+
*/
|
1590 |
+
public function manual_upgrades_request() {
|
1591 |
+
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1592 |
+
die();
|
1593 |
+
}
|
1594 |
+
|
1595 |
+
$last_request = get_option( 'um_last_manual_upgrades_request', false );
|
1596 |
+
|
1597 |
+
if ( empty( $last_request ) || time() > $last_request + DAY_IN_SECONDS ) {
|
1598 |
+
|
1599 |
+
if ( is_multisite() ) {
|
1600 |
+
$blogs_ids = get_sites();
|
1601 |
+
foreach( $blogs_ids as $b ) {
|
1602 |
+
switch_to_blog( $b->blog_id );
|
1603 |
+
wp_clean_update_cache();
|
1604 |
+
|
1605 |
+
UM()->plugin_updater()->um_checklicenses();
|
1606 |
+
|
1607 |
+
update_option( 'um_last_manual_upgrades_request', time() );
|
1608 |
+
restore_current_blog();
|
1609 |
+
}
|
1610 |
+
} else {
|
1611 |
+
wp_clean_update_cache();
|
1612 |
+
|
1613 |
+
UM()->plugin_updater()->um_checklicenses();
|
1614 |
+
|
1615 |
+
update_option( 'um_last_manual_upgrades_request', time() );
|
1616 |
+
}
|
1617 |
+
|
1618 |
+
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'got_updates' ), admin_url( 'admin.php' ) );
|
1619 |
+
} else {
|
1620 |
+
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'often_updates' ), admin_url( 'admin.php' ) );
|
1621 |
+
}
|
1622 |
+
exit( wp_redirect( $url ) );
|
1623 |
+
}
|
1624 |
+
|
1625 |
+
|
1626 |
+
/**
|
1627 |
+
* Core pages installation
|
1628 |
+
*/
|
1629 |
+
function install_core_pages() {
|
1630 |
+
if ( ! is_admin() ) {
|
1631 |
+
die();
|
1632 |
+
}
|
1633 |
+
|
1634 |
+
UM()->setup()->install_default_pages();
|
1635 |
+
|
1636 |
+
//check empty pages in settings
|
1637 |
+
$empty_pages = array();
|
1638 |
+
|
1639 |
+
$pages = UM()->config()->permalinks;
|
1640 |
+
if ( $pages && is_array( $pages ) ) {
|
1641 |
+
foreach ( $pages as $slug => $page_id ) {
|
1642 |
+
$page = get_post( $page_id );
|
1643 |
+
|
1644 |
+
if ( ! isset( $page->ID ) && in_array( $slug, array_keys( UM()->config()->core_pages ) ) ) {
|
1645 |
+
$empty_pages[] = $slug;
|
1646 |
+
}
|
1647 |
+
}
|
1648 |
+
}
|
1649 |
+
|
1650 |
+
//if there aren't empty pages - then hide pages notice
|
1651 |
+
if ( empty( $empty_pages ) ) {
|
1652 |
+
$hidden_notices = get_option( 'um_hidden_admin_notices', array() );
|
1653 |
+
$hidden_notices[] = 'wrong_pages';
|
1654 |
+
|
1655 |
+
update_option( 'um_hidden_admin_notices', $hidden_notices );
|
1656 |
+
}
|
1657 |
+
|
1658 |
+
$url = add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) );
|
1659 |
+
exit( wp_redirect( $url ) );
|
1660 |
+
}
|
1661 |
+
|
1662 |
+
|
1663 |
+
/**
|
1664 |
+
* Clear all users cache
|
1665 |
+
*
|
1666 |
+
* @param $action
|
1667 |
+
*/
|
1668 |
+
function user_cache( $action ) {
|
1669 |
+
global $wpdb;
|
1670 |
+
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1671 |
+
die();
|
1672 |
+
}
|
1673 |
+
|
1674 |
+
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
|
1675 |
+
|
1676 |
+
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) );
|
1677 |
+
exit( wp_redirect( $url ) );
|
1678 |
+
}
|
1679 |
+
|
1680 |
+
|
1681 |
+
/**
|
1682 |
+
* Purge temp uploads dir
|
1683 |
+
* @param $action
|
1684 |
+
*/
|
1685 |
+
function purge_temp( $action ) {
|
1686 |
+
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1687 |
+
die();
|
1688 |
+
}
|
1689 |
+
|
1690 |
+
UM()->files()->remove_dir( UM()->files()->upload_temp );
|
1691 |
+
|
1692 |
+
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'purged_temp' ), admin_url( 'admin.php' ) );
|
1693 |
+
exit( wp_redirect( $url ) );
|
1694 |
+
}
|
1695 |
+
|
1696 |
+
|
1697 |
+
/**
|
1698 |
+
* Duplicate form
|
1699 |
+
*
|
1700 |
+
* @param $action
|
1701 |
+
*/
|
1702 |
+
function duplicate_form( $action ) {
|
1703 |
+
if ( ! is_admin() || ! current_user_can('manage_options') ) {
|
1704 |
+
die();
|
1705 |
+
}
|
1706 |
+
if ( ! isset( $_REQUEST['post_id'] ) || ! is_numeric( $_REQUEST['post_id'] ) ) {
|
1707 |
+
die();
|
1708 |
+
}
|
1709 |
+
|
1710 |
+
$post_id = absint( $_REQUEST['post_id'] );
|
1711 |
+
|
1712 |
+
$n = array(
|
1713 |
+
'post_type' => 'um_form',
|
1714 |
+
'post_title' => sprintf( __( 'Duplicate of %s', 'ultimate-member' ), get_the_title( $post_id ) ),
|
1715 |
+
'post_status' => 'publish',
|
1716 |
+
'post_author' => get_current_user_id(),
|
1717 |
+
);
|
1718 |
+
|
1719 |
+
$n_id = wp_insert_post( $n );
|
1720 |
+
|
1721 |
+
$n_fields = get_post_custom( $post_id );
|
1722 |
+
foreach ( $n_fields as $key => $value ) {
|
1723 |
+
|
1724 |
+
if ( $key == '_um_custom_fields' ) {
|
1725 |
+
$the_value = unserialize( $value[0] );
|
1726 |
+
} else {
|
1727 |
+
$the_value = $value[0];
|
1728 |
+
}
|
1729 |
+
|
1730 |
+
update_post_meta( $n_id, $key, $the_value );
|
1731 |
+
|
1732 |
+
}
|
1733 |
+
|
1734 |
+
delete_post_meta( $n_id, '_um_core' );
|
1735 |
+
|
1736 |
+
$url = admin_url( 'edit.php?post_type=um_form' );
|
1737 |
+
$url = add_query_arg( 'update', 'form_duplicated', $url );
|
1738 |
+
|
1739 |
+
exit( wp_redirect( $url ) );
|
1740 |
+
|
1741 |
+
}
|
1742 |
+
|
1743 |
+
|
1744 |
+
/**
|
1745 |
+
* Action to hide notices in admin
|
1746 |
+
*
|
1747 |
+
* @param $action
|
1748 |
+
*/
|
1749 |
+
function um_hide_notice( $action ) {
|
1750 |
+
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1751 |
+
die();
|
1752 |
+
}
|
1753 |
+
|
1754 |
+
update_option( $action, 1 );
|
1755 |
+
exit( wp_redirect( remove_query_arg( 'um_adm_action' ) ) );
|
1756 |
+
}
|
1757 |
+
|
1758 |
+
|
1759 |
+
/**
|
1760 |
+
* Various user actions
|
1761 |
+
*
|
1762 |
+
* @param $action
|
1763 |
+
*/
|
1764 |
+
function user_action( $action ) {
|
1765 |
+
if ( ! is_admin() || ! current_user_can( 'edit_users' ) ) {
|
1766 |
+
die();
|
1767 |
+
}
|
1768 |
+
if ( ! isset( $_REQUEST['sub'] ) ) {
|
1769 |
+
die();
|
1770 |
+
}
|
1771 |
+
if ( ! isset( $_REQUEST['user_id'] ) ) {
|
1772 |
+
die();
|
1773 |
+
}
|
1774 |
+
|
1775 |
+
um_fetch_user( absint( $_REQUEST['user_id'] ) );
|
1776 |
+
|
1777 |
+
$subaction = sanitize_key( $_REQUEST['sub'] );
|
1778 |
+
|
1779 |
+
/**
|
1780 |
+
* UM hook
|
1781 |
+
*
|
1782 |
+
* @type action
|
1783 |
+
* @title um_admin_user_action_hook
|
1784 |
+
* @description Action on bulk user subaction
|
1785 |
+
* @input_vars
|
1786 |
+
* [{"var":"$subaction","type":"string","desc":"Bulk Subaction"}]
|
1787 |
+
* @change_log
|
1788 |
+
* ["Since: 2.0"]
|
1789 |
+
* @usage add_action( 'um_admin_user_action_hook', 'function_name', 10, 1 );
|
1790 |
+
* @example
|
1791 |
+
* <?php
|
1792 |
+
* add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
|
1793 |
+
* function my_admin_user_action( $subaction ) {
|
1794 |
+
* // your code here
|
1795 |
+
* }
|
1796 |
+
* ?>
|
1797 |
+
*/
|
1798 |
+
do_action( 'um_admin_user_action_hook', $subaction );
|
1799 |
+
/**
|
1800 |
+
* UM hook
|
1801 |
+
*
|
1802 |
+
* @type action
|
1803 |
+
* @title um_admin_user_action_{$subaction}_hook
|
1804 |
+
* @description Action on bulk user subaction
|
1805 |
+
* @change_log
|
1806 |
+
* ["Since: 2.0"]
|
1807 |
+
* @usage add_action( 'um_admin_user_action_{$subaction}_hook', 'function_name', 10 );
|
1808 |
+
* @example
|
1809 |
+
* <?php
|
1810 |
+
* add_action( 'um_admin_user_action_{$subaction}_hook', 'my_admin_user_action', 10 );
|
1811 |
+
* function my_admin_user_action() {
|
1812 |
+
* // your code here
|
1813 |
+
* }
|
1814 |
+
* ?>
|
1815 |
+
*/
|
1816 |
+
do_action( "um_admin_user_action_{$subaction}_hook" );
|
1817 |
+
|
1818 |
+
um_reset_user();
|
1819 |
+
|
1820 |
+
wp_redirect( add_query_arg( 'update', 'user_updated', admin_url( '?page=ultimatemember' ) ) );
|
1821 |
+
exit;
|
1822 |
+
|
1823 |
+
}
|
1824 |
+
|
1825 |
+
|
1826 |
+
/**
|
1827 |
+
* Add any custom links to plugin page
|
1828 |
+
*
|
1829 |
+
* @param array $links
|
1830 |
+
*
|
1831 |
+
* @return array
|
1832 |
+
*/
|
1833 |
+
function plugin_links( $links ) {
|
1834 |
+
$more_links[] = '<a href="http://docs.ultimatemember.com/">' . __( 'Docs', 'ultimate-member' ) . '</a>';
|
1835 |
+
$more_links[] = '<a href="'.admin_url().'admin.php?page=um_options">' . __( 'Settings', 'ultimate-member' ) . '</a>';
|
1836 |
+
|
1837 |
+
$links = $more_links + $links;
|
1838 |
+
return $links;
|
1839 |
+
}
|
1840 |
+
|
1841 |
+
|
1842 |
+
/**
|
1843 |
+
* Init admin action/filters + request handlers
|
1844 |
+
*/
|
1845 |
+
function admin_init() {
|
1846 |
+
$this->init_variables();
|
1847 |
+
|
1848 |
+
if ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_REQUEST['um_adm_action'] ) ) {
|
1849 |
+
$action = sanitize_key( $_REQUEST['um_adm_action'] );
|
1850 |
+
|
1851 |
+
/**
|
1852 |
+
* UM hook
|
1853 |
+
*
|
1854 |
+
* @type action
|
1855 |
+
* @title um_admin_do_action__
|
1856 |
+
* @description Make some action on custom admin action
|
1857 |
+
* @input_vars
|
1858 |
+
* [{"var":"$action","type":"string","desc":"Admin Action"}]
|
1859 |
+
* @change_log
|
1860 |
+
* ["Since: 2.0"]
|
1861 |
+
* @usage add_action( 'um_admin_do_action__', 'function_name', 10, 1 );
|
1862 |
+
* @example
|
1863 |
+
* <?php
|
1864 |
+
* add_action( 'um_admin_do_action__', 'my_admin_do_action', 10, 1 );
|
1865 |
+
* function my_admin_do_action( $action ) {
|
1866 |
+
* // your code here
|
1867 |
+
* }
|
1868 |
+
* ?>
|
1869 |
+
*/
|
1870 |
+
do_action( 'um_admin_do_action__', $action );
|
1871 |
+
/**
|
1872 |
+
* UM hook
|
1873 |
+
*
|
1874 |
+
* @type action
|
1875 |
+
* @title um_admin_do_action__{$action}
|
1876 |
+
* @description Make some action on custom admin $action
|
1877 |
+
* @input_vars
|
1878 |
+
* [{"var":"$action","type":"string","desc":"Admin Action"}]
|
1879 |
+
* @change_log
|
1880 |
+
* ["Since: 2.0"]
|
1881 |
+
* @usage add_action( 'um_admin_do_action__{$action}', 'function_name', 10, 1 );
|
1882 |
+
* @example
|
1883 |
+
* <?php
|
1884 |
+
* add_action( 'um_admin_do_action__{$action}', 'my_admin_do_action', 10, 1 );
|
1885 |
+
* function my_admin_do_action( $action ) {
|
1886 |
+
* // your code here
|
1887 |
+
* }
|
1888 |
+
* ?>
|
1889 |
+
*/
|
1890 |
+
do_action( "um_admin_do_action__{$action}", $action );
|
1891 |
+
}
|
1892 |
+
}
|
1893 |
+
|
1894 |
+
|
1895 |
+
/**
|
1896 |
+
* Updated post messages
|
1897 |
+
*
|
1898 |
+
* @param array $messages
|
1899 |
+
*
|
1900 |
+
* @return array
|
1901 |
+
*/
|
1902 |
+
function post_updated_messages( $messages ) {
|
1903 |
+
global $post_ID;
|
1904 |
+
|
1905 |
+
$post_type = get_post_type( $post_ID );
|
1906 |
+
|
1907 |
+
if ( $post_type == 'um_form' ) {
|
1908 |
+
$messages['um_form'] = array(
|
1909 |
+
0 => '',
|
1910 |
+
1 => __( 'Form updated.', 'ultimate-member' ),
|
1911 |
+
2 => __( 'Custom field updated.', 'ultimate-member' ),
|
1912 |
+
3 => __( 'Custom field deleted.', 'ultimate-member' ),
|
1913 |
+
4 => __( 'Form updated.', 'ultimate-member' ),
|
1914 |
+
5 => isset( $_GET['revision'] ) ? __( 'Form restored to revision.', 'ultimate-member' ) : false,
|
1915 |
+
6 => __( 'Form created.', 'ultimate-member' ),
|
1916 |
+
7 => __( 'Form saved.', 'ultimate-member' ),
|
1917 |
+
8 => __( 'Form submitted.', 'ultimate-member' ),
|
1918 |
+
9 => __( 'Form scheduled.', 'ultimate-member' ),
|
1919 |
+
10 => __( 'Form draft updated.', 'ultimate-member' ),
|
1920 |
+
);
|
1921 |
+
}
|
1922 |
+
|
1923 |
+
return $messages;
|
1924 |
+
}
|
1925 |
+
|
1926 |
+
|
1927 |
+
/**
|
1928 |
+
* Gettext filters
|
1929 |
+
*
|
1930 |
+
* @param $translation
|
1931 |
+
* @param $text
|
1932 |
+
* @param $domain
|
1933 |
+
*
|
1934 |
+
* @return string
|
1935 |
+
*/
|
1936 |
+
function gettext( $translation, $text, $domain ) {
|
1937 |
+
global $post;
|
1938 |
+
if ( isset( $post->post_type ) && $this->is_plugin_post_type() ) {
|
1939 |
+
$translations = get_translations_for_domain( $domain );
|
1940 |
+
if ( $text == 'Publish' ) {
|
1941 |
+
return $translations->translate( 'Create' );
|
1942 |
+
} elseif ( $text == 'Move to Trash' ) {
|
1943 |
+
return $translations->translate( 'Delete' );
|
1944 |
+
}
|
1945 |
+
}
|
1946 |
+
|
1947 |
+
return $translation;
|
1948 |
+
}
|
1949 |
+
|
1950 |
+
|
1951 |
+
/**
|
1952 |
+
* Fix parent file for correct highlighting
|
1953 |
+
*
|
1954 |
+
* @param $parent_file
|
1955 |
+
*
|
1956 |
+
* @return string
|
1957 |
+
*/
|
1958 |
+
function parent_file( $parent_file ) {
|
1959 |
+
global $current_screen;
|
1960 |
+
$screen_id = $current_screen->id;
|
1961 |
+
if ( strstr( $screen_id, 'um_' ) ) {
|
1962 |
+
$parent_file = 'ultimatemember';
|
1963 |
+
}
|
1964 |
+
return $parent_file;
|
1965 |
+
}
|
1966 |
+
|
1967 |
+
|
1968 |
+
/**
|
1969 |
+
* @since 2.0
|
1970 |
+
*
|
1971 |
+
* @return core\Admin_Notices()
|
1972 |
+
*/
|
1973 |
+
function notices() {
|
1974 |
+
if ( empty( UM()->classes['admin_notices'] ) ) {
|
1975 |
+
UM()->classes['admin_notices'] = new core\Admin_Notices();
|
1976 |
+
}
|
1977 |
+
return UM()->classes['admin_notices'];
|
1978 |
+
}
|
1979 |
+
}
|
1980 |
+
}
|
includes/admin/core/class-admin-metabox.php
CHANGED
@@ -1725,7 +1725,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
|
1725 |
?>
|
1726 |
|
1727 |
<p><label for="_force_good_pass"><?php _e( 'Force strong password?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on to force users to create a strong password (A combination of one lowercase letter, one uppercase letter, and one number). If turned on this option is only applied to register forms and not to login forms.', 'ultimate-member' ) ); ?></label>
|
1728 |
-
<input type="checkbox" name="_force_good_pass" id="_force_good_pass" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value :
|
1729 |
</p>
|
1730 |
|
1731 |
<?php
|
1725 |
?>
|
1726 |
|
1727 |
<p><label for="_force_good_pass"><?php _e( 'Force strong password?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on to force users to create a strong password (A combination of one lowercase letter, one uppercase letter, and one number). If turned on this option is only applied to register forms and not to login forms.', 'ultimate-member' ) ); ?></label>
|
1728 |
+
<input type="checkbox" name="_force_good_pass" id="_force_good_pass" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : UM()->options()->get( 'require_strongpass' ) ) ?> />
|
1729 |
</p>
|
1730 |
|
1731 |
<?php
|
includes/admin/core/class-admin-settings.php
CHANGED
@@ -1,3475 +1,3466 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\admin\core;
|
3 |
-
|
4 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
-
exit;
|
6 |
-
}
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Admin_Settings
|
13 |
-
* @package um\admin\core
|
14 |
-
*/
|
15 |
-
class Admin_Settings {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var array
|
20 |
-
*/
|
21 |
-
public $settings_map;
|
22 |
-
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @var array
|
26 |
-
*/
|
27 |
-
public $settings_structure;
|
28 |
-
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @var
|
32 |
-
*/
|
33 |
-
private $previous_licenses;
|
34 |
-
|
35 |
-
|
36 |
-
/**
|
37 |
-
* @var
|
38 |
-
*/
|
39 |
-
private $need_change_permalinks;
|
40 |
-
|
41 |
-
|
42 |
-
private $gravatar_changed = false;
|
43 |
-
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Admin_Settings constructor.
|
47 |
-
*/
|
48 |
-
public function __construct() {
|
49 |
-
//init settings structure
|
50 |
-
add_action( 'admin_init', array( &$this, 'init_variables' ), 9 );
|
51 |
-
|
52 |
-
//admin menu
|
53 |
-
add_action( 'admin_menu', array( &$this, 'primary_admin_menu' ), 0 );
|
54 |
-
|
55 |
-
//settings structure handlers
|
56 |
-
add_action( 'um_settings_page_before_email__content', array( $this, 'settings_before_email_tab' ) );
|
57 |
-
add_filter( 'um_settings_section_email__content', array( $this, 'settings_email_tab' ), 10, 1 );
|
58 |
-
|
59 |
-
//enqueue wp_media for profiles tab
|
60 |
-
add_action( 'um_settings_page_appearance__before_section', array( $this, 'settings_appearance_profile_tab' ) );
|
61 |
-
|
62 |
-
//custom content for licenses tab
|
63 |
-
add_filter( 'um_settings_section_licenses__content', array( $this, 'settings_licenses_tab' ), 10, 2 );
|
64 |
-
|
65 |
-
add_filter( 'um_settings_section_install_info__content', array( $this, 'settings_install_info_tab' ), 10, 2 );
|
66 |
-
|
67 |
-
|
68 |
-
add_filter( 'um_settings_structure', array( $this, 'sorting_licenses_options' ), 9999, 1 );
|
69 |
-
|
70 |
-
|
71 |
-
//save handlers
|
72 |
-
add_action( 'admin_init', array( $this, 'save_settings_handler' ), 10 );
|
73 |
-
|
74 |
-
//save pages options
|
75 |
-
add_action( 'um_settings_before_save', array( $this, 'check_permalinks_changes' ) );
|
76 |
-
add_action( 'um_settings_save', array( $this, 'on_settings_save' ) );
|
77 |
-
|
78 |
-
|
79 |
-
add_filter( 'um_change_settings_before_save', array( $this, 'save_email_templates' ) );
|
80 |
-
|
81 |
-
|
82 |
-
//save licenses options
|
83 |
-
add_action( 'um_settings_before_save', array( $this, 'before_licenses_save' ) );
|
84 |
-
add_action( 'um_settings_save', array( $this, 'licenses_save' ) );
|
85 |
-
|
86 |
-
add_filter( 'um_change_settings_before_save', array( $this, 'set_default_if_empty' ), 9, 1 );
|
87 |
-
add_filter( 'um_change_settings_before_save', array( $this, 'remove_empty_values' ), 10, 1 );
|
88 |
-
|
89 |
-
add_action( 'admin_init', array( &$this, 'um_download_install_info' ) );
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
public function same_page_update_ajax() {
|
95 |
-
UM()->admin()->check_ajax_nonce();
|
96 |
-
|
97 |
-
if ( empty( $_POST['cb_func'] ) ) {
|
98 |
-
wp_send_json_error( __( 'Wrong callback', 'ultimate-member' ) );
|
99 |
-
}
|
100 |
-
|
101 |
-
$cb_func = sanitize_key( $_POST['cb_func'] );
|
102 |
-
|
103 |
-
if ( 'um_usermeta_fields' === $cb_func ) {
|
104 |
-
//first install metatable
|
105 |
-
global $wpdb;
|
106 |
-
|
107 |
-
$metakeys = array();
|
108 |
-
foreach ( UM()->builtin()->all_user_fields as $all_user_field ) {
|
109 |
-
$metakeys[] = $all_user_field['metakey'];
|
110 |
-
}
|
111 |
-
|
112 |
-
$metakeys = apply_filters( 'um_metadata_same_page_update_ajax', $metakeys, UM()->builtin()->all_user_fields );
|
113 |
-
|
114 |
-
if ( is_multisite() ) {
|
115 |
-
|
116 |
-
$sites = get_sites( array( 'fields' => 'ids' ) );
|
117 |
-
foreach ( $sites as $blog_id ) {
|
118 |
-
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
119 |
-
}
|
120 |
-
} else {
|
121 |
-
$blog_id = get_current_blog_id();
|
122 |
-
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
123 |
-
}
|
124 |
-
|
125 |
-
//member directory data
|
126 |
-
$metakeys[] = 'um_member_directory_data';
|
127 |
-
$metakeys[] = '_um_verified';
|
128 |
-
$metakeys[] = '_money_spent';
|
129 |
-
$metakeys[] = '_completed';
|
130 |
-
$metakeys[] = '_reviews_avg';
|
131 |
-
|
132 |
-
//myCred meta
|
133 |
-
if ( function_exists( 'mycred_get_types' ) ) {
|
134 |
-
$mycred_types = mycred_get_types();
|
135 |
-
if ( ! empty( $mycred_types ) ) {
|
136 |
-
foreach ( array_keys( $mycred_types ) as $point_type ) {
|
137 |
-
$metakeys[] = $point_type;
|
138 |
-
}
|
139 |
-
}
|
140 |
-
}
|
141 |
-
|
142 |
-
$sortby_custom_keys = $wpdb->get_col( "SELECT DISTINCT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sortby_custom'" );
|
143 |
-
if ( empty( $sortby_custom_keys ) ) {
|
144 |
-
$sortby_custom_keys = array();
|
145 |
-
}
|
146 |
-
|
147 |
-
$sortby_custom_keys2 = $wpdb->get_col( "SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sorting_fields'" );
|
148 |
-
if ( ! empty( $sortby_custom_keys2 ) ) {
|
149 |
-
foreach ( $sortby_custom_keys2 as $custom_val ) {
|
150 |
-
$custom_val = maybe_unserialize( $custom_val );
|
151 |
-
|
152 |
-
foreach ( $custom_val as $sort_value ) {
|
153 |
-
if ( is_array( $sort_value ) ) {
|
154 |
-
$field_keys = array_keys( $sort_value );
|
155 |
-
$sortby_custom_keys[] = $field_keys[0];
|
156 |
-
}
|
157 |
-
}
|
158 |
-
}
|
159 |
-
}
|
160 |
-
|
161 |
-
if ( ! empty( $sortby_custom_keys ) ) {
|
162 |
-
$sortby_custom_keys = array_unique( $sortby_custom_keys );
|
163 |
-
$metakeys = array_merge( $metakeys, $sortby_custom_keys );
|
164 |
-
}
|
165 |
-
|
166 |
-
$skip_fields = UM()->builtin()->get_fields_without_metakey();
|
167 |
-
$skip_fields = array_merge( $skip_fields, UM()->member_directory()->core_search_fields );
|
168 |
-
|
169 |
-
$real_usermeta = $wpdb->get_col( "SELECT DISTINCT meta_key FROM {$wpdb->usermeta}" );
|
170 |
-
$real_usermeta = ! empty( $real_usermeta ) ? $real_usermeta : array();
|
171 |
-
$real_usermeta = array_merge( $real_usermeta, array( 'um_member_directory_data' ) );
|
172 |
-
|
173 |
-
if ( ! empty( $sortby_custom_keys ) ) {
|
174 |
-
$real_usermeta = array_merge( $real_usermeta, $sortby_custom_keys );
|
175 |
-
}
|
176 |
-
|
177 |
-
$wp_usermeta_option = array_intersect( array_diff( $metakeys, $skip_fields ), $real_usermeta );
|
178 |
-
|
179 |
-
update_option( 'um_usermeta_fields', array_values( $wp_usermeta_option ) );
|
180 |
-
|
181 |
-
update_option( 'um_member_directory_update_meta', time() );
|
182 |
-
|
183 |
-
UM()->options()->update( 'member_directory_own_table', true );
|
184 |
-
|
185 |
-
wp_send_json_success();
|
186 |
-
} elseif ( 'um_get_metadata' === $cb_func ) {
|
187 |
-
global $wpdb;
|
188 |
-
|
189 |
-
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
190 |
-
|
191 |
-
$count = $wpdb->get_var(
|
192 |
-
"SELECT COUNT(*)
|
193 |
-
FROM {$wpdb->usermeta}
|
194 |
-
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')"
|
195 |
-
);
|
196 |
-
|
197 |
-
wp_send_json_success( array( 'count' => $count ) );
|
198 |
-
} elseif ( 'um_update_metadata_per_page' === $cb_func ) {
|
199 |
-
|
200 |
-
if ( empty( $_POST['page'] ) ) {
|
201 |
-
wp_send_json_error( __( 'Wrong data', 'ultimate-member' ) );
|
202 |
-
}
|
203 |
-
|
204 |
-
$per_page = 500;
|
205 |
-
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
206 |
-
|
207 |
-
global $wpdb;
|
208 |
-
$metadata = $wpdb->get_results(
|
209 |
-
$wpdb->prepare(
|
210 |
-
"SELECT *
|
211 |
-
FROM {$wpdb->usermeta}
|
212 |
-
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')
|
213 |
-
LIMIT %d, %d",
|
214 |
-
( absint( $_POST['page'] ) - 1 ) * $per_page,
|
215 |
-
$per_page
|
216 |
-
),
|
217 |
-
ARRAY_A
|
218 |
-
);
|
219 |
-
|
220 |
-
$values = array();
|
221 |
-
foreach ( $metadata as $metarow ) {
|
222 |
-
$values[] = $wpdb->prepare( '(%d, %s, %s)', $metarow['user_id'], $metarow['meta_key'], $metarow['meta_value'] );
|
223 |
-
}
|
224 |
-
|
225 |
-
if ( ! empty( $values ) ) {
|
226 |
-
$wpdb->query(
|
227 |
-
"INSERT INTO
|
228 |
-
{$wpdb->prefix}um_metadata(user_id, um_key, um_value)
|
229 |
-
VALUES " . implode( ',', $values )
|
230 |
-
);
|
231 |
-
}
|
232 |
-
|
233 |
-
$from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1;
|
234 |
-
$to = absint( $_POST['page'] ) * $per_page;
|
235 |
-
|
236 |
-
wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %1$s to %2$s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
|
237 |
-
}
|
238 |
-
}
|
239 |
-
|
240 |
-
|
241 |
-
/**
|
242 |
-
*
|
243 |
-
*/
|
244 |
-
public function init_variables() {
|
245 |
-
|
246 |
-
$settings_map = array();
|
247 |
-
|
248 |
-
$general_pages_fields = array(
|
249 |
-
array(
|
250 |
-
'id' => 'pages_settings',
|
251 |
-
'type' => 'hidden',
|
252 |
-
'value' => true,
|
253 |
-
'is_option' => false,
|
254 |
-
),
|
255 |
-
);
|
256 |
-
|
257 |
-
$core_pages = UM()->config()->core_pages;
|
258 |
-
|
259 |
-
foreach ( $core_pages as $page_s => $page ) {
|
260 |
-
$have_pages = UM()->query()->wp_pages();
|
261 |
-
$page_id = UM()->options()->get_core_page_id( $page_s );
|
262 |
-
|
263 |
-
$page_title = ! empty( $page['title'] ) ? $page['title'] : '';
|
264 |
-
|
265 |
-
if ( 'reached_maximum_limit' === $have_pages ) {
|
266 |
-
$general_pages_fields[] = array(
|
267 |
-
'id' => $page_id,
|
268 |
-
'type' => 'text',
|
269 |
-
// translators: %s: Page title
|
270 |
-
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
271 |
-
'placeholder' => __( 'Add page ID', 'ultimate-member' ),
|
272 |
-
'compiler' => true,
|
273 |
-
'size' => 'small',
|
274 |
-
);
|
275 |
-
} else {
|
276 |
-
$general_pages_fields[] = array(
|
277 |
-
'id' => $page_id,
|
278 |
-
'type' => 'select',
|
279 |
-
// translators: %s: Page title
|
280 |
-
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
281 |
-
'options' => UM()->query()->wp_pages(),
|
282 |
-
'placeholder' => __( 'Choose a page...', 'ultimate-member' ),
|
283 |
-
'compiler' => true,
|
284 |
-
'size' => 'small',
|
285 |
-
);
|
286 |
-
}
|
287 |
-
|
288 |
-
|
289 |
-
$settings_map[ $page_id ] = array(
|
290 |
-
'sanitize' => 'absint',
|
291 |
-
);
|
292 |
-
}
|
293 |
-
|
294 |
-
$appearances_profile_menu_fields = array(
|
295 |
-
array(
|
296 |
-
'id' => 'profile_menu',
|
297 |
-
'type' => 'checkbox',
|
298 |
-
'label' => __( 'Enable profile menu', 'ultimate-member' ),
|
299 |
-
),
|
300 |
-
);
|
301 |
-
|
302 |
-
$settings_map['profile_menu'] = array(
|
303 |
-
'sanitize' => 'bool',
|
304 |
-
);
|
305 |
-
|
306 |
-
$tabs = UM()->profile()->tabs();
|
307 |
-
|
308 |
-
$tabs_options = array();
|
309 |
-
$tabs_condition = array();
|
310 |
-
foreach ( $tabs as $id => $tab ) {
|
311 |
-
|
312 |
-
if ( ! empty( $tab['hidden'] ) ) {
|
313 |
-
continue;
|
314 |
-
}
|
315 |
-
|
316 |
-
if ( isset( $tab['name'] ) ) {
|
317 |
-
$tabs_options[ $id ] = $tab['name'];
|
318 |
-
$tabs_condition[] = 'profile_tab_' . $id;
|
319 |
-
}
|
320 |
-
|
321 |
-
if ( isset( $tab['default_privacy'] ) ) {
|
322 |
-
$fields = array(
|
323 |
-
array(
|
324 |
-
'id' => 'profile_tab_' . $id,
|
325 |
-
'type' => 'checkbox',
|
326 |
-
// translators: %s: Tab title
|
327 |
-
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
328 |
-
'conditional' => array( 'profile_menu', '=', 1 ),
|
329 |
-
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
330 |
-
),
|
331 |
-
);
|
332 |
-
|
333 |
-
$settings_map[ 'profile_tab_' . $id ] = array(
|
334 |
-
'sanitize' => 'bool',
|
335 |
-
);
|
336 |
-
} else {
|
337 |
-
|
338 |
-
$fields = array(
|
339 |
-
array(
|
340 |
-
'id' => 'profile_tab_' . $id,
|
341 |
-
'type' => 'checkbox',
|
342 |
-
// translators: %s: Tab title
|
343 |
-
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
344 |
-
'conditional' => array( 'profile_menu', '=', 1 ),
|
345 |
-
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
346 |
-
),
|
347 |
-
array(
|
348 |
-
'id' => 'profile_tab_' . $id . '_privacy',
|
349 |
-
'type' => 'select',
|
350 |
-
// translators: %s: Tab title
|
351 |
-
'label' => sprintf( __( 'Who can see %s Tab?', 'ultimate-member' ), $tab['name'] ),
|
352 |
-
'tooltip' => __( 'Select which users can view this tab.', 'ultimate-member' ),
|
353 |
-
'options' => UM()->profile()->tabs_privacy(),
|
354 |
-
'conditional' => array( 'profile_tab_' . $id, '=', 1 ),
|
355 |
-
'size' => 'small',
|
356 |
-
),
|
357 |
-
array(
|
358 |
-
'id' => 'profile_tab_' . $id . '_roles',
|
359 |
-
'type' => 'select',
|
360 |
-
'multi' => true,
|
361 |
-
'label' => __( 'Allowed roles', 'ultimate-member' ),
|
362 |
-
'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ),
|
363 |
-
'options' => UM()->roles()->get_roles(),
|
364 |
-
'placeholder' => __( 'Choose user roles...', 'ultimate-member' ),
|
365 |
-
'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', array( '4', '5' ) ),
|
366 |
-
'size' => 'small',
|
367 |
-
),
|
368 |
-
);
|
369 |
-
|
370 |
-
$settings_map = array_merge(
|
371 |
-
$settings_map,
|
372 |
-
array(
|
373 |
-
"profile_tab_{$id}" => array(
|
374 |
-
'sanitize' => 'bool',
|
375 |
-
),
|
376 |
-
"profile_tab_{$id}_privacy" => array(
|
377 |
-
'sanitize' => array( UM()->admin(), 'sanitize_tabs_privacy' ),
|
378 |
-
),
|
379 |
-
"profile_tab_{$id}_roles" => array(
|
380 |
-
'sanitize' => array( UM()->admin(), 'sanitize_existed_role' ),
|
381 |
-
),
|
382 |
-
)
|
383 |
-
);
|
384 |
-
}
|
385 |
-
|
386 |
-
$appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, $fields );
|
387 |
-
}
|
388 |
-
|
389 |
-
$appearances_profile_menu_fields[] = array(
|
390 |
-
'id' => 'profile_menu_default_tab',
|
391 |
-
'type' => 'select',
|
392 |
-
'label' => __( 'Profile menu default tab', 'ultimate-member' ),
|
393 |
-
'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ),
|
394 |
-
'options' => $tabs_options,
|
395 |
-
'conditional' => array( implode( '|', $tabs_condition ), '~', 1 ),
|
396 |
-
'size' => 'small',
|
397 |
-
);
|
398 |
-
|
399 |
-
$settings_map['profile_menu_default_tab'] = array(
|
400 |
-
'sanitize' => 'key',
|
401 |
-
);
|
402 |
-
|
403 |
-
$appearances_profile_menu_fields = array_merge(
|
404 |
-
$appearances_profile_menu_fields,
|
405 |
-
array(
|
406 |
-
array(
|
407 |
-
'id' => 'profile_menu_icons',
|
408 |
-
'type' => 'checkbox',
|
409 |
-
'label' => __( 'Enable menu icons in desktop view', 'ultimate-member' ),
|
410 |
-
'conditional' => array( 'profile_menu', '=', 1 ),
|
411 |
-
),
|
412 |
-
)
|
413 |
-
);
|
414 |
-
|
415 |
-
$settings_map['profile_menu_icons'] = array(
|
416 |
-
'sanitize' => 'bool',
|
417 |
-
);
|
418 |
-
|
419 |
-
$post_types_options = array();
|
420 |
-
$all_post_types = get_post_types( array( 'public' => true ), 'objects' );
|
421 |
-
foreach ( $all_post_types as $key => $post_type_data ) {
|
422 |
-
$post_types_options[ $key ] = $post_type_data->labels->singular_name;
|
423 |
-
}
|
424 |
-
|
425 |
-
$duplicates = array();
|
426 |
-
$taxonomies_options = array();
|
427 |
-
$exclude_taxonomies = UM()->excluded_taxonomies();
|
428 |
-
$all_taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
|
429 |
-
foreach ( $all_taxonomies as $key => $taxonomy ) {
|
430 |
-
if ( in_array( $key, $exclude_taxonomies, true ) ) {
|
431 |
-
continue;
|
432 |
-
}
|
433 |
-
|
434 |
-
if ( ! in_array( $taxonomy->labels->singular_name, $duplicates, true ) ) {
|
435 |
-
$duplicates[] = $taxonomy->labels->singular_name;
|
436 |
-
$label = $taxonomy->labels->singular_name;
|
437 |
-
} else {
|
438 |
-
$label = $taxonomy->labels->singular_name . ' (' . $key . ')';
|
439 |
-
}
|
440 |
-
|
441 |
-
$taxonomies_options[ $key ] = $label;
|
442 |
-
}
|
443 |
-
|
444 |
-
$restricted_access_post_metabox_value = array();
|
445 |
-
$restricted_access_post_metabox = UM()->options()->get( 'restricted_access_post_metabox' );
|
446 |
-
if ( ! empty( $restricted_access_post_metabox ) && is_array( $restricted_access_post_metabox ) ) {
|
447 |
-
foreach ( $restricted_access_post_metabox as $key => $value ) {
|
448 |
-
if ( $value ) {
|
449 |
-
$restricted_access_post_metabox_value[] = $key;
|
450 |
-
}
|
451 |
-
}
|
452 |
-
}
|
453 |
-
|
454 |
-
|
455 |
-
$restricted_access_taxonomy_metabox_value = array();
|
456 |
-
$restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
457 |
-
if ( ! empty( $restricted_access_taxonomy_metabox ) && is_array( $restricted_access_taxonomy_metabox ) ) {
|
458 |
-
foreach ( $restricted_access_taxonomy_metabox as $key => $value ) {
|
459 |
-
if ( $value ) {
|
460 |
-
$restricted_access_taxonomy_metabox_value[] = $key;
|
461 |
-
}
|
462 |
-
}
|
463 |
-
}
|
464 |
-
|
465 |
-
$access_fields = array(
|
466 |
-
array(
|
467 |
-
'id' => 'accessible',
|
468 |
-
'type' => 'select',
|
469 |
-
'label' => __( 'Global Site Access', 'ultimate-member' ),
|
470 |
-
'tooltip' => __( 'Globally control the access of your site, you can have separate restrict options per post/page by editing the desired item.', 'ultimate-member' ),
|
471 |
-
'options' => array(
|
472 |
-
0 => __( 'Site accessible to Everyone', 'ultimate-member' ),
|
473 |
-
2 => __( 'Site accessible to Logged In Users', 'ultimate-member' ),
|
474 |
-
),
|
475 |
-
'size' => 'medium',
|
476 |
-
),
|
477 |
-
array(
|
478 |
-
'id' => 'access_redirect',
|
479 |
-
'type' => 'text',
|
480 |
-
'label' => __( 'Custom Redirect URL', 'ultimate-member' ),
|
481 |
-
'tooltip' => __( 'A logged out user will be redirected to this url If he is not permitted to access the site', 'ultimate-member' ),
|
482 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
483 |
-
),
|
484 |
-
array(
|
485 |
-
'id' => 'access_exclude_uris',
|
486 |
-
'type' => 'multi_text',
|
487 |
-
'label' => __( 'Exclude the following URLs', 'ultimate-member' ),
|
488 |
-
'tooltip' => __( 'Here you can exclude URLs beside the redirect URI to be accessible to everyone', 'ultimate-member' ),
|
489 |
-
'add_text' => __( 'Add New URL', 'ultimate-member' ),
|
490 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
491 |
-
'show_default_number' => 0,
|
492 |
-
),
|
493 |
-
array(
|
494 |
-
'id' => 'home_page_accessible',
|
495 |
-
'type' => 'checkbox',
|
496 |
-
'label' => __( 'Allow Homepage to be accessible', 'ultimate-member' ),
|
497 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
498 |
-
),
|
499 |
-
array(
|
500 |
-
'id' => 'category_page_accessible',
|
501 |
-
'type' => 'checkbox',
|
502 |
-
'label' => __( 'Allow Category pages to be accessible', 'ultimate-member' ),
|
503 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
504 |
-
),
|
505 |
-
array(
|
506 |
-
'id' => 'restricted_post_title_replace',
|
507 |
-
'type' => 'checkbox',
|
508 |
-
'label' => __( 'Replace the restricted Post Title', 'ultimate-member' ),
|
509 |
-
'tooltip' => __( 'Allow to replace the restricted post title to users that do not have permission to view the content', 'ultimate-member' ),
|
510 |
-
),
|
511 |
-
array(
|
512 |
-
'id' => 'restricted_access_post_title',
|
513 |
-
'type' => 'text',
|
514 |
-
'label' => __( 'Restricted Access Post Title', 'ultimate-member' ),
|
515 |
-
'tooltip' => __( 'This is the post title shown to users that do not have permission to view the content', 'ultimate-member' ),
|
516 |
-
'conditional' => array( 'restricted_post_title_replace', '=', 1 ),
|
517 |
-
),
|
518 |
-
array(
|
519 |
-
'id' => 'restricted_access_message',
|
520 |
-
'type' => 'wp_editor',
|
521 |
-
'label' => __( 'Restricted Access Message', 'ultimate-member' ),
|
522 |
-
'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ),
|
523 |
-
),
|
524 |
-
);
|
525 |
-
|
526 |
-
$settings_map = array_merge(
|
527 |
-
$settings_map,
|
528 |
-
array(
|
529 |
-
'accessible' => array(
|
530 |
-
'sanitize' => 'int',
|
531 |
-
),
|
532 |
-
'access_redirect' => array(
|
533 |
-
'sanitize' => 'url',
|
534 |
-
),
|
535 |
-
'access_exclude_uris' => array(
|
536 |
-
'sanitize' => 'url',
|
537 |
-
),
|
538 |
-
'home_page_accessible' => array(
|
539 |
-
'sanitize' => 'bool',
|
540 |
-
),
|
541 |
-
'category_page_accessible' => array(
|
542 |
-
'sanitize' => 'bool',
|
543 |
-
),
|
544 |
-
'restricted_post_title_replace' => array(
|
545 |
-
'sanitize' => 'bool',
|
546 |
-
),
|
547 |
-
'restricted_access_post_title' => array(
|
548 |
-
'sanitize' => 'text',
|
549 |
-
),
|
550 |
-
'restricted_access_message' => array(
|
551 |
-
'sanitize' => 'wp_kses',
|
552 |
-
),
|
553 |
-
)
|
554 |
-
);
|
555 |
-
|
556 |
-
global $wp_version;
|
557 |
-
if ( version_compare( $wp_version, '5.0', '>=' ) ) {
|
558 |
-
$access_fields = array_merge(
|
559 |
-
$access_fields,
|
560 |
-
array(
|
561 |
-
array(
|
562 |
-
'id' => 'restricted_blocks',
|
563 |
-
'type' => 'checkbox',
|
564 |
-
'label' => __( 'Enable the "Content Restriction" settings for the Gutenberg Blocks', 'ultimate-member' ),
|
565 |
-
),
|
566 |
-
array(
|
567 |
-
'id' => 'restricted_block_message',
|
568 |
-
'type' => 'textarea',
|
569 |
-
'label' => __( 'Restricted Access Block Message', 'ultimate-member' ),
|
570 |
-
'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ),
|
571 |
-
'conditional' => array( 'restricted_blocks', '=', 1 ),
|
572 |
-
),
|
573 |
-
)
|
574 |
-
);
|
575 |
-
|
576 |
-
$settings_map['restricted_blocks'] = array(
|
577 |
-
'sanitize' => 'bool',
|
578 |
-
);
|
579 |
-
$settings_map['restricted_block_message'] = array(
|
580 |
-
'sanitize' => 'textarea',
|
581 |
-
);
|
582 |
-
}
|
583 |
-
|
584 |
-
$access_fields = array_merge(
|
585 |
-
$access_fields,
|
586 |
-
array(
|
587 |
-
array(
|
588 |
-
'id' => 'restricted_access_post_metabox',
|
589 |
-
'type' => 'hidden',
|
590 |
-
'value' => '',
|
591 |
-
),
|
592 |
-
array(
|
593 |
-
'id' => 'restricted_access_taxonomy_metabox',
|
594 |
-
'type' => 'hidden',
|
595 |
-
'value' => '',
|
596 |
-
),
|
597 |
-
array(
|
598 |
-
'id' => 'restricted_access_post_metabox',
|
599 |
-
'type' => 'multi_checkbox',
|
600 |
-
'label' => __( 'Enable the "Content Restriction" settings for post types', 'ultimate-member' ),
|
601 |
-
'tooltip' => __( 'Check post types for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
602 |
-
'options' => $post_types_options,
|
603 |
-
'columns' => 3,
|
604 |
-
'value' => $restricted_access_post_metabox_value,
|
605 |
-
'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ),
|
606 |
-
),
|
607 |
-
array(
|
608 |
-
'id' => 'restricted_access_taxonomy_metabox',
|
609 |
-
'type' => 'multi_checkbox',
|
610 |
-
'label' => __( 'Enable the "Content Restriction" settings for taxonomies', 'ultimate-member' ),
|
611 |
-
'tooltip' => __( 'Check taxonomies for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
612 |
-
'options' => $taxonomies_options,
|
613 |
-
'columns' => 3,
|
614 |
-
'value' => $restricted_access_taxonomy_metabox_value,
|
615 |
-
'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ),
|
616 |
-
),
|
617 |
-
)
|
618 |
-
);
|
619 |
-
|
620 |
-
$settings_map = array_merge(
|
621 |
-
$settings_map,
|
622 |
-
array(
|
623 |
-
'restricted_access_post_metabox' => array(
|
624 |
-
'sanitize' => 'key',
|
625 |
-
),
|
626 |
-
'restricted_access_taxonomy_metabox' => array(
|
627 |
-
'sanitize' => 'key',
|
628 |
-
),
|
629 |
-
)
|
630 |
-
);
|
631 |
-
|
632 |
-
$latest_update = get_option( 'um_member_directory_update_meta', false );
|
633 |
-
$latest_truncate = get_option( 'um_member_directory_truncated', false );
|
634 |
-
|
635 |
-
$same_page_update = array(
|
636 |
-
'id' => 'member_directory_own_table',
|
637 |
-
'type' => 'same_page_update',
|
638 |
-
'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ),
|
639 |
-
'tooltip' => __( 'Check this box if you would like to enable the use of a custom table for user metadata. Improved performance for member directory searches.', 'ultimate-member' ),
|
640 |
-
);
|
641 |
-
|
642 |
-
if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) {
|
643 |
-
$same_page_update['upgrade_cb'] = 'sync_metatable';
|
644 |
-
$same_page_update['upgrade_description'] = '<p>' . __( 'We recommend creating a backup of your site before running the update process. Do not exit the page before the update process has complete.', 'ultimate-member' ) . '</p>
|
645 |
-
<p>' . __( 'After clicking the <strong>"Run"</strong> button, the update process will start. All information will be displayed in the field below.', 'ultimate-member' ) . '</p>
|
646 |
-
<p>' . __( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ) . '</p>';
|
647 |
-
}
|
648 |
-
|
649 |
-
$settings_map = array_merge(
|
650 |
-
$settings_map,
|
651 |
-
array(
|
652 |
-
'permalink_base' => array(
|
653 |
-
'sanitize' => 'key',
|
654 |
-
),
|
655 |
-
'display_name' => array(
|
656 |
-
'sanitize' => 'key',
|
657 |
-
),
|
658 |
-
'display_name_field' => array(
|
659 |
-
'sanitize' => 'text',
|
660 |
-
),
|
661 |
-
'author_redirect' => array(
|
662 |
-
'sanitize' => 'bool',
|
663 |
-
),
|
664 |
-
'members_page' => array(
|
665 |
-
'sanitize' => 'bool',
|
666 |
-
),
|
667 |
-
'use_gravatars' => array(
|
668 |
-
'sanitize' => 'bool',
|
669 |
-
),
|
670 |
-
'use_um_gravatar_default_builtin_image' => array(
|
671 |
-
'sanitize' => 'key',
|
672 |
-
),
|
673 |
-
'use_um_gravatar_default_image' => array(
|
674 |
-
'sanitize' => 'bool',
|
675 |
-
),
|
676 |
-
'
|
677 |
-
'sanitize' => 'bool',
|
678 |
-
),
|
679 |
-
'password_min_chars' => array(
|
680 |
-
'sanitize' => 'absint',
|
681 |
-
),
|
682 |
-
'password_max_chars' => array(
|
683 |
-
'sanitize' => 'absint',
|
684 |
-
),
|
685 |
-
'profile_noindex' => array(
|
686 |
-
'sanitize' => 'bool',
|
687 |
-
),
|
688 |
-
'activation_link_expiry_time' => array(
|
689 |
-
'sanitize' => 'absint',
|
690 |
-
),
|
691 |
-
'account_tab_password' => array(
|
692 |
-
'sanitize' => 'bool',
|
693 |
-
),
|
694 |
-
'account_tab_privacy' => array(
|
695 |
-
'sanitize' => 'bool',
|
696 |
-
),
|
697 |
-
'account_tab_notifications' => array(
|
698 |
-
'sanitize' => 'bool',
|
699 |
-
),
|
700 |
-
'account_tab_delete' => array(
|
701 |
-
'sanitize' => 'bool',
|
702 |
-
),
|
703 |
-
'delete_account_text' => array(
|
704 |
-
'sanitize' => 'textarea',
|
705 |
-
),
|
706 |
-
'delete_account_no_pass_required_text' => array(
|
707 |
-
'sanitize' => 'textarea',
|
708 |
-
),
|
709 |
-
'account_name' => array(
|
710 |
-
'sanitize' => 'bool',
|
711 |
-
),
|
712 |
-
'account_name_disable' => array(
|
713 |
-
'sanitize' => 'bool',
|
714 |
-
),
|
715 |
-
'account_name_require' => array(
|
716 |
-
'sanitize' => 'bool',
|
717 |
-
),
|
718 |
-
'account_email' => array(
|
719 |
-
'sanitize' => 'bool',
|
720 |
-
),
|
721 |
-
'account_general_password' => array(
|
722 |
-
'sanitize' => 'bool',
|
723 |
-
),
|
724 |
-
'
|
725 |
-
'sanitize' => 'bool',
|
726 |
-
),
|
727 |
-
'
|
728 |
-
'sanitize' => '
|
729 |
-
),
|
730 |
-
'
|
731 |
-
'sanitize' => '
|
732 |
-
),
|
733 |
-
'
|
734 |
-
'sanitize' => 'absint',
|
735 |
-
),
|
736 |
-
'
|
737 |
-
'sanitize' => 'absint',
|
738 |
-
),
|
739 |
-
'
|
740 |
-
'sanitize' => 'absint',
|
741 |
-
),
|
742 |
-
'
|
743 |
-
'sanitize' => '
|
744 |
-
),
|
745 |
-
'
|
746 |
-
'sanitize' => '
|
747 |
-
),
|
748 |
-
'
|
749 |
-
'sanitize' => 'absint',
|
750 |
-
),
|
751 |
-
'
|
752 |
-
'sanitize' => 'absint',
|
753 |
-
),
|
754 |
-
'
|
755 |
-
'sanitize' => '
|
756 |
-
),
|
757 |
-
'
|
758 |
-
'sanitize' => '
|
759 |
-
),
|
760 |
-
'
|
761 |
-
'sanitize' => '
|
762 |
-
),
|
763 |
-
'
|
764 |
-
'sanitize' => 'textarea',
|
765 |
-
),
|
766 |
-
'
|
767 |
-
'sanitize' => '
|
768 |
-
),
|
769 |
-
'
|
770 |
-
'sanitize' => 'text',
|
771 |
-
),
|
772 |
-
'
|
773 |
-
'sanitize' => 'text',
|
774 |
-
),
|
775 |
-
'
|
776 |
-
'sanitize' => '
|
777 |
-
),
|
778 |
-
'
|
779 |
-
'sanitize' => '
|
780 |
-
),
|
781 |
-
'
|
782 |
-
'sanitize' => 'text',
|
783 |
-
),
|
784 |
-
'
|
785 |
-
'sanitize' => 'text',
|
786 |
-
),
|
787 |
-
'
|
788 |
-
'sanitize' => '
|
789 |
-
),
|
790 |
-
'
|
791 |
-
'sanitize' => '
|
792 |
-
),
|
793 |
-
'
|
794 |
-
'sanitize' => '
|
795 |
-
),
|
796 |
-
'
|
797 |
-
'sanitize' => '
|
798 |
-
),
|
799 |
-
'
|
800 |
-
'sanitize' => '
|
801 |
-
),
|
802 |
-
'
|
803 |
-
'sanitize' => 'url',
|
804 |
-
),
|
805 |
-
'
|
806 |
-
'sanitize' => '
|
807 |
-
),
|
808 |
-
'
|
809 |
-
'sanitize' => '
|
810 |
-
),
|
811 |
-
'
|
812 |
-
'sanitize' =>
|
813 |
-
),
|
814 |
-
'
|
815 |
-
'sanitize' => '
|
816 |
-
),
|
817 |
-
'
|
818 |
-
'sanitize' =>
|
819 |
-
),
|
820 |
-
'
|
821 |
-
'sanitize' => '
|
822 |
-
),
|
823 |
-
'
|
824 |
-
'sanitize' => 'bool',
|
825 |
-
),
|
826 |
-
'
|
827 |
-
'sanitize' => 'bool',
|
828 |
-
),
|
829 |
-
'
|
830 |
-
'sanitize' => 'bool',
|
831 |
-
),
|
832 |
-
'
|
833 |
-
'sanitize' => 'bool',
|
834 |
-
),
|
835 |
-
'
|
836 |
-
'sanitize' => '
|
837 |
-
),
|
838 |
-
'
|
839 |
-
'sanitize' => '
|
840 |
-
),
|
841 |
-
'
|
842 |
-
'sanitize' => '
|
843 |
-
),
|
844 |
-
'
|
845 |
-
'sanitize' => 'bool',
|
846 |
-
),
|
847 |
-
'
|
848 |
-
'sanitize' => '
|
849 |
-
),
|
850 |
-
'
|
851 |
-
'sanitize' => 'text',
|
852 |
-
),
|
853 |
-
'
|
854 |
-
'sanitize' => '
|
855 |
-
),
|
856 |
-
'
|
857 |
-
'sanitize' => 'key',
|
858 |
-
),
|
859 |
-
'
|
860 |
-
'sanitize' => '
|
861 |
-
),
|
862 |
-
'
|
863 |
-
'sanitize' => '
|
864 |
-
),
|
865 |
-
'
|
866 |
-
'sanitize' => '
|
867 |
-
),
|
868 |
-
'
|
869 |
-
'sanitize' => '
|
870 |
-
),
|
871 |
-
'
|
872 |
-
'sanitize' => '
|
873 |
-
),
|
874 |
-
'
|
875 |
-
'sanitize' => '
|
876 |
-
),
|
877 |
-
'
|
878 |
-
'sanitize' => 'text',
|
879 |
-
),
|
880 |
-
'
|
881 |
-
'sanitize' => '
|
882 |
-
),
|
883 |
-
'
|
884 |
-
'sanitize' => 'key',
|
885 |
-
),
|
886 |
-
'
|
887 |
-
'sanitize' => '
|
888 |
-
),
|
889 |
-
'
|
890 |
-
'sanitize' => '
|
891 |
-
),
|
892 |
-
'
|
893 |
-
'sanitize' => '
|
894 |
-
),
|
895 |
-
'
|
896 |
-
'sanitize' => '
|
897 |
-
),
|
898 |
-
'
|
899 |
-
'sanitize' => '
|
900 |
-
),
|
901 |
-
'
|
902 |
-
'sanitize' => 'bool',
|
903 |
-
),
|
904 |
-
'
|
905 |
-
'sanitize' => 'bool',
|
906 |
-
),
|
907 |
-
'
|
908 |
-
'sanitize' => '
|
909 |
-
),
|
910 |
-
'
|
911 |
-
'sanitize' => '
|
912 |
-
),
|
913 |
-
'
|
914 |
-
'sanitize' => '
|
915 |
-
),
|
916 |
-
'
|
917 |
-
'sanitize' => 'bool',
|
918 |
-
),
|
919 |
-
'
|
920 |
-
'sanitize' => '
|
921 |
-
),
|
922 |
-
'
|
923 |
-
'sanitize' => '
|
924 |
-
),
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
*
|
935 |
-
*
|
936 |
-
* @
|
937 |
-
*
|
938 |
-
* @
|
939 |
-
*
|
940 |
-
*
|
941 |
-
* @
|
942 |
-
*
|
943 |
-
*
|
944 |
-
*
|
945 |
-
*
|
946 |
-
*
|
947 |
-
*
|
948 |
-
*
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
'
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
'
|
968 |
-
|
969 |
-
'
|
970 |
-
'
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
'
|
975 |
-
'
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
'
|
981 |
-
|
982 |
-
|
983 |
-
'
|
984 |
-
'
|
985 |
-
'
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
'
|
990 |
-
'
|
991 |
-
'
|
992 |
-
'
|
993 |
-
'
|
994 |
-
'
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
'
|
1000 |
-
|
1001 |
-
|
1002 |
-
'
|
1003 |
-
'
|
1004 |
-
|
1005 |
-
|
1006 |
-
'
|
1007 |
-
|
1008 |
-
|
1009 |
-
'
|
1010 |
-
|
1011 |
-
|
1012 |
-
'
|
1013 |
-
|
1014 |
-
|
1015 |
-
'
|
1016 |
-
|
1017 |
-
|
1018 |
-
'
|
1019 |
-
|
1020 |
-
|
1021 |
-
'
|
1022 |
-
|
1023 |
-
|
1024 |
-
'
|
1025 |
-
|
1026 |
-
|
1027 |
-
'
|
1028 |
-
'
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
'
|
1033 |
-
'
|
1034 |
-
'
|
1035 |
-
'
|
1036 |
-
'
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
'
|
1043 |
-
|
1044 |
-
|
1045 |
-
'
|
1046 |
-
'
|
1047 |
-
|
1048 |
-
|
1049 |
-
'
|
1050 |
-
|
1051 |
-
|
1052 |
-
'
|
1053 |
-
|
1054 |
-
|
1055 |
-
'
|
1056 |
-
|
1057 |
-
|
1058 |
-
'
|
1059 |
-
'
|
1060 |
-
|
1061 |
-
|
1062 |
-
'
|
1063 |
-
|
1064 |
-
|
1065 |
-
'
|
1066 |
-
'
|
1067 |
-
|
1068 |
-
|
1069 |
-
'
|
1070 |
-
|
1071 |
-
|
1072 |
-
'
|
1073 |
-
'
|
1074 |
-
'
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
'
|
1084 |
-
'
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
),
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
'
|
1096 |
-
|
1097 |
-
|
1098 |
-
'
|
1099 |
-
|
1100 |
-
|
1101 |
-
'
|
1102 |
-
|
1103 |
-
|
1104 |
-
'
|
1105 |
-
|
1106 |
-
|
1107 |
-
'
|
1108 |
-
|
1109 |
-
|
1110 |
-
'
|
1111 |
-
|
1112 |
-
|
1113 |
-
'
|
1114 |
-
|
1115 |
-
|
1116 |
-
'
|
1117 |
-
|
1118 |
-
|
1119 |
-
'
|
1120 |
-
'
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
'
|
1129 |
-
'
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
'
|
1138 |
-
|
1139 |
-
|
1140 |
-
'
|
1141 |
-
|
1142 |
-
|
1143 |
-
'
|
1144 |
-
'
|
1145 |
-
|
1146 |
-
|
1147 |
-
'
|
1148 |
-
|
1149 |
-
|
1150 |
-
'
|
1151 |
-
'
|
1152 |
-
|
1153 |
-
|
1154 |
-
'
|
1155 |
-
|
1156 |
-
|
1157 |
-
'
|
1158 |
-
|
1159 |
-
|
1160 |
-
'
|
1161 |
-
|
1162 |
-
|
1163 |
-
'
|
1164 |
-
|
1165 |
-
|
1166 |
-
'
|
1167 |
-
|
1168 |
-
|
1169 |
-
'
|
1170 |
-
'
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
'
|
1176 |
-
'
|
1177 |
-
'
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
'
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
'
|
1191 |
-
'
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
'
|
1200 |
-
'
|
1201 |
-
'
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
'
|
1207 |
-
'
|
1208 |
-
'
|
1209 |
-
'
|
1210 |
-
'
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
'
|
1215 |
-
'
|
1216 |
-
'
|
1217 |
-
'
|
1218 |
-
'
|
1219 |
-
'
|
1220 |
-
'
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
'
|
1225 |
-
'
|
1226 |
-
'label'
|
1227 |
-
'tooltip'
|
1228 |
-
|
1229 |
-
|
1230 |
-
'
|
1231 |
-
|
1232 |
-
|
1233 |
-
'
|
1234 |
-
'
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
'
|
1240 |
-
'
|
1241 |
-
'
|
1242 |
-
'
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
'
|
1248 |
-
'
|
1249 |
-
'
|
1250 |
-
'
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
),
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
'
|
1277 |
-
'
|
1278 |
-
'
|
1279 |
-
),
|
1280 |
-
array(
|
1281 |
-
'id'
|
1282 |
-
'type'
|
1283 |
-
'label'
|
1284 |
-
'tooltip'
|
1285 |
-
|
1286 |
-
|
1287 |
-
'
|
1288 |
-
|
1289 |
-
|
1290 |
-
'
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
'
|
1310 |
-
|
1311 |
-
|
1312 |
-
'
|
1313 |
-
|
1314 |
-
|
1315 |
-
'
|
1316 |
-
|
1317 |
-
|
1318 |
-
'
|
1319 |
-
|
1320 |
-
|
1321 |
-
'
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
'
|
1330 |
-
'
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
array(
|
1341 |
-
'id' => '
|
1342 |
-
'type' => '
|
1343 |
-
'label' => __( 'Profile
|
1344 |
-
'
|
1345 |
-
'
|
1346 |
-
'
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
'
|
1351 |
-
'
|
1352 |
-
'
|
1353 |
-
'
|
1354 |
-
'
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
'
|
1359 |
-
'
|
1360 |
-
'
|
1361 |
-
'default' => um_get_metadefault( '
|
1362 |
-
'
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
'
|
1368 |
-
|
1369 |
-
|
1370 |
-
'
|
1371 |
-
'
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
'
|
1380 |
-
'
|
1381 |
-
'
|
1382 |
-
'
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
'
|
1388 |
-
'
|
1389 |
-
'
|
1390 |
-
'
|
1391 |
-
'
|
1392 |
-
),
|
1393 |
-
array(
|
1394 |
-
'id'
|
1395 |
-
'type'
|
1396 |
-
'label'
|
1397 |
-
'
|
1398 |
-
'
|
1399 |
-
'
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
'
|
1405 |
-
'
|
1406 |
-
'
|
1407 |
-
'
|
1408 |
-
'
|
1409 |
-
|
1410 |
-
),
|
1411 |
-
),
|
1412 |
-
array(
|
1413 |
-
'id'
|
1414 |
-
'type'
|
1415 |
-
'
|
1416 |
-
'
|
1417 |
-
'
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
'
|
1423 |
-
'
|
1424 |
-
'
|
1425 |
-
'tooltip' => __( '
|
1426 |
-
'
|
1427 |
-
),
|
1428 |
-
array(
|
1429 |
-
'id' => '
|
1430 |
-
'type' => '
|
1431 |
-
'label' => __( 'Profile
|
1432 |
-
'default' => um_get_metadefault( '
|
1433 |
-
'
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
'
|
1439 |
-
'
|
1440 |
-
'
|
1441 |
-
'
|
1442 |
-
'
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
'
|
1447 |
-
'
|
1448 |
-
'
|
1449 |
-
'
|
1450 |
-
'
|
1451 |
-
'
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
'
|
1458 |
-
'
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
),
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
'
|
1471 |
-
'
|
1472 |
-
'
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
'
|
1478 |
-
'
|
1479 |
-
'
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
'
|
1485 |
-
'
|
1486 |
-
'
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
'
|
1492 |
-
'
|
1493 |
-
|
1494 |
-
|
1495 |
-
'
|
1496 |
-
|
1497 |
-
|
1498 |
-
'
|
1499 |
-
'
|
1500 |
-
'
|
1501 |
-
'
|
1502 |
-
),
|
1503 |
-
array(
|
1504 |
-
'id'
|
1505 |
-
'type'
|
1506 |
-
'label'
|
1507 |
-
'default'
|
1508 |
-
'tooltip'
|
1509 |
-
'
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
'
|
1514 |
-
|
1515 |
-
|
1516 |
-
'
|
1517 |
-
'
|
1518 |
-
'
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
'
|
1526 |
-
'
|
1527 |
-
'
|
1528 |
-
'
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
array(
|
1549 |
-
'id' => '
|
1550 |
-
'type' => '
|
1551 |
-
'label' => __( 'Registration
|
1552 |
-
'
|
1553 |
-
'
|
1554 |
-
'
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
'
|
1559 |
-
'
|
1560 |
-
'
|
1561 |
-
'default' => um_get_metadefault( '
|
1562 |
-
'
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
'
|
1568 |
-
|
1569 |
-
|
1570 |
-
'
|
1571 |
-
'
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
'
|
1581 |
-
|
1582 |
-
|
1583 |
-
'
|
1584 |
-
'
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
'
|
1593 |
-
'
|
1594 |
-
'
|
1595 |
-
'
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
'
|
1601 |
-
'
|
1602 |
-
'
|
1603 |
-
'
|
1604 |
-
'
|
1605 |
-
),
|
1606 |
-
array(
|
1607 |
-
'id' => '
|
1608 |
-
'type' => 'text',
|
1609 |
-
'label' => __( 'Registration Secondary Button
|
1610 |
-
'default' => um_get_metadefault( '
|
1611 |
-
'tooltip' => __( '
|
1612 |
-
'conditional' => array( 'register_secondary_btn', '=', 1 ),
|
1613 |
-
'size' => 'medium',
|
1614 |
-
),
|
1615 |
-
array(
|
1616 |
-
'id'
|
1617 |
-
'type'
|
1618 |
-
'label'
|
1619 |
-
'
|
1620 |
-
'
|
1621 |
-
'
|
1622 |
-
'size'
|
1623 |
-
),
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
'
|
1631 |
-
'
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
array(
|
1639 |
-
'id' => '
|
1640 |
-
'type' => '
|
1641 |
-
'label' => __( 'Login
|
1642 |
-
'
|
1643 |
-
'
|
1644 |
-
'
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
'
|
1649 |
-
'
|
1650 |
-
'
|
1651 |
-
'default' => um_get_metadefault( '
|
1652 |
-
'
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
'
|
1658 |
-
|
1659 |
-
|
1660 |
-
'
|
1661 |
-
'
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
'
|
1671 |
-
|
1672 |
-
|
1673 |
-
'
|
1674 |
-
'
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
'
|
1683 |
-
'
|
1684 |
-
'
|
1685 |
-
'
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
'
|
1691 |
-
'
|
1692 |
-
'
|
1693 |
-
'
|
1694 |
-
'
|
1695 |
-
),
|
1696 |
-
array(
|
1697 |
-
'id' => '
|
1698 |
-
'type' => 'text',
|
1699 |
-
'label' => __( 'Login Secondary Button
|
1700 |
-
'default' => um_get_metadefault( '
|
1701 |
-
'tooltip' => __( '
|
1702 |
-
'conditional' => array( 'login_secondary_btn', '=', 1 ),
|
1703 |
-
'size' => 'medium',
|
1704 |
-
),
|
1705 |
-
array(
|
1706 |
-
'id'
|
1707 |
-
'type'
|
1708 |
-
'label'
|
1709 |
-
'default'
|
1710 |
-
'tooltip'
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
'
|
1716 |
-
'
|
1717 |
-
'
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
),
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
'
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
'
|
1748 |
-
'
|
1749 |
-
'
|
1750 |
-
|
1751 |
-
|
1752 |
-
),
|
1753 |
-
array(
|
1754 |
-
'id' => '
|
1755 |
-
'type' => '
|
1756 |
-
'label' => __( 'User Profile
|
1757 |
-
'tooltip' => __( '
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
'
|
1764 |
-
|
1765 |
-
|
1766 |
-
'
|
1767 |
-
|
1768 |
-
|
1769 |
-
'
|
1770 |
-
'
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
'
|
1779 |
-
'
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
'
|
1788 |
-
'
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
'
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
*
|
1926 |
-
*
|
1927 |
-
*
|
1928 |
-
*
|
1929 |
-
*
|
1930 |
-
*
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
*
|
1947 |
-
*
|
1948 |
-
*
|
1949 |
-
*
|
1950 |
-
*
|
1951 |
-
*
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
*
|
1960 |
-
*
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
*
|
1969 |
-
*
|
1970 |
-
* @
|
1971 |
-
* @
|
1972 |
-
*
|
1973 |
-
*
|
1974 |
-
*
|
1975 |
-
*
|
1976 |
-
*
|
1977 |
-
*
|
1978 |
-
*
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
*
|
2002 |
-
*
|
2003 |
-
*
|
2004 |
-
*
|
2005 |
-
*
|
2006 |
-
*
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
*
|
2015 |
-
*
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
*
|
2024 |
-
*
|
2025 |
-
* @
|
2026 |
-
*
|
2027 |
-
*
|
2028 |
-
*
|
2029 |
-
*
|
2030 |
-
*
|
2031 |
-
*
|
2032 |
-
*
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
*
|
2099 |
-
*
|
2100 |
-
*
|
2101 |
-
*
|
2102 |
-
*
|
2103 |
-
*
|
2104 |
-
*
|
2105 |
-
*
|
2106 |
-
*
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
$menu_subtabs
|
2136 |
-
|
2137 |
-
$
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
*
|
2173 |
-
*
|
2174 |
-
*
|
2175 |
-
*
|
2176 |
-
*
|
2177 |
-
*
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
|
2182 |
-
*
|
2183 |
-
*
|
2184 |
-
*
|
2185 |
-
*
|
2186 |
-
*
|
2187 |
-
|
2188 |
-
|
2189 |
-
|
2190 |
-
|
2191 |
-
*
|
2192 |
-
*
|
2193 |
-
*
|
2194 |
-
*
|
2195 |
-
*
|
2196 |
-
*
|
2197 |
-
*
|
2198 |
-
*
|
2199 |
-
*
|
2200 |
-
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
-
|
2208 |
-
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
*
|
2220 |
-
*
|
2221 |
-
*
|
2222 |
-
*
|
2223 |
-
*
|
2224 |
-
*
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
2257 |
-
|
2258 |
-
|
2259 |
-
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
if (
|
2286 |
-
$
|
2287 |
-
}
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
|
2294 |
-
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
-
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
-
|
2323 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
if (
|
2327 |
-
$this->
|
2328 |
-
}
|
2329 |
-
}
|
2330 |
-
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
$
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
LEFT JOIN {$wpdb->usermeta} AS
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
|
2433 |
-
|
2434 |
-
|
2435 |
-
|
2436 |
-
|
2437 |
-
|
2438 |
-
|
2439 |
-
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
-
|
2445 |
-
|
2446 |
-
|
2447 |
-
|
2448 |
-
|
2449 |
-
|
2450 |
-
LEFT JOIN {$wpdb->usermeta} AS
|
2451 |
-
|
2452 |
-
|
2453 |
-
|
2454 |
-
|
2455 |
-
|
2456 |
-
|
2457 |
-
|
2458 |
-
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
-
|
2465 |
-
|
2466 |
-
|
2467 |
-
|
2468 |
-
|
2469 |
-
|
2470 |
-
|
2471 |
-
|
2472 |
-
|
2473 |
-
|
2474 |
-
|
2475 |
-
|
2476 |
-
|
2477 |
-
|
2478 |
-
|
2479 |
-
|
2480 |
-
|
2481 |
-
|
2482 |
-
|
2483 |
-
|
2484 |
-
|
2485 |
-
|
2486 |
-
|
2487 |
-
|
2488 |
-
|
2489 |
-
|
2490 |
-
|
2491 |
-
|
2492 |
-
|
2493 |
-
|
2494 |
-
|
2495 |
-
|
2496 |
-
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
|
2502 |
-
|
2503 |
-
|
2504 |
-
|
2505 |
-
|
2506 |
-
|
2507 |
-
|
2508 |
-
|
2509 |
-
|
2510 |
-
|
2511 |
-
|
2512 |
-
|
2513 |
-
|
2514 |
-
|
2515 |
-
|
2516 |
-
|
2517 |
-
|
2518 |
-
|
2519 |
-
|
2520 |
-
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
|
2527 |
-
$
|
2528 |
-
|
2529 |
-
|
2530 |
-
|
2531 |
-
|
2532 |
-
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
$
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
);
|
2544 |
-
|
2545 |
-
$request
|
2546 |
-
|
2547 |
-
|
2548 |
-
|
2549 |
-
|
2550 |
-
|
2551 |
-
|
2552 |
-
|
2553 |
-
|
2554 |
-
|
2555 |
-
|
2556 |
-
|
2557 |
-
$request
|
2558 |
-
|
2559 |
-
|
2560 |
-
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
|
2577 |
-
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
|
2589 |
-
|
2590 |
-
|
2591 |
-
|
2592 |
-
|
2593 |
-
|
2594 |
-
|
2595 |
-
|
2596 |
-
|
2597 |
-
|
2598 |
-
|
2599 |
-
|
2600 |
-
|
2601 |
-
|
2602 |
-
|
2603 |
-
|
2604 |
-
|
2605 |
-
|
2606 |
-
|
2607 |
-
|
2608 |
-
|
2609 |
-
|
2610 |
-
|
2611 |
-
|
2612 |
-
*
|
2613 |
-
*
|
2614 |
-
* @
|
2615 |
-
*
|
2616 |
-
*
|
2617 |
-
*
|
2618 |
-
*
|
2619 |
-
*
|
2620 |
-
*
|
2621 |
-
*
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
-
|
2626 |
-
|
2627 |
-
|
2628 |
-
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
|
2635 |
-
|
2636 |
-
'
|
2637 |
-
|
2638 |
-
|
2639 |
-
'
|
2640 |
-
'
|
2641 |
-
|
2642 |
-
|
2643 |
-
|
2644 |
-
|
2645 |
-
'
|
2646 |
-
'
|
2647 |
-
'
|
2648 |
-
'
|
2649 |
-
'
|
2650 |
-
),
|
2651 |
-
|
2652 |
-
|
2653 |
-
|
2654 |
-
|
2655 |
-
|
2656 |
-
|
2657 |
-
|
2658 |
-
|
2659 |
-
|
2660 |
-
|
2661 |
-
|
2662 |
-
|
2663 |
-
|
2664 |
-
|
2665 |
-
|
2666 |
-
|
2667 |
-
*
|
2668 |
-
|
2669 |
-
|
2670 |
-
|
2671 |
-
|
2672 |
-
|
2673 |
-
|
2674 |
-
|
2675 |
-
|
2676 |
-
|
2677 |
-
|
2678 |
-
|
2679 |
-
|
2680 |
-
|
2681 |
-
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
|
2711 |
-
|
2712 |
-
|
2713 |
-
|
2714 |
-
|
2715 |
-
|
2716 |
-
|
2717 |
-
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
|
2722 |
-
|
2723 |
-
|
2724 |
-
|
2725 |
-
|
2726 |
-
|
2727 |
-
|
2728 |
-
|
2729 |
-
|
2730 |
-
|
2731 |
-
|
2732 |
-
|
2733 |
-
|
2734 |
-
|
2735 |
-
|
2736 |
-
|
2737 |
-
|
2738 |
-
|
2739 |
-
|
2740 |
-
|
2741 |
-
|
2742 |
-
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
-
|
2747 |
-
);
|
2748 |
-
|
2749 |
-
$license_status = 'license-' . $class . '-notice';
|
2750 |
-
|
2751 |
-
break;
|
2752 |
-
|
2753 |
-
case '
|
2754 |
-
|
2755 |
-
$class = 'error';
|
2756 |
-
$messages[] = sprintf( __( '
|
2757 |
-
|
2758 |
-
$license_status = 'license-' . $class . '-notice';
|
2759 |
-
|
2760 |
-
break;
|
2761 |
-
|
2762 |
-
case '
|
2763 |
-
|
2764 |
-
$class = 'error';
|
2765 |
-
$messages[] =
|
2766 |
-
|
2767 |
-
$license_status = 'license-' . $class . '-notice';
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
-
|
2772 |
-
|
2773 |
-
$
|
2774 |
-
$messages[] = __( '
|
2775 |
-
|
2776 |
-
$license_status = 'license-' . $class . '-notice';
|
2777 |
-
break;
|
2778 |
-
|
2779 |
-
|
2780 |
-
|
2781 |
-
|
2782 |
-
|
2783 |
-
|
2784 |
-
|
2785 |
-
|
2786 |
-
|
2787 |
-
|
2788 |
-
|
2789 |
-
|
2790 |
-
|
2791 |
-
|
2792 |
-
|
2793 |
-
|
2794 |
-
|
2795 |
-
|
2796 |
-
|
2797 |
-
|
2798 |
-
|
2799 |
-
|
2800 |
-
|
2801 |
-
$
|
2802 |
-
|
2803 |
-
|
2804 |
-
|
2805 |
-
|
2806 |
-
|
2807 |
-
|
2808 |
-
|
2809 |
-
|
2810 |
-
|
2811 |
-
|
2812 |
-
|
2813 |
-
|
2814 |
-
|
2815 |
-
|
2816 |
-
|
2817 |
-
|
2818 |
-
|
2819 |
-
|
2820 |
-
|
2821 |
-
|
2822 |
-
|
2823 |
-
|
2824 |
-
|
2825 |
-
|
2826 |
-
|
2827 |
-
|
2828 |
-
|
2829 |
-
|
2830 |
-
|
2831 |
-
|
2832 |
-
|
2833 |
-
|
2834 |
-
|
2835 |
-
|
2836 |
-
|
2837 |
-
|
2838 |
-
|
2839 |
-
|
2840 |
-
|
2841 |
-
|
2842 |
-
|
2843 |
-
|
2844 |
-
|
2845 |
-
|
2846 |
-
|
2847 |
-
|
2848 |
-
|
2849 |
-
|
2850 |
-
|
2851 |
-
|
2852 |
-
|
2853 |
-
|
2854 |
-
|
2855 |
-
|
2856 |
-
|
2857 |
-
);
|
2858 |
-
|
2859 |
-
$license_status = 'license-' . $class . '-notice';
|
2860 |
-
|
2861 |
-
break;
|
2862 |
-
|
2863 |
-
case '
|
2864 |
-
|
2865 |
-
$class = 'error';
|
2866 |
-
$messages[] = sprintf( __( '
|
2867 |
-
|
2868 |
-
$license_status = 'license-' . $class . '-notice';
|
2869 |
-
|
2870 |
-
break;
|
2871 |
-
|
2872 |
-
case '
|
2873 |
-
|
2874 |
-
$class = 'error';
|
2875 |
-
$messages[] =
|
2876 |
-
|
2877 |
-
$license_status = 'license-' . $class . '-notice';
|
2878 |
-
|
2879 |
-
|
2880 |
-
|
2881 |
-
|
2882 |
-
|
2883 |
-
$class = '
|
2884 |
-
|
2885 |
-
|
2886 |
-
$
|
2887 |
-
|
2888 |
-
|
2889 |
-
|
2890 |
-
|
2891 |
-
|
2892 |
-
|
2893 |
-
|
2894 |
-
$now
|
2895 |
-
|
2896 |
-
|
2897 |
-
|
2898 |
-
|
2899 |
-
|
2900 |
-
|
2901 |
-
|
2902 |
-
|
2903 |
-
|
2904 |
-
|
2905 |
-
|
2906 |
-
|
2907 |
-
|
2908 |
-
'
|
2909 |
-
);
|
2910 |
-
|
2911 |
-
$license_status = 'license-
|
2912 |
-
|
2913 |
-
}
|
2914 |
-
|
2915 |
-
|
2916 |
-
|
2917 |
-
|
2918 |
-
|
2919 |
-
|
2920 |
-
|
2921 |
-
|
2922 |
-
|
2923 |
-
|
2924 |
-
|
2925 |
-
|
2926 |
-
|
2927 |
-
|
2928 |
-
|
2929 |
-
|
2930 |
-
|
2931 |
-
|
2932 |
-
|
2933 |
-
|
2934 |
-
|
2935 |
-
|
2936 |
-
|
2937 |
-
|
2938 |
-
|
2939 |
-
|
2940 |
-
|
2941 |
-
|
2942 |
-
|
2943 |
-
|
2944 |
-
|
2945 |
-
|
2946 |
-
|
2947 |
-
|
2948 |
-
<?php
|
2949 |
-
|
2950 |
-
|
2951 |
-
|
2952 |
-
|
2953 |
-
|
2954 |
-
|
2955 |
-
|
2956 |
-
|
2957 |
-
|
2958 |
-
|
2959 |
-
|
2960 |
-
|
2961 |
-
|
2962 |
-
|
2963 |
-
|
2964 |
-
|
2965 |
-
|
2966 |
-
|
2967 |
-
|
2968 |
-
|
2969 |
-
|
2970 |
-
|
2971 |
-
|
2972 |
-
|
2973 |
-
|
2974 |
-
|
2975 |
-
|
2976 |
-
|
2977 |
-
|
2978 |
-
|
2979 |
-
|
2980 |
-
|
2981 |
-
|
2982 |
-
|
2983 |
-
|
2984 |
-
|
2985 |
-
|
2986 |
-
|
2987 |
-
|
2988 |
-
|
2989 |
-
|
2990 |
-
|
2991 |
-
|
2992 |
-
|
2993 |
-
|
2994 |
-
|
2995 |
-
|
2996 |
-
|
2997 |
-
|
2998 |
-
|
2999 |
-
|
3000 |
-
|
3001 |
-
|
3002 |
-
|
3003 |
-
|
3004 |
-
|
3005 |
-
|
3006 |
-
|
3007 |
-
|
3008 |
-
|
3009 |
-
|
3010 |
-
|
3011 |
-
|
3012 |
-
|
3013 |
-
|
3014 |
-
|
3015 |
-
|
3016 |
-
|
3017 |
-
|
3018 |
-
|
3019 |
-
*
|
3020 |
-
*
|
3021 |
-
*
|
3022 |
-
*
|
3023 |
-
*
|
3024 |
-
*
|
3025 |
-
|
3026 |
-
|
3027 |
-
|
3028 |
-
|
3029 |
-
|
3030 |
-
|
3031 |
-
|
3032 |
-
|
3033 |
-
|
3034 |
-
|
3035 |
-
|
3036 |
-
|
3037 |
-
|
3038 |
-
|
3039 |
-
|
3040 |
-
|
3041 |
-
|
3042 |
-
|
3043 |
-
|
3044 |
-
|
3045 |
-
|
3046 |
-
|
3047 |
-
<?php
|
3048 |
-
|
3049 |
-
|
3050 |
-
|
3051 |
-
|
3052 |
-
|
3053 |
-
|
3054 |
-
|
3055 |
-
<?php $
|
3056 |
-
|
3057 |
-
|
3058 |
-
|
3059 |
-
|
3060 |
-
|
3061 |
-
|
3062 |
-
|
3063 |
-
|
3064 |
-
|
3065 |
-
<?php
|
3066 |
-
<?php
|
3067 |
-
|
3068 |
-
|
3069 |
-
|
3070 |
-
|
3071 |
-
|
3072 |
-
|
3073 |
-
|
3074 |
-
|
3075 |
-
|
3076 |
-
$
|
3077 |
-
|
3078 |
-
$
|
3079 |
-
'
|
3080 |
-
|
3081 |
-
'
|
3082 |
-
|
3083 |
-
|
3084 |
-
|
3085 |
-
|
3086 |
-
|
3087 |
-
|
3088 |
-
|
3089 |
-
|
3090 |
-
|
3091 |
-
|
3092 |
-
?>
|
3093 |
-
|
3094 |
-
|
3095 |
-
|
3096 |
-
|
3097 |
-
|
3098 |
-
|
3099 |
-
|
3100 |
-
|
3101 |
-
|
3102 |
-
|
3103 |
-
|
3104 |
-
|
3105 |
-
|
3106 |
-
|
3107 |
-
|
3108 |
-
<?php
|
3109 |
-
|
3110 |
-
|
3111 |
-
|
3112 |
-
|
3113 |
-
|
3114 |
-
|
3115 |
-
|
3116 |
-
|
3117 |
-
|
3118 |
-
|
3119 |
-
*
|
3120 |
-
*
|
3121 |
-
*
|
3122 |
-
*
|
3123 |
-
*
|
3124 |
-
*
|
3125 |
-
|
3126 |
-
|
3127 |
-
|
3128 |
-
|
3129 |
-
|
3130 |
-
|
3131 |
-
|
3132 |
-
|
3133 |
-
|
3134 |
-
|
3135 |
-
|
3136 |
-
|
3137 |
-
|
3138 |
-
|
3139 |
-
|
3140 |
-
|
3141 |
-
|
3142 |
-
|
3143 |
-
|
3144 |
-
|
3145 |
-
*
|
3146 |
-
*
|
3147 |
-
*
|
3148 |
-
*
|
3149 |
-
*
|
3150 |
-
*
|
3151 |
-
|
3152 |
-
|
3153 |
-
|
3154 |
-
|
3155 |
-
|
3156 |
-
|
3157 |
-
|
3158 |
-
|
3159 |
-
|
3160 |
-
|
3161 |
-
|
3162 |
-
|
3163 |
-
|
3164 |
-
|
3165 |
-
|
3166 |
-
|
3167 |
-
|
3168 |
-
|
3169 |
-
|
3170 |
-
|
3171 |
-
|
3172 |
-
|
3173 |
-
<?php if( UM()->options()->get('
|
3174 |
-
|
3175 |
-
|
3176 |
-
|
3177 |
-
|
3178 |
-
|
3179 |
-
|
3180 |
-
|
3181 |
-
|
3182 |
-
<?php if( UM()->options()->get('
|
3183 |
-
|
3184 |
-
|
3185 |
-
<?php
|
3186 |
-
|
3187 |
-
<?php if(
|
3188 |
-
|
3189 |
-
<?php
|
3190 |
-
|
3191 |
-
<?php
|
3192 |
-
|
3193 |
-
<?php } ?>
|
3194 |
-
|
3195 |
-
|
3196 |
-
<?php
|
3197 |
-
|
3198 |
-
|
3199 |
-
<?php } ?>
|
3200 |
-
<?php $
|
3201 |
-
|
3202 |
-
<?php } ?>
|
3203 |
-
|
3204 |
-
|
3205 |
-
|
3206 |
-
|
3207 |
-
|
3208 |
-
<?php }
|
3209 |
-
<?php $
|
3210 |
-
|
3211 |
-
<?php
|
3212 |
-
|
3213 |
-
|
3214 |
-
|
3215 |
-
|
3216 |
-
|
3217 |
-
|
3218 |
-
|
3219 |
-
|
3220 |
-
|
3221 |
-
|
3222 |
-
|
3223 |
-
|
3224 |
-
|
3225 |
-
|
3226 |
-
|
3227 |
-
|
3228 |
-
|
3229 |
-
|
3230 |
-
--- UM
|
3231 |
-
|
3232 |
-
<?php $
|
3233 |
-
|
3234 |
-
|
3235 |
-
|
3236 |
-
|
3237 |
-
|
3238 |
-
|
3239 |
-
|
3240 |
-
|
3241 |
-
|
3242 |
-
|
3243 |
-
|
3244 |
-
|
3245 |
-
|
3246 |
-
|
3247 |
-
|
3248 |
-
|
3249 |
-
|
3250 |
-
|
3251 |
-
|
3252 |
-
|
3253 |
-
|
3254 |
-
|
3255 |
-
|
3256 |
-
|
3257 |
-
|
3258 |
-
|
3259 |
-
|
3260 |
-
|
3261 |
-
|
3262 |
-
|
3263 |
-
|
3264 |
-
|
3265 |
-
|
3266 |
-
|
3267 |
-
|
3268 |
-
|
3269 |
-
|
3270 |
-
|
3271 |
-
|
3272 |
-
|
3273 |
-
|
3274 |
-
|
3275 |
-
|
3276 |
-
|
3277 |
-
|
3278 |
-
|
3279 |
-
|
3280 |
-
PHP
|
3281 |
-
|
3282 |
-
|
3283 |
-
|
3284 |
-
|
3285 |
-
|
3286 |
-
|
3287 |
-
|
3288 |
-
|
3289 |
-
|
3290 |
-
|
3291 |
-
|
3292 |
-
|
3293 |
-
|
3294 |
-
|
3295 |
-
|
3296 |
-
|
3297 |
-
|
3298 |
-
|
3299 |
-
|
3300 |
-
|
3301 |
-
|
3302 |
-
|
3303 |
-
|
3304 |
-
|
3305 |
-
|
3306 |
-
|
3307 |
-
|
3308 |
-
|
3309 |
-
|
3310 |
-
|
3311 |
-
|
3312 |
-
|
3313 |
-
|
3314 |
-
|
3315 |
-
|
3316 |
-
|
3317 |
-
|
3318 |
-
|
3319 |
-
|
3320 |
-
|
3321 |
-
|
3322 |
-
|
3323 |
-
|
3324 |
-
|
3325 |
-
|
3326 |
-
|
3327 |
-
|
3328 |
-
|
3329 |
-
|
3330 |
-
|
3331 |
-
|
3332 |
-
|
3333 |
-
|
3334 |
-
|
3335 |
-
|
3336 |
-
|
3337 |
-
|
3338 |
-
|
3339 |
-
|
3340 |
-
|
3341 |
-
|
3342 |
-
|
3343 |
-
|
3344 |
-
|
3345 |
-
|
3346 |
-
|
3347 |
-
|
3348 |
-
|
3349 |
-
|
3350 |
-
|
3351 |
-
|
3352 |
-
|
3353 |
-
|
3354 |
-
*
|
3355 |
-
*
|
3356 |
-
*
|
3357 |
-
*
|
3358 |
-
*
|
3359 |
-
*
|
3360 |
-
|
3361 |
-
|
3362 |
-
|
3363 |
-
|
3364 |
-
|
3365 |
-
|
3366 |
-
|
3367 |
-
|
3368 |
-
|
3369 |
-
|
3370 |
-
|
3371 |
-
|
3372 |
-
|
3373 |
-
|
3374 |
-
|
3375 |
-
|
3376 |
-
|
3377 |
-
|
3378 |
-
|
3379 |
-
|
3380 |
-
|
3381 |
-
|
3382 |
-
|
3383 |
-
|
3384 |
-
|
3385 |
-
|
3386 |
-
|
3387 |
-
|
3388 |
-
|
3389 |
-
|
3390 |
-
|
3391 |
-
|
3392 |
-
|
3393 |
-
|
3394 |
-
|
3395 |
-
|
3396 |
-
|
3397 |
-
|
3398 |
-
|
3399 |
-
|
3400 |
-
|
3401 |
-
|
3402 |
-
|
3403 |
-
|
3404 |
-
|
3405 |
-
|
3406 |
-
|
3407 |
-
|
3408 |
-
|
3409 |
-
|
3410 |
-
|
3411 |
-
|
3412 |
-
|
3413 |
-
|
3414 |
-
|
3415 |
-
|
3416 |
-
|
3417 |
-
|
3418 |
-
|
3419 |
-
|
3420 |
-
|
3421 |
-
|
3422 |
-
|
3423 |
-
|
3424 |
-
|
3425 |
-
|
3426 |
-
|
3427 |
-
|
3428 |
-
|
3429 |
-
|
3430 |
-
|
3431 |
-
|
3432 |
-
|
3433 |
-
|
3434 |
-
|
3435 |
-
|
3436 |
-
|
3437 |
-
|
3438 |
-
|
3439 |
-
|
3440 |
-
|
3441 |
-
|
3442 |
-
|
3443 |
-
|
3444 |
-
|
3445 |
-
|
3446 |
-
|
3447 |
-
|
3448 |
-
|
3449 |
-
|
3450 |
-
if (
|
3451 |
-
|
3452 |
-
}
|
3453 |
-
|
3454 |
-
$
|
3455 |
-
$
|
3456 |
-
|
3457 |
-
|
3458 |
-
|
3459 |
-
|
3460 |
-
|
3461 |
-
}
|
3462 |
-
|
3463 |
-
|
3464 |
-
|
3465 |
-
|
3466 |
-
|
3467 |
-
if ( $result !== false ) {
|
3468 |
-
unset( $settings['um_email_template'] );
|
3469 |
-
unset( $settings[ $template ] );
|
3470 |
-
}
|
3471 |
-
|
3472 |
-
return $settings;
|
3473 |
-
}
|
3474 |
-
}
|
3475 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\admin\core;
|
3 |
+
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Admin_Settings
|
13 |
+
* @package um\admin\core
|
14 |
+
*/
|
15 |
+
class Admin_Settings {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var array
|
20 |
+
*/
|
21 |
+
public $settings_map;
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var array
|
26 |
+
*/
|
27 |
+
public $settings_structure;
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var
|
32 |
+
*/
|
33 |
+
private $previous_licenses;
|
34 |
+
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @var
|
38 |
+
*/
|
39 |
+
private $need_change_permalinks;
|
40 |
+
|
41 |
+
|
42 |
+
private $gravatar_changed = false;
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Admin_Settings constructor.
|
47 |
+
*/
|
48 |
+
public function __construct() {
|
49 |
+
//init settings structure
|
50 |
+
add_action( 'admin_init', array( &$this, 'init_variables' ), 9 );
|
51 |
+
|
52 |
+
//admin menu
|
53 |
+
add_action( 'admin_menu', array( &$this, 'primary_admin_menu' ), 0 );
|
54 |
+
|
55 |
+
//settings structure handlers
|
56 |
+
add_action( 'um_settings_page_before_email__content', array( $this, 'settings_before_email_tab' ) );
|
57 |
+
add_filter( 'um_settings_section_email__content', array( $this, 'settings_email_tab' ), 10, 1 );
|
58 |
+
|
59 |
+
//enqueue wp_media for profiles tab
|
60 |
+
add_action( 'um_settings_page_appearance__before_section', array( $this, 'settings_appearance_profile_tab' ) );
|
61 |
+
|
62 |
+
//custom content for licenses tab
|
63 |
+
add_filter( 'um_settings_section_licenses__content', array( $this, 'settings_licenses_tab' ), 10, 2 );
|
64 |
+
|
65 |
+
add_filter( 'um_settings_section_install_info__content', array( $this, 'settings_install_info_tab' ), 10, 2 );
|
66 |
+
|
67 |
+
|
68 |
+
add_filter( 'um_settings_structure', array( $this, 'sorting_licenses_options' ), 9999, 1 );
|
69 |
+
|
70 |
+
|
71 |
+
//save handlers
|
72 |
+
add_action( 'admin_init', array( $this, 'save_settings_handler' ), 10 );
|
73 |
+
|
74 |
+
//save pages options
|
75 |
+
add_action( 'um_settings_before_save', array( $this, 'check_permalinks_changes' ) );
|
76 |
+
add_action( 'um_settings_save', array( $this, 'on_settings_save' ) );
|
77 |
+
|
78 |
+
|
79 |
+
add_filter( 'um_change_settings_before_save', array( $this, 'save_email_templates' ) );
|
80 |
+
|
81 |
+
|
82 |
+
//save licenses options
|
83 |
+
add_action( 'um_settings_before_save', array( $this, 'before_licenses_save' ) );
|
84 |
+
add_action( 'um_settings_save', array( $this, 'licenses_save' ) );
|
85 |
+
|
86 |
+
add_filter( 'um_change_settings_before_save', array( $this, 'set_default_if_empty' ), 9, 1 );
|
87 |
+
add_filter( 'um_change_settings_before_save', array( $this, 'remove_empty_values' ), 10, 1 );
|
88 |
+
|
89 |
+
add_action( 'admin_init', array( &$this, 'um_download_install_info' ) );
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
public function same_page_update_ajax() {
|
95 |
+
UM()->admin()->check_ajax_nonce();
|
96 |
+
|
97 |
+
if ( empty( $_POST['cb_func'] ) ) {
|
98 |
+
wp_send_json_error( __( 'Wrong callback', 'ultimate-member' ) );
|
99 |
+
}
|
100 |
+
|
101 |
+
$cb_func = sanitize_key( $_POST['cb_func'] );
|
102 |
+
|
103 |
+
if ( 'um_usermeta_fields' === $cb_func ) {
|
104 |
+
//first install metatable
|
105 |
+
global $wpdb;
|
106 |
+
|
107 |
+
$metakeys = array();
|
108 |
+
foreach ( UM()->builtin()->all_user_fields as $all_user_field ) {
|
109 |
+
$metakeys[] = $all_user_field['metakey'];
|
110 |
+
}
|
111 |
+
|
112 |
+
$metakeys = apply_filters( 'um_metadata_same_page_update_ajax', $metakeys, UM()->builtin()->all_user_fields );
|
113 |
+
|
114 |
+
if ( is_multisite() ) {
|
115 |
+
|
116 |
+
$sites = get_sites( array( 'fields' => 'ids' ) );
|
117 |
+
foreach ( $sites as $blog_id ) {
|
118 |
+
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
119 |
+
}
|
120 |
+
} else {
|
121 |
+
$blog_id = get_current_blog_id();
|
122 |
+
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
123 |
+
}
|
124 |
+
|
125 |
+
//member directory data
|
126 |
+
$metakeys[] = 'um_member_directory_data';
|
127 |
+
$metakeys[] = '_um_verified';
|
128 |
+
$metakeys[] = '_money_spent';
|
129 |
+
$metakeys[] = '_completed';
|
130 |
+
$metakeys[] = '_reviews_avg';
|
131 |
+
|
132 |
+
//myCred meta
|
133 |
+
if ( function_exists( 'mycred_get_types' ) ) {
|
134 |
+
$mycred_types = mycred_get_types();
|
135 |
+
if ( ! empty( $mycred_types ) ) {
|
136 |
+
foreach ( array_keys( $mycred_types ) as $point_type ) {
|
137 |
+
$metakeys[] = $point_type;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
$sortby_custom_keys = $wpdb->get_col( "SELECT DISTINCT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sortby_custom'" );
|
143 |
+
if ( empty( $sortby_custom_keys ) ) {
|
144 |
+
$sortby_custom_keys = array();
|
145 |
+
}
|
146 |
+
|
147 |
+
$sortby_custom_keys2 = $wpdb->get_col( "SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sorting_fields'" );
|
148 |
+
if ( ! empty( $sortby_custom_keys2 ) ) {
|
149 |
+
foreach ( $sortby_custom_keys2 as $custom_val ) {
|
150 |
+
$custom_val = maybe_unserialize( $custom_val );
|
151 |
+
|
152 |
+
foreach ( $custom_val as $sort_value ) {
|
153 |
+
if ( is_array( $sort_value ) ) {
|
154 |
+
$field_keys = array_keys( $sort_value );
|
155 |
+
$sortby_custom_keys[] = $field_keys[0];
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
if ( ! empty( $sortby_custom_keys ) ) {
|
162 |
+
$sortby_custom_keys = array_unique( $sortby_custom_keys );
|
163 |
+
$metakeys = array_merge( $metakeys, $sortby_custom_keys );
|
164 |
+
}
|
165 |
+
|
166 |
+
$skip_fields = UM()->builtin()->get_fields_without_metakey();
|
167 |
+
$skip_fields = array_merge( $skip_fields, UM()->member_directory()->core_search_fields );
|
168 |
+
|
169 |
+
$real_usermeta = $wpdb->get_col( "SELECT DISTINCT meta_key FROM {$wpdb->usermeta}" );
|
170 |
+
$real_usermeta = ! empty( $real_usermeta ) ? $real_usermeta : array();
|
171 |
+
$real_usermeta = array_merge( $real_usermeta, array( 'um_member_directory_data' ) );
|
172 |
+
|
173 |
+
if ( ! empty( $sortby_custom_keys ) ) {
|
174 |
+
$real_usermeta = array_merge( $real_usermeta, $sortby_custom_keys );
|
175 |
+
}
|
176 |
+
|
177 |
+
$wp_usermeta_option = array_intersect( array_diff( $metakeys, $skip_fields ), $real_usermeta );
|
178 |
+
|
179 |
+
update_option( 'um_usermeta_fields', array_values( $wp_usermeta_option ) );
|
180 |
+
|
181 |
+
update_option( 'um_member_directory_update_meta', time() );
|
182 |
+
|
183 |
+
UM()->options()->update( 'member_directory_own_table', true );
|
184 |
+
|
185 |
+
wp_send_json_success();
|
186 |
+
} elseif ( 'um_get_metadata' === $cb_func ) {
|
187 |
+
global $wpdb;
|
188 |
+
|
189 |
+
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
190 |
+
|
191 |
+
$count = $wpdb->get_var(
|
192 |
+
"SELECT COUNT(*)
|
193 |
+
FROM {$wpdb->usermeta}
|
194 |
+
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')"
|
195 |
+
);
|
196 |
+
|
197 |
+
wp_send_json_success( array( 'count' => $count ) );
|
198 |
+
} elseif ( 'um_update_metadata_per_page' === $cb_func ) {
|
199 |
+
|
200 |
+
if ( empty( $_POST['page'] ) ) {
|
201 |
+
wp_send_json_error( __( 'Wrong data', 'ultimate-member' ) );
|
202 |
+
}
|
203 |
+
|
204 |
+
$per_page = 500;
|
205 |
+
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
206 |
+
|
207 |
+
global $wpdb;
|
208 |
+
$metadata = $wpdb->get_results(
|
209 |
+
$wpdb->prepare(
|
210 |
+
"SELECT *
|
211 |
+
FROM {$wpdb->usermeta}
|
212 |
+
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')
|
213 |
+
LIMIT %d, %d",
|
214 |
+
( absint( $_POST['page'] ) - 1 ) * $per_page,
|
215 |
+
$per_page
|
216 |
+
),
|
217 |
+
ARRAY_A
|
218 |
+
);
|
219 |
+
|
220 |
+
$values = array();
|
221 |
+
foreach ( $metadata as $metarow ) {
|
222 |
+
$values[] = $wpdb->prepare( '(%d, %s, %s)', $metarow['user_id'], $metarow['meta_key'], $metarow['meta_value'] );
|
223 |
+
}
|
224 |
+
|
225 |
+
if ( ! empty( $values ) ) {
|
226 |
+
$wpdb->query(
|
227 |
+
"INSERT INTO
|
228 |
+
{$wpdb->prefix}um_metadata(user_id, um_key, um_value)
|
229 |
+
VALUES " . implode( ',', $values )
|
230 |
+
);
|
231 |
+
}
|
232 |
+
|
233 |
+
$from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1;
|
234 |
+
$to = absint( $_POST['page'] ) * $per_page;
|
235 |
+
|
236 |
+
wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %1$s to %2$s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
|
241 |
+
/**
|
242 |
+
*
|
243 |
+
*/
|
244 |
+
public function init_variables() {
|
245 |
+
|
246 |
+
$settings_map = array();
|
247 |
+
|
248 |
+
$general_pages_fields = array(
|
249 |
+
array(
|
250 |
+
'id' => 'pages_settings',
|
251 |
+
'type' => 'hidden',
|
252 |
+
'value' => true,
|
253 |
+
'is_option' => false,
|
254 |
+
),
|
255 |
+
);
|
256 |
+
|
257 |
+
$core_pages = UM()->config()->core_pages;
|
258 |
+
|
259 |
+
foreach ( $core_pages as $page_s => $page ) {
|
260 |
+
$have_pages = UM()->query()->wp_pages();
|
261 |
+
$page_id = UM()->options()->get_core_page_id( $page_s );
|
262 |
+
|
263 |
+
$page_title = ! empty( $page['title'] ) ? $page['title'] : '';
|
264 |
+
|
265 |
+
if ( 'reached_maximum_limit' === $have_pages ) {
|
266 |
+
$general_pages_fields[] = array(
|
267 |
+
'id' => $page_id,
|
268 |
+
'type' => 'text',
|
269 |
+
// translators: %s: Page title
|
270 |
+
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
271 |
+
'placeholder' => __( 'Add page ID', 'ultimate-member' ),
|
272 |
+
'compiler' => true,
|
273 |
+
'size' => 'small',
|
274 |
+
);
|
275 |
+
} else {
|
276 |
+
$general_pages_fields[] = array(
|
277 |
+
'id' => $page_id,
|
278 |
+
'type' => 'select',
|
279 |
+
// translators: %s: Page title
|
280 |
+
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
281 |
+
'options' => UM()->query()->wp_pages(),
|
282 |
+
'placeholder' => __( 'Choose a page...', 'ultimate-member' ),
|
283 |
+
'compiler' => true,
|
284 |
+
'size' => 'small',
|
285 |
+
);
|
286 |
+
}
|
287 |
+
|
288 |
+
|
289 |
+
$settings_map[ $page_id ] = array(
|
290 |
+
'sanitize' => 'absint',
|
291 |
+
);
|
292 |
+
}
|
293 |
+
|
294 |
+
$appearances_profile_menu_fields = array(
|
295 |
+
array(
|
296 |
+
'id' => 'profile_menu',
|
297 |
+
'type' => 'checkbox',
|
298 |
+
'label' => __( 'Enable profile menu', 'ultimate-member' ),
|
299 |
+
),
|
300 |
+
);
|
301 |
+
|
302 |
+
$settings_map['profile_menu'] = array(
|
303 |
+
'sanitize' => 'bool',
|
304 |
+
);
|
305 |
+
|
306 |
+
$tabs = UM()->profile()->tabs();
|
307 |
+
|
308 |
+
$tabs_options = array();
|
309 |
+
$tabs_condition = array();
|
310 |
+
foreach ( $tabs as $id => $tab ) {
|
311 |
+
|
312 |
+
if ( ! empty( $tab['hidden'] ) ) {
|
313 |
+
continue;
|
314 |
+
}
|
315 |
+
|
316 |
+
if ( isset( $tab['name'] ) ) {
|
317 |
+
$tabs_options[ $id ] = $tab['name'];
|
318 |
+
$tabs_condition[] = 'profile_tab_' . $id;
|
319 |
+
}
|
320 |
+
|
321 |
+
if ( isset( $tab['default_privacy'] ) ) {
|
322 |
+
$fields = array(
|
323 |
+
array(
|
324 |
+
'id' => 'profile_tab_' . $id,
|
325 |
+
'type' => 'checkbox',
|
326 |
+
// translators: %s: Tab title
|
327 |
+
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
328 |
+
'conditional' => array( 'profile_menu', '=', 1 ),
|
329 |
+
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
330 |
+
),
|
331 |
+
);
|
332 |
+
|
333 |
+
$settings_map[ 'profile_tab_' . $id ] = array(
|
334 |
+
'sanitize' => 'bool',
|
335 |
+
);
|
336 |
+
} else {
|
337 |
+
|
338 |
+
$fields = array(
|
339 |
+
array(
|
340 |
+
'id' => 'profile_tab_' . $id,
|
341 |
+
'type' => 'checkbox',
|
342 |
+
// translators: %s: Tab title
|
343 |
+
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
344 |
+
'conditional' => array( 'profile_menu', '=', 1 ),
|
345 |
+
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
346 |
+
),
|
347 |
+
array(
|
348 |
+
'id' => 'profile_tab_' . $id . '_privacy',
|
349 |
+
'type' => 'select',
|
350 |
+
// translators: %s: Tab title
|
351 |
+
'label' => sprintf( __( 'Who can see %s Tab?', 'ultimate-member' ), $tab['name'] ),
|
352 |
+
'tooltip' => __( 'Select which users can view this tab.', 'ultimate-member' ),
|
353 |
+
'options' => UM()->profile()->tabs_privacy(),
|
354 |
+
'conditional' => array( 'profile_tab_' . $id, '=', 1 ),
|
355 |
+
'size' => 'small',
|
356 |
+
),
|
357 |
+
array(
|
358 |
+
'id' => 'profile_tab_' . $id . '_roles',
|
359 |
+
'type' => 'select',
|
360 |
+
'multi' => true,
|
361 |
+
'label' => __( 'Allowed roles', 'ultimate-member' ),
|
362 |
+
'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ),
|
363 |
+
'options' => UM()->roles()->get_roles(),
|
364 |
+
'placeholder' => __( 'Choose user roles...', 'ultimate-member' ),
|
365 |
+
'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', array( '4', '5' ) ),
|
366 |
+
'size' => 'small',
|
367 |
+
),
|
368 |
+
);
|
369 |
+
|
370 |
+
$settings_map = array_merge(
|
371 |
+
$settings_map,
|
372 |
+
array(
|
373 |
+
"profile_tab_{$id}" => array(
|
374 |
+
'sanitize' => 'bool',
|
375 |
+
),
|
376 |
+
"profile_tab_{$id}_privacy" => array(
|
377 |
+
'sanitize' => array( UM()->admin(), 'sanitize_tabs_privacy' ),
|
378 |
+
),
|
379 |
+
"profile_tab_{$id}_roles" => array(
|
380 |
+
'sanitize' => array( UM()->admin(), 'sanitize_existed_role' ),
|
381 |
+
),
|
382 |
+
)
|
383 |
+
);
|
384 |
+
}
|
385 |
+
|
386 |
+
$appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, $fields );
|
387 |
+
}
|
388 |
+
|
389 |
+
$appearances_profile_menu_fields[] = array(
|
390 |
+
'id' => 'profile_menu_default_tab',
|
391 |
+
'type' => 'select',
|
392 |
+
'label' => __( 'Profile menu default tab', 'ultimate-member' ),
|
393 |
+
'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ),
|
394 |
+
'options' => $tabs_options,
|
395 |
+
'conditional' => array( implode( '|', $tabs_condition ), '~', 1 ),
|
396 |
+
'size' => 'small',
|
397 |
+
);
|
398 |
+
|
399 |
+
$settings_map['profile_menu_default_tab'] = array(
|
400 |
+
'sanitize' => 'key',
|
401 |
+
);
|
402 |
+
|
403 |
+
$appearances_profile_menu_fields = array_merge(
|
404 |
+
$appearances_profile_menu_fields,
|
405 |
+
array(
|
406 |
+
array(
|
407 |
+
'id' => 'profile_menu_icons',
|
408 |
+
'type' => 'checkbox',
|
409 |
+
'label' => __( 'Enable menu icons in desktop view', 'ultimate-member' ),
|
410 |
+
'conditional' => array( 'profile_menu', '=', 1 ),
|
411 |
+
),
|
412 |
+
)
|
413 |
+
);
|
414 |
+
|
415 |
+
$settings_map['profile_menu_icons'] = array(
|
416 |
+
'sanitize' => 'bool',
|
417 |
+
);
|
418 |
+
|
419 |
+
$post_types_options = array();
|
420 |
+
$all_post_types = get_post_types( array( 'public' => true ), 'objects' );
|
421 |
+
foreach ( $all_post_types as $key => $post_type_data ) {
|
422 |
+
$post_types_options[ $key ] = $post_type_data->labels->singular_name;
|
423 |
+
}
|
424 |
+
|
425 |
+
$duplicates = array();
|
426 |
+
$taxonomies_options = array();
|
427 |
+
$exclude_taxonomies = UM()->excluded_taxonomies();
|
428 |
+
$all_taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
|
429 |
+
foreach ( $all_taxonomies as $key => $taxonomy ) {
|
430 |
+
if ( in_array( $key, $exclude_taxonomies, true ) ) {
|
431 |
+
continue;
|
432 |
+
}
|
433 |
+
|
434 |
+
if ( ! in_array( $taxonomy->labels->singular_name, $duplicates, true ) ) {
|
435 |
+
$duplicates[] = $taxonomy->labels->singular_name;
|
436 |
+
$label = $taxonomy->labels->singular_name;
|
437 |
+
} else {
|
438 |
+
$label = $taxonomy->labels->singular_name . ' (' . $key . ')';
|
439 |
+
}
|
440 |
+
|
441 |
+
$taxonomies_options[ $key ] = $label;
|
442 |
+
}
|
443 |
+
|
444 |
+
$restricted_access_post_metabox_value = array();
|
445 |
+
$restricted_access_post_metabox = UM()->options()->get( 'restricted_access_post_metabox' );
|
446 |
+
if ( ! empty( $restricted_access_post_metabox ) && is_array( $restricted_access_post_metabox ) ) {
|
447 |
+
foreach ( $restricted_access_post_metabox as $key => $value ) {
|
448 |
+
if ( $value ) {
|
449 |
+
$restricted_access_post_metabox_value[] = $key;
|
450 |
+
}
|
451 |
+
}
|
452 |
+
}
|
453 |
+
|
454 |
+
|
455 |
+
$restricted_access_taxonomy_metabox_value = array();
|
456 |
+
$restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
457 |
+
if ( ! empty( $restricted_access_taxonomy_metabox ) && is_array( $restricted_access_taxonomy_metabox ) ) {
|
458 |
+
foreach ( $restricted_access_taxonomy_metabox as $key => $value ) {
|
459 |
+
if ( $value ) {
|
460 |
+
$restricted_access_taxonomy_metabox_value[] = $key;
|
461 |
+
}
|
462 |
+
}
|
463 |
+
}
|
464 |
+
|
465 |
+
$access_fields = array(
|
466 |
+
array(
|
467 |
+
'id' => 'accessible',
|
468 |
+
'type' => 'select',
|
469 |
+
'label' => __( 'Global Site Access', 'ultimate-member' ),
|
470 |
+
'tooltip' => __( 'Globally control the access of your site, you can have separate restrict options per post/page by editing the desired item.', 'ultimate-member' ),
|
471 |
+
'options' => array(
|
472 |
+
0 => __( 'Site accessible to Everyone', 'ultimate-member' ),
|
473 |
+
2 => __( 'Site accessible to Logged In Users', 'ultimate-member' ),
|
474 |
+
),
|
475 |
+
'size' => 'medium',
|
476 |
+
),
|
477 |
+
array(
|
478 |
+
'id' => 'access_redirect',
|
479 |
+
'type' => 'text',
|
480 |
+
'label' => __( 'Custom Redirect URL', 'ultimate-member' ),
|
481 |
+
'tooltip' => __( 'A logged out user will be redirected to this url If he is not permitted to access the site', 'ultimate-member' ),
|
482 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
483 |
+
),
|
484 |
+
array(
|
485 |
+
'id' => 'access_exclude_uris',
|
486 |
+
'type' => 'multi_text',
|
487 |
+
'label' => __( 'Exclude the following URLs', 'ultimate-member' ),
|
488 |
+
'tooltip' => __( 'Here you can exclude URLs beside the redirect URI to be accessible to everyone', 'ultimate-member' ),
|
489 |
+
'add_text' => __( 'Add New URL', 'ultimate-member' ),
|
490 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
491 |
+
'show_default_number' => 0,
|
492 |
+
),
|
493 |
+
array(
|
494 |
+
'id' => 'home_page_accessible',
|
495 |
+
'type' => 'checkbox',
|
496 |
+
'label' => __( 'Allow Homepage to be accessible', 'ultimate-member' ),
|
497 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
498 |
+
),
|
499 |
+
array(
|
500 |
+
'id' => 'category_page_accessible',
|
501 |
+
'type' => 'checkbox',
|
502 |
+
'label' => __( 'Allow Category pages to be accessible', 'ultimate-member' ),
|
503 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
504 |
+
),
|
505 |
+
array(
|
506 |
+
'id' => 'restricted_post_title_replace',
|
507 |
+
'type' => 'checkbox',
|
508 |
+
'label' => __( 'Replace the restricted Post Title', 'ultimate-member' ),
|
509 |
+
'tooltip' => __( 'Allow to replace the restricted post title to users that do not have permission to view the content', 'ultimate-member' ),
|
510 |
+
),
|
511 |
+
array(
|
512 |
+
'id' => 'restricted_access_post_title',
|
513 |
+
'type' => 'text',
|
514 |
+
'label' => __( 'Restricted Access Post Title', 'ultimate-member' ),
|
515 |
+
'tooltip' => __( 'This is the post title shown to users that do not have permission to view the content', 'ultimate-member' ),
|
516 |
+
'conditional' => array( 'restricted_post_title_replace', '=', 1 ),
|
517 |
+
),
|
518 |
+
array(
|
519 |
+
'id' => 'restricted_access_message',
|
520 |
+
'type' => 'wp_editor',
|
521 |
+
'label' => __( 'Restricted Access Message', 'ultimate-member' ),
|
522 |
+
'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ),
|
523 |
+
),
|
524 |
+
);
|
525 |
+
|
526 |
+
$settings_map = array_merge(
|
527 |
+
$settings_map,
|
528 |
+
array(
|
529 |
+
'accessible' => array(
|
530 |
+
'sanitize' => 'int',
|
531 |
+
),
|
532 |
+
'access_redirect' => array(
|
533 |
+
'sanitize' => 'url',
|
534 |
+
),
|
535 |
+
'access_exclude_uris' => array(
|
536 |
+
'sanitize' => 'url',
|
537 |
+
),
|
538 |
+
'home_page_accessible' => array(
|
539 |
+
'sanitize' => 'bool',
|
540 |
+
),
|
541 |
+
'category_page_accessible' => array(
|
542 |
+
'sanitize' => 'bool',
|
543 |
+
),
|
544 |
+
'restricted_post_title_replace' => array(
|
545 |
+
'sanitize' => 'bool',
|
546 |
+
),
|
547 |
+
'restricted_access_post_title' => array(
|
548 |
+
'sanitize' => 'text',
|
549 |
+
),
|
550 |
+
'restricted_access_message' => array(
|
551 |
+
'sanitize' => 'wp_kses',
|
552 |
+
),
|
553 |
+
)
|
554 |
+
);
|
555 |
+
|
556 |
+
global $wp_version;
|
557 |
+
if ( version_compare( $wp_version, '5.0', '>=' ) ) {
|
558 |
+
$access_fields = array_merge(
|
559 |
+
$access_fields,
|
560 |
+
array(
|
561 |
+
array(
|
562 |
+
'id' => 'restricted_blocks',
|
563 |
+
'type' => 'checkbox',
|
564 |
+
'label' => __( 'Enable the "Content Restriction" settings for the Gutenberg Blocks', 'ultimate-member' ),
|
565 |
+
),
|
566 |
+
array(
|
567 |
+
'id' => 'restricted_block_message',
|
568 |
+
'type' => 'textarea',
|
569 |
+
'label' => __( 'Restricted Access Block Message', 'ultimate-member' ),
|
570 |
+
'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ),
|
571 |
+
'conditional' => array( 'restricted_blocks', '=', 1 ),
|
572 |
+
),
|
573 |
+
)
|
574 |
+
);
|
575 |
+
|
576 |
+
$settings_map['restricted_blocks'] = array(
|
577 |
+
'sanitize' => 'bool',
|
578 |
+
);
|
579 |
+
$settings_map['restricted_block_message'] = array(
|
580 |
+
'sanitize' => 'textarea',
|
581 |
+
);
|
582 |
+
}
|
583 |
+
|
584 |
+
$access_fields = array_merge(
|
585 |
+
$access_fields,
|
586 |
+
array(
|
587 |
+
array(
|
588 |
+
'id' => 'restricted_access_post_metabox',
|
589 |
+
'type' => 'hidden',
|
590 |
+
'value' => '',
|
591 |
+
),
|
592 |
+
array(
|
593 |
+
'id' => 'restricted_access_taxonomy_metabox',
|
594 |
+
'type' => 'hidden',
|
595 |
+
'value' => '',
|
596 |
+
),
|
597 |
+
array(
|
598 |
+
'id' => 'restricted_access_post_metabox',
|
599 |
+
'type' => 'multi_checkbox',
|
600 |
+
'label' => __( 'Enable the "Content Restriction" settings for post types', 'ultimate-member' ),
|
601 |
+
'tooltip' => __( 'Check post types for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
602 |
+
'options' => $post_types_options,
|
603 |
+
'columns' => 3,
|
604 |
+
'value' => $restricted_access_post_metabox_value,
|
605 |
+
'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ),
|
606 |
+
),
|
607 |
+
array(
|
608 |
+
'id' => 'restricted_access_taxonomy_metabox',
|
609 |
+
'type' => 'multi_checkbox',
|
610 |
+
'label' => __( 'Enable the "Content Restriction" settings for taxonomies', 'ultimate-member' ),
|
611 |
+
'tooltip' => __( 'Check taxonomies for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
612 |
+
'options' => $taxonomies_options,
|
613 |
+
'columns' => 3,
|
614 |
+
'value' => $restricted_access_taxonomy_metabox_value,
|
615 |
+
'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ),
|
616 |
+
),
|
617 |
+
)
|
618 |
+
);
|
619 |
+
|
620 |
+
$settings_map = array_merge(
|
621 |
+
$settings_map,
|
622 |
+
array(
|
623 |
+
'restricted_access_post_metabox' => array(
|
624 |
+
'sanitize' => 'key',
|
625 |
+
),
|
626 |
+
'restricted_access_taxonomy_metabox' => array(
|
627 |
+
'sanitize' => 'key',
|
628 |
+
),
|
629 |
+
)
|
630 |
+
);
|
631 |
+
|
632 |
+
$latest_update = get_option( 'um_member_directory_update_meta', false );
|
633 |
+
$latest_truncate = get_option( 'um_member_directory_truncated', false );
|
634 |
+
|
635 |
+
$same_page_update = array(
|
636 |
+
'id' => 'member_directory_own_table',
|
637 |
+
'type' => 'same_page_update',
|
638 |
+
'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ),
|
639 |
+
'tooltip' => __( 'Check this box if you would like to enable the use of a custom table for user metadata. Improved performance for member directory searches.', 'ultimate-member' ),
|
640 |
+
);
|
641 |
+
|
642 |
+
if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) {
|
643 |
+
$same_page_update['upgrade_cb'] = 'sync_metatable';
|
644 |
+
$same_page_update['upgrade_description'] = '<p>' . __( 'We recommend creating a backup of your site before running the update process. Do not exit the page before the update process has complete.', 'ultimate-member' ) . '</p>
|
645 |
+
<p>' . __( 'After clicking the <strong>"Run"</strong> button, the update process will start. All information will be displayed in the field below.', 'ultimate-member' ) . '</p>
|
646 |
+
<p>' . __( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ) . '</p>';
|
647 |
+
}
|
648 |
+
|
649 |
+
$settings_map = array_merge(
|
650 |
+
$settings_map,
|
651 |
+
array(
|
652 |
+
'permalink_base' => array(
|
653 |
+
'sanitize' => 'key',
|
654 |
+
),
|
655 |
+
'display_name' => array(
|
656 |
+
'sanitize' => 'key',
|
657 |
+
),
|
658 |
+
'display_name_field' => array(
|
659 |
+
'sanitize' => 'text',
|
660 |
+
),
|
661 |
+
'author_redirect' => array(
|
662 |
+
'sanitize' => 'bool',
|
663 |
+
),
|
664 |
+
'members_page' => array(
|
665 |
+
'sanitize' => 'bool',
|
666 |
+
),
|
667 |
+
'use_gravatars' => array(
|
668 |
+
'sanitize' => 'bool',
|
669 |
+
),
|
670 |
+
'use_um_gravatar_default_builtin_image' => array(
|
671 |
+
'sanitize' => 'key',
|
672 |
+
),
|
673 |
+
'use_um_gravatar_default_image' => array(
|
674 |
+
'sanitize' => 'bool',
|
675 |
+
),
|
676 |
+
'require_strongpass' => array(
|
677 |
+
'sanitize' => 'bool',
|
678 |
+
),
|
679 |
+
'password_min_chars' => array(
|
680 |
+
'sanitize' => 'absint',
|
681 |
+
),
|
682 |
+
'password_max_chars' => array(
|
683 |
+
'sanitize' => 'absint',
|
684 |
+
),
|
685 |
+
'profile_noindex' => array(
|
686 |
+
'sanitize' => 'bool',
|
687 |
+
),
|
688 |
+
'activation_link_expiry_time' => array(
|
689 |
+
'sanitize' => 'absint',
|
690 |
+
),
|
691 |
+
'account_tab_password' => array(
|
692 |
+
'sanitize' => 'bool',
|
693 |
+
),
|
694 |
+
'account_tab_privacy' => array(
|
695 |
+
'sanitize' => 'bool',
|
696 |
+
),
|
697 |
+
'account_tab_notifications' => array(
|
698 |
+
'sanitize' => 'bool',
|
699 |
+
),
|
700 |
+
'account_tab_delete' => array(
|
701 |
+
'sanitize' => 'bool',
|
702 |
+
),
|
703 |
+
'delete_account_text' => array(
|
704 |
+
'sanitize' => 'textarea',
|
705 |
+
),
|
706 |
+
'delete_account_no_pass_required_text' => array(
|
707 |
+
'sanitize' => 'textarea',
|
708 |
+
),
|
709 |
+
'account_name' => array(
|
710 |
+
'sanitize' => 'bool',
|
711 |
+
),
|
712 |
+
'account_name_disable' => array(
|
713 |
+
'sanitize' => 'bool',
|
714 |
+
),
|
715 |
+
'account_name_require' => array(
|
716 |
+
'sanitize' => 'bool',
|
717 |
+
),
|
718 |
+
'account_email' => array(
|
719 |
+
'sanitize' => 'bool',
|
720 |
+
),
|
721 |
+
'account_general_password' => array(
|
722 |
+
'sanitize' => 'bool',
|
723 |
+
),
|
724 |
+
'account_hide_in_directory' => array(
|
725 |
+
'sanitize' => 'bool',
|
726 |
+
),
|
727 |
+
'account_hide_in_directory_default' => array(
|
728 |
+
'sanitize' => 'text',
|
729 |
+
),
|
730 |
+
'profile_photo_max_size' => array(
|
731 |
+
'sanitize' => 'absint',
|
732 |
+
),
|
733 |
+
'cover_photo_max_size' => array(
|
734 |
+
'sanitize' => 'absint',
|
735 |
+
),
|
736 |
+
'photo_thumb_sizes' => array(
|
737 |
+
'sanitize' => 'absint',
|
738 |
+
),
|
739 |
+
'cover_thumb_sizes' => array(
|
740 |
+
'sanitize' => 'absint',
|
741 |
+
),
|
742 |
+
'image_orientation_by_exif' => array(
|
743 |
+
'sanitize' => 'bool',
|
744 |
+
),
|
745 |
+
'image_compression' => array(
|
746 |
+
'sanitize' => 'absint',
|
747 |
+
),
|
748 |
+
'image_max_width' => array(
|
749 |
+
'sanitize' => 'absint',
|
750 |
+
),
|
751 |
+
'cover_min_width' => array(
|
752 |
+
'sanitize' => 'absint',
|
753 |
+
),
|
754 |
+
'enable_reset_password_limit' => array(
|
755 |
+
'sanitize' => 'bool',
|
756 |
+
),
|
757 |
+
'reset_password_limit_number' => array(
|
758 |
+
'sanitize' => 'absint',
|
759 |
+
),
|
760 |
+
'blocked_emails' => array(
|
761 |
+
'sanitize' => 'textarea',
|
762 |
+
),
|
763 |
+
'blocked_words' => array(
|
764 |
+
'sanitize' => 'textarea',
|
765 |
+
),
|
766 |
+
'admin_email' => array(
|
767 |
+
'sanitize' => 'text',
|
768 |
+
),
|
769 |
+
'mail_from' => array(
|
770 |
+
'sanitize' => 'text',
|
771 |
+
),
|
772 |
+
'mail_from_addr' => array(
|
773 |
+
'sanitize' => 'text',
|
774 |
+
),
|
775 |
+
'email_html' => array(
|
776 |
+
'sanitize' => 'bool',
|
777 |
+
),
|
778 |
+
'profile_template' => array(
|
779 |
+
'sanitize' => 'text',
|
780 |
+
),
|
781 |
+
'profile_max_width' => array(
|
782 |
+
'sanitize' => 'text',
|
783 |
+
),
|
784 |
+
'profile_area_max_width' => array(
|
785 |
+
'sanitize' => 'text',
|
786 |
+
),
|
787 |
+
'profile_icons' => array(
|
788 |
+
'sanitize' => 'key',
|
789 |
+
),
|
790 |
+
'profile_primary_btn_word' => array(
|
791 |
+
'sanitize' => 'text',
|
792 |
+
),
|
793 |
+
'profile_secondary_btn' => array(
|
794 |
+
'sanitize' => 'bool',
|
795 |
+
),
|
796 |
+
'profile_secondary_btn_word' => array(
|
797 |
+
'sanitize' => 'text',
|
798 |
+
),
|
799 |
+
'default_avatar' => array(
|
800 |
+
'sanitize' => 'url',
|
801 |
+
),
|
802 |
+
'default_cover' => array(
|
803 |
+
'sanitize' => 'url',
|
804 |
+
),
|
805 |
+
'disable_profile_photo_upload' => array(
|
806 |
+
'sanitize' => 'bool',
|
807 |
+
),
|
808 |
+
'profile_photosize' => array(
|
809 |
+
'sanitize' => array( UM()->admin(), 'sanitize_photosize' ),
|
810 |
+
),
|
811 |
+
'profile_cover_enabled' => array(
|
812 |
+
'sanitize' => 'bool',
|
813 |
+
),
|
814 |
+
'profile_coversize' => array(
|
815 |
+
'sanitize' => array( UM()->admin(), 'sanitize_cover_photosize' ),
|
816 |
+
),
|
817 |
+
'profile_cover_ratio' => array(
|
818 |
+
'sanitize' => 'text',
|
819 |
+
),
|
820 |
+
'profile_show_metaicon' => array(
|
821 |
+
'sanitize' => 'bool',
|
822 |
+
),
|
823 |
+
'profile_show_name' => array(
|
824 |
+
'sanitize' => 'bool',
|
825 |
+
),
|
826 |
+
'profile_show_social_links' => array(
|
827 |
+
'sanitize' => 'bool',
|
828 |
+
),
|
829 |
+
'profile_show_bio' => array(
|
830 |
+
'sanitize' => 'bool',
|
831 |
+
),
|
832 |
+
'profile_show_html_bio' => array(
|
833 |
+
'sanitize' => 'bool',
|
834 |
+
),
|
835 |
+
'profile_bio_maxchars' => array(
|
836 |
+
'sanitize' => 'absint',
|
837 |
+
),
|
838 |
+
'profile_header_menu' => array(
|
839 |
+
'sanitize' => 'key',
|
840 |
+
),
|
841 |
+
'profile_empty_text' => array(
|
842 |
+
'sanitize' => 'bool',
|
843 |
+
),
|
844 |
+
'profile_empty_text_emo' => array(
|
845 |
+
'sanitize' => 'bool',
|
846 |
+
),
|
847 |
+
'register_template' => array(
|
848 |
+
'sanitize' => 'text',
|
849 |
+
),
|
850 |
+
'register_max_width' => array(
|
851 |
+
'sanitize' => 'text',
|
852 |
+
),
|
853 |
+
'register_align' => array(
|
854 |
+
'sanitize' => 'key',
|
855 |
+
),
|
856 |
+
'register_icons' => array(
|
857 |
+
'sanitize' => 'key',
|
858 |
+
),
|
859 |
+
'register_primary_btn_word' => array(
|
860 |
+
'sanitize' => 'text',
|
861 |
+
),
|
862 |
+
'register_secondary_btn' => array(
|
863 |
+
'sanitize' => 'bool',
|
864 |
+
),
|
865 |
+
'register_secondary_btn_word' => array(
|
866 |
+
'sanitize' => 'text',
|
867 |
+
),
|
868 |
+
'register_secondary_btn_url' => array(
|
869 |
+
'sanitize' => 'url',
|
870 |
+
),
|
871 |
+
'register_role' => array(
|
872 |
+
'sanitize' => 'key',
|
873 |
+
),
|
874 |
+
'login_template' => array(
|
875 |
+
'sanitize' => 'text',
|
876 |
+
),
|
877 |
+
'login_max_width' => array(
|
878 |
+
'sanitize' => 'text',
|
879 |
+
),
|
880 |
+
'login_align' => array(
|
881 |
+
'sanitize' => 'key',
|
882 |
+
),
|
883 |
+
'login_icons' => array(
|
884 |
+
'sanitize' => 'key',
|
885 |
+
),
|
886 |
+
'login_primary_btn_word' => array(
|
887 |
+
'sanitize' => 'text',
|
888 |
+
),
|
889 |
+
'login_secondary_btn' => array(
|
890 |
+
'sanitize' => 'bool',
|
891 |
+
),
|
892 |
+
'login_secondary_btn_word' => array(
|
893 |
+
'sanitize' => 'text',
|
894 |
+
),
|
895 |
+
'login_secondary_btn_url' => array(
|
896 |
+
'sanitize' => 'url',
|
897 |
+
),
|
898 |
+
'login_forgot_pass_link' => array(
|
899 |
+
'sanitize' => 'bool',
|
900 |
+
),
|
901 |
+
'login_show_rememberme' => array(
|
902 |
+
'sanitize' => 'bool',
|
903 |
+
),
|
904 |
+
'form_asterisk' => array(
|
905 |
+
'sanitize' => 'bool',
|
906 |
+
),
|
907 |
+
'profile_title' => array(
|
908 |
+
'sanitize' => 'text',
|
909 |
+
),
|
910 |
+
'profile_desc' => array(
|
911 |
+
'sanitize' => 'textarea',
|
912 |
+
),
|
913 |
+
'um_profile_object_cache_stop' => array(
|
914 |
+
'sanitize' => 'bool',
|
915 |
+
),
|
916 |
+
'enable_blocks' => array(
|
917 |
+
'sanitize' => 'bool',
|
918 |
+
),
|
919 |
+
'rest_api_version' => array(
|
920 |
+
'sanitize' => 'text',
|
921 |
+
),
|
922 |
+
'uninstall_on_delete' => array(
|
923 |
+
'sanitize' => 'bool',
|
924 |
+
),
|
925 |
+
)
|
926 |
+
);
|
927 |
+
|
928 |
+
$this->settings_map = apply_filters( 'um_settings_map', $settings_map );
|
929 |
+
|
930 |
+
/**
|
931 |
+
* UM hook
|
932 |
+
*
|
933 |
+
* @type filter
|
934 |
+
* @title um_settings_structure
|
935 |
+
* @description Extend UM Settings
|
936 |
+
* @input_vars
|
937 |
+
* [{"var":"$settings","type":"array","desc":"UM Settings"}]
|
938 |
+
* @change_log
|
939 |
+
* ["Since: 2.0"]
|
940 |
+
* @usage add_filter( 'um_settings_structure', 'function_name', 10, 1 );
|
941 |
+
* @example
|
942 |
+
* <?php
|
943 |
+
* add_filter( 'um_settings_structure', 'my_settings_structure', 10, 1 );
|
944 |
+
* function my_settings_structure( $settings ) {
|
945 |
+
* // your code here
|
946 |
+
* return $settings;
|
947 |
+
* }
|
948 |
+
* ?>
|
949 |
+
*/
|
950 |
+
$this->settings_structure = apply_filters(
|
951 |
+
'um_settings_structure',
|
952 |
+
array(
|
953 |
+
'' => array(
|
954 |
+
'title' => __( 'General', 'ultimate-member' ),
|
955 |
+
'sections' => array(
|
956 |
+
'' => array(
|
957 |
+
'title' => __( 'Pages', 'ultimate-member' ),
|
958 |
+
'fields' => $general_pages_fields,
|
959 |
+
),
|
960 |
+
'users' => array(
|
961 |
+
'title' => __( 'Users', 'ultimate-member' ),
|
962 |
+
'fields' => array(
|
963 |
+
array(
|
964 |
+
'id' => 'permalink_base',
|
965 |
+
'type' => 'select',
|
966 |
+
'size' => 'small',
|
967 |
+
'label' => __( 'Profile Permalink Base', 'ultimate-member' ),
|
968 |
+
// translators: %s: Profile page URL
|
969 |
+
'tooltip' => sprintf( __( 'Here you can control the permalink structure of the user profile URL globally e.g. %s<strong>username</strong>/', 'ultimate-member' ), trailingslashit( um_get_core_page( 'user' ) ) ),
|
970 |
+
'options' => array(
|
971 |
+
'user_login' => __( 'Username', 'ultimate-member' ),
|
972 |
+
'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ),
|
973 |
+
'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ),
|
974 |
+
'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ),
|
975 |
+
'user_id' => __( 'User ID', 'ultimate-member' ),
|
976 |
+
),
|
977 |
+
'placeholder' => __( 'Select...', 'ultimate-member' ),
|
978 |
+
),
|
979 |
+
array(
|
980 |
+
'id' => 'display_name',
|
981 |
+
'type' => 'select',
|
982 |
+
'size' => 'medium',
|
983 |
+
'label' => __( 'User Display Name', 'ultimate-member' ),
|
984 |
+
'tooltip' => __( 'This is the name that will be displayed for users on the front end of your site. Default setting uses first/last name as display name if it exists', 'ultimate-member' ),
|
985 |
+
'options' => array(
|
986 |
+
'default' => __( 'Default WP Display Name', 'ultimate-member' ),
|
987 |
+
'nickname' => __( 'Nickname', 'ultimate-member' ),
|
988 |
+
'username' => __( 'Username', 'ultimate-member' ),
|
989 |
+
'full_name' => __( 'First name & last name', 'ultimate-member' ),
|
990 |
+
'sur_name' => __( 'Last name & first name', 'ultimate-member' ),
|
991 |
+
'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ),
|
992 |
+
'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ),
|
993 |
+
'first_name' => __( 'First name only', 'ultimate-member' ),
|
994 |
+
'field' => __( 'Custom field(s)', 'ultimate-member' ),
|
995 |
+
),
|
996 |
+
'placeholder' => __( 'Select...', 'ultimate-member' ),
|
997 |
+
),
|
998 |
+
array(
|
999 |
+
'id' => 'display_name_field',
|
1000 |
+
'type' => 'text',
|
1001 |
+
'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ),
|
1002 |
+
'tooltip' => __( 'Specify the custom field meta key or custom fields seperated by comma that you want to use to display users name on the frontend of your site', 'ultimate-member' ),
|
1003 |
+
'conditional' => array( 'display_name', '=', 'field' ),
|
1004 |
+
),
|
1005 |
+
array(
|
1006 |
+
'id' => 'author_redirect',
|
1007 |
+
'type' => 'checkbox',
|
1008 |
+
'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ),
|
1009 |
+
'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ),
|
1010 |
+
),
|
1011 |
+
array(
|
1012 |
+
'id' => 'members_page',
|
1013 |
+
'type' => 'checkbox',
|
1014 |
+
'label' => __( 'Enable Members Directory', 'ultimate-member' ),
|
1015 |
+
'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ),
|
1016 |
+
),
|
1017 |
+
array(
|
1018 |
+
'id' => 'use_gravatars',
|
1019 |
+
'type' => 'checkbox',
|
1020 |
+
'label' => __( 'Use Gravatars?', 'ultimate-member' ),
|
1021 |
+
'tooltip' => __( 'Do you want to use gravatars instead of the default plugin profile photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ),
|
1022 |
+
),
|
1023 |
+
array(
|
1024 |
+
'id' => 'use_um_gravatar_default_builtin_image',
|
1025 |
+
'type' => 'select',
|
1026 |
+
'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ),
|
1027 |
+
'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ),
|
1028 |
+
'options' => array(
|
1029 |
+
'default' => __( 'Default', 'ultimate-member' ),
|
1030 |
+
'404' => __( '404 ( File Not Found response )', 'ultimate-member' ),
|
1031 |
+
'mm' => __( 'Mystery Man', 'ultimate-member' ),
|
1032 |
+
'identicon' => __( 'Identicon', 'ultimate-member' ),
|
1033 |
+
'monsterid' => __( 'Monsterid', 'ultimate-member' ),
|
1034 |
+
'wavatar' => __( 'Wavatar', 'ultimate-member' ),
|
1035 |
+
'retro' => __( 'Retro', 'ultimate-member' ),
|
1036 |
+
'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ),
|
1037 |
+
),
|
1038 |
+
'conditional' => array( 'use_gravatars', '=', 1 ),
|
1039 |
+
'size' => 'medium',
|
1040 |
+
),
|
1041 |
+
array(
|
1042 |
+
'id' => 'use_um_gravatar_default_image',
|
1043 |
+
'type' => 'checkbox',
|
1044 |
+
'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ),
|
1045 |
+
'tooltip' => __( 'Do you want to use the plugin default avatar instead of the gravatar default photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ),
|
1046 |
+
'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ),
|
1047 |
+
),
|
1048 |
+
array(
|
1049 |
+
'id' => 'require_strongpass',
|
1050 |
+
'type' => 'checkbox',
|
1051 |
+
'label' => __( 'Require a strong password?', 'ultimate-member' ),
|
1052 |
+
'tooltip' => __( 'Enable or disable a strong password rules common for all Ultimate Member forms.', 'ultimate-member' ),
|
1053 |
+
),
|
1054 |
+
array(
|
1055 |
+
'id' => 'password_min_chars',
|
1056 |
+
'type' => 'number',
|
1057 |
+
'label' => __( 'Password minimum length', 'ultimate-member' ),
|
1058 |
+
'tooltip' => __( 'If you want to enable a minimum number of characters to be in password. User password field in the UM forms has own settings for that. Leave empty to use default value 8', 'ultimate-member' ),
|
1059 |
+
'size' => 'small',
|
1060 |
+
),
|
1061 |
+
array(
|
1062 |
+
'id' => 'password_max_chars',
|
1063 |
+
'type' => 'number',
|
1064 |
+
'label' => __( 'Password maximum length', 'ultimate-member' ),
|
1065 |
+
'tooltip' => __( 'If you want to enable a maximum number of characters to be in password. User password field in the UM forms has own settings for that. Leave empty to use default value 30', 'ultimate-member' ),
|
1066 |
+
'size' => 'small',
|
1067 |
+
),
|
1068 |
+
array(
|
1069 |
+
'id' => 'profile_noindex',
|
1070 |
+
'type' => 'select',
|
1071 |
+
'size' => 'small',
|
1072 |
+
'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
|
1073 |
+
'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ),
|
1074 |
+
'options' => array(
|
1075 |
+
'0' => __( 'No', 'ultimate-member' ),
|
1076 |
+
'1' => __( 'Yes', 'ultimate-member' ),
|
1077 |
+
),
|
1078 |
+
),
|
1079 |
+
array(
|
1080 |
+
'id' => 'activation_link_expiry_time',
|
1081 |
+
'type' => 'number',
|
1082 |
+
'label' => __( 'Activation link lifetime', 'ultimate-member' ),
|
1083 |
+
'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ),
|
1084 |
+
'size' => 'small',
|
1085 |
+
),
|
1086 |
+
),
|
1087 |
+
),
|
1088 |
+
'account' => array(
|
1089 |
+
'title' => __( 'Account', 'ultimate-member' ),
|
1090 |
+
'fields' => array(
|
1091 |
+
array(
|
1092 |
+
'id' => 'account_tab_password',
|
1093 |
+
'type' => 'checkbox',
|
1094 |
+
'label' => __( 'Password Account Tab', 'ultimate-member' ),
|
1095 |
+
'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ),
|
1096 |
+
),
|
1097 |
+
array(
|
1098 |
+
'id' => 'account_tab_privacy',
|
1099 |
+
'type' => 'checkbox',
|
1100 |
+
'label' => __( 'Privacy Account Tab', 'ultimate-member' ),
|
1101 |
+
'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ),
|
1102 |
+
),
|
1103 |
+
array(
|
1104 |
+
'id' => 'account_tab_notifications',
|
1105 |
+
'type' => 'checkbox',
|
1106 |
+
'label' => __( 'Notifications Account Tab', 'ultimate-member' ),
|
1107 |
+
'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ),
|
1108 |
+
),
|
1109 |
+
array(
|
1110 |
+
'id' => 'account_tab_delete',
|
1111 |
+
'type' => 'checkbox',
|
1112 |
+
'label' => __( 'Delete Account Tab', 'ultimate-member' ),
|
1113 |
+
'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ),
|
1114 |
+
),
|
1115 |
+
array(
|
1116 |
+
'id' => 'delete_account_text',
|
1117 |
+
'type' => 'textarea', // bug with wp 4.4? should be editor
|
1118 |
+
'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ),
|
1119 |
+
'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password is required.', 'ultimate-member' ),
|
1120 |
+
'args' => array(
|
1121 |
+
'textarea_rows' => 6,
|
1122 |
+
),
|
1123 |
+
),
|
1124 |
+
array(
|
1125 |
+
'id' => 'delete_account_no_pass_required_text',
|
1126 |
+
'type' => 'textarea',
|
1127 |
+
'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ),
|
1128 |
+
'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password isn\'t required.', 'ultimate-member' ),
|
1129 |
+
'args' => array(
|
1130 |
+
'textarea_rows' => 6,
|
1131 |
+
),
|
1132 |
+
),
|
1133 |
+
array(
|
1134 |
+
'id' => 'account_name',
|
1135 |
+
'type' => 'checkbox',
|
1136 |
+
'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ),
|
1137 |
+
'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ),
|
1138 |
+
),
|
1139 |
+
array(
|
1140 |
+
'id' => 'account_name_disable',
|
1141 |
+
'type' => 'checkbox',
|
1142 |
+
'label' => __( 'Disable First & Last Name fields', 'ultimate-member' ),
|
1143 |
+
'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ),
|
1144 |
+
'conditional' => array( 'account_name', '=', '1' ),
|
1145 |
+
),
|
1146 |
+
array(
|
1147 |
+
'id' => 'account_name_require',
|
1148 |
+
'type' => 'checkbox',
|
1149 |
+
'label' => __( 'Require First & Last Name', 'ultimate-member' ),
|
1150 |
+
'tooltip' => __( 'Require first and last name?', 'ultimate-member' ),
|
1151 |
+
'conditional' => array( 'account_name', '=', '1' ),
|
1152 |
+
),
|
1153 |
+
array(
|
1154 |
+
'id' => 'account_email',
|
1155 |
+
'type' => 'checkbox',
|
1156 |
+
'label' => __( 'Allow users to change e-mail', 'ultimate-member' ),
|
1157 |
+
'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ),
|
1158 |
+
),
|
1159 |
+
array(
|
1160 |
+
'id' => 'account_general_password',
|
1161 |
+
'type' => 'checkbox',
|
1162 |
+
'label' => __( 'Password is required?', 'ultimate-member' ),
|
1163 |
+
'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ),
|
1164 |
+
),
|
1165 |
+
array(
|
1166 |
+
'id' => 'account_hide_in_directory',
|
1167 |
+
'type' => 'checkbox',
|
1168 |
+
'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ),
|
1169 |
+
'tooltip' => __( 'Whether to allow users changing their profile visibility from member directory in account page.', 'ultimate-member' ),
|
1170 |
+
'conditional' => array( 'account_tab_privacy', '=', '1' ),
|
1171 |
+
),
|
1172 |
+
array(
|
1173 |
+
'id' => 'account_hide_in_directory_default',
|
1174 |
+
'type' => 'select',
|
1175 |
+
'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ),
|
1176 |
+
'tooltip' => __( 'Set default value for the "Hide my profile from directory" option', 'ultimate-member' ),
|
1177 |
+
'options' => array(
|
1178 |
+
'No' => __( 'No', 'ultimate-member' ),
|
1179 |
+
'Yes' => __( 'Yes', 'ultimate-member' ),
|
1180 |
+
),
|
1181 |
+
'size' => 'small',
|
1182 |
+
'conditional' => array( 'account_hide_in_directory', '=', '1' ),
|
1183 |
+
),
|
1184 |
+
),
|
1185 |
+
),
|
1186 |
+
'uploads' => array(
|
1187 |
+
'title' => __( 'Uploads', 'ultimate-member' ),
|
1188 |
+
'fields' => array(
|
1189 |
+
array(
|
1190 |
+
'id' => 'profile_photo_max_size',
|
1191 |
+
'type' => 'text',
|
1192 |
+
'size' => 'small',
|
1193 |
+
'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ),
|
1194 |
+
'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ),
|
1195 |
+
),
|
1196 |
+
array(
|
1197 |
+
'id' => 'cover_photo_max_size',
|
1198 |
+
'type' => 'text',
|
1199 |
+
'size' => 'small',
|
1200 |
+
'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ),
|
1201 |
+
'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ),
|
1202 |
+
),
|
1203 |
+
array(
|
1204 |
+
'id' => 'photo_thumb_sizes',
|
1205 |
+
'type' => 'multi_text',
|
1206 |
+
'size' => 'small',
|
1207 |
+
'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ),
|
1208 |
+
'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ),
|
1209 |
+
'validate' => 'numeric',
|
1210 |
+
'add_text' => __( 'Add New Size', 'ultimate-member' ),
|
1211 |
+
'show_default_number' => 1,
|
1212 |
+
),
|
1213 |
+
array(
|
1214 |
+
'id' => 'cover_thumb_sizes',
|
1215 |
+
'type' => 'multi_text',
|
1216 |
+
'size' => 'small',
|
1217 |
+
'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ),
|
1218 |
+
'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ),
|
1219 |
+
'validate' => 'numeric',
|
1220 |
+
'add_text' => __( 'Add New Size', 'ultimate-member' ),
|
1221 |
+
'show_default_number' => 1,
|
1222 |
+
),
|
1223 |
+
array(
|
1224 |
+
'id' => 'image_orientation_by_exif',
|
1225 |
+
'type' => 'checkbox',
|
1226 |
+
'label' => __( 'Change image orientation', 'ultimate-member' ),
|
1227 |
+
'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ),
|
1228 |
+
),
|
1229 |
+
array(
|
1230 |
+
'id' => 'image_compression',
|
1231 |
+
'type' => 'text',
|
1232 |
+
'size' => 'small',
|
1233 |
+
'label' => __( 'Image Quality', 'ultimate-member' ),
|
1234 |
+
'tooltip' => __( 'Quality is used to determine quality of image uploads, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default range is 60.', 'ultimate-member' ),
|
1235 |
+
),
|
1236 |
+
|
1237 |
+
array(
|
1238 |
+
'id' => 'image_max_width',
|
1239 |
+
'type' => 'text',
|
1240 |
+
'size' => 'small',
|
1241 |
+
'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ),
|
1242 |
+
'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ),
|
1243 |
+
),
|
1244 |
+
|
1245 |
+
array(
|
1246 |
+
'id' => 'cover_min_width',
|
1247 |
+
'type' => 'text',
|
1248 |
+
'size' => 'small',
|
1249 |
+
'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ),
|
1250 |
+
'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ),
|
1251 |
+
),
|
1252 |
+
),
|
1253 |
+
),
|
1254 |
+
),
|
1255 |
+
),
|
1256 |
+
'access' => array(
|
1257 |
+
'title' => __( 'Access', 'ultimate-member' ),
|
1258 |
+
'sections' => array(
|
1259 |
+
'' => array(
|
1260 |
+
'title' => __( 'Restriction Content', 'ultimate-member' ),
|
1261 |
+
'fields' => $access_fields,
|
1262 |
+
),
|
1263 |
+
'other' => array(
|
1264 |
+
'title' => __( 'Other', 'ultimate-member' ),
|
1265 |
+
'fields' => array(
|
1266 |
+
array(
|
1267 |
+
'id' => 'enable_reset_password_limit',
|
1268 |
+
'type' => 'checkbox',
|
1269 |
+
'label' => __( 'Enable the Reset Password Limit?', 'ultimate-member' ),
|
1270 |
+
),
|
1271 |
+
array(
|
1272 |
+
'id' => 'reset_password_limit_number',
|
1273 |
+
'type' => 'text',
|
1274 |
+
'label' => __( 'Reset Password Limit', 'ultimate-member' ),
|
1275 |
+
'tooltip' => __( 'Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.', 'ultimate-member' ),
|
1276 |
+
'validate' => 'numeric',
|
1277 |
+
'conditional' => array( 'enable_reset_password_limit', '=', 1 ),
|
1278 |
+
'size' => 'small',
|
1279 |
+
),
|
1280 |
+
array(
|
1281 |
+
'id' => 'blocked_emails',
|
1282 |
+
'type' => 'textarea',
|
1283 |
+
'label' => __( 'Blocked Email Addresses', 'ultimate-member' ),
|
1284 |
+
'tooltip' => __( 'This will block the specified e-mail addresses from being able to sign up or sign in to your site. To block an entire domain, use something like *@domain.com', 'ultimate-member' ),
|
1285 |
+
),
|
1286 |
+
array(
|
1287 |
+
'id' => 'blocked_words',
|
1288 |
+
'type' => 'textarea',
|
1289 |
+
'label' => __( 'Blacklist Words', 'ultimate-member' ),
|
1290 |
+
'tooltip' => __( 'This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username', 'ultimate-member' ),
|
1291 |
+
),
|
1292 |
+
),
|
1293 |
+
),
|
1294 |
+
),
|
1295 |
+
),
|
1296 |
+
'email' => array(
|
1297 |
+
'title' => __( 'Email', 'ultimate-member' ),
|
1298 |
+
'fields' => array(
|
1299 |
+
array(
|
1300 |
+
'id' => 'admin_email',
|
1301 |
+
'type' => 'text',
|
1302 |
+
'label' => __( 'Admin E-mail Address', 'ultimate-member' ),
|
1303 |
+
'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
|
1304 |
+
),
|
1305 |
+
array(
|
1306 |
+
'id' => 'mail_from',
|
1307 |
+
'type' => 'text',
|
1308 |
+
'label' => __( 'Mail appears from', 'ultimate-member' ),
|
1309 |
+
'tooltip' => __( 'e.g. Site Name', 'ultimate-member' ),
|
1310 |
+
),
|
1311 |
+
array(
|
1312 |
+
'id' => 'mail_from_addr',
|
1313 |
+
'type' => 'text',
|
1314 |
+
'label' => __( 'Mail appears from address', 'ultimate-member' ),
|
1315 |
+
'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
|
1316 |
+
),
|
1317 |
+
array(
|
1318 |
+
'id' => 'email_html',
|
1319 |
+
'type' => 'checkbox',
|
1320 |
+
'label' => __( 'Use HTML for E-mails?', 'ultimate-member' ),
|
1321 |
+
'tooltip' => __( 'If you plan use e-mails with HTML, please make sure that this option is enabled. Otherwise, HTML will be displayed as plain text.', 'ultimate-member' ),
|
1322 |
+
),
|
1323 |
+
),
|
1324 |
+
),
|
1325 |
+
'appearance' => array(
|
1326 |
+
'title' => __( 'Appearance', 'ultimate-member' ),
|
1327 |
+
'sections' => array(
|
1328 |
+
'' => array(
|
1329 |
+
'title' => __( 'Profile', 'ultimate-member' ),
|
1330 |
+
'fields' => array(
|
1331 |
+
array(
|
1332 |
+
'id' => 'profile_template',
|
1333 |
+
'type' => 'select',
|
1334 |
+
'label' => __( 'Profile Default Template', 'ultimate-member' ),
|
1335 |
+
'tooltip' => __( 'This will be the default template to output profile', 'ultimate-member' ),
|
1336 |
+
'default' => um_get_metadefault( 'profile_template' ),
|
1337 |
+
'options' => UM()->shortcodes()->get_templates( 'profile' ),
|
1338 |
+
'size' => 'small',
|
1339 |
+
),
|
1340 |
+
array(
|
1341 |
+
'id' => 'profile_max_width',
|
1342 |
+
'type' => 'text',
|
1343 |
+
'label' => __( 'Profile Maximum Width', 'ultimate-member' ),
|
1344 |
+
'default' => um_get_metadefault( 'profile_max_width' ),
|
1345 |
+
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1346 |
+
'size' => 'small',
|
1347 |
+
),
|
1348 |
+
array(
|
1349 |
+
'id' => 'profile_area_max_width',
|
1350 |
+
'type' => 'text',
|
1351 |
+
'label' => __( 'Profile Area Maximum Width', 'ultimate-member' ),
|
1352 |
+
'default' => um_get_metadefault( 'profile_area_max_width' ),
|
1353 |
+
'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
|
1354 |
+
'size' => 'small',
|
1355 |
+
),
|
1356 |
+
array(
|
1357 |
+
'id' => 'profile_icons',
|
1358 |
+
'type' => 'select',
|
1359 |
+
'label' => __( 'Profile Field Icons', 'ultimate-member' ),
|
1360 |
+
'tooltip' => __( 'This is applicable for edit mode only', 'ultimate-member' ),
|
1361 |
+
'default' => um_get_metadefault( 'profile_icons' ),
|
1362 |
+
'options' => array(
|
1363 |
+
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1364 |
+
'label' => __( 'Show with label', 'ultimate-member' ),
|
1365 |
+
'off' => __( 'Turn off', 'ultimate-member' ),
|
1366 |
+
),
|
1367 |
+
'size' => 'small',
|
1368 |
+
),
|
1369 |
+
array(
|
1370 |
+
'id' => 'profile_primary_btn_word',
|
1371 |
+
'type' => 'text',
|
1372 |
+
'label' => __( 'Profile Primary Button Text', 'ultimate-member' ),
|
1373 |
+
'default' => um_get_metadefault( 'profile_primary_btn_word' ),
|
1374 |
+
'tooltip' => __( 'The text that is used for updating profile button', 'ultimate-member' ),
|
1375 |
+
'size' => 'medium',
|
1376 |
+
),
|
1377 |
+
array(
|
1378 |
+
'id' => 'profile_secondary_btn',
|
1379 |
+
'type' => 'checkbox',
|
1380 |
+
'label' => __( 'Profile Secondary Button', 'ultimate-member' ),
|
1381 |
+
'default' => um_get_metadefault( 'profile_secondary_btn' ),
|
1382 |
+
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1383 |
+
),
|
1384 |
+
array(
|
1385 |
+
'id' => 'profile_secondary_btn_word',
|
1386 |
+
'type' => 'text',
|
1387 |
+
'label' => __( 'Profile Secondary Button Text', 'ultimate-member' ),
|
1388 |
+
'default' => um_get_metadefault( 'profile_secondary_btn_word' ),
|
1389 |
+
'tooltip' => __( 'The text that is used for cancelling update profile button', 'ultimate-member' ),
|
1390 |
+
'conditional' => array( 'profile_secondary_btn', '=', 1 ),
|
1391 |
+
'size' => 'medium',
|
1392 |
+
),
|
1393 |
+
array(
|
1394 |
+
'id' => 'default_avatar',
|
1395 |
+
'type' => 'media',
|
1396 |
+
'label' => __( 'Default Profile Photo', 'ultimate-member' ),
|
1397 |
+
'tooltip' => __( 'You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member' ),
|
1398 |
+
'upload_frame_title' => __( 'Select Default Profile Photo', 'ultimate-member' ),
|
1399 |
+
'default' => array(
|
1400 |
+
'url' => um_url . 'assets/img/default_avatar.jpg',
|
1401 |
+
),
|
1402 |
+
),
|
1403 |
+
array(
|
1404 |
+
'id' => 'default_cover',
|
1405 |
+
'type' => 'media',
|
1406 |
+
'url' => true,
|
1407 |
+
'preview' => false,
|
1408 |
+
'label' => __( 'Default Cover Photo', 'ultimate-member' ),
|
1409 |
+
'tooltip' => __( 'You can change the default cover photo globally here. Please make sure that the default cover is large enough and respects the ratio you are using for cover photos.', 'ultimate-member' ),
|
1410 |
+
'upload_frame_title' => __( 'Select Default Cover Photo', 'ultimate-member' ),
|
1411 |
+
),
|
1412 |
+
array(
|
1413 |
+
'id' => 'disable_profile_photo_upload',
|
1414 |
+
'type' => 'checkbox',
|
1415 |
+
'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
|
1416 |
+
'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
|
1417 |
+
'default' => um_get_metadefault( 'disable_profile_photo_upload' ),
|
1418 |
+
),
|
1419 |
+
array(
|
1420 |
+
'id' => 'profile_photosize',
|
1421 |
+
'type' => 'select',
|
1422 |
+
'label' => __( 'Profile Photo Size', 'ultimate-member' ),
|
1423 |
+
'default' => um_get_metadefault( 'profile_photosize' ),
|
1424 |
+
'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
|
1425 |
+
'tooltip' => __( 'The global default of profile photo size. This can be overridden by individual form settings', 'ultimate-member' ),
|
1426 |
+
'size' => 'small',
|
1427 |
+
),
|
1428 |
+
array(
|
1429 |
+
'id' => 'profile_cover_enabled',
|
1430 |
+
'type' => 'checkbox',
|
1431 |
+
'label' => __( 'Profile Cover Photos', 'ultimate-member' ),
|
1432 |
+
'default' => um_get_metadefault( 'profile_cover_enabled' ),
|
1433 |
+
'tooltip' => __( 'Switch on/off the profile cover photos', 'ultimate-member' ),
|
1434 |
+
),
|
1435 |
+
array(
|
1436 |
+
'id' => 'profile_coversize',
|
1437 |
+
'type' => 'select',
|
1438 |
+
'label' => __( 'Profile Cover Size', 'ultimate-member' ),
|
1439 |
+
'default' => um_get_metadefault( 'profile_coversize' ),
|
1440 |
+
'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
|
1441 |
+
'tooltip' => __( 'The global default width of cover photo size. This can be overridden by individual form settings', 'ultimate-member' ),
|
1442 |
+
'conditional' => array( 'profile_cover_enabled', '=', 1 ),
|
1443 |
+
'size' => 'small',
|
1444 |
+
),
|
1445 |
+
array(
|
1446 |
+
'id' => 'profile_cover_ratio',
|
1447 |
+
'type' => 'select',
|
1448 |
+
'label' => __( 'Profile Cover Ratio', 'ultimate-member' ),
|
1449 |
+
'tooltip' => __( 'Choose global ratio for cover photos of profiles', 'ultimate-member' ),
|
1450 |
+
'default' => um_get_metadefault( 'profile_cover_ratio' ),
|
1451 |
+
'options' => array(
|
1452 |
+
'1.6:1' => '1.6:1',
|
1453 |
+
'2.7:1' => '2.7:1',
|
1454 |
+
'2.2:1' => '2.2:1',
|
1455 |
+
'3.2:1' => '3.2:1',
|
1456 |
+
),
|
1457 |
+
'conditional' => array( 'profile_cover_enabled', '=', 1 ),
|
1458 |
+
'size' => 'small',
|
1459 |
+
),
|
1460 |
+
array(
|
1461 |
+
'id' => 'profile_show_metaicon',
|
1462 |
+
'type' => 'checkbox',
|
1463 |
+
'label' => __( 'Profile Header Meta Text Icon', 'ultimate-member' ),
|
1464 |
+
'default' => 0,
|
1465 |
+
'tooltip' => __( 'Display field icons for related user meta fields in header or not', 'ultimate-member' ),
|
1466 |
+
),
|
1467 |
+
array(
|
1468 |
+
'id' => 'profile_show_name',
|
1469 |
+
'type' => 'checkbox',
|
1470 |
+
'label' => __( 'Show display name in profile header', 'ultimate-member' ),
|
1471 |
+
'default' => um_get_metadefault( 'profile_show_name' ),
|
1472 |
+
'tooltip' => __( 'Switch on/off the user name on profile header', 'ultimate-member' ),
|
1473 |
+
),
|
1474 |
+
array(
|
1475 |
+
'id' => 'profile_show_social_links',
|
1476 |
+
'type' => 'checkbox',
|
1477 |
+
'label' => __( 'Show social links in profile header', 'ultimate-member' ),
|
1478 |
+
'default' => um_get_metadefault( 'profile_show_social_links' ),
|
1479 |
+
'tooltip' => __( 'Switch on/off the social links on profile header', 'ultimate-member' ),
|
1480 |
+
),
|
1481 |
+
array(
|
1482 |
+
'id' => 'profile_show_bio',
|
1483 |
+
'type' => 'checkbox',
|
1484 |
+
'label' => __( 'Show user description in header', 'ultimate-member' ),
|
1485 |
+
'default' => um_get_metadefault( 'profile_show_bio' ),
|
1486 |
+
'tooltip' => __( 'Switch on/off the user description on profile header', 'ultimate-member' ),
|
1487 |
+
),
|
1488 |
+
array(
|
1489 |
+
'id' => 'profile_show_html_bio',
|
1490 |
+
'type' => 'checkbox',
|
1491 |
+
'label' => __( 'Enable HTML support for user description', 'ultimate-member' ),
|
1492 |
+
'tooltip' => __( 'Switch on/off to enable/disable support for html tags on user description.', 'ultimate-member' ),
|
1493 |
+
),
|
1494 |
+
array(
|
1495 |
+
'id' => 'profile_bio_maxchars',
|
1496 |
+
'type' => 'text',
|
1497 |
+
'label' => __( 'User description maximum chars', 'ultimate-member' ),
|
1498 |
+
'default' => um_get_metadefault( 'profile_bio_maxchars' ),
|
1499 |
+
'tooltip' => __( 'Maximum number of characters to allow in user description field in header.', 'ultimate-member' ),
|
1500 |
+
'conditional' => array( 'profile_show_bio', '=', 1 ),
|
1501 |
+
'size' => 'small',
|
1502 |
+
),
|
1503 |
+
array(
|
1504 |
+
'id' => 'profile_header_menu',
|
1505 |
+
'type' => 'select',
|
1506 |
+
'label' => __( 'Profile Header Menu Position', 'ultimate-member' ),
|
1507 |
+
'default' => um_get_metadefault( 'profile_header_menu' ),
|
1508 |
+
'tooltip' => __( 'For incompatible themes, please make the menu open from left instead of bottom by default.', 'ultimate-member' ),
|
1509 |
+
'options' => array(
|
1510 |
+
'bc' => __( 'Bottom of Icon', 'ultimate-member' ),
|
1511 |
+
'lc' => __( 'Left of Icon (right for RTL)', 'ultimate-member' ),
|
1512 |
+
),
|
1513 |
+
'size' => 'small',
|
1514 |
+
),
|
1515 |
+
array(
|
1516 |
+
'id' => 'profile_empty_text',
|
1517 |
+
'type' => 'checkbox',
|
1518 |
+
'label' => __( 'Show a custom message if profile is empty', 'ultimate-member' ),
|
1519 |
+
'default' => um_get_metadefault( 'profile_empty_text' ),
|
1520 |
+
'tooltip' => __( 'Switch on/off the custom message that appears when the profile is empty', 'ultimate-member' ),
|
1521 |
+
),
|
1522 |
+
array(
|
1523 |
+
'id' => 'profile_empty_text_emo',
|
1524 |
+
'type' => 'checkbox',
|
1525 |
+
'label' => __( 'Show the emoticon', 'ultimate-member' ),
|
1526 |
+
'default' => um_get_metadefault( 'profile_empty_text_emo' ),
|
1527 |
+
'tooltip' => __( 'Switch on/off the emoticon (sad face) that appears above the message', 'ultimate-member' ),
|
1528 |
+
'conditional' => array( 'profile_empty_text', '=', 1 ),
|
1529 |
+
),
|
1530 |
+
),
|
1531 |
+
),
|
1532 |
+
'profile_menu' => array(
|
1533 |
+
'title' => __( 'Profile Menu', 'ultimate-member' ),
|
1534 |
+
'fields' => $appearances_profile_menu_fields,
|
1535 |
+
),
|
1536 |
+
'registration_form' => array(
|
1537 |
+
'title' => __( 'Registration Form', 'ultimate-member' ),
|
1538 |
+
'fields' => array(
|
1539 |
+
array(
|
1540 |
+
'id' => 'register_template',
|
1541 |
+
'type' => 'select',
|
1542 |
+
'label' => __( 'Registration Default Template', 'ultimate-member' ),
|
1543 |
+
'tooltip' => __( 'This will be the default template to output registration', 'ultimate-member' ),
|
1544 |
+
'default' => um_get_metadefault( 'register_template' ),
|
1545 |
+
'options' => UM()->shortcodes()->get_templates( 'register' ),
|
1546 |
+
'size' => 'small',
|
1547 |
+
),
|
1548 |
+
array(
|
1549 |
+
'id' => 'register_max_width',
|
1550 |
+
'type' => 'text',
|
1551 |
+
'label' => __( 'Registration Maximum Width', 'ultimate-member' ),
|
1552 |
+
'default' => um_get_metadefault( 'register_max_width' ),
|
1553 |
+
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1554 |
+
'size' => 'small',
|
1555 |
+
),
|
1556 |
+
array(
|
1557 |
+
'id' => 'register_align',
|
1558 |
+
'type' => 'select',
|
1559 |
+
'label' => __( 'Registration Shortcode Alignment', 'ultimate-member' ),
|
1560 |
+
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
|
1561 |
+
'default' => um_get_metadefault( 'register_align' ),
|
1562 |
+
'options' => array(
|
1563 |
+
'center' => __( 'Centered', 'ultimate-member' ),
|
1564 |
+
'left' => __( 'Left aligned', 'ultimate-member' ),
|
1565 |
+
'right' => __( 'Right aligned', 'ultimate-member' ),
|
1566 |
+
),
|
1567 |
+
'size' => 'small',
|
1568 |
+
),
|
1569 |
+
array(
|
1570 |
+
'id' => 'register_icons',
|
1571 |
+
'type' => 'select',
|
1572 |
+
'label' => __( 'Registration Field Icons', 'ultimate-member' ),
|
1573 |
+
'tooltip' => __( 'This controls the display of field icons in the registration form', 'ultimate-member' ),
|
1574 |
+
'default' => um_get_metadefault( 'register_icons' ),
|
1575 |
+
'options' => array(
|
1576 |
+
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1577 |
+
'label' => __( 'Show with label', 'ultimate-member' ),
|
1578 |
+
'off' => __( 'Turn off', 'ultimate-member' ),
|
1579 |
+
),
|
1580 |
+
'size' => 'small',
|
1581 |
+
),
|
1582 |
+
array(
|
1583 |
+
'id' => 'register_primary_btn_word',
|
1584 |
+
'type' => 'text',
|
1585 |
+
'label' => __( 'Registration Primary Button Text', 'ultimate-member' ),
|
1586 |
+
'default' => um_get_metadefault( 'register_primary_btn_word' ),
|
1587 |
+
'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
|
1588 |
+
'size' => 'medium',
|
1589 |
+
),
|
1590 |
+
array(
|
1591 |
+
'id' => 'register_secondary_btn',
|
1592 |
+
'type' => 'checkbox',
|
1593 |
+
'label' => __( 'Registration Secondary Button', 'ultimate-member' ),
|
1594 |
+
'default' => 1,
|
1595 |
+
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1596 |
+
),
|
1597 |
+
array(
|
1598 |
+
'id' => 'register_secondary_btn_word',
|
1599 |
+
'type' => 'text',
|
1600 |
+
'label' => __( 'Registration Secondary Button Text', 'ultimate-member' ),
|
1601 |
+
'default' => um_get_metadefault( 'register_secondary_btn_word' ),
|
1602 |
+
'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
|
1603 |
+
'conditional' => array( 'register_secondary_btn', '=', 1 ),
|
1604 |
+
'size' => 'medium',
|
1605 |
+
),
|
1606 |
+
array(
|
1607 |
+
'id' => 'register_secondary_btn_url',
|
1608 |
+
'type' => 'text',
|
1609 |
+
'label' => __( 'Registration Secondary Button URL', 'ultimate-member' ),
|
1610 |
+
'default' => um_get_metadefault( 'register_secondary_btn_url' ),
|
1611 |
+
'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
|
1612 |
+
'conditional' => array( 'register_secondary_btn', '=', 1 ),
|
1613 |
+
'size' => 'medium',
|
1614 |
+
),
|
1615 |
+
array(
|
1616 |
+
'id' => 'register_role',
|
1617 |
+
'type' => 'select',
|
1618 |
+
'label' => __( 'Registration Default Role', 'ultimate-member' ),
|
1619 |
+
'tooltip' => __( 'This will be the default role assigned to users registering thru registration form', 'ultimate-member' ),
|
1620 |
+
'default' => um_get_metadefault( 'register_role' ),
|
1621 |
+
'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
|
1622 |
+
'size' => 'small',
|
1623 |
+
),
|
1624 |
+
),
|
1625 |
+
),
|
1626 |
+
'login_form' => array(
|
1627 |
+
'title' => __( 'Login Form', 'ultimate-member' ),
|
1628 |
+
'fields' => array(
|
1629 |
+
array(
|
1630 |
+
'id' => 'login_template',
|
1631 |
+
'type' => 'select',
|
1632 |
+
'label' => __( 'Login Default Template', 'ultimate-member' ),
|
1633 |
+
'tooltip' => __( 'This will be the default template to output login', 'ultimate-member' ),
|
1634 |
+
'default' => um_get_metadefault( 'login_template' ),
|
1635 |
+
'options' => UM()->shortcodes()->get_templates( 'login' ),
|
1636 |
+
'size' => 'small',
|
1637 |
+
),
|
1638 |
+
array(
|
1639 |
+
'id' => 'login_max_width',
|
1640 |
+
'type' => 'text',
|
1641 |
+
'label' => __( 'Login Maximum Width', 'ultimate-member' ),
|
1642 |
+
'default' => um_get_metadefault( 'login_max_width' ),
|
1643 |
+
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1644 |
+
'size' => 'small',
|
1645 |
+
),
|
1646 |
+
array(
|
1647 |
+
'id' => 'login_align',
|
1648 |
+
'type' => 'select',
|
1649 |
+
'label' => __( 'Login Shortcode Alignment', 'ultimate-member' ),
|
1650 |
+
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
|
1651 |
+
'default' => um_get_metadefault( 'login_align' ),
|
1652 |
+
'options' => array(
|
1653 |
+
'center' => __( 'Centered', 'ultimate-member' ),
|
1654 |
+
'left' => __( 'Left aligned', 'ultimate-member' ),
|
1655 |
+
'right' => __( 'Right aligned', 'ultimate-member' ),
|
1656 |
+
),
|
1657 |
+
'size' => 'small',
|
1658 |
+
),
|
1659 |
+
array(
|
1660 |
+
'id' => 'login_icons',
|
1661 |
+
'type' => 'select',
|
1662 |
+
'label' => __( 'Login Field Icons', 'ultimate-member' ),
|
1663 |
+
'tooltip' => __( 'This controls the display of field icons in the login form', 'ultimate-member' ),
|
1664 |
+
'default' => um_get_metadefault( 'login_icons' ),
|
1665 |
+
'options' => array(
|
1666 |
+
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1667 |
+
'label' => __( 'Show with label', 'ultimate-member' ),
|
1668 |
+
'off' => __( 'Turn off', 'ultimate-member' ),
|
1669 |
+
),
|
1670 |
+
'size' => 'small',
|
1671 |
+
),
|
1672 |
+
array(
|
1673 |
+
'id' => 'login_primary_btn_word',
|
1674 |
+
'type' => 'text',
|
1675 |
+
'label' => __( 'Login Primary Button Text', 'ultimate-member' ),
|
1676 |
+
'default' => um_get_metadefault( 'login_primary_btn_word' ),
|
1677 |
+
'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
|
1678 |
+
'size' => 'medium',
|
1679 |
+
),
|
1680 |
+
array(
|
1681 |
+
'id' => 'login_secondary_btn',
|
1682 |
+
'type' => 'checkbox',
|
1683 |
+
'label' => __( 'Login Secondary Button', 'ultimate-member' ),
|
1684 |
+
'default' => 1,
|
1685 |
+
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1686 |
+
),
|
1687 |
+
array(
|
1688 |
+
'id' => 'login_secondary_btn_word',
|
1689 |
+
'type' => 'text',
|
1690 |
+
'label' => __( 'Login Secondary Button Text', 'ultimate-member' ),
|
1691 |
+
'default' => um_get_metadefault( 'login_secondary_btn_word' ),
|
1692 |
+
'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
|
1693 |
+
'conditional' => array( 'login_secondary_btn', '=', 1 ),
|
1694 |
+
'size' => 'medium',
|
1695 |
+
),
|
1696 |
+
array(
|
1697 |
+
'id' => 'login_secondary_btn_url',
|
1698 |
+
'type' => 'text',
|
1699 |
+
'label' => __( 'Login Secondary Button URL', 'ultimate-member' ),
|
1700 |
+
'default' => um_get_metadefault( 'login_secondary_btn_url' ),
|
1701 |
+
'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
|
1702 |
+
'conditional' => array( 'login_secondary_btn', '=', 1 ),
|
1703 |
+
'size' => 'medium',
|
1704 |
+
),
|
1705 |
+
array(
|
1706 |
+
'id' => 'login_forgot_pass_link',
|
1707 |
+
'type' => 'checkbox',
|
1708 |
+
'label' => __( 'Login Forgot Password Link', 'ultimate-member' ),
|
1709 |
+
'default' => 1,
|
1710 |
+
'tooltip' => __( 'Switch on/off the forgot password link in login form', 'ultimate-member' ),
|
1711 |
+
),
|
1712 |
+
array(
|
1713 |
+
'id' => 'login_show_rememberme',
|
1714 |
+
'type' => 'checkbox',
|
1715 |
+
'label' => __( 'Show "Remember Me"', 'ultimate-member' ),
|
1716 |
+
'default' => 1,
|
1717 |
+
'tooltip' => __( 'Allow users to choose If they want to stay signed in even after closing the browser. If you do not show this option, the default will be to not remember login session.', 'ultimate-member' ),
|
1718 |
+
),
|
1719 |
+
),
|
1720 |
+
),
|
1721 |
+
),
|
1722 |
+
),
|
1723 |
+
'extensions' => array(
|
1724 |
+
'title' => __( 'Extensions', 'ultimate-member' ),
|
1725 |
+
),
|
1726 |
+
'licenses' => array(
|
1727 |
+
'title' => __( 'Licenses', 'ultimate-member' ),
|
1728 |
+
),
|
1729 |
+
'misc' => array(
|
1730 |
+
'title' => __( 'Misc', 'ultimate-member' ),
|
1731 |
+
'fields' => array(
|
1732 |
+
array(
|
1733 |
+
'id' => 'form_asterisk',
|
1734 |
+
'type' => 'checkbox',
|
1735 |
+
'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ),
|
1736 |
+
),
|
1737 |
+
array(
|
1738 |
+
'id' => 'profile_title',
|
1739 |
+
'type' => 'text',
|
1740 |
+
'label' => __( 'User Profile Title', 'ultimate-member' ),
|
1741 |
+
'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ),
|
1742 |
+
'size' => 'medium',
|
1743 |
+
),
|
1744 |
+
array(
|
1745 |
+
'id' => 'profile_desc',
|
1746 |
+
'type' => 'textarea',
|
1747 |
+
'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ),
|
1748 |
+
'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ),
|
1749 |
+
'args' => array(
|
1750 |
+
'textarea_rows' => 6,
|
1751 |
+
),
|
1752 |
+
),
|
1753 |
+
array(
|
1754 |
+
'id' => 'um_profile_object_cache_stop',
|
1755 |
+
'type' => 'checkbox',
|
1756 |
+
'label' => __( 'Disable Cache User Profile', 'ultimate-member' ),
|
1757 |
+
'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ),
|
1758 |
+
),
|
1759 |
+
array(
|
1760 |
+
'id' => 'enable_blocks',
|
1761 |
+
'type' => 'checkbox',
|
1762 |
+
'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ),
|
1763 |
+
'tooltip' => __( 'Check this box if you would like to use Ultimate Member blocks in Gutenberg editor. Important some themes have the conflicts with Gutenberg editor.', 'ultimate-member' ),
|
1764 |
+
),
|
1765 |
+
array(
|
1766 |
+
'id' => 'rest_api_version',
|
1767 |
+
'type' => 'select',
|
1768 |
+
'label' => __( 'REST API version', 'ultimate-member' ),
|
1769 |
+
'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ),
|
1770 |
+
'options' => array(
|
1771 |
+
'1.0' => __( '1.0 version', 'ultimate-member' ),
|
1772 |
+
'2.0' => __( '2.0 version', 'ultimate-member' ),
|
1773 |
+
),
|
1774 |
+
),
|
1775 |
+
// backward compatibility option leave it disabled for better security and ability to exclude posts/terms pre-query
|
1776 |
+
// otherwise we filtering only results and restricted posts/terms can be visible
|
1777 |
+
array(
|
1778 |
+
'id' => 'disable_restriction_pre_queries',
|
1779 |
+
'type' => 'checkbox',
|
1780 |
+
'label' => __( 'Disable pre-queries for restriction content logic (advanced)', 'ultimate-member' ),
|
1781 |
+
'tooltip' => __( 'Please enable this option only in the cases when you have big or unnecessary queries on your site with active restriction logic. If you want to exclude posts only from the results queries instead of pre_get_posts and fully-hidden post logic also please enable this option. It activates the restriction content logic until 2.2.x version without latest security enhancements', 'ultimate-member' ),
|
1782 |
+
),
|
1783 |
+
$same_page_update,
|
1784 |
+
array(
|
1785 |
+
'id' => 'uninstall_on_delete',
|
1786 |
+
'type' => 'checkbox',
|
1787 |
+
'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ),
|
1788 |
+
'tooltip' => __( 'Check this box if you would like Ultimate Member to completely remove all of its data when the plugin/extensions are deleted.', 'ultimate-member' ),
|
1789 |
+
),
|
1790 |
+
),
|
1791 |
+
),
|
1792 |
+
'install_info' => array(
|
1793 |
+
'title' => __( 'Install Info', 'ultimate-member' ),
|
1794 |
+
'fields' => array(
|
1795 |
+
array(
|
1796 |
+
'type' => 'install_info',
|
1797 |
+
),
|
1798 |
+
),
|
1799 |
+
),
|
1800 |
+
)
|
1801 |
+
);
|
1802 |
+
|
1803 |
+
}
|
1804 |
+
|
1805 |
+
|
1806 |
+
/**
|
1807 |
+
* @param array $settings
|
1808 |
+
*
|
1809 |
+
* @return array
|
1810 |
+
*/
|
1811 |
+
public function sorting_licenses_options( $settings ) {
|
1812 |
+
//sorting licenses
|
1813 |
+
if ( empty( $settings['licenses']['fields'] ) ) {
|
1814 |
+
return $settings;
|
1815 |
+
}
|
1816 |
+
|
1817 |
+
$licenses = $settings['licenses']['fields'];
|
1818 |
+
@uasort( $licenses, function( $a, $b ) {
|
1819 |
+
return strnatcasecmp( $a['label'], $b['label'] );
|
1820 |
+
} );
|
1821 |
+
$settings['licenses']['fields'] = $licenses;
|
1822 |
+
|
1823 |
+
//sorting extensions
|
1824 |
+
if ( empty( $settings['extensions']['sections'] ) ) {
|
1825 |
+
return $settings;
|
1826 |
+
}
|
1827 |
+
|
1828 |
+
$extensions = $settings['extensions']['sections'];
|
1829 |
+
@uasort( $extensions, function( $a, $b ) {
|
1830 |
+
return strnatcasecmp( $a['title'], $b['title'] );
|
1831 |
+
} );
|
1832 |
+
|
1833 |
+
$keys = array_keys( $extensions );
|
1834 |
+
if ( $keys[0] !== '' ) {
|
1835 |
+
$new_key = strtolower( str_replace( ' ', '_', $extensions['']['title'] ) );
|
1836 |
+
$temp = $extensions[''];
|
1837 |
+
$extensions[ $new_key ] = $temp;
|
1838 |
+
$extensions[''] = $extensions[ $keys[0] ];
|
1839 |
+
unset( $extensions[ $keys[0] ] );
|
1840 |
+
@uasort( $extensions, function( $a, $b ) {
|
1841 |
+
return strnatcasecmp( $a['title'], $b['title'] );
|
1842 |
+
} );
|
1843 |
+
}
|
1844 |
+
|
1845 |
+
$settings['extensions']['sections'] = $extensions;
|
1846 |
+
|
1847 |
+
return $settings;
|
1848 |
+
}
|
1849 |
+
|
1850 |
+
|
1851 |
+
/**
|
1852 |
+
* @param $tab
|
1853 |
+
* @param $section
|
1854 |
+
*
|
1855 |
+
* @return array
|
1856 |
+
*/
|
1857 |
+
function get_section_fields( $tab, $section ) {
|
1858 |
+
|
1859 |
+
if ( empty( $this->settings_structure[ $tab ] ) ) {
|
1860 |
+
return array();
|
1861 |
+
}
|
1862 |
+
|
1863 |
+
if ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
|
1864 |
+
return $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
|
1865 |
+
} elseif ( ! empty( $this->settings_structure[ $tab ]['fields'] ) ) {
|
1866 |
+
return $this->settings_structure[ $tab ]['fields'];
|
1867 |
+
}
|
1868 |
+
|
1869 |
+
return array();
|
1870 |
+
}
|
1871 |
+
|
1872 |
+
|
1873 |
+
/**
|
1874 |
+
* Setup admin menu
|
1875 |
+
*/
|
1876 |
+
function primary_admin_menu() {
|
1877 |
+
add_submenu_page( 'ultimatemember', __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( &$this, 'settings_page' ) );
|
1878 |
+
}
|
1879 |
+
|
1880 |
+
|
1881 |
+
/**
|
1882 |
+
* Settings page callback
|
1883 |
+
*/
|
1884 |
+
function settings_page() {
|
1885 |
+
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
1886 |
+
$current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
|
1887 |
+
|
1888 |
+
$settings_struct = $this->settings_structure[ $current_tab ];
|
1889 |
+
|
1890 |
+
//remove not option hidden fields
|
1891 |
+
if ( ! empty( $settings_struct['fields'] ) ) {
|
1892 |
+
foreach ( $settings_struct['fields'] as $field_key => $field_options ) {
|
1893 |
+
|
1894 |
+
if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
|
1895 |
+
unset( $settings_struct['fields'][ $field_key ] );
|
1896 |
+
}
|
1897 |
+
|
1898 |
+
}
|
1899 |
+
}
|
1900 |
+
|
1901 |
+
if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) ) {
|
1902 |
+
um_js_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) );
|
1903 |
+
}
|
1904 |
+
|
1905 |
+
if ( ! empty( $settings_struct['sections'] ) ) {
|
1906 |
+
if ( empty( $settings_struct['sections'][ $current_subtab ] ) ) {
|
1907 |
+
um_js_redirect( add_query_arg( array( 'page' => 'um_options', 'tab' => $current_tab ), admin_url( 'admin.php' ) ) );
|
1908 |
+
}
|
1909 |
+
}
|
1910 |
+
|
1911 |
+
echo '<div id="um-settings-wrap" class="wrap"><h2>' . __( 'Ultimate Member - Settings', 'ultimate-member' ) . '</h2>';
|
1912 |
+
|
1913 |
+
echo $this->generate_tabs_menu() . $this->generate_subtabs_menu( $current_tab );
|
1914 |
+
|
1915 |
+
/**
|
1916 |
+
* UM hook
|
1917 |
+
*
|
1918 |
+
* @type action
|
1919 |
+
* @title um_settings_page_before_{$current_tab}_{$current_subtab}_content
|
1920 |
+
* @description Show some content before settings page content
|
1921 |
+
* @change_log
|
1922 |
+
* ["Since: 2.0"]
|
1923 |
+
* @usage add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'function_name', 10 );
|
1924 |
+
* @example
|
1925 |
+
* <?php
|
1926 |
+
* add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'my_settings_page_before', 10 );
|
1927 |
+
* function my_settings_page_before() {
|
1928 |
+
* // your code here
|
1929 |
+
* }
|
1930 |
+
* ?>
|
1931 |
+
*/
|
1932 |
+
do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" );
|
1933 |
+
|
1934 |
+
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(), $current_tab ) ) ) {
|
1935 |
+
|
1936 |
+
/**
|
1937 |
+
* UM hook
|
1938 |
+
*
|
1939 |
+
* @type action
|
1940 |
+
* @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
|
1941 |
+
* @description Show some content before section content at settings page
|
1942 |
+
* @change_log
|
1943 |
+
* ["Since: 2.0"]
|
1944 |
+
* @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
|
1945 |
+
* @example
|
1946 |
+
* <?php
|
1947 |
+
* add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
|
1948 |
+
* function my_settings_page_before_section() {
|
1949 |
+
* // your code here
|
1950 |
+
* }
|
1951 |
+
* ?>
|
1952 |
+
*/
|
1953 |
+
do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
|
1954 |
+
|
1955 |
+
$section_fields = $this->get_section_fields( $current_tab, $current_subtab );
|
1956 |
+
$settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
|
1957 |
+
|
1958 |
+
/**
|
1959 |
+
* UM hook
|
1960 |
+
*
|
1961 |
+
* @type filter
|
1962 |
+
* @title um_settings_section_{$current_tab}_{$current_subtab}_content
|
1963 |
+
*
|
1964 |
+
* @description Render settings section
|
1965 |
+
* @input_vars
|
1966 |
+
* [{"var":"$content","type":"string","desc":"Section content"},
|
1967 |
+
* {"var":"$section_fields","type":"array","desc":"Section Fields"}]
|
1968 |
+
* @change_log
|
1969 |
+
* ["Since: 2.0"]
|
1970 |
+
* @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
|
1971 |
+
* @example
|
1972 |
+
* <?php
|
1973 |
+
* add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
|
1974 |
+
* function my_settings_section( $content ) {
|
1975 |
+
* // your code here
|
1976 |
+
* return $content;
|
1977 |
+
* }
|
1978 |
+
* ?>
|
1979 |
+
*/
|
1980 |
+
echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
|
1981 |
+
$settings_section,
|
1982 |
+
$section_fields
|
1983 |
+
);
|
1984 |
+
|
1985 |
+
} else { ?>
|
1986 |
+
|
1987 |
+
<form method="post" action="" name="um-settings-form" id="um-settings-form">
|
1988 |
+
<input type="hidden" value="save" name="um-settings-action" />
|
1989 |
+
|
1990 |
+
<?php
|
1991 |
+
/**
|
1992 |
+
* UM hook
|
1993 |
+
*
|
1994 |
+
* @type action
|
1995 |
+
* @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
|
1996 |
+
* @description Show some content before section content at settings page
|
1997 |
+
* @change_log
|
1998 |
+
* ["Since: 2.0"]
|
1999 |
+
* @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
|
2000 |
+
* @example
|
2001 |
+
* <?php
|
2002 |
+
* add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
|
2003 |
+
* function my_settings_page_before_section() {
|
2004 |
+
* // your code here
|
2005 |
+
* }
|
2006 |
+
* ?>
|
2007 |
+
*/
|
2008 |
+
do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
|
2009 |
+
|
2010 |
+
$section_fields = $this->get_section_fields( $current_tab, $current_subtab );
|
2011 |
+
$settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
|
2012 |
+
|
2013 |
+
/**
|
2014 |
+
* UM hook
|
2015 |
+
*
|
2016 |
+
* @type filter
|
2017 |
+
* @title um_settings_section_{$current_tab}_{$current_subtab}_content
|
2018 |
+
* @description Render settings section
|
2019 |
+
* @input_vars
|
2020 |
+
* [{"var":"$content","type":"string","desc":"Section content"},
|
2021 |
+
* {"var":"$section_fields","type":"array","desc":"Section Fields"}]
|
2022 |
+
* @change_log
|
2023 |
+
* ["Since: 2.0"]
|
2024 |
+
* @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
|
2025 |
+
* @example
|
2026 |
+
* <?php
|
2027 |
+
* add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
|
2028 |
+
* function my_settings_section( $content ) {
|
2029 |
+
* // your code here
|
2030 |
+
* return $content;
|
2031 |
+
* }
|
2032 |
+
* ?>
|
2033 |
+
*/
|
2034 |
+
echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
|
2035 |
+
$settings_section,
|
2036 |
+
$section_fields
|
2037 |
+
); ?>
|
2038 |
+
|
2039 |
+
|
2040 |
+
<p class="submit">
|
2041 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save Changes', 'ultimate-member' ) ?>" />
|
2042 |
+
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2043 |
+
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2044 |
+
</p>
|
2045 |
+
</form>
|
2046 |
+
|
2047 |
+
<?php }
|
2048 |
+
}
|
2049 |
+
|
2050 |
+
|
2051 |
+
/**
|
2052 |
+
* Generate pages tabs
|
2053 |
+
*
|
2054 |
+
* @param string $page
|
2055 |
+
* @return string
|
2056 |
+
*/
|
2057 |
+
function generate_tabs_menu( $page = 'settings' ) {
|
2058 |
+
|
2059 |
+
$tabs = '<h2 class="nav-tab-wrapper um-nav-tab-wrapper">';
|
2060 |
+
|
2061 |
+
switch( $page ) {
|
2062 |
+
case 'settings':
|
2063 |
+
$menu_tabs = array();
|
2064 |
+
foreach ( $this->settings_structure as $slug => $tab ) {
|
2065 |
+
if ( ! empty( $tab['fields'] ) ) {
|
2066 |
+
foreach ( $tab['fields'] as $field_key => $field_options ) {
|
2067 |
+
if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
|
2068 |
+
unset( $tab['fields'][ $field_key ] );
|
2069 |
+
}
|
2070 |
+
}
|
2071 |
+
}
|
2072 |
+
|
2073 |
+
if ( ! empty( $tab['fields'] ) || ! empty( $tab['sections'] ) ) {
|
2074 |
+
$menu_tabs[ $slug ] = $tab['title'];
|
2075 |
+
}
|
2076 |
+
}
|
2077 |
+
|
2078 |
+
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
2079 |
+
foreach ( $menu_tabs as $name => $label ) {
|
2080 |
+
$active = ( $current_tab == $name ) ? 'nav-tab-active' : '';
|
2081 |
+
$tabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $name ) ? '' : '&tab=' . $name ) ) ) . '" class="nav-tab ' . esc_attr( $active ) . '">' .
|
2082 |
+
$label .
|
2083 |
+
'</a>';
|
2084 |
+
}
|
2085 |
+
|
2086 |
+
break;
|
2087 |
+
default:
|
2088 |
+
/**
|
2089 |
+
* UM hook
|
2090 |
+
*
|
2091 |
+
* @type filter
|
2092 |
+
* @title um_generate_tabs_menu_{$page}
|
2093 |
+
* @description Generate tabs menu
|
2094 |
+
* @input_vars
|
2095 |
+
* [{"var":"$tabs","type":"array","desc":"UM menu tabs"}]
|
2096 |
+
* @change_log
|
2097 |
+
* ["Since: 2.0"]
|
2098 |
+
* @usage add_filter( 'um_generate_tabs_menu_{$page}', 'function_name', 10, 1 );
|
2099 |
+
* @example
|
2100 |
+
* <?php
|
2101 |
+
* add_filter( 'um_generate_tabs_menu_{$page}', 'my_tabs_menu', 10, 1 );
|
2102 |
+
* function my_tabs_menu( $tabs ) {
|
2103 |
+
* // your code here
|
2104 |
+
* return $tabs;
|
2105 |
+
* }
|
2106 |
+
* ?>
|
2107 |
+
*/
|
2108 |
+
$tabs = apply_filters( 'um_generate_tabs_menu_' . $page, $tabs );
|
2109 |
+
break;
|
2110 |
+
}
|
2111 |
+
|
2112 |
+
return $tabs . '</h2>';
|
2113 |
+
}
|
2114 |
+
|
2115 |
+
|
2116 |
+
/**
|
2117 |
+
* @param string $tab
|
2118 |
+
*
|
2119 |
+
* @return string
|
2120 |
+
*/
|
2121 |
+
function generate_subtabs_menu( $tab = '' ) {
|
2122 |
+
if ( empty( $this->settings_structure[ $tab ]['sections'] ) ) {
|
2123 |
+
return '';
|
2124 |
+
}
|
2125 |
+
|
2126 |
+
$menu_subtabs = array();
|
2127 |
+
foreach ( $this->settings_structure[ $tab ]['sections'] as $slug => $subtab ) {
|
2128 |
+
$menu_subtabs[ $slug ] = $subtab['title'];
|
2129 |
+
}
|
2130 |
+
|
2131 |
+
$subtabs = '<div><ul class="subsubsub">';
|
2132 |
+
|
2133 |
+
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
2134 |
+
$current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
|
2135 |
+
foreach ( $menu_subtabs as $name => $label ) {
|
2136 |
+
$active = ( $current_subtab == $name ) ? 'current' : '';
|
2137 |
+
$subtabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $current_tab ) ? '' : '&tab=' . $current_tab ) . ( empty( $name ) ? '' : '§ion=' . $name ) ) ) . '" class="' . $active . '">'
|
2138 |
+
. $label .
|
2139 |
+
'</a> | ';
|
2140 |
+
}
|
2141 |
+
|
2142 |
+
return substr( $subtabs, 0, -3 ) . '</ul></div>';
|
2143 |
+
}
|
2144 |
+
|
2145 |
+
|
2146 |
+
/**
|
2147 |
+
* Handler for settings forms
|
2148 |
+
* when "Save Settings" button click
|
2149 |
+
*
|
2150 |
+
*/
|
2151 |
+
function save_settings_handler() {
|
2152 |
+
|
2153 |
+
if ( isset( $_POST['um-settings-action'] ) && 'save' === sanitize_key( $_POST['um-settings-action'] ) && ! empty( $_POST['um_options'] ) ) {
|
2154 |
+
|
2155 |
+
$nonce = ! empty( $_POST['__umnonce'] ) ? $_POST['__umnonce'] : '';
|
2156 |
+
|
2157 |
+
if ( ( ! wp_verify_nonce( $nonce, 'um-settings-nonce' ) || empty( $nonce ) ) || ! current_user_can( 'manage_options' ) ) {
|
2158 |
+
// This nonce is not valid.
|
2159 |
+
wp_die( __( 'Security Check', 'ultimate-member' ) );
|
2160 |
+
}
|
2161 |
+
|
2162 |
+
/**
|
2163 |
+
* UM hook
|
2164 |
+
*
|
2165 |
+
* @type action
|
2166 |
+
* @title um_settings_before_save
|
2167 |
+
* @description Before settings save action
|
2168 |
+
* @change_log
|
2169 |
+
* ["Since: 2.0"]
|
2170 |
+
* @usage add_action( 'um_settings_before_save', 'function_name', 10 );
|
2171 |
+
* @example
|
2172 |
+
* <?php
|
2173 |
+
* add_action( 'um_settings_before_save', 'my_settings_before_save', 10 );
|
2174 |
+
* function my_settings_before_save() {
|
2175 |
+
* // your code here
|
2176 |
+
* }
|
2177 |
+
* ?>
|
2178 |
+
*/
|
2179 |
+
do_action( "um_settings_before_save" );
|
2180 |
+
|
2181 |
+
/**
|
2182 |
+
* UM hook
|
2183 |
+
*
|
2184 |
+
* @type filter
|
2185 |
+
* @title um_change_settings_before_save
|
2186 |
+
* @description Change settings before save
|
2187 |
+
* @input_vars
|
2188 |
+
* [{"var":"$settings","type":"array","desc":"UM Settings on save"}]
|
2189 |
+
* @change_log
|
2190 |
+
* ["Since: 2.0"]
|
2191 |
+
* @usage add_filter( 'um_change_settings_before_save', 'function_name', 10, 1 );
|
2192 |
+
* @example
|
2193 |
+
* <?php
|
2194 |
+
* add_filter( 'um_change_settings_before_save', 'my_change_settings_before_save', 10, 1 );
|
2195 |
+
* function my_change_settings_before_save( $settings ) {
|
2196 |
+
* // your code here
|
2197 |
+
* return $settings;
|
2198 |
+
* }
|
2199 |
+
* ?>
|
2200 |
+
*/
|
2201 |
+
$settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] );
|
2202 |
+
|
2203 |
+
$settings = UM()->admin()->sanitize_options( $settings );
|
2204 |
+
|
2205 |
+
foreach ( $settings as $key => $value ) {
|
2206 |
+
UM()->options()->update( $key, $value );
|
2207 |
+
}
|
2208 |
+
|
2209 |
+
/**
|
2210 |
+
* UM hook
|
2211 |
+
*
|
2212 |
+
* @type action
|
2213 |
+
* @title um_settings_save
|
2214 |
+
* @description After settings save action
|
2215 |
+
* @change_log
|
2216 |
+
* ["Since: 2.0"]
|
2217 |
+
* @usage add_action( 'um_settings_save', 'function_name', 10 );
|
2218 |
+
* @example
|
2219 |
+
* <?php
|
2220 |
+
* add_action( 'um_settings_save', 'my_settings_save', 10 );
|
2221 |
+
* function my_settings_save() {
|
2222 |
+
* // your code here
|
2223 |
+
* }
|
2224 |
+
* ?>
|
2225 |
+
*/
|
2226 |
+
do_action( 'um_settings_save' );
|
2227 |
+
|
2228 |
+
//redirect after save settings
|
2229 |
+
$arg = array(
|
2230 |
+
'page' => 'um_options',
|
2231 |
+
);
|
2232 |
+
|
2233 |
+
if ( ! empty( $_GET['tab'] ) ) {
|
2234 |
+
$arg['tab'] = sanitize_key( $_GET['tab'] );
|
2235 |
+
}
|
2236 |
+
|
2237 |
+
if ( ! empty( $_GET['section'] ) ) {
|
2238 |
+
$arg['section'] = sanitize_key( $_GET['section'] );
|
2239 |
+
}
|
2240 |
+
|
2241 |
+
um_js_redirect( add_query_arg( $arg, admin_url( 'admin.php' ) ) );
|
2242 |
+
}
|
2243 |
+
}
|
2244 |
+
|
2245 |
+
|
2246 |
+
function set_default_if_empty( $settings ) {
|
2247 |
+
$tab = '';
|
2248 |
+
if ( ! empty( $_GET['tab'] ) ) {
|
2249 |
+
$tab = sanitize_key( $_GET['tab'] );
|
2250 |
+
}
|
2251 |
+
|
2252 |
+
$section = '';
|
2253 |
+
if ( ! empty( $_GET['section'] ) ) {
|
2254 |
+
$section = sanitize_key( $_GET['section'] );
|
2255 |
+
}
|
2256 |
+
|
2257 |
+
|
2258 |
+
if ( 'access' === $tab && empty( $section ) ) {
|
2259 |
+
if ( ! array_key_exists( 'access_exclude_uris', $settings ) ) {
|
2260 |
+
$settings['access_exclude_uris'] = array();
|
2261 |
+
}
|
2262 |
+
}
|
2263 |
+
|
2264 |
+
return $settings;
|
2265 |
+
}
|
2266 |
+
|
2267 |
+
|
2268 |
+
/**
|
2269 |
+
* Remove empty values from multi text fields
|
2270 |
+
*
|
2271 |
+
* @param $settings
|
2272 |
+
* @return array
|
2273 |
+
*/
|
2274 |
+
function remove_empty_values( $settings ) {
|
2275 |
+
$tab = '';
|
2276 |
+
if ( ! empty( $_GET['tab'] ) ) {
|
2277 |
+
$tab = sanitize_key( $_GET['tab'] );
|
2278 |
+
}
|
2279 |
+
|
2280 |
+
$section = '';
|
2281 |
+
if ( ! empty( $_GET['section'] ) ) {
|
2282 |
+
$section = sanitize_key( $_GET['section'] );
|
2283 |
+
}
|
2284 |
+
|
2285 |
+
if ( isset( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
|
2286 |
+
$fields = $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
|
2287 |
+
} else {
|
2288 |
+
$fields = $this->settings_structure[ $tab ]['fields'];
|
2289 |
+
}
|
2290 |
+
|
2291 |
+
if ( empty( $fields ) ) {
|
2292 |
+
return $settings;
|
2293 |
+
}
|
2294 |
+
|
2295 |
+
|
2296 |
+
$filtered_settings = array();
|
2297 |
+
foreach ( $settings as $key => $value ) {
|
2298 |
+
|
2299 |
+
$filtered_settings[ $key ] = $value;
|
2300 |
+
|
2301 |
+
foreach ( $fields as $field ) {
|
2302 |
+
if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) {
|
2303 |
+
$filtered_settings[ $key ] = array_filter( $settings[ $key ] );
|
2304 |
+
}
|
2305 |
+
}
|
2306 |
+
}
|
2307 |
+
|
2308 |
+
return $filtered_settings;
|
2309 |
+
}
|
2310 |
+
|
2311 |
+
|
2312 |
+
/**
|
2313 |
+
*
|
2314 |
+
*/
|
2315 |
+
function check_permalinks_changes() {
|
2316 |
+
if ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
|
2317 |
+
if ( UM()->options()->get( 'permalink_base' ) !== $_POST['um_options']['permalink_base'] ) {
|
2318 |
+
$this->need_change_permalinks = true;
|
2319 |
+
}
|
2320 |
+
}
|
2321 |
+
|
2322 |
+
// set variable if gravatar settings were changed
|
2323 |
+
// update for um_member_directory_data metakey
|
2324 |
+
if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
|
2325 |
+
$use_gravatar = UM()->options()->get( 'use_gravatars' );
|
2326 |
+
if ( ( empty( $use_gravatar ) && ! empty( $_POST['um_options']['use_gravatars'] ) ) || ( ! empty( $use_gravatar ) && empty( $_POST['um_options']['use_gravatars'] ) ) ) {
|
2327 |
+
$this->gravatar_changed = true;
|
2328 |
+
}
|
2329 |
+
}
|
2330 |
+
}
|
2331 |
+
|
2332 |
+
|
2333 |
+
/**
|
2334 |
+
*
|
2335 |
+
*/
|
2336 |
+
function on_settings_save() {
|
2337 |
+
if ( ! empty( $_POST['um_options'] ) ) {
|
2338 |
+
|
2339 |
+
if ( ! empty( $_POST['um_options']['pages_settings'] ) ) {
|
2340 |
+
$post_ids = new \WP_Query( array(
|
2341 |
+
'post_type' => 'page',
|
2342 |
+
'meta_query' => array(
|
2343 |
+
array(
|
2344 |
+
'key' => '_um_core',
|
2345 |
+
'compare' => 'EXISTS'
|
2346 |
+
)
|
2347 |
+
),
|
2348 |
+
'posts_per_page' => -1,
|
2349 |
+
'fields' => 'ids'
|
2350 |
+
) );
|
2351 |
+
|
2352 |
+
$post_ids = $post_ids->get_posts();
|
2353 |
+
|
2354 |
+
if ( ! empty( $post_ids ) ) {
|
2355 |
+
foreach ( $post_ids as $post_id ) {
|
2356 |
+
delete_post_meta( $post_id, '_um_core' );
|
2357 |
+
}
|
2358 |
+
}
|
2359 |
+
|
2360 |
+
foreach ( $_POST['um_options'] as $option_slug => $post_id ) {
|
2361 |
+
$slug = str_replace( 'core_', '', $option_slug );
|
2362 |
+
update_post_meta( $post_id, '_um_core', $slug );
|
2363 |
+
}
|
2364 |
+
|
2365 |
+
// reset rewrite rules after re-save pages
|
2366 |
+
UM()->rewrite()->reset_rules();
|
2367 |
+
|
2368 |
+
} elseif ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
|
2369 |
+
if ( ! empty( $this->need_change_permalinks ) ) {
|
2370 |
+
$users = get_users( array(
|
2371 |
+
'fields' => 'ids',
|
2372 |
+
) );
|
2373 |
+
if ( ! empty( $users ) ) {
|
2374 |
+
foreach ( $users as $user_id ) {
|
2375 |
+
UM()->user()->generate_profile_slug( $user_id );
|
2376 |
+
}
|
2377 |
+
}
|
2378 |
+
}
|
2379 |
+
|
2380 |
+
|
2381 |
+
// update for um_member_directory_data metakey
|
2382 |
+
if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
|
2383 |
+
if ( $this->gravatar_changed ) {
|
2384 |
+
global $wpdb;
|
2385 |
+
|
2386 |
+
if ( ! empty( $_POST['um_options']['use_gravatars'] ) ) {
|
2387 |
+
|
2388 |
+
$results = $wpdb->get_col(
|
2389 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2390 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'synced_gravatar_hashed_id' )
|
2391 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2392 |
+
WHERE um.meta_value != '' AND um.meta_value IS NOT NULL AND
|
2393 |
+
um2.meta_value LIKE '%s:13:\"profile_photo\";b:0;%'"
|
2394 |
+
);
|
2395 |
+
|
2396 |
+
} else {
|
2397 |
+
|
2398 |
+
$results = $wpdb->get_col(
|
2399 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2400 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND ( um.meta_key = 'synced_profile_photo' || um.meta_key = 'profile_photo' ) )
|
2401 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2402 |
+
WHERE ( um.meta_value IS NULL OR um.meta_value = '' ) AND
|
2403 |
+
um2.meta_value LIKE '%s:13:\"profile_photo\";b:1;%'"
|
2404 |
+
);
|
2405 |
+
|
2406 |
+
}
|
2407 |
+
|
2408 |
+
if ( ! empty( $results ) ) {
|
2409 |
+
foreach ( $results as $user_id ) {
|
2410 |
+
$md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
|
2411 |
+
if ( ! empty( $md_data ) ) {
|
2412 |
+
$md_data['profile_photo'] = ! empty( $_POST['um_options']['use_gravatars'] );
|
2413 |
+
update_user_meta( $user_id, 'um_member_directory_data', $md_data );
|
2414 |
+
}
|
2415 |
+
}
|
2416 |
+
}
|
2417 |
+
}
|
2418 |
+
}
|
2419 |
+
|
2420 |
+
} elseif ( isset( $_POST['um_options']['member_directory_own_table'] ) ) {
|
2421 |
+
if ( empty( $_POST['um_options']['member_directory_own_table'] ) ) {
|
2422 |
+
global $wpdb;
|
2423 |
+
|
2424 |
+
$results = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}um_metadata LIMIT 1", ARRAY_A );
|
2425 |
+
|
2426 |
+
if ( ! empty( $results ) ) {
|
2427 |
+
$wpdb->query("TRUNCATE TABLE {$wpdb->prefix}um_metadata" );
|
2428 |
+
}
|
2429 |
+
|
2430 |
+
update_option( 'um_member_directory_truncated', time() );
|
2431 |
+
}
|
2432 |
+
} elseif ( isset( $_POST['um_options']['account_hide_in_directory_default'] ) ) {
|
2433 |
+
|
2434 |
+
global $wpdb;
|
2435 |
+
|
2436 |
+
if ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) {
|
2437 |
+
|
2438 |
+
$results = $wpdb->get_col(
|
2439 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2440 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
|
2441 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2442 |
+
WHERE um.meta_value IS NULL AND
|
2443 |
+
um2.meta_value LIKE '%s:15:\"hide_in_members\";b:1;%'"
|
2444 |
+
);
|
2445 |
+
|
2446 |
+
} else {
|
2447 |
+
|
2448 |
+
$results = $wpdb->get_col(
|
2449 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2450 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
|
2451 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2452 |
+
WHERE um.meta_value IS NULL AND
|
2453 |
+
um2.meta_value LIKE '%s:15:\"hide_in_members\";b:0;%'"
|
2454 |
+
);
|
2455 |
+
|
2456 |
+
}
|
2457 |
+
|
2458 |
+
if ( ! empty( $results ) ) {
|
2459 |
+
foreach ( $results as $user_id ) {
|
2460 |
+
$md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
|
2461 |
+
if ( ! empty( $md_data ) ) {
|
2462 |
+
$md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) ? false : true;
|
2463 |
+
update_user_meta( $user_id, 'um_member_directory_data', $md_data );
|
2464 |
+
}
|
2465 |
+
}
|
2466 |
+
}
|
2467 |
+
|
2468 |
+
}
|
2469 |
+
}
|
2470 |
+
}
|
2471 |
+
|
2472 |
+
|
2473 |
+
/**
|
2474 |
+
*
|
2475 |
+
*/
|
2476 |
+
function before_licenses_save() {
|
2477 |
+
if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
|
2478 |
+
return;
|
2479 |
+
}
|
2480 |
+
|
2481 |
+
foreach ( $_POST['um_options'] as $key => $value ) {
|
2482 |
+
$this->previous_licenses[ sanitize_key( $key ) ] = UM()->options()->get( $key );
|
2483 |
+
}
|
2484 |
+
}
|
2485 |
+
|
2486 |
+
|
2487 |
+
/**
|
2488 |
+
*
|
2489 |
+
*/
|
2490 |
+
function licenses_save() {
|
2491 |
+
if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
|
2492 |
+
return;
|
2493 |
+
}
|
2494 |
+
|
2495 |
+
foreach ( $_POST['um_options'] as $key => $value ) {
|
2496 |
+
$key = sanitize_key( $key );
|
2497 |
+
$value = sanitize_text_field( $value );
|
2498 |
+
|
2499 |
+
$edd_action = '';
|
2500 |
+
$license_key = '';
|
2501 |
+
if ( empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) && $this->previous_licenses[ $key ] != $value ) ) {
|
2502 |
+
$edd_action = 'activate_license';
|
2503 |
+
$license_key = $value;
|
2504 |
+
} elseif ( ! empty( $this->previous_licenses[ $key ] ) && empty( $value ) ) {
|
2505 |
+
$edd_action = 'deactivate_license';
|
2506 |
+
$license_key = $this->previous_licenses[ $key ];
|
2507 |
+
} elseif ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) ) {
|
2508 |
+
$edd_action = 'check_license';
|
2509 |
+
$license_key = $value;
|
2510 |
+
}
|
2511 |
+
|
2512 |
+
if ( empty( $edd_action ) ) {
|
2513 |
+
continue;
|
2514 |
+
}
|
2515 |
+
|
2516 |
+
$item_name = false;
|
2517 |
+
$version = false;
|
2518 |
+
$author = false;
|
2519 |
+
foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) {
|
2520 |
+
if ( $field_data['id'] == $key ) {
|
2521 |
+
$item_name = ! empty( $field_data['item_name'] ) ? $field_data['item_name'] : false;
|
2522 |
+
$version = ! empty( $field_data['version'] ) ? $field_data['version'] : false;
|
2523 |
+
$author = ! empty( $field_data['author'] ) ? $field_data['author'] : false;
|
2524 |
+
}
|
2525 |
+
}
|
2526 |
+
|
2527 |
+
$api_params = array(
|
2528 |
+
'edd_action' => $edd_action,
|
2529 |
+
'license' => $license_key,
|
2530 |
+
'item_name' => $item_name,
|
2531 |
+
'version' => $version,
|
2532 |
+
'author' => $author,
|
2533 |
+
'url' => home_url(),
|
2534 |
+
);
|
2535 |
+
|
2536 |
+
$request = wp_remote_post(
|
2537 |
+
UM()->store_url,
|
2538 |
+
array(
|
2539 |
+
'timeout' => UM()->request_timeout,
|
2540 |
+
'sslverify' => false,
|
2541 |
+
'body' => $api_params
|
2542 |
+
)
|
2543 |
+
);
|
2544 |
+
|
2545 |
+
if ( ! is_wp_error( $request ) ) {
|
2546 |
+
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
2547 |
+
} else {
|
2548 |
+
$request = wp_remote_post(
|
2549 |
+
UM()->store_url,
|
2550 |
+
array(
|
2551 |
+
'timeout' => UM()->request_timeout,
|
2552 |
+
'sslverify' => true,
|
2553 |
+
'body' => $api_params
|
2554 |
+
)
|
2555 |
+
);
|
2556 |
+
|
2557 |
+
if ( ! is_wp_error( $request ) ) {
|
2558 |
+
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
2559 |
+
}
|
2560 |
+
}
|
2561 |
+
|
2562 |
+
$request = ( $request ) ? maybe_unserialize( $request ) : false;
|
2563 |
+
|
2564 |
+
if ( $edd_action == 'activate_license' || $edd_action == 'check_license' ) {
|
2565 |
+
update_option( "{$key}_edd_answer", $request );
|
2566 |
+
} else {
|
2567 |
+
delete_option( "{$key}_edd_answer" );
|
2568 |
+
}
|
2569 |
+
|
2570 |
+
}
|
2571 |
+
}
|
2572 |
+
|
2573 |
+
|
2574 |
+
/**
|
2575 |
+
*
|
2576 |
+
*/
|
2577 |
+
function settings_before_email_tab() {
|
2578 |
+
$email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
|
2579 |
+
$emails = UM()->config()->email_notifications;
|
2580 |
+
|
2581 |
+
if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
|
2582 |
+
include_once um_path . 'includes/admin/core/list-tables/emails-list-table.php';
|
2583 |
+
}
|
2584 |
+
}
|
2585 |
+
|
2586 |
+
|
2587 |
+
/**
|
2588 |
+
* @param $section
|
2589 |
+
*
|
2590 |
+
* @return string
|
2591 |
+
*/
|
2592 |
+
function settings_email_tab( $section ) {
|
2593 |
+
$email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
|
2594 |
+
$emails = UM()->config()->email_notifications;
|
2595 |
+
|
2596 |
+
if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
|
2597 |
+
return $section;
|
2598 |
+
}
|
2599 |
+
|
2600 |
+
$in_theme = UM()->mail()->template_in_theme( $email_key );
|
2601 |
+
|
2602 |
+
/**
|
2603 |
+
* UM hook
|
2604 |
+
*
|
2605 |
+
* @type filter
|
2606 |
+
* @title um_admin_settings_email_section_fields
|
2607 |
+
* @description Extend UM Email Settings
|
2608 |
+
* @input_vars
|
2609 |
+
* [{"var":"$settings","type":"array","desc":"UM Email Settings"},
|
2610 |
+
* {"var":"$email_key","type":"string","desc":"Email Key"}]
|
2611 |
+
* @change_log
|
2612 |
+
* ["Since: 2.0"]
|
2613 |
+
* @usage add_filter( 'um_admin_settings_email_section_fields', 'function_name', 10, 2 );
|
2614 |
+
* @example
|
2615 |
+
* <?php
|
2616 |
+
* add_filter( 'um_admin_settings_email_section_fields', 'my_admin_settings_email_section', 10, 2 );
|
2617 |
+
* function my_admin_settings_email_section( $settings, $email_key ) {
|
2618 |
+
* // your code here
|
2619 |
+
* return $settings;
|
2620 |
+
* }
|
2621 |
+
* ?>
|
2622 |
+
*/
|
2623 |
+
$section_fields = apply_filters( 'um_admin_settings_email_section_fields', array(
|
2624 |
+
array(
|
2625 |
+
'id' => 'um_email_template',
|
2626 |
+
'type' => 'hidden',
|
2627 |
+
'value' => $email_key,
|
2628 |
+
),
|
2629 |
+
array(
|
2630 |
+
'id' => $email_key . '_on',
|
2631 |
+
'type' => 'checkbox',
|
2632 |
+
'label' => $emails[ $email_key ]['title'],
|
2633 |
+
'tooltip' => $emails[ $email_key ]['description'],
|
2634 |
+
),
|
2635 |
+
array(
|
2636 |
+
'id' => $email_key . '_sub',
|
2637 |
+
'type' => 'text',
|
2638 |
+
'label' => __( 'Subject Line', 'ultimate-member' ),
|
2639 |
+
'conditional' => array( $email_key . '_on', '=', 1 ),
|
2640 |
+
'tooltip' => __( 'This is the subject line of the e-mail', 'ultimate-member' ),
|
2641 |
+
),
|
2642 |
+
array(
|
2643 |
+
'id' => $email_key,
|
2644 |
+
'type' => 'email_template',
|
2645 |
+
'label' => __( 'Message Body', 'ultimate-member' ),
|
2646 |
+
'conditional' => array( $email_key . '_on', '=', 1 ),
|
2647 |
+
'tooltip' => __( 'This is the content of the e-mail', 'ultimate-member' ),
|
2648 |
+
'value' => UM()->mail()->get_email_template( $email_key ),
|
2649 |
+
'in_theme' => $in_theme
|
2650 |
+
),
|
2651 |
+
), $email_key );
|
2652 |
+
|
2653 |
+
return $this->render_settings_section( $section_fields, 'email', $email_key );
|
2654 |
+
}
|
2655 |
+
|
2656 |
+
|
2657 |
+
/**
|
2658 |
+
*
|
2659 |
+
*/
|
2660 |
+
function settings_appearance_profile_tab() {
|
2661 |
+
wp_enqueue_media();
|
2662 |
+
}
|
2663 |
+
|
2664 |
+
|
2665 |
+
/**
|
2666 |
+
* @param $html
|
2667 |
+
* @param $section_fields
|
2668 |
+
*
|
2669 |
+
* @return string
|
2670 |
+
*/
|
2671 |
+
function settings_licenses_tab( $html, $section_fields ) {
|
2672 |
+
ob_start(); ?>
|
2673 |
+
|
2674 |
+
<div class="wrap-licenses">
|
2675 |
+
<input type="hidden" id="licenses_settings" name="licenses_settings" value="1">
|
2676 |
+
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2677 |
+
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2678 |
+
<table class="form-table um-settings-section">
|
2679 |
+
<tbody>
|
2680 |
+
<?php foreach ( $section_fields as $field_data ) {
|
2681 |
+
$option_value = UM()->options()->get( $field_data['id'] );
|
2682 |
+
$value = isset( $option_value ) && ! empty( $option_value ) ? $option_value : ( isset( $field_data['default'] ) ? $field_data['default'] : '' );
|
2683 |
+
|
2684 |
+
$license = get_option( "{$field_data['id']}_edd_answer" );
|
2685 |
+
|
2686 |
+
if ( is_object( $license ) && ! empty( $value ) ) {
|
2687 |
+
// activate_license 'invalid' on anything other than valid, so if there was an error capture it
|
2688 |
+
if ( empty( $license->success ) ) {
|
2689 |
+
|
2690 |
+
if ( ! empty( $license->error ) ) {
|
2691 |
+
switch ( $license->error ) {
|
2692 |
+
|
2693 |
+
case 'expired' :
|
2694 |
+
|
2695 |
+
$class = 'expired';
|
2696 |
+
$messages[] = sprintf(
|
2697 |
+
__( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
|
2698 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2699 |
+
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
|
2700 |
+
);
|
2701 |
+
|
2702 |
+
$license_status = 'license-' . $class . '-notice';
|
2703 |
+
|
2704 |
+
break;
|
2705 |
+
|
2706 |
+
case 'revoked' :
|
2707 |
+
|
2708 |
+
$class = 'error';
|
2709 |
+
$messages[] = sprintf(
|
2710 |
+
__( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
|
2711 |
+
'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
|
2712 |
+
);
|
2713 |
+
|
2714 |
+
$license_status = 'license-' . $class . '-notice';
|
2715 |
+
|
2716 |
+
break;
|
2717 |
+
|
2718 |
+
case 'missing' :
|
2719 |
+
|
2720 |
+
$class = 'error';
|
2721 |
+
$messages[] = sprintf(
|
2722 |
+
__( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
|
2723 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
|
2724 |
+
);
|
2725 |
+
|
2726 |
+
$license_status = 'license-' . $class . '-notice';
|
2727 |
+
|
2728 |
+
break;
|
2729 |
+
|
2730 |
+
case 'invalid' :
|
2731 |
+
case 'site_inactive' :
|
2732 |
+
|
2733 |
+
$class = 'error';
|
2734 |
+
$messages[] = sprintf(
|
2735 |
+
__( 'Your %s is not active for this URL. Please <a href="%s" target="_blank">visit your account page</a> to manage your license key URLs.', 'ultimate-member' ),
|
2736 |
+
$field_data['item_name'],
|
2737 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
|
2738 |
+
);
|
2739 |
+
|
2740 |
+
$license_status = 'license-' . $class . '-notice';
|
2741 |
+
|
2742 |
+
break;
|
2743 |
+
|
2744 |
+
case 'item_name_mismatch' :
|
2745 |
+
|
2746 |
+
$class = 'error';
|
2747 |
+
$messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
|
2748 |
+
|
2749 |
+
$license_status = 'license-' . $class . '-notice';
|
2750 |
+
|
2751 |
+
break;
|
2752 |
+
|
2753 |
+
case 'no_activations_left':
|
2754 |
+
|
2755 |
+
$class = 'error';
|
2756 |
+
$messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
|
2757 |
+
|
2758 |
+
$license_status = 'license-' . $class . '-notice';
|
2759 |
+
|
2760 |
+
break;
|
2761 |
+
|
2762 |
+
case 'license_not_activable':
|
2763 |
+
|
2764 |
+
$class = 'error';
|
2765 |
+
$messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
|
2766 |
+
|
2767 |
+
$license_status = 'license-' . $class . '-notice';
|
2768 |
+
break;
|
2769 |
+
|
2770 |
+
default :
|
2771 |
+
|
2772 |
+
$class = 'error';
|
2773 |
+
$error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
|
2774 |
+
$messages[] = sprintf( __( 'There was an error with this license key: %s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, 'https://ultimatemember.com/support' );
|
2775 |
+
|
2776 |
+
$license_status = 'license-' . $class . '-notice';
|
2777 |
+
break;
|
2778 |
+
}
|
2779 |
+
} else {
|
2780 |
+
$class = 'error';
|
2781 |
+
$error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
|
2782 |
+
$messages[] = sprintf( __( 'There was an error with this license key: %s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, 'https://ultimatemember.com/support' );
|
2783 |
+
|
2784 |
+
$license_status = 'license-' . $class . '-notice';
|
2785 |
+
}
|
2786 |
+
|
2787 |
+
} elseif ( ! empty( $license->errors ) ) {
|
2788 |
+
|
2789 |
+
$errors = array_keys( $license->errors );
|
2790 |
+
$errors_data = array_values( $license->errors );
|
2791 |
+
|
2792 |
+
$class = 'error';
|
2793 |
+
$error = ! empty( $errors[0] ) ? $errors[0] : __( 'unknown_error', 'ultimate-member' );
|
2794 |
+
$errors_data = ! empty( $errors_data[0][0] ) ? ', ' . $errors_data[0][0] : '';
|
2795 |
+
$messages[] = sprintf( __( 'There was an error with this license key: %s%s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, $errors_data, 'https://ultimatemember.com/support' );
|
2796 |
+
|
2797 |
+
$license_status = 'license-' . $class . '-notice';
|
2798 |
+
|
2799 |
+
} else {
|
2800 |
+
|
2801 |
+
switch( $license->license ) {
|
2802 |
+
|
2803 |
+
case 'expired' :
|
2804 |
+
|
2805 |
+
$class = 'expired';
|
2806 |
+
$messages[] = sprintf(
|
2807 |
+
__( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
|
2808 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2809 |
+
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
|
2810 |
+
);
|
2811 |
+
|
2812 |
+
$license_status = 'license-' . $class . '-notice';
|
2813 |
+
|
2814 |
+
break;
|
2815 |
+
|
2816 |
+
case 'revoked' :
|
2817 |
+
|
2818 |
+
$class = 'error';
|
2819 |
+
$messages[] = sprintf(
|
2820 |
+
__( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
|
2821 |
+
'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
|
2822 |
+
);
|
2823 |
+
|
2824 |
+
$license_status = 'license-' . $class . '-notice';
|
2825 |
+
|
2826 |
+
break;
|
2827 |
+
|
2828 |
+
case 'missing' :
|
2829 |
+
|
2830 |
+
$class = 'error';
|
2831 |
+
$messages[] = sprintf(
|
2832 |
+
__( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
|
2833 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
|
2834 |
+
);
|
2835 |
+
|
2836 |
+
$license_status = 'license-' . $class . '-notice';
|
2837 |
+
|
2838 |
+
break;
|
2839 |
+
|
2840 |
+
case 'invalid' :
|
2841 |
+
case 'site_inactive' :
|
2842 |
+
|
2843 |
+
$class = 'error';
|
2844 |
+
$messages[] = sprintf(
|
2845 |
+
__( 'Your %s is not active for this URL. Please <a href="%s" target="_blank">visit your account page</a> to manage your license key URLs.', 'ultimate-member' ),
|
2846 |
+
$field_data['item_name'],
|
2847 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
|
2848 |
+
);
|
2849 |
+
|
2850 |
+
$license_status = 'license-' . $class . '-notice';
|
2851 |
+
|
2852 |
+
break;
|
2853 |
+
|
2854 |
+
case 'item_name_mismatch' :
|
2855 |
+
|
2856 |
+
$class = 'error';
|
2857 |
+
$messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
|
2858 |
+
|
2859 |
+
$license_status = 'license-' . $class . '-notice';
|
2860 |
+
|
2861 |
+
break;
|
2862 |
+
|
2863 |
+
case 'no_activations_left':
|
2864 |
+
|
2865 |
+
$class = 'error';
|
2866 |
+
$messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
|
2867 |
+
|
2868 |
+
$license_status = 'license-' . $class . '-notice';
|
2869 |
+
|
2870 |
+
break;
|
2871 |
+
|
2872 |
+
case 'license_not_activable':
|
2873 |
+
|
2874 |
+
$class = 'error';
|
2875 |
+
$messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
|
2876 |
+
|
2877 |
+
$license_status = 'license-' . $class . '-notice';
|
2878 |
+
break;
|
2879 |
+
|
2880 |
+
case 'valid' :
|
2881 |
+
default:
|
2882 |
+
|
2883 |
+
$class = 'valid';
|
2884 |
+
|
2885 |
+
$now = current_time( 'timestamp' );
|
2886 |
+
$expiration = strtotime( $license->expires, $now );
|
2887 |
+
|
2888 |
+
if( 'lifetime' === $license->expires ) {
|
2889 |
+
|
2890 |
+
$messages[] = __( 'License key never expires.', 'ultimate-member' );
|
2891 |
+
|
2892 |
+
$license_status = 'license-lifetime-notice';
|
2893 |
+
|
2894 |
+
} elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
|
2895 |
+
|
2896 |
+
$messages[] = sprintf(
|
2897 |
+
__( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank">Renew your license key</a>.', 'ultimate-member' ),
|
2898 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2899 |
+
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
|
2900 |
+
);
|
2901 |
+
|
2902 |
+
$license_status = 'license-expires-soon-notice';
|
2903 |
+
|
2904 |
+
} else {
|
2905 |
+
|
2906 |
+
$messages[] = sprintf(
|
2907 |
+
__( 'Your license key expires on %s.', 'ultimate-member' ),
|
2908 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
|
2909 |
+
);
|
2910 |
+
|
2911 |
+
$license_status = 'license-expiration-date-notice';
|
2912 |
+
|
2913 |
+
}
|
2914 |
+
|
2915 |
+
break;
|
2916 |
+
|
2917 |
+
}
|
2918 |
+
|
2919 |
+
}
|
2920 |
+
|
2921 |
+
} else {
|
2922 |
+
$class = 'empty';
|
2923 |
+
|
2924 |
+
$messages[] = sprintf(
|
2925 |
+
__( 'To receive updates, please enter your valid %s license key.', 'ultimate-member' ),
|
2926 |
+
$field_data['item_name']
|
2927 |
+
);
|
2928 |
+
|
2929 |
+
$license_status = null;
|
2930 |
+
|
2931 |
+
} ?>
|
2932 |
+
|
2933 |
+
<tr class="um-settings-line">
|
2934 |
+
<th><label for="um_options_<?php echo esc_attr( $field_data['id'] ) ?>"><?php echo esc_html( $field_data['label'] ) ?></label></th>
|
2935 |
+
<td>
|
2936 |
+
<form method="post" action="" name="um-settings-form" class="um-settings-form">
|
2937 |
+
<input type="hidden" value="save" name="um-settings-action" />
|
2938 |
+
<input type="hidden" name="licenses_settings" value="1" />
|
2939 |
+
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2940 |
+
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2941 |
+
<input type="text" id="um_options_<?php echo esc_attr( $field_data['id'] ) ?>" name="um_options[<?php echo esc_attr( $field_data['id'] ) ?>]" value="<?php echo $value ?>" class="um-option-field um-long-field" data-field_id="<?php echo esc_attr( $field_data['id'] ) ?>" />
|
2942 |
+
<?php if ( ! empty( $field_data['description'] ) ) { ?>
|
2943 |
+
<div class="description"><?php echo $field_data['description'] ?></div>
|
2944 |
+
<?php } ?>
|
2945 |
+
|
2946 |
+
<?php if ( ! empty( $value ) && ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) ) { ?>
|
2947 |
+
<input type="button" class="button um_license_deactivate" id="<?php echo esc_attr( $field_data['id'] ) ?>_deactivate" value="<?php esc_attr_e( 'Clear License', 'ultimate-member' ) ?>"/>
|
2948 |
+
<?php } elseif ( empty( $value ) ) { ?>
|
2949 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Activate', 'ultimate-member' ) ?>" />
|
2950 |
+
<?php } else { ?>
|
2951 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Re-Activate', 'ultimate-member' ) ?>" />
|
2952 |
+
<?php }
|
2953 |
+
|
2954 |
+
if ( ! empty( $messages ) ) {
|
2955 |
+
foreach ( $messages as $message ) { ?>
|
2956 |
+
<div class="edd-license-data edd-license-<?php echo esc_attr( $class . ' ' . $license_status ) ?>">
|
2957 |
+
<p><?php echo $message ?></p>
|
2958 |
+
</div>
|
2959 |
+
<?php }
|
2960 |
+
} ?>
|
2961 |
+
</form>
|
2962 |
+
</td>
|
2963 |
+
</tr>
|
2964 |
+
<?php } ?>
|
2965 |
+
</tbody>
|
2966 |
+
</table>
|
2967 |
+
</div>
|
2968 |
+
<?php $section = ob_get_clean();
|
2969 |
+
|
2970 |
+
return $section;
|
2971 |
+
}
|
2972 |
+
|
2973 |
+
|
2974 |
+
/**
|
2975 |
+
* @param $html
|
2976 |
+
* @param $section_fields
|
2977 |
+
*/
|
2978 |
+
function settings_install_info_tab( $html, $section_fields ) {
|
2979 |
+
global $wpdb;
|
2980 |
+
|
2981 |
+
if ( ! class_exists( '\Browser' ) )
|
2982 |
+
require_once um_path . 'includes/lib/browser.php';
|
2983 |
+
|
2984 |
+
// Detect browser
|
2985 |
+
$browser = new \Browser();
|
2986 |
+
|
2987 |
+
// Get theme info
|
2988 |
+
$theme_data = wp_get_theme();
|
2989 |
+
$theme = $theme_data->Name . ' ' . $theme_data->Version;
|
2990 |
+
|
2991 |
+
// Identify Hosting Provider
|
2992 |
+
$host = um_get_host();
|
2993 |
+
|
2994 |
+
um_fetch_user( get_current_user_id() );
|
2995 |
+
|
2996 |
+
if ( isset( $this->content ) ) {
|
2997 |
+
echo $this->content;
|
2998 |
+
} else { ?>
|
2999 |
+
|
3000 |
+
<h3>Install Info</h3>
|
3001 |
+
|
3002 |
+
<form action="" method="post" dir="ltr">
|
3003 |
+
<textarea style="width:70%; height:400px;" readonly="readonly" onclick="this.focus();this.select()" id="install-info-textarea" name="um-install-info" title="<?php _e( 'To copy the Install info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'ultimate-member' ); ?>">
|
3004 |
+
### Begin Install Info ###
|
3005 |
+
|
3006 |
+
## Please include this information when posting support requests ##
|
3007 |
+
|
3008 |
+
<?php
|
3009 |
+
/**
|
3010 |
+
* UM hook
|
3011 |
+
*
|
3012 |
+
* @type action
|
3013 |
+
* @title um_install_info_before
|
3014 |
+
* @description Before install info settings
|
3015 |
+
* @change_log
|
3016 |
+
* ["Since: 2.0"]
|
3017 |
+
* @usage add_action( 'um_install_info_before', 'function_name', 10 );
|
3018 |
+
* @example
|
3019 |
+
* <?php
|
3020 |
+
* add_action( 'um_install_info_before', 'my_install_info_before', 10 );
|
3021 |
+
* function my_install_info_before() {
|
3022 |
+
* // your code here
|
3023 |
+
* }
|
3024 |
+
* ?>
|
3025 |
+
*/
|
3026 |
+
do_action( 'um_install_info_before' ); ?>
|
3027 |
+
|
3028 |
+
--- Site Info ---
|
3029 |
+
|
3030 |
+
Site URL: <?php echo site_url() . "\n"; ?>
|
3031 |
+
Home URL: <?php echo home_url() . "\n"; ?>
|
3032 |
+
Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
|
3033 |
+
|
3034 |
+
--- Hosting Provider ---
|
3035 |
+
|
3036 |
+
<?php if( $host ) : ?>
|
3037 |
+
Host: <?php echo $host . "\n"; ?>
|
3038 |
+
<?php endif; ?>
|
3039 |
+
|
3040 |
+
--- User Browser ---
|
3041 |
+
|
3042 |
+
<?php echo $browser ; ?>
|
3043 |
+
|
3044 |
+
---- Current User Details --
|
3045 |
+
|
3046 |
+
<?php $user = wp_get_current_user(); ?>
|
3047 |
+
Role: <?php echo implode( ', ', um_user( 'roles' ) ). "\n"; ?>
|
3048 |
+
|
3049 |
+
|
3050 |
+
--- WordPress Configurations ---
|
3051 |
+
|
3052 |
+
Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
|
3053 |
+
Language: <?php echo get_locale()."\n"; ?>
|
3054 |
+
Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
|
3055 |
+
Active Theme: <?php echo $theme . "\n"; ?>
|
3056 |
+
<?php $show_on_front = get_option( 'show_on_front' ); ?>
|
3057 |
+
<?php if( $show_on_front == "posts" ): ?>
|
3058 |
+
Show On Front: <?php echo get_option( 'show_on_front' ) . "/static\n" ?>
|
3059 |
+
<?php elseif( $show_on_front == "page" ): ?>
|
3060 |
+
Page On Front: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
|
3061 |
+
Page For Posts: <?php $id = get_option( 'page_for_posts' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
|
3062 |
+
<?php endif; ?>
|
3063 |
+
ABSPATH: <?php echo ABSPATH."\n"; ?>
|
3064 |
+
<?php $wp_count_posts = wp_count_posts(); ?>
|
3065 |
+
All Posts/Pages: <?php echo array_sum((array)$wp_count_posts)."\n";?>
|
3066 |
+
<?php
|
3067 |
+
$request['cmd'] = '_notify-validate';
|
3068 |
+
|
3069 |
+
$params = array(
|
3070 |
+
'sslverify' => false,
|
3071 |
+
'timeout' => 60,
|
3072 |
+
'user-agent' => 'UltimateMember/' . ultimatemember_version,
|
3073 |
+
'body' => $request
|
3074 |
+
);
|
3075 |
+
|
3076 |
+
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
|
3077 |
+
|
3078 |
+
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
|
3079 |
+
$WP_REMOTE_POST = 'wp_remote_post() works' . "\n";
|
3080 |
+
} else {
|
3081 |
+
$WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n";
|
3082 |
+
}
|
3083 |
+
?>
|
3084 |
+
WP Remote Post: <?php echo $WP_REMOTE_POST; ?>
|
3085 |
+
WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
|
3086 |
+
WP Table Prefix: <?php echo "Length: ". strlen( $wpdb->prefix ); echo ", Status:"; if ( strlen( $wpdb->prefix )>16 ) {echo " ERROR: Too Long";} else {echo " Acceptable";} echo "\n"; ?>
|
3087 |
+
Memory Limit: <?php echo ( um_let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>
|
3088 |
+
|
3089 |
+
|
3090 |
+
--- UM Configurations ---
|
3091 |
+
|
3092 |
+
Version: <?php echo ultimatemember_version . "\n"; ?>
|
3093 |
+
Upgraded From: <?php echo get_option( 'um_last_version_upgrade', 'None' ) . "\n"; ?>
|
3094 |
+
Current URL Method: <?php echo UM()->options()->get( 'current_url_method' ). "\n"; ?>
|
3095 |
+
Cache User Profile: <?php if( UM()->options()->get( 'um_profile_object_cache_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
|
3096 |
+
Generate Slugs on Directories: <?php if( UM()->options()->get( 'um_generate_slug_in_directory' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
|
3097 |
+
Force UTF-8 Encoding: <?php if( UM()->options()->get( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3098 |
+
JS/CSS Compression: <?php if ( defined('SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3099 |
+
<?php if( is_multisite() ): ?>
|
3100 |
+
Network Structure: <?php echo UM()->options()->get( 'network_permalink_structure' ). "\n"; ?>
|
3101 |
+
<?php endif; ?>
|
3102 |
+
Port Forwarding in URL: <?php if( UM()->options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3103 |
+
Exclude CSS/JS on Home: <?php if( UM()->options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3104 |
+
|
3105 |
+
|
3106 |
+
--- UM Pages Configuration ---
|
3107 |
+
|
3108 |
+
<?php
|
3109 |
+
/**
|
3110 |
+
* UM hook
|
3111 |
+
*
|
3112 |
+
* @type action
|
3113 |
+
* @title um_install_info_before_page_config
|
3114 |
+
* @description Before page config install info
|
3115 |
+
* @change_log
|
3116 |
+
* ["Since: 2.0"]
|
3117 |
+
* @usage add_action( 'um_install_info_before_page_config', 'function_name', 10 );
|
3118 |
+
* @example
|
3119 |
+
* <?php
|
3120 |
+
* add_action( 'um_install_info_before_page_config', 'my_install_info_before_page_config', 10 );
|
3121 |
+
* function my_install_info_before_page_config() {
|
3122 |
+
* // your code here
|
3123 |
+
* }
|
3124 |
+
* ?>
|
3125 |
+
*/
|
3126 |
+
do_action( "um_install_info_before_page_config" ); ?>
|
3127 |
+
User: <?php echo get_permalink( UM()->options()->get('core_user') ) . "\n"; ?>
|
3128 |
+
Account: <?php echo get_permalink( UM()->options()->get('core_account') ) . "\n"; ?>
|
3129 |
+
Members: <?php echo get_permalink( UM()->options()->get('core_members') ) . "\n"; ?>
|
3130 |
+
Register: <?php echo get_permalink( UM()->options()->get('core_register') ) . "\n"; ?>
|
3131 |
+
Login: <?php echo get_permalink( UM()->options()->get('core_login') ) . "\n"; ?>
|
3132 |
+
Logout: <?php echo get_permalink( UM()->options()->get('core_logout') ) . "\n"; ?>
|
3133 |
+
Password Reset: <?php echo get_permalink( UM()->options()->get('core_password-reset') ) . "\n"; ?>
|
3134 |
+
<?php
|
3135 |
+
/**
|
3136 |
+
* UM hook
|
3137 |
+
*
|
3138 |
+
* @type action
|
3139 |
+
* @title um_install_info_after_page_config
|
3140 |
+
* @description After page config install info
|
3141 |
+
* @change_log
|
3142 |
+
* ["Since: 2.0"]
|
3143 |
+
* @usage add_action( 'um_install_info_after_page_config', 'function_name', 10 );
|
3144 |
+
* @example
|
3145 |
+
* <?php
|
3146 |
+
* add_action( 'um_install_info_after_page_config', 'my_install_info_after_page_config', 10 );
|
3147 |
+
* function my_install_info_after_page_config() {
|
3148 |
+
* // your code here
|
3149 |
+
* }
|
3150 |
+
* ?>
|
3151 |
+
*/
|
3152 |
+
do_action( "um_install_info_after_page_config" ); ?>
|
3153 |
+
|
3154 |
+
|
3155 |
+
--- UM Users Configuration ---
|
3156 |
+
|
3157 |
+
Default New User Role: <?php echo UM()->options()->get('register_role') . "\n"; ?>
|
3158 |
+
Profile Permalink Base: <?php echo UM()->options()->get('permalink_base') . "\n"; ?>
|
3159 |
+
User Display Name: <?php echo UM()->options()->get('display_name') . "\n"; ?>
|
3160 |
+
Force Name to Uppercase: <?php echo $this->info_value( UM()->options()->get('force_display_name_capitlized'), 'yesno', true ); ?>
|
3161 |
+
Redirect author to profile: <?php echo $this->info_value( UM()->options()->get('author_redirect'), 'yesno', true ); ?>
|
3162 |
+
Enable Members Directory: <?php echo $this->info_value( UM()->options()->get('members_page'), 'yesno', true ); ?>
|
3163 |
+
Use Gravatars: <?php echo $this->info_value( UM()->options()->get('use_gravatars'), 'yesno', true ); ?>
|
3164 |
+
<?php if( UM()->options()->get('use_gravatars') ): ?>Gravatar builtin image: <?php echo UM()->options()->get('use_um_gravatar_default_builtin_image') . "\n"; ?>
|
3165 |
+
UM Avatar as blank Gravatar: <?php echo $this->info_value( UM()->options()->get('use_um_gravatar_default_image'), 'yesno', true ); ?><?php endif; ?>
|
3166 |
+
Require a strong password: <?php echo $this->info_value( UM()->options()->get('require_strongpass'), 'onoff', true ); ?>
|
3167 |
+
|
3168 |
+
|
3169 |
+
--- UM Access Configuration ---
|
3170 |
+
|
3171 |
+
Panic Key: <?php echo UM()->options()->get('panic_key') . "\n"; ?>
|
3172 |
+
Global Site Access: <?php $arr = array('Site accessible to Everyone','','Site accessible to Logged In Users'); echo $arr[ (int) UM()->options()->get('accessible') ] . "\n"; ?>
|
3173 |
+
<?php if( UM()->options()->get('accessible') == 2 ) { ?>
|
3174 |
+
Custom Redirect URL: <?php echo UM()->options()->get('access_redirect')."\n";?>
|
3175 |
+
Exclude the following URLs:<?php echo "\t\t\t\t".implode("\t\n\t\t\t\t\t\t\t\t\t\t",UM()->options()->get('access_exclude_uris') )."\n";?>
|
3176 |
+
<?php } ?>
|
3177 |
+
Backend Login Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_login'), 'yesno', true ); ?>
|
3178 |
+
<?php if( ! UM()->options()->get('wpadmin_login') ) { ?>
|
3179 |
+
Redirect to alternative login page: <?php if( UM()->options()->get('wpadmin_login_redirect') == 'um_login_page' ){ echo um_get_core_page('login')."\n"; }else{ echo UM()->options()->get('wpadmin_login_redirect_url')."\n"; }?>
|
3180 |
+
<?php } ?>
|
3181 |
+
Backend Register Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_register'), 'yesno', true ); ?>
|
3182 |
+
<?php if( ! UM()->options()->get('wpadmin_register') ) { ?>
|
3183 |
+
Redirect to alternative register page: <?php if( UM()->options()->get('wpadmin_register_redirect') == 'um_register_page' ){ echo um_get_core_page('register')."\n"; }else{ echo UM()->options()->get('wpadmin_register_redirect_url')."\n"; }?>
|
3184 |
+
<?php } ?>
|
3185 |
+
Access Control widget for Admins only: <?php echo $this->info_value( UM()->options()->get('access_widget_admin_only'), 'yesno', true ); ?>
|
3186 |
+
Enable the Reset Password Limit: <?php echo $this->info_value( UM()->options()->get('enable_reset_password_limit'), 'yesno', true ); ?>
|
3187 |
+
<?php if( UM()->options()->get('enable_reset_password_limit') ) { ?>
|
3188 |
+
Reset Password Limit: <?php echo UM()->options()->get('reset_password_limit_number') ?>
|
3189 |
+
Disable Reset Password Limit for Admins: <?php echo $this->info_value( UM()->options()->get('disable_admin_reset_password_limit'), 'yesno', true ) ?>
|
3190 |
+
<?php } ?>
|
3191 |
+
<?php $wpadmin_allow_ips = UM()->options()->get( 'wpadmin_allow_ips' ); if( ! empty( $wpadmin_allow_ips ) ) { ?>
|
3192 |
+
Whitelisted Backend IPs: <?php echo count( explode("\n",trim(UM()->options()->get('wpadmin_allow_ips') ) ) )."\n"; ?>
|
3193 |
+
<?php } ?>
|
3194 |
+
<?php $blocked_ips = UM()->options()->get('blocked_ips'); if( ! empty( $blocked_ips ) ){ ?>
|
3195 |
+
Blocked IP Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_ips') ) )."\n"; ?>
|
3196 |
+
<?php } ?>
|
3197 |
+
<?php $blocked_emails = UM()->options()->get('blocked_emails'); if( ! empty( $blocked_emails ) ){ ?>
|
3198 |
+
Blocked Email Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_emails') ) )."\n"; ?>
|
3199 |
+
<?php } ?>
|
3200 |
+
<?php $blocked_words = UM()->options()->get('blocked_words'); if( ! empty( $blocked_words ) ){ ?>
|
3201 |
+
Blacklist Words: <?php echo count( explode("\n",UM()->options()->get('blocked_words') ) )."\n"; ?>
|
3202 |
+
<?php } ?>
|
3203 |
+
|
3204 |
+
|
3205 |
+
--- UM Email Configurations ---
|
3206 |
+
|
3207 |
+
Mail appears from: <?php $mail_from = UM()->options()->get('mail_from'); if( ! empty( $mail_from ) ){echo UM()->options()->get('mail_from');}else{echo "-";}; echo "\n";?>
|
3208 |
+
Mail appears from address: <?php $mail_from_addr = UM()->options()->get('mail_from_addr'); if( ! empty( $mail_from_addr ) ){echo UM()->options()->get('mail_from_addr');}else{echo "-";}; echo "\n";?>
|
3209 |
+
Use HTML for E-mails: <?php echo $this->info_value( UM()->options()->get('email_html'), 'yesno', true ); ?>
|
3210 |
+
Account Welcome Email: <?php echo $this->info_value( UM()->options()->get('welcome_email_on'), 'yesno', true ); ?>
|
3211 |
+
Account Activation Email: <?php echo $this->info_value( UM()->options()->get('checkmail_email_on'), 'yesno', true ); ?>
|
3212 |
+
Pending Review Email: <?php echo $this->info_value( UM()->options()->get('pending_email_on'), 'yesno', true ); ?>
|
3213 |
+
Account Approved Email: <?php echo $this->info_value( UM()->options()->get('approved_email_on'), 'yesno', true ); ?>
|
3214 |
+
Account Rejected Email: <?php echo $this->info_value( UM()->options()->get('rejected_email_on'), 'yesno', true ); ?>
|
3215 |
+
Account Deactivated Email: <?php echo $this->info_value( UM()->options()->get('inactive_email_on'), 'yesno', true ); ?>
|
3216 |
+
Account Deleted Email: <?php echo $this->info_value( UM()->options()->get('deletion_email_on'), 'yesno', true ); ?>
|
3217 |
+
Password Reset Email: <?php echo $this->info_value( UM()->options()->get('resetpw_email_on'), 'yesno', true ); ?>
|
3218 |
+
Password Changed Email: <?php echo $this->info_value( UM()->options()->get('changedpw_email_on'), 'yesno', true ); ?>
|
3219 |
+
|
3220 |
+
|
3221 |
+
--- UM Total Users ---
|
3222 |
+
|
3223 |
+
<?php $result = count_users();
|
3224 |
+
echo 'All Users('.$result['total_users'].")\n";
|
3225 |
+
foreach( $result['avail_roles'] as $role => $count ) {
|
3226 |
+
echo $role."(".$count.")\n";
|
3227 |
+
} ?>
|
3228 |
+
|
3229 |
+
|
3230 |
+
--- UM Roles ---
|
3231 |
+
|
3232 |
+
<?php foreach( UM()->roles()->get_roles() as $role_id => $role ) {
|
3233 |
+
echo $role." ({$role_id})\n";
|
3234 |
+
} ?>
|
3235 |
+
|
3236 |
+
|
3237 |
+
--- UM Custom Templates ---
|
3238 |
+
|
3239 |
+
<?php // Show templates that have been copied to the theme's edd_templates dir
|
3240 |
+
$dir = get_stylesheet_directory() . '/ultimate-member/templates/*.php';
|
3241 |
+
if ( ! empty( $dir ) ) {
|
3242 |
+
$found = glob( $dir );
|
3243 |
+
if ( ! empty( $found ) ) {
|
3244 |
+
foreach ( glob( $dir ) as $file ) {
|
3245 |
+
echo "File: " . $file . "\n";
|
3246 |
+
}
|
3247 |
+
} else {
|
3248 |
+
echo 'N/A'."\n";
|
3249 |
+
}
|
3250 |
+
} ?>
|
3251 |
+
|
3252 |
+
|
3253 |
+
--- UM Email HTML Templates ---
|
3254 |
+
|
3255 |
+
<?php $dir = get_stylesheet_directory() . '/ultimate-member/templates/emails/*.html';
|
3256 |
+
|
3257 |
+
if ( ! empty( $dir ) ) {
|
3258 |
+
$found = glob( $dir );
|
3259 |
+
if ( ! empty( $found ) ){
|
3260 |
+
foreach ( glob( $dir ) as $file ) {
|
3261 |
+
echo "File: ". $file . "\n";
|
3262 |
+
}
|
3263 |
+
} else {
|
3264 |
+
echo 'N/A'."\n";
|
3265 |
+
}
|
3266 |
+
} ?>
|
3267 |
+
|
3268 |
+
|
3269 |
+
--- Web Server Configurations ---
|
3270 |
+
|
3271 |
+
PHP Version: <?php echo PHP_VERSION . "\n"; ?>
|
3272 |
+
MySQL Version: <?php echo $wpdb->db_version() . "\n"; ?>
|
3273 |
+
Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
|
3274 |
+
|
3275 |
+
|
3276 |
+
--- PHP Configurations ---
|
3277 |
+
|
3278 |
+
PHP Memory Limit: <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
|
3279 |
+
PHP Upload Max Size: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
|
3280 |
+
PHP Post Max Size: <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
|
3281 |
+
PHP Upload Max Filesize: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
|
3282 |
+
PHP Time Limit: <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
|
3283 |
+
PHP Max Input Vars: <?php echo ini_get( 'max_input_vars' ) . "\n"; ?>
|
3284 |
+
PHP Arg Separator: <?php echo ini_get( 'arg_separator.output' ) . "\n"; ?>
|
3285 |
+
PHP Allow URL File Open: <?php echo ini_get( 'allow_url_fopen' ) ? "Yes\n" : "No\n"; ?>
|
3286 |
+
|
3287 |
+
|
3288 |
+
--- Web Server Extensions/Modules ---
|
3289 |
+
|
3290 |
+
DISPLAY ERRORS: <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
|
3291 |
+
FSOCKOPEN: <?php echo ( function_exists( 'fsockopen' ) ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; ?><?php echo "\n"; ?>
|
3292 |
+
cURL: <?php echo ( function_exists( 'curl_init' ) ) ? 'Your server supports cURL.' : 'Your server does not support cURL.'; ?><?php echo "\n"; ?>
|
3293 |
+
SOAP Client: <?php echo ( class_exists( 'SoapClient' ) ) ? 'Your server has the SOAP Client enabled.' : 'Your server does not have the SOAP Client enabled.'; ?><?php echo "\n"; ?>
|
3294 |
+
SUHOSIN: <?php echo ( extension_loaded( 'suhosin' ) ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; ?><?php echo "\n"; ?>
|
3295 |
+
GD Library: <?php echo ( extension_loaded( 'gd' ) && function_exists('gd_info') ) ? 'PHP GD library is installed on your web server.' : 'PHP GD library is NOT installed on your web server.'; ?><?php echo "\n"; ?>
|
3296 |
+
Mail: <?php echo ( function_exists('mail') ) ? 'PHP mail function exist on your web server.' : 'PHP mail function doesn\'t exist on your web server.'; ?><?php echo "\n"; ?>
|
3297 |
+
Exif: <?php echo ( extension_loaded( 'exif' ) && function_exists('exif_imagetype') ) ? 'PHP Exif library is installed on your web server.' : 'PHP Exif library is NOT installed on your web server.'; ?><?php echo "\n"; ?>
|
3298 |
+
|
3299 |
+
|
3300 |
+
--- Session Configurations ---
|
3301 |
+
|
3302 |
+
Session: <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; ?><?php echo "\n"; ?>
|
3303 |
+
Session Name: <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
|
3304 |
+
Cookie Path: <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
|
3305 |
+
Save Path: <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
|
3306 |
+
Use Cookies: <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
|
3307 |
+
Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
|
3308 |
+
|
3309 |
+
|
3310 |
+
--- WordPress Active Plugins ---
|
3311 |
+
|
3312 |
+
<?php $plugins = get_plugins();
|
3313 |
+
$active_plugins = get_option( 'active_plugins', array() );
|
3314 |
+
|
3315 |
+
foreach ( $plugins as $plugin_path => $plugin ) {
|
3316 |
+
// If the plugin isn't active, don't show it.
|
3317 |
+
if ( ! in_array( $plugin_path, $active_plugins ) )
|
3318 |
+
continue;
|
3319 |
+
|
3320 |
+
echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
|
3321 |
+
}
|
3322 |
+
|
3323 |
+
if ( is_multisite() ) { ?>
|
3324 |
+
|
3325 |
+
--- WordPress Network Active Plugins ---
|
3326 |
+
|
3327 |
+
<?php $plugins = wp_get_active_network_plugins();
|
3328 |
+
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
|
3329 |
+
|
3330 |
+
foreach ( $plugins as $plugin_path ) {
|
3331 |
+
$plugin_base = plugin_basename( $plugin_path );
|
3332 |
+
|
3333 |
+
// If the plugin isn't active, don't show it.
|
3334 |
+
if ( ! array_key_exists( $plugin_base, $active_plugins ) )
|
3335 |
+
continue;
|
3336 |
+
|
3337 |
+
$plugin = get_plugin_data( $plugin_path );
|
3338 |
+
|
3339 |
+
echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n";
|
3340 |
+
}
|
3341 |
+
|
3342 |
+
}
|
3343 |
+
|
3344 |
+
/**
|
3345 |
+
* UM hook
|
3346 |
+
*
|
3347 |
+
* @type action
|
3348 |
+
* @title um_install_info_after
|
3349 |
+
* @description After install info
|
3350 |
+
* @change_log
|
3351 |
+
* ["Since: 2.0"]
|
3352 |
+
* @usage add_action( 'um_install_info_after', 'function_name', 10 );
|
3353 |
+
* @example
|
3354 |
+
* <?php
|
3355 |
+
* add_action( 'um_install_info_after', 'my_install_info_after', 10 );
|
3356 |
+
* function my_install_info_after() {
|
3357 |
+
* // your code here
|
3358 |
+
* }
|
3359 |
+
* ?>
|
3360 |
+
*/
|
3361 |
+
do_action( 'um_install_info_after' ); ?>
|
3362 |
+
|
3363 |
+
### End Install Info ###
|
3364 |
+
</textarea>
|
3365 |
+
<p class="submit">
|
3366 |
+
<input type="hidden" name="um-addon-hook" value="download_install_info" />
|
3367 |
+
<?php submit_button( 'Download Install Info File', 'primary', 'download_install_info', false ); ?>
|
3368 |
+
</p>
|
3369 |
+
</form>
|
3370 |
+
|
3371 |
+
<?php }
|
3372 |
+
}
|
3373 |
+
|
3374 |
+
|
3375 |
+
/**
|
3376 |
+
*
|
3377 |
+
*/
|
3378 |
+
function um_download_install_info() {
|
3379 |
+
if ( ! empty( $_POST['download_install_info'] ) ) {
|
3380 |
+
nocache_headers();
|
3381 |
+
|
3382 |
+
header( "Content-type: text/plain" );
|
3383 |
+
header( 'Content-Disposition: attachment; filename="ultimatemember-install-info.txt"' );
|
3384 |
+
|
3385 |
+
echo wp_strip_all_tags( sanitize_textarea_field( $_POST['um-install-info'] ) );
|
3386 |
+
exit;
|
3387 |
+
}
|
3388 |
+
}
|
3389 |
+
|
3390 |
+
|
3391 |
+
/**
|
3392 |
+
* @param string $raw_value
|
3393 |
+
* @param string $type
|
3394 |
+
* @param string $default
|
3395 |
+
*
|
3396 |
+
* @return string
|
3397 |
+
*/
|
3398 |
+
function info_value( $raw_value = '', $type = 'yesno', $default = '' ) {
|
3399 |
+
|
3400 |
+
if ( $type == 'yesno' ) {
|
3401 |
+
$raw_value = ( $default == $raw_value ) ? "Yes" : "No";
|
3402 |
+
} elseif( $type == 'onoff' ) {
|
3403 |
+
$raw_value = ( $default == $raw_value ) ? "On" : "Off";
|
3404 |
+
}
|
3405 |
+
|
3406 |
+
return $raw_value."\n";
|
3407 |
+
}
|
3408 |
+
|
3409 |
+
|
3410 |
+
/**
|
3411 |
+
* Render settings section
|
3412 |
+
*
|
3413 |
+
* @param array $section_fields
|
3414 |
+
* @param string $current_tab
|
3415 |
+
* @param string $current_subtab
|
3416 |
+
*
|
3417 |
+
* @return string
|
3418 |
+
*/
|
3419 |
+
function render_settings_section( $section_fields, $current_tab, $current_subtab ) {
|
3420 |
+
ob_start();
|
3421 |
+
|
3422 |
+
UM()->admin_forms_settings( array(
|
3423 |
+
'class' => 'um_options-' . $current_tab . '-' . $current_subtab . ' um-third-column',
|
3424 |
+
'prefix_id' => 'um_options',
|
3425 |
+
'fields' => $section_fields
|
3426 |
+
) )->render_form(); ?>
|
3427 |
+
|
3428 |
+
<?php $section = ob_get_clean();
|
3429 |
+
|
3430 |
+
return $section;
|
3431 |
+
}
|
3432 |
+
|
3433 |
+
|
3434 |
+
/**
|
3435 |
+
* @param array $settings
|
3436 |
+
*
|
3437 |
+
* @return array
|
3438 |
+
*/
|
3439 |
+
function save_email_templates( $settings ) {
|
3440 |
+
|
3441 |
+
if ( empty( $settings['um_email_template'] ) ) {
|
3442 |
+
return $settings;
|
3443 |
+
}
|
3444 |
+
|
3445 |
+
$template = $settings['um_email_template'];
|
3446 |
+
$content = wp_kses_post( stripslashes( $settings[ $template ] ) );
|
3447 |
+
|
3448 |
+
$theme_template_path = UM()->mail()->get_template_file( 'theme', $template );
|
3449 |
+
|
3450 |
+
if ( ! file_exists( $theme_template_path ) ) {
|
3451 |
+
UM()->mail()->copy_email_template( $template );
|
3452 |
+
}
|
3453 |
+
|
3454 |
+
$fp = fopen( $theme_template_path, "w" );
|
3455 |
+
$result = fputs( $fp, $content );
|
3456 |
+
fclose( $fp );
|
3457 |
+
|
3458 |
+
if ( $result !== false ) {
|
3459 |
+
unset( $settings['um_email_template'] );
|
3460 |
+
unset( $settings[ $template ] );
|
3461 |
+
}
|
3462 |
+
|
3463 |
+
return $settings;
|
3464 |
+
}
|
3465 |
+
}
|
3466 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/admin/core/packages/2.3.0/functions.php
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
2 |
+
|
3 |
+
|
4 |
+
function um_upgrade_skypeid_fields230() {
|
5 |
+
UM()->admin()->check_ajax_nonce();
|
6 |
+
|
7 |
+
um_maybe_unset_time_limit();
|
8 |
+
|
9 |
+
$forms_query = new WP_Query;
|
10 |
+
$forms = $forms_query->query( array(
|
11 |
+
'post_type' => 'um_form',
|
12 |
+
'posts_per_page' => -1,
|
13 |
+
'fields' => 'ids'
|
14 |
+
) );
|
15 |
+
|
16 |
+
$fields_for_upgrade = array();
|
17 |
+
|
18 |
+
foreach ( $forms as $form_id ) {
|
19 |
+
$forms_fields = get_post_meta( $form_id, '_um_custom_fields', true );
|
20 |
+
|
21 |
+
$changed = false;
|
22 |
+
foreach ( $forms_fields as $key => &$field ) {
|
23 |
+
if ( isset( $field['validate'] ) && 'skype' === $field['validate'] ) {
|
24 |
+
if ( isset( $field['type'] ) && 'url' === $field['type'] ) {
|
25 |
+
$field['type'] = 'text';
|
26 |
+
$changed = true;
|
27 |
+
|
28 |
+
$fields_for_upgrade[] = $field['metakey'];
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
if ( $changed ) {
|
34 |
+
update_post_meta( $form_id, '_um_custom_fields', $forms_fields );
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
$changed = false;
|
39 |
+
$custom_fields = get_option( 'um_fields', array() );
|
40 |
+
foreach ( $custom_fields as &$custom_field ) {
|
41 |
+
if ( isset( $custom_field['validate'] ) && 'skype' === $custom_field['validate'] ) {
|
42 |
+
if ( isset( $custom_field['type'] ) && 'url' === $custom_field['type'] ) {
|
43 |
+
$custom_field['type'] = 'text';
|
44 |
+
$changed = true;
|
45 |
+
|
46 |
+
$fields_for_upgrade[] = $custom_field['metakey'];
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
if ( $changed ) {
|
51 |
+
update_option( 'um_fields', $custom_fields );
|
52 |
+
}
|
53 |
+
|
54 |
+
$fields_for_upgrade = array_unique( $fields_for_upgrade );
|
55 |
+
|
56 |
+
if ( ! empty( $fields_for_upgrade ) ) {
|
57 |
+
update_option( 'um_upgrade_230_skype_fields_for_upgrade', $fields_for_upgrade );
|
58 |
+
wp_send_json_success( array( 'message' => __( 'SkypeID fields have been updated successfully', 'ultimate-member' ), 'count' => count( $fields_for_upgrade ) ) );
|
59 |
+
} else {
|
60 |
+
wp_send_json_success( array( 'message' => __( 'Database has been updated successfully', 'ultimate-member' ), 'count' => 0 ) );
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
function um_upgrade_usermeta_count230() {
|
66 |
+
UM()->admin()->check_ajax_nonce();
|
67 |
+
|
68 |
+
um_maybe_unset_time_limit();
|
69 |
+
|
70 |
+
$fields_for_upgrade = get_option( 'um_upgrade_230_skype_fields_for_upgrade', array() );
|
71 |
+
|
72 |
+
if ( ! empty( $fields_for_upgrade ) ) {
|
73 |
+
global $wpdb;
|
74 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->usermeta} WHERE meta_key IN( '" . implode( "','", $fields_for_upgrade ) . "' )" );
|
75 |
+
} else {
|
76 |
+
$count = 0;
|
77 |
+
}
|
78 |
+
|
79 |
+
wp_send_json_success( array( 'count' => $count ) );
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
function um_upgrade_usermeta_part230() {
|
84 |
+
UM()->admin()->check_ajax_nonce();
|
85 |
+
|
86 |
+
um_maybe_unset_time_limit();
|
87 |
+
|
88 |
+
if ( empty( $_POST['page'] ) ) {
|
89 |
+
wp_send_json_error( __( 'Wrong data', 'ultimate-member' ) );
|
90 |
+
}
|
91 |
+
|
92 |
+
$fields_for_upgrade = get_option( 'um_upgrade_230_skype_fields_for_upgrade', array() );
|
93 |
+
if ( empty( $fields_for_upgrade ) ) {
|
94 |
+
wp_send_json_success( array( 'message' => __( 'Database has been updated successfully', 'ultimate-member' ) ) );
|
95 |
+
}
|
96 |
+
|
97 |
+
$per_page = 100;
|
98 |
+
|
99 |
+
// avoid 'https://', 'http://' at the start of the Skype field is there is nickname but not https://join.skype.com/
|
100 |
+
// change only links with nickname skip https://join.skype.com/
|
101 |
+
global $wpdb;
|
102 |
+
$usermetas = $wpdb->get_results(
|
103 |
+
$wpdb->prepare(
|
104 |
+
"SELECT user_id,
|
105 |
+
meta_key,
|
106 |
+
meta_value
|
107 |
+
FROM {$wpdb->usermeta}
|
108 |
+
WHERE meta_key IN( '" . implode( "','", $fields_for_upgrade ) . "' )
|
109 |
+
LIMIT %d, %d",
|
110 |
+
( absint( $_POST['page'] ) - 1 ) * $per_page,
|
111 |
+
$per_page
|
112 |
+
),
|
113 |
+
ARRAY_A
|
114 |
+
);
|
115 |
+
|
116 |
+
if ( ! empty( $usermetas ) ) {
|
117 |
+
foreach ( $usermetas as $usermeta ) {
|
118 |
+
if ( false !== strstr( $usermeta['meta_value'], 'https://' ) || false !== strstr( $usermeta['meta_value'], 'http://' ) ) {
|
119 |
+
if ( false === strstr( $usermeta['meta_value'], 'join.skype.com/' ) ) {
|
120 |
+
$usermeta['meta_value'] = str_replace( array( 'https://', 'http://' ), '', $usermeta['meta_value'] );
|
121 |
+
update_user_meta( $usermeta['user_id'], $usermeta['meta_key'], $usermeta['meta_value'] );
|
122 |
+
|
123 |
+
delete_option( "um_cache_userdata_{$usermeta['user_id']}" );
|
124 |
+
}
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
$from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1;
|
130 |
+
$to = absint( $_POST['page'] ) * $per_page;
|
131 |
+
|
132 |
+
wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %s to %s row were upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
+
function um_upgrade_reset_password230() {
|
137 |
+
UM()->admin()->check_ajax_nonce();
|
138 |
+
|
139 |
+
um_maybe_unset_time_limit();
|
140 |
+
|
141 |
+
$require_strongpass = UM()->options()->get( 'account_require_strongpass' ) || UM()->options()->get( 'reset_require_strongpass' );
|
142 |
+
|
143 |
+
UM()->options()->update( 'require_strongpass', $require_strongpass );
|
144 |
+
UM()->options()->remove( 'account_require_strongpass' );
|
145 |
+
UM()->options()->remove( 'reset_require_strongpass' );
|
146 |
+
|
147 |
+
// delete temporarily option for fields upgrade
|
148 |
+
delete_option( 'um_upgrade_230_skype_fields_for_upgrade' );
|
149 |
+
update_option( 'um_last_version_upgrade', '2.3.0' );
|
150 |
+
|
151 |
+
wp_send_json_success( array( 'message' => __( 'Reset Password options have been updated successfully.', 'ultimate-member' ) ) );
|
152 |
+
}
|
includes/admin/core/packages/2.3.0/hooks.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
2 |
+
|
3 |
+
return array(
|
4 |
+
'skypeid_fields230' => 'skypeid_fields230',
|
5 |
+
'usermeta_count230' => 'usermeta_count230',
|
6 |
+
'usermeta_part230' => 'usermeta_part230',
|
7 |
+
'reset_password230' => 'reset_password230',
|
8 |
+
);
|
includes/admin/core/packages/2.3.0/init.php
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
2 |
+
|
3 |
+
|
4 |
+
<script type="text/javascript">
|
5 |
+
jQuery( document ).ready( function() {
|
6 |
+
var metarows_pages;
|
7 |
+
var current_page = 1;
|
8 |
+
var metarows_per_page = 100;
|
9 |
+
|
10 |
+
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade SkypeID fields in UM Forms and generally in predefined fields...', 'ultimate-member' ) ) ?>' );
|
11 |
+
|
12 |
+
jQuery.ajax({
|
13 |
+
url: wp.ajax.settings.url,
|
14 |
+
type: 'POST',
|
15 |
+
dataType: 'json',
|
16 |
+
data: {
|
17 |
+
action: 'um_skypeid_fields230',
|
18 |
+
nonce: um_admin_scripts.nonce
|
19 |
+
},
|
20 |
+
success: function( response ) {
|
21 |
+
if ( typeof response.data.message != 'undefined' ) {
|
22 |
+
um_add_upgrade_log( response.data.message );
|
23 |
+
|
24 |
+
setTimeout( function () {
|
25 |
+
if ( response.data.count > 0 ) {
|
26 |
+
um_update_get_usermeta_count230();
|
27 |
+
} else {
|
28 |
+
um_reset_password230();
|
29 |
+
}
|
30 |
+
}, um_request_throttle );
|
31 |
+
} else {
|
32 |
+
um_wrong_ajax();
|
33 |
+
}
|
34 |
+
},
|
35 |
+
error: function() {
|
36 |
+
um_something_wrong();
|
37 |
+
}
|
38 |
+
});
|
39 |
+
|
40 |
+
|
41 |
+
function um_update_get_usermeta_count230() {
|
42 |
+
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade SkypeID fields metadata for users...', 'ultimate-member' ) ) ?>' );
|
43 |
+
|
44 |
+
jQuery.ajax({
|
45 |
+
url: wp.ajax.settings.url,
|
46 |
+
type: 'POST',
|
47 |
+
dataType: 'json',
|
48 |
+
data: {
|
49 |
+
action: 'um_usermeta_count230',
|
50 |
+
nonce: um_admin_scripts.nonce
|
51 |
+
},
|
52 |
+
success: function( response ) {
|
53 |
+
if ( typeof response.data.count != 'undefined' ) {
|
54 |
+
um_add_upgrade_log( '<?php echo esc_js( __( 'There are ', 'ultimate-member' ) ) ?>' + response.data.count + '<?php echo esc_js( __( ' metadata rows...', 'ultimate-member' ) ) ?>' );
|
55 |
+
um_add_upgrade_log( '<?php echo esc_js( __( 'Start metadata upgrading...', 'ultimate-member' ) ) ?>' );
|
56 |
+
|
57 |
+
metarows_pages = Math.ceil( response.data.count / metarows_per_page );
|
58 |
+
|
59 |
+
setTimeout( function () {
|
60 |
+
um_update_usermeta_part230();
|
61 |
+
}, um_request_throttle );
|
62 |
+
} else {
|
63 |
+
um_wrong_ajax();
|
64 |
+
}
|
65 |
+
},
|
66 |
+
error: function() {
|
67 |
+
um_something_wrong();
|
68 |
+
}
|
69 |
+
});
|
70 |
+
}
|
71 |
+
|
72 |
+
|
73 |
+
function um_update_usermeta_part230() {
|
74 |
+
if ( current_page <= metarows_pages ) {
|
75 |
+
jQuery.ajax({
|
76 |
+
url: wp.ajax.settings.url,
|
77 |
+
type: 'POST',
|
78 |
+
dataType: 'json',
|
79 |
+
data: {
|
80 |
+
action: 'um_usermeta_part230',
|
81 |
+
page: current_page,
|
82 |
+
nonce: um_admin_scripts.nonce
|
83 |
+
},
|
84 |
+
success: function( response ) {
|
85 |
+
if ( typeof response.data != 'undefined' ) {
|
86 |
+
um_add_upgrade_log( response.data.message );
|
87 |
+
current_page++;
|
88 |
+
setTimeout( function() {
|
89 |
+
um_update_usermeta_part230();
|
90 |
+
}, um_request_throttle );
|
91 |
+
} else {
|
92 |
+
um_wrong_ajax();
|
93 |
+
}
|
94 |
+
},
|
95 |
+
error: function() {
|
96 |
+
um_something_wrong();
|
97 |
+
}
|
98 |
+
});
|
99 |
+
} else {
|
100 |
+
setTimeout( function () {
|
101 |
+
um_reset_password230();
|
102 |
+
}, um_request_throttle );
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
function um_reset_password230() {
|
108 |
+
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade the "Require strong password" options...', 'ultimate-member' ) ) ?>' );
|
109 |
+
|
110 |
+
jQuery.ajax({
|
111 |
+
url: wp.ajax.settings.url,
|
112 |
+
type: 'POST',
|
113 |
+
dataType: 'json',
|
114 |
+
data: {
|
115 |
+
action: 'um_reset_password230',
|
116 |
+
nonce: um_admin_scripts.nonce
|
117 |
+
},
|
118 |
+
success: function( response ) {
|
119 |
+
if ( typeof response.data.message != 'undefined' ) {
|
120 |
+
um_add_upgrade_log( response.data.message );
|
121 |
+
//switch to the next package
|
122 |
+
um_run_upgrade();
|
123 |
+
} else {
|
124 |
+
um_wrong_ajax();
|
125 |
+
}
|
126 |
+
},
|
127 |
+
error: function() {
|
128 |
+
um_something_wrong();
|
129 |
+
}
|
130 |
+
});
|
131 |
+
}
|
132 |
+
});
|
133 |
+
</script>
|
includes/class-config.php
CHANGED
@@ -1,809 +1,808 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um;
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\Config' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Config
|
13 |
-
*
|
14 |
-
* Class with global variables for UM
|
15 |
-
*
|
16 |
-
* @package um
|
17 |
-
*/
|
18 |
-
class Config {
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @var array
|
23 |
-
*/
|
24 |
-
var $core_forms;
|
25 |
-
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var array
|
29 |
-
*/
|
30 |
-
var $core_directories;
|
31 |
-
|
32 |
-
|
33 |
-
/**
|
34 |
-
* @var mixed|void
|
35 |
-
*/
|
36 |
-
var $core_pages;
|
37 |
-
|
38 |
-
|
39 |
-
/**
|
40 |
-
* @var array
|
41 |
-
*/
|
42 |
-
var $core_directory_meta = array();
|
43 |
-
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @var array
|
47 |
-
*/
|
48 |
-
var $core_global_meta_all;
|
49 |
-
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @var mixed|void
|
53 |
-
*/
|
54 |
-
var $core_form_meta_all;
|
55 |
-
|
56 |
-
|
57 |
-
/**
|
58 |
-
* @var array
|
59 |
-
*/
|
60 |
-
var $core_form_meta = array();
|
61 |
-
|
62 |
-
|
63 |
-
/**
|
64 |
-
* @var
|
65 |
-
*/
|
66 |
-
var $perms;
|
67 |
-
|
68 |
-
|
69 |
-
/**
|
70 |
-
* @var
|
71 |
-
*/
|
72 |
-
var $nonadmin_perms;
|
73 |
-
|
74 |
-
|
75 |
-
/**
|
76 |
-
* @var mixed|void
|
77 |
-
*/
|
78 |
-
var $email_notifications;
|
79 |
-
|
80 |
-
|
81 |
-
/**
|
82 |
-
* @var mixed|void
|
83 |
-
*/
|
84 |
-
var $settings_defaults;
|
85 |
-
|
86 |
-
|
87 |
-
/**
|
88 |
-
* @var array
|
89 |
-
*/
|
90 |
-
var $permalinks;
|
91 |
-
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Config constructor.
|
95 |
-
*/
|
96 |
-
function __construct() {
|
97 |
-
$this->core_forms = array(
|
98 |
-
'register',
|
99 |
-
'login',
|
100 |
-
'profile',
|
101 |
-
);
|
102 |
-
|
103 |
-
$this->core_directories = array(
|
104 |
-
'members',
|
105 |
-
);
|
106 |
-
|
107 |
-
|
108 |
-
/**
|
109 |
-
* UM hook
|
110 |
-
*
|
111 |
-
* @type filter
|
112 |
-
* @title um_core_pages
|
113 |
-
* @description Extend UM core pages
|
114 |
-
* @input_vars
|
115 |
-
* [{"var":"$pages","type":"array","desc":"UM core pages"}]
|
116 |
-
* @change_log
|
117 |
-
* ["Since: 2.0"]
|
118 |
-
* @usage
|
119 |
-
* <?php add_filter( 'um_core_pages', 'function_name', 10, 1 ); ?>
|
120 |
-
* @example
|
121 |
-
* <?php
|
122 |
-
* add_filter( 'um_core_pages', 'my_core_pages', 10, 1 );
|
123 |
-
* function my_core_pages( $pages ) {
|
124 |
-
* // your code here
|
125 |
-
* $pages['my_page_key'] = array( 'title' => __( 'My Page Title', 'my-translate-key' ) );
|
126 |
-
* return $pages;
|
127 |
-
* }
|
128 |
-
* ?>
|
129 |
-
*/
|
130 |
-
$this->core_pages = apply_filters( 'um_core_pages', array(
|
131 |
-
'user' => array( 'title' => __( 'User', 'ultimate-member' ) ),
|
132 |
-
'login' => array( 'title' => __( 'Login', 'ultimate-member' ) ),
|
133 |
-
'register' => array( 'title' => __( 'Register', 'ultimate-member' ) ),
|
134 |
-
'members' => array( 'title' => __( 'Members', 'ultimate-member' ) ),
|
135 |
-
'logout' => array( 'title' => __( 'Logout', 'ultimate-member' ) ),
|
136 |
-
'account' => array( 'title' => __( 'Account', 'ultimate-member' ) ),
|
137 |
-
'password-reset' => array( 'title' => __( 'Password Reset', 'ultimate-member' ) ),
|
138 |
-
) );
|
139 |
-
|
140 |
-
$this->core_directory_meta['members'] = array(
|
141 |
-
'_um_core' => 'members',
|
142 |
-
'_um_template' => 'members',
|
143 |
-
'_um_mode' => 'directory',
|
144 |
-
'_um_view_types' => array( 'grid' ),
|
145 |
-
'_um_default_view' => 'grid',
|
146 |
-
'_um_roles' => array(),
|
147 |
-
'_um_has_profile_photo' => 0,
|
148 |
-
'_um_has_cover_photo' => 0,
|
149 |
-
'_um_show_these_users' => '',
|
150 |
-
'_um_exclude_these_users' => '',
|
151 |
-
|
152 |
-
'_um_sortby' => 'user_registered_desc',
|
153 |
-
'_um_sortby_custom' => '',
|
154 |
-
'_um_sortby_custom_label' => '',
|
155 |
-
'_um_enable_sorting' => 0,
|
156 |
-
'_um_sorting_fields' => array(),
|
157 |
-
|
158 |
-
'_um_profile_photo' => '1',
|
159 |
-
'_um_cover_photos' => '1',
|
160 |
-
'_um_show_name' => '1',
|
161 |
-
'_um_show_tagline' => 0,
|
162 |
-
'_um_tagline_fields' => array(),
|
163 |
-
'_um_show_userinfo' => 0,
|
164 |
-
'_um_reveal_fields' => array(),
|
165 |
-
'_um_show_social' => 0,
|
166 |
-
'_um_userinfo_animate' => '1',
|
167 |
-
|
168 |
-
'_um_search' => 0,
|
169 |
-
'_um_roles_can_search' => array(),
|
170 |
-
'_um_filters' => 0,
|
171 |
-
'_um_roles_can_filter' => array(),
|
172 |
-
'_um_search_fields' => array(),
|
173 |
-
'_um_filters_expanded' => 0,
|
174 |
-
'_um_filters_is_collapsible' => 1,
|
175 |
-
'_um_search_filters' => array(),
|
176 |
-
|
177 |
-
'_um_must_search' => 0,
|
178 |
-
'_um_max_users' => '',
|
179 |
-
'_um_profiles_per_page' => 12,
|
180 |
-
'_um_profiles_per_page_mobile' => 6,
|
181 |
-
'_um_directory_header' => __( '{total_users} Members', 'ultimate-member' ),
|
182 |
-
'_um_directory_header_single' => __( '{total_users} Member', 'ultimate-member' ),
|
183 |
-
'_um_directory_no_users' => __( 'We are sorry. We cannot find any users who match your search criteria.', 'ultimate-member' ),
|
184 |
-
);
|
185 |
-
|
186 |
-
$this->core_global_meta_all = array(
|
187 |
-
'_um_primary_btn_color',
|
188 |
-
'_um_primary_btn_hover',
|
189 |
-
'_um_primary_btn_text',
|
190 |
-
'_um_secondary_btn_color',
|
191 |
-
'_um_secondary_btn_hover',
|
192 |
-
'_um_secondary_btn_text',
|
193 |
-
'_um_form_border',
|
194 |
-
'_um_form_border_hover',
|
195 |
-
'_um_form_bg_color',
|
196 |
-
'_um_form_bg_color_focus',
|
197 |
-
'_um_form_placeholder',
|
198 |
-
'_um_form_icon_color',
|
199 |
-
'_um_form_asterisk_color',
|
200 |
-
'_um_form_field_label',
|
201 |
-
'_um_form_text_color',
|
202 |
-
'_um_active_color',
|
203 |
-
'_um_help_tip_color',
|
204 |
-
'_um_secondary_color',
|
205 |
-
);
|
206 |
-
|
207 |
-
|
208 |
-
/**
|
209 |
-
* UM hook
|
210 |
-
*
|
211 |
-
* @type filter
|
212 |
-
* @title um_core_form_meta_all
|
213 |
-
* @description Extend UM forms meta keys
|
214 |
-
* @input_vars
|
215 |
-
* [{"var":"$meta","type":"array","desc":"UM forms meta"}]
|
216 |
-
* @change_log
|
217 |
-
* ["Since: 2.0"]
|
218 |
-
* @usage
|
219 |
-
* <?php add_filter( 'um_core_form_meta_all', 'function_name', 10, 1 ); ?>
|
220 |
-
* @example
|
221 |
-
* <?php
|
222 |
-
* add_filter( 'um_core_form_meta_all', 'my_core_form_meta', 10, 1 );
|
223 |
-
* function my_core_form_meta( $meta ) {
|
224 |
-
* // your code here
|
225 |
-
* $meta['my_meta_key'] = 'my_meta_value';
|
226 |
-
* return $meta;
|
227 |
-
* }
|
228 |
-
* ?>
|
229 |
-
*/
|
230 |
-
$this->core_form_meta_all = apply_filters( 'um_core_form_meta_all', array(
|
231 |
-
/*Profile Form*/
|
232 |
-
'_um_profile_show_name' => 1,
|
233 |
-
'_um_profile_show_social_links' => 0,
|
234 |
-
'_um_profile_show_bio' => 1,
|
235 |
-
'_um_profile_bio_maxchars' => 180,
|
236 |
-
'_um_profile_header_menu' => 'bc',
|
237 |
-
'_um_profile_empty_text' => 1,
|
238 |
-
'_um_profile_empty_text_emo' => 1,
|
239 |
-
'_um_profile_role' => array(),
|
240 |
-
'_um_profile_template' => 'profile',
|
241 |
-
'_um_profile_max_width' => '1000px',
|
242 |
-
'_um_profile_area_max_width' => '600px',
|
243 |
-
'_um_profile_align' => 'center',
|
244 |
-
'_um_profile_icons' => 'label',
|
245 |
-
'_um_profile_disable_photo_upload' => 0,
|
246 |
-
'_um_profile_photosize' => '190',
|
247 |
-
'_um_profile_cover_enabled' => 1,
|
248 |
-
'_um_profile_coversize' => 'original',
|
249 |
-
'_um_profile_cover_ratio' => '2.7:1',
|
250 |
-
'_um_profile_photocorner' => '1',
|
251 |
-
'_um_profile_header_bg' => '',
|
252 |
-
'_um_profile_primary_btn_word' => __( 'Update Profile', 'ultimate-member' ),
|
253 |
-
'_um_profile_secondary_btn' => '1',
|
254 |
-
'_um_profile_secondary_btn_word' => __( 'Cancel', 'ultimate-member' ),
|
255 |
-
|
256 |
-
/*Registration Form*/
|
257 |
-
'_um_register_role' => '0',
|
258 |
-
'_um_register_template' => 'register',
|
259 |
-
'_um_register_max_width' => '450px',
|
260 |
-
'_um_register_align' => 'center',
|
261 |
-
'_um_register_icons' => 'label',
|
262 |
-
'_um_register_primary_btn_word' => __( 'Register', 'ultimate-member' ),
|
263 |
-
'_um_register_secondary_btn' => 1,
|
264 |
-
'_um_register_secondary_btn_word' => __( 'Login', 'ultimate-member' ),
|
265 |
-
'_um_register_secondary_btn_url' => '',
|
266 |
-
|
267 |
-
/*Login Form*/
|
268 |
-
'_um_login_template' => 'login',
|
269 |
-
'_um_login_max_width' => '450px',
|
270 |
-
'_um_login_align' => 'center',
|
271 |
-
'_um_login_icons' => 'label',
|
272 |
-
'_um_login_primary_btn_word' => __( 'Login', 'ultimate-member' ),
|
273 |
-
'_um_login_forgot_pass_link' => 1,
|
274 |
-
'_um_login_show_rememberme' => 1,
|
275 |
-
'_um_login_secondary_btn' => 1,
|
276 |
-
'_um_login_secondary_btn_word' => __( 'Register', 'ultimate-member' ),
|
277 |
-
'_um_login_secondary_btn_url' => '',
|
278 |
-
|
279 |
-
/*Member Directory*/
|
280 |
-
'_um_directory_template' => 'members',
|
281 |
-
'_um_directory_header' => __( '{total_users} Members', 'ultimate-member' ),
|
282 |
-
'_um_directory_header_single' => __( '{total_users} Member', 'ultimate-member' ),
|
283 |
-
) );
|
284 |
-
|
285 |
-
$this->core_form_meta['register'] = array(
|
286 |
-
'_um_custom_fields' => 'a:6:{s:10:"user_login";a:15:{s:5:"title";s:8:"Username";s:7:"metakey";s:10:"user_login";s:4:"type";s:4:"text";s:5:"label";s:8:"Username";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:0;s:8:"validate";s:15:"unique_username";s:9:"min_chars";i:3;s:9:"max_chars";i:24;s:8:"position";s:1:"1";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:10:"user_email";a:13:{s:5:"title";s:14:"E-mail Address";s:7:"metakey";s:10:"user_email";s:4:"type";s:4:"text";s:5:"label";s:14:"E-mail Address";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"validate";s:12:"unique_email";s:8:"position";s:1:"4";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:13:"user_password";a:16:{s:5:"title";s:8:"Password";s:7:"metakey";s:13:"user_password";s:4:"type";s:8:"password";s:5:"label";s:8:"Password";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:1;s:9:"min_chars";i:8;s:9:"max_chars";i:30;s:15:"force_good_pass";i:1;s:18:"force_confirm_pass";i:1;s:8:"position";s:1:"5";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:10:"first_name";a:12:{s:5:"title";s:10:"First Name";s:7:"metakey";s:10:"first_name";s:4:"type";s:4:"text";s:5:"label";s:10:"First Name";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"position";s:1:"2";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"last_name";a:12:{s:5:"title";s:9:"Last Name";s:7:"metakey";s:9:"last_name";s:4:"type";s:4:"text";s:5:"label";s:9:"Last Name";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"position";s:1:"3";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
287 |
-
'_um_mode' => 'register',
|
288 |
-
'_um_core' => 'register',
|
289 |
-
'_um_register_use_custom_settings' => 0,
|
290 |
-
);
|
291 |
-
|
292 |
-
$this->core_form_meta['login'] = array(
|
293 |
-
'_um_custom_fields' => 'a:3:{s:8:"username";a:13:{s:5:"title";s:18:"Username or E-mail";s:7:"metakey";s:8:"username";s:4:"type";s:4:"text";s:5:"label";s:18:"Username or E-mail";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:0;s:8:"validate";s:24:"unique_username_or_email";s:8:"position";s:1:"1";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:13:"user_password";a:16:{s:5:"title";s:8:"Password";s:7:"metakey";s:13:"user_password";s:4:"type";s:8:"password";s:5:"label";s:8:"Password";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:1;s:9:"min_chars";i:8;s:9:"max_chars";i:30;s:15:"force_good_pass";i:1;s:18:"force_confirm_pass";i:1;s:8:"position";s:1:"2";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
294 |
-
'_um_mode' => 'login',
|
295 |
-
'_um_core' => 'login',
|
296 |
-
'_um_login_use_custom_settings' => 0,
|
297 |
-
);
|
298 |
-
|
299 |
-
$this->core_form_meta['profile'] = array(
|
300 |
-
'_um_custom_fields' => 'a:1:{s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
301 |
-
'_um_mode' => 'profile',
|
302 |
-
'_um_core' => 'profile',
|
303 |
-
'_um_profile_use_custom_settings' => 0,
|
304 |
-
);
|
305 |
-
|
306 |
-
|
307 |
-
/**
|
308 |
-
* UM hook
|
309 |
-
*
|
310 |
-
* @type filter
|
311 |
-
* @title um_email_notifications
|
312 |
-
* @description Extend UM email notifications
|
313 |
-
* @input_vars
|
314 |
-
* [{"var":"$emails","type":"array","desc":"UM email notifications"}]
|
315 |
-
* @change_log
|
316 |
-
* ["Since: 2.0"]
|
317 |
-
* @usage
|
318 |
-
* <?php add_filter( 'um_email_notifications', 'function_name', 10, 1 ); ?>
|
319 |
-
* @example
|
320 |
-
* <?php
|
321 |
-
* add_filter( 'um_email_notifications', 'my_email_notifications', 10, 1 );
|
322 |
-
* function my_email_notifications( $emails ) {
|
323 |
-
* // your code here
|
324 |
-
* $emails['my_email'] = array(
|
325 |
-
* 'key' => 'my_email',
|
326 |
-
* 'title' => __( 'my_email_title','ultimate-member' ),
|
327 |
-
* 'subject' => 'my_email_subject',
|
328 |
-
* 'body' => 'my_email_body',
|
329 |
-
* 'description' => 'my_email_description',
|
330 |
-
* 'recipient' => 'user', // set 'admin' for make administrator as recipient
|
331 |
-
* 'default_active' => true // can be false for make disabled by default
|
332 |
-
* );
|
333 |
-
*
|
334 |
-
* return $emails;
|
335 |
-
* }
|
336 |
-
* ?>
|
337 |
-
*/
|
338 |
-
$this->email_notifications = apply_filters( 'um_email_notifications', array(
|
339 |
-
'welcome_email' => array(
|
340 |
-
'key' => 'welcome_email',
|
341 |
-
'title' => __( 'Account Welcome Email','ultimate-member' ),
|
342 |
-
'subject' => 'Welcome to {site_name}!',
|
343 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
344 |
-
'Thank you for signing up with {site_name}! Your account is now active.<br /><br />' .
|
345 |
-
'To login please visit the following url:<br /><br />' .
|
346 |
-
'{login_url} <br /><br />' .
|
347 |
-
'Your account e-mail: {email} <br />' .
|
348 |
-
'Your account username: {username} <br /><br />' .
|
349 |
-
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
350 |
-
'Thanks,<br />' .
|
351 |
-
'{site_name}',
|
352 |
-
'description' => __('Whether to send the user an email when his account is automatically approved','ultimate-member'),
|
353 |
-
'recipient' => 'user',
|
354 |
-
'default_active' => true
|
355 |
-
),
|
356 |
-
'checkmail_email' => array(
|
357 |
-
'key' => 'checkmail_email',
|
358 |
-
'title' => __( 'Account Activation Email','ultimate-member' ),
|
359 |
-
'subject' => 'Please activate your account',
|
360 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
361 |
-
'Thank you for signing up with {site_name}! To activate your account, please click the link below to confirm your email address:<br /><br />' .
|
362 |
-
'{account_activation_link} <br /><br />' .
|
363 |
-
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
364 |
-
'Thanks, <br />' .
|
365 |
-
'{site_name}',
|
366 |
-
'description' => __('Whether to send the user an email when his account needs e-mail activation','ultimate-member'),
|
367 |
-
'recipient' => 'user'
|
368 |
-
),
|
369 |
-
'pending_email' => array(
|
370 |
-
'key' => 'pending_email',
|
371 |
-
'title' => __( 'Your account is pending review','ultimate-member' ),
|
372 |
-
'subject' => '[{site_name}] New user account',
|
373 |
-
'body' => 'Hi {display_name}, <br /><br />' .
|
374 |
-
'Thank you for signing up with {site_name}! Your account is currently being reviewed by a member of our team.<br /><br />' .
|
375 |
-
'Please allow us some time to process your request.<br /><br />' .
|
376 |
-
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
377 |
-
'Thanks,<br />' .
|
378 |
-
'{site_name}',
|
379 |
-
'description' => __('Whether to send the user an email when his account needs admin review','ultimate-member'),
|
380 |
-
'recipient' => 'user'
|
381 |
-
),
|
382 |
-
'approved_email' => array(
|
383 |
-
'key' => 'approved_email',
|
384 |
-
'title' => __( 'Account Approved Email','ultimate-member' ),
|
385 |
-
'subject' => 'Your account at {site_name} is now active',
|
386 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
387 |
-
'Thank you for signing up with {site_name}! Your account has been approved and is now active.<br /><br />' .
|
388 |
-
'To login please visit the following url:<br /><br />' .
|
389 |
-
'{login_url}<br /><br />' .
|
390 |
-
'Your account e-mail: {email}<br />' .
|
391 |
-
'Your account username: {username}<br />' .
|
392 |
-
'Set your account password: {password_reset_link}<br /><br />' .
|
393 |
-
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
394 |
-
'Thanks,<br />' .
|
395 |
-
'{site_name}',
|
396 |
-
'description' => __('Whether to send the user an email when his account is approved','ultimate-member'),
|
397 |
-
'recipient' => 'user'
|
398 |
-
),
|
399 |
-
'rejected_email' => array(
|
400 |
-
'key' => 'rejected_email',
|
401 |
-
'title' => __( 'Account Rejected Email','ultimate-member' ),
|
402 |
-
'subject' => 'Your account has been rejected',
|
403 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
404 |
-
'Thank you for applying for membership to {site_name}! We have reviewed your information and unfortunately we are unable to accept you as a member at this moment.<br /><br />' .
|
405 |
-
'Please feel free to apply again at a future date.<br /><br />' .
|
406 |
-
'Thanks,<br />' .
|
407 |
-
'{site_name}',
|
408 |
-
'description' => __('Whether to send the user an email when his account is rejected','ultimate-member'),
|
409 |
-
'recipient' => 'user'
|
410 |
-
),
|
411 |
-
'inactive_email' => array(
|
412 |
-
'key' => 'inactive_email',
|
413 |
-
'title' => __( 'Account Deactivated Email','ultimate-member' ),
|
414 |
-
'subject' => 'Your account has been deactivated',
|
415 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
416 |
-
'This is an automated email to let you know your {site_name} account has been deactivated.<br /><br />' .
|
417 |
-
'If you would like your account to be reactivated please contact us at {admin_email}<br /><br />' .
|
418 |
-
'Thanks,<br />' .
|
419 |
-
'{site_name}',
|
420 |
-
'description' => __('Whether to send the user an email when his account is deactivated','ultimate-member'),
|
421 |
-
'recipient' => 'user',
|
422 |
-
'default_active' => true
|
423 |
-
),
|
424 |
-
'deletion_email' => array(
|
425 |
-
'key' => 'deletion_email',
|
426 |
-
'title' => __( 'Account Deleted Email','ultimate-member' ),
|
427 |
-
'subject' => 'Your account has been deleted',
|
428 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
429 |
-
'This is an automated email to let you know your {site_name} account has been deleted. All of your personal information has been permanently deleted and you will no longer be able to login to {site_name}.<br /><br />' .
|
430 |
-
'If your account has been deleted by accident please contact us at {admin_email} <br />' .
|
431 |
-
'Thanks,<br />' .
|
432 |
-
'{site_name}',
|
433 |
-
'description' => __('Whether to send the user an email when his account is deleted','ultimate-member'),
|
434 |
-
'recipient' => 'user',
|
435 |
-
'default_active' => true
|
436 |
-
),
|
437 |
-
'resetpw_email' => array(
|
438 |
-
'key' => 'resetpw_email',
|
439 |
-
'title' => __( 'Password Reset Email','ultimate-member' ),
|
440 |
-
'subject' => 'Reset your password',
|
441 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
442 |
-
'We received a request to reset the password for your account. If you made this request, click the link below to change your password:<br /><br />' .
|
443 |
-
'{password_reset_link}<br /><br />' .
|
444 |
-
'If you didn\'t make this request, you can ignore this email <br /><br />' .
|
445 |
-
'Thanks,<br />' .
|
446 |
-
'{site_name}',
|
447 |
-
'description' => __('Whether to send an email when users changed their password (Recommended, please keep on)','ultimate-member'),
|
448 |
-
'recipient' => 'user',
|
449 |
-
'default_active' => true
|
450 |
-
),
|
451 |
-
'changedpw_email' => array(
|
452 |
-
'key' => 'changedpw_email',
|
453 |
-
'title' => __( 'Password Changed Email','ultimate-member' ),
|
454 |
-
'subject' => 'Your {site_name} password has been changed',
|
455 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
456 |
-
'You recently changed the password associated with your {site_name} account.<br /><br />' .
|
457 |
-
'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}<br /><br />' .
|
458 |
-
'Thanks,<br />' .
|
459 |
-
'{site_name}',
|
460 |
-
'description' => __('Whether to send the user an email when he request to reset password (Recommended, please keep on)','ultimate-member'),
|
461 |
-
'recipient' => 'user',
|
462 |
-
'default_active' => true
|
463 |
-
),
|
464 |
-
'changedaccount_email' => array(
|
465 |
-
'key' => 'changedaccount_email',
|
466 |
-
'title' => __( 'Account Updated Email','ultimate-member' ),
|
467 |
-
'subject' => 'Your account at {site_name} was updated',
|
468 |
-
'body' => 'Hi {display_name},<br /><br />' .
|
469 |
-
'You recently updated your {site_name} account.<br /><br />' .
|
470 |
-
'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}<br /><br />' .
|
471 |
-
'Thanks,<br />' .
|
472 |
-
'{site_name}',
|
473 |
-
'description' => __('Whether to send the user an email when he updated their account','ultimate-member'),
|
474 |
-
'recipient' => 'user',
|
475 |
-
'default_active'=> true
|
476 |
-
),
|
477 |
-
'notification_new_user' => array(
|
478 |
-
'key' => 'notification_new_user',
|
479 |
-
'title' => __( 'New User Notification','ultimate-member' ),
|
480 |
-
'subject' => '[{site_name}] New user account',
|
481 |
-
'body' => '{display_name} has just created an account on {site_name}. To view their profile click here:<br /><br />' .
|
482 |
-
'{user_profile_link}<br /><br />' .
|
483 |
-
'Here is the submitted registration form:<br /><br />' .
|
484 |
-
'{submitted_registration}',
|
485 |
-
'description' => __('Whether to receive notification when a new user account is approved','ultimate-member'),
|
486 |
-
'recipient' => 'admin',
|
487 |
-
'default_active' => true
|
488 |
-
),
|
489 |
-
'notification_review' => array(
|
490 |
-
'key' => 'notification_review',
|
491 |
-
'title' => __( 'Account Needs Review Notification','ultimate-member' ),
|
492 |
-
'subject' => '[{site_name}] New user awaiting review',
|
493 |
-
'body' => '{display_name} has just applied for membership to {site_name} and is waiting to be reviewed.<br /><br />' .
|
494 |
-
'To review this member please click the following link:<br /><br />' .
|
495 |
-
'{user_profile_link}<br /><br />' .
|
496 |
-
'Here is the submitted registration form:<br /><br />' .
|
497 |
-
'{submitted_registration}',
|
498 |
-
'description' => __('Whether to receive notification when an account needs admin review','ultimate-member'),
|
499 |
-
'recipient' => 'admin'
|
500 |
-
),
|
501 |
-
'notification_deletion' => array(
|
502 |
-
'key' => 'notification_deletion',
|
503 |
-
'title' => __( 'Account Deletion Notification','ultimate-member' ),
|
504 |
-
'subject' => '[{site_name}] Account deleted',
|
505 |
-
'body' => '{display_name} has just deleted their {site_name} account.',
|
506 |
-
'description' => __('Whether to receive notification when an account is deleted','ultimate-member'),
|
507 |
-
'recipient' => 'admin'
|
508 |
-
)
|
509 |
-
) );
|
510 |
-
|
511 |
-
|
512 |
-
//settings defaults
|
513 |
-
$this->settings_defaults = array(
|
514 |
-
'restricted_access_post_metabox' => array( 'post' => 1, 'page' => 1 ),
|
515 |
-
'disable_restriction_pre_queries' => 0,
|
516 |
-
'uninstall_on_delete' => 0,
|
517 |
-
'permalink_base' => 'user_login',
|
518 |
-
'display_name' => 'full_name',
|
519 |
-
'display_name_field' => '',
|
520 |
-
'author_redirect' => 1,
|
521 |
-
'members_page' => 1,
|
522 |
-
'use_gravatars' => 0,
|
523 |
-
'use_um_gravatar_default_builtin_image' => 'default',
|
524 |
-
'use_um_gravatar_default_image' => 0,
|
525 |
-
'
|
526 |
-
'password_min_chars' => 8,
|
527 |
-
'password_max_chars' => 30,
|
528 |
-
'account_tab_password' => 1,
|
529 |
-
'account_tab_privacy' => 1,
|
530 |
-
'account_tab_notifications' => 1,
|
531 |
-
'account_tab_delete' => 1,
|
532 |
-
'delete_account_text' => __( 'Are you sure you want to delete your account? This will erase all of your account data from the site. To delete your account enter your password below.', 'ultimate-member' ),
|
533 |
-
'delete_account_no_pass_required_text' => __( 'Are you sure you want to delete your account? This will erase all of your account data from the site. To delete your account, click on the button below.', 'ultimate-member' ),
|
534 |
-
'account_name' => 1,
|
535 |
-
'account_name_disable' => 0,
|
536 |
-
'account_name_require' => 1,
|
537 |
-
'account_email' => 1,
|
538 |
-
'account_general_password' => 0,
|
539 |
-
'account_hide_in_directory' => 1,
|
540 |
-
'account_hide_in_directory_default' => 'No',
|
541 |
-
'
|
542 |
-
'
|
543 |
-
'
|
544 |
-
'
|
545 |
-
'
|
546 |
-
'
|
547 |
-
'
|
548 |
-
'
|
549 |
-
'
|
550 |
-
'
|
551 |
-
'
|
552 |
-
'
|
553 |
-
'
|
554 |
-
'
|
555 |
-
'
|
556 |
-
'
|
557 |
-
'
|
558 |
-
'
|
559 |
-
'
|
560 |
-
'
|
561 |
-
'
|
562 |
-
'
|
563 |
-
'
|
564 |
-
'
|
565 |
-
'
|
566 |
-
'
|
567 |
-
'
|
568 |
-
'
|
569 |
-
'
|
570 |
-
'
|
571 |
-
'
|
572 |
-
'
|
573 |
-
'
|
574 |
-
'
|
575 |
-
'
|
576 |
-
'
|
577 |
-
'
|
578 |
-
'
|
579 |
-
'
|
580 |
-
'
|
581 |
-
'
|
582 |
-
'
|
583 |
-
'
|
584 |
-
'
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
$this->settings_defaults[ 'profile_tab_' . $id . '
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
$this->settings_defaults[ $key . '
|
608 |
-
$this->settings_defaults[ $key
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
$page_id =
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
*
|
624 |
-
*
|
625 |
-
* @
|
626 |
-
* @
|
627 |
-
* @
|
628 |
-
*
|
629 |
-
*
|
630 |
-
*
|
631 |
-
*
|
632 |
-
*
|
633 |
-
*
|
634 |
-
*
|
635 |
-
*
|
636 |
-
*
|
637 |
-
*
|
638 |
-
*
|
639 |
-
*
|
640 |
-
*
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
*
|
652 |
-
*
|
653 |
-
|
654 |
-
'
|
655 |
-
'
|
656 |
-
'
|
657 |
-
'
|
658 |
-
'
|
659 |
-
'
|
660 |
-
'
|
661 |
-
'
|
662 |
-
'
|
663 |
-
'
|
664 |
-
'
|
665 |
-
'
|
666 |
-
'
|
667 |
-
'
|
668 |
-
'
|
669 |
-
'
|
670 |
-
'
|
671 |
-
'
|
672 |
-
'
|
673 |
-
'
|
674 |
-
'
|
675 |
-
'
|
676 |
-
'
|
677 |
-
'
|
678 |
-
'
|
679 |
-
'
|
680 |
-
'
|
681 |
-
'
|
682 |
-
'
|
683 |
-
|
684 |
-
*
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
'
|
690 |
-
'
|
691 |
-
'
|
692 |
-
'
|
693 |
-
'
|
694 |
-
'
|
695 |
-
'
|
696 |
-
'
|
697 |
-
'
|
698 |
-
'
|
699 |
-
'
|
700 |
-
'
|
701 |
-
'
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
'
|
706 |
-
'
|
707 |
-
'
|
708 |
-
'
|
709 |
-
'
|
710 |
-
'
|
711 |
-
'
|
712 |
-
'
|
713 |
-
'
|
714 |
-
'
|
715 |
-
'
|
716 |
-
'
|
717 |
-
'
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
'
|
722 |
-
'
|
723 |
-
'
|
724 |
-
'
|
725 |
-
'
|
726 |
-
'
|
727 |
-
'
|
728 |
-
'
|
729 |
-
'
|
730 |
-
'
|
731 |
-
'
|
732 |
-
'
|
733 |
-
'
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
'
|
738 |
-
'
|
739 |
-
'
|
740 |
-
'
|
741 |
-
'
|
742 |
-
'
|
743 |
-
'
|
744 |
-
'
|
745 |
-
'
|
746 |
-
'
|
747 |
-
'
|
748 |
-
'
|
749 |
-
'
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
'
|
754 |
-
'
|
755 |
-
'
|
756 |
-
'
|
757 |
-
'
|
758 |
-
'
|
759 |
-
'
|
760 |
-
'
|
761 |
-
'
|
762 |
-
'
|
763 |
-
'
|
764 |
-
'
|
765 |
-
'
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
*
|
774 |
-
*
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
$
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
$
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
'
|
799 |
-
'
|
800 |
-
'
|
801 |
-
'
|
802 |
-
'
|
803 |
-
'
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\Config' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Config
|
13 |
+
*
|
14 |
+
* Class with global variables for UM
|
15 |
+
*
|
16 |
+
* @package um
|
17 |
+
*/
|
18 |
+
class Config {
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @var array
|
23 |
+
*/
|
24 |
+
var $core_forms;
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
var $core_directories;
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @var mixed|void
|
35 |
+
*/
|
36 |
+
var $core_pages;
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @var array
|
41 |
+
*/
|
42 |
+
var $core_directory_meta = array();
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @var array
|
47 |
+
*/
|
48 |
+
var $core_global_meta_all;
|
49 |
+
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @var mixed|void
|
53 |
+
*/
|
54 |
+
var $core_form_meta_all;
|
55 |
+
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @var array
|
59 |
+
*/
|
60 |
+
var $core_form_meta = array();
|
61 |
+
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @var
|
65 |
+
*/
|
66 |
+
var $perms;
|
67 |
+
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @var
|
71 |
+
*/
|
72 |
+
var $nonadmin_perms;
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @var mixed|void
|
77 |
+
*/
|
78 |
+
var $email_notifications;
|
79 |
+
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @var mixed|void
|
83 |
+
*/
|
84 |
+
var $settings_defaults;
|
85 |
+
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @var array
|
89 |
+
*/
|
90 |
+
var $permalinks;
|
91 |
+
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Config constructor.
|
95 |
+
*/
|
96 |
+
function __construct() {
|
97 |
+
$this->core_forms = array(
|
98 |
+
'register',
|
99 |
+
'login',
|
100 |
+
'profile',
|
101 |
+
);
|
102 |
+
|
103 |
+
$this->core_directories = array(
|
104 |
+
'members',
|
105 |
+
);
|
106 |
+
|
107 |
+
|
108 |
+
/**
|
109 |
+
* UM hook
|
110 |
+
*
|
111 |
+
* @type filter
|
112 |
+
* @title um_core_pages
|
113 |
+
* @description Extend UM core pages
|
114 |
+
* @input_vars
|
115 |
+
* [{"var":"$pages","type":"array","desc":"UM core pages"}]
|
116 |
+
* @change_log
|
117 |
+
* ["Since: 2.0"]
|
118 |
+
* @usage
|
119 |
+
* <?php add_filter( 'um_core_pages', 'function_name', 10, 1 ); ?>
|
120 |
+
* @example
|
121 |
+
* <?php
|
122 |
+
* add_filter( 'um_core_pages', 'my_core_pages', 10, 1 );
|
123 |
+
* function my_core_pages( $pages ) {
|
124 |
+
* // your code here
|
125 |
+
* $pages['my_page_key'] = array( 'title' => __( 'My Page Title', 'my-translate-key' ) );
|
126 |
+
* return $pages;
|
127 |
+
* }
|
128 |
+
* ?>
|
129 |
+
*/
|
130 |
+
$this->core_pages = apply_filters( 'um_core_pages', array(
|
131 |
+
'user' => array( 'title' => __( 'User', 'ultimate-member' ) ),
|
132 |
+
'login' => array( 'title' => __( 'Login', 'ultimate-member' ) ),
|
133 |
+
'register' => array( 'title' => __( 'Register', 'ultimate-member' ) ),
|
134 |
+
'members' => array( 'title' => __( 'Members', 'ultimate-member' ) ),
|
135 |
+
'logout' => array( 'title' => __( 'Logout', 'ultimate-member' ) ),
|
136 |
+
'account' => array( 'title' => __( 'Account', 'ultimate-member' ) ),
|
137 |
+
'password-reset' => array( 'title' => __( 'Password Reset', 'ultimate-member' ) ),
|
138 |
+
) );
|
139 |
+
|
140 |
+
$this->core_directory_meta['members'] = array(
|
141 |
+
'_um_core' => 'members',
|
142 |
+
'_um_template' => 'members',
|
143 |
+
'_um_mode' => 'directory',
|
144 |
+
'_um_view_types' => array( 'grid' ),
|
145 |
+
'_um_default_view' => 'grid',
|
146 |
+
'_um_roles' => array(),
|
147 |
+
'_um_has_profile_photo' => 0,
|
148 |
+
'_um_has_cover_photo' => 0,
|
149 |
+
'_um_show_these_users' => '',
|
150 |
+
'_um_exclude_these_users' => '',
|
151 |
+
|
152 |
+
'_um_sortby' => 'user_registered_desc',
|
153 |
+
'_um_sortby_custom' => '',
|
154 |
+
'_um_sortby_custom_label' => '',
|
155 |
+
'_um_enable_sorting' => 0,
|
156 |
+
'_um_sorting_fields' => array(),
|
157 |
+
|
158 |
+
'_um_profile_photo' => '1',
|
159 |
+
'_um_cover_photos' => '1',
|
160 |
+
'_um_show_name' => '1',
|
161 |
+
'_um_show_tagline' => 0,
|
162 |
+
'_um_tagline_fields' => array(),
|
163 |
+
'_um_show_userinfo' => 0,
|
164 |
+
'_um_reveal_fields' => array(),
|
165 |
+
'_um_show_social' => 0,
|
166 |
+
'_um_userinfo_animate' => '1',
|
167 |
+
|
168 |
+
'_um_search' => 0,
|
169 |
+
'_um_roles_can_search' => array(),
|
170 |
+
'_um_filters' => 0,
|
171 |
+
'_um_roles_can_filter' => array(),
|
172 |
+
'_um_search_fields' => array(),
|
173 |
+
'_um_filters_expanded' => 0,
|
174 |
+
'_um_filters_is_collapsible' => 1,
|
175 |
+
'_um_search_filters' => array(),
|
176 |
+
|
177 |
+
'_um_must_search' => 0,
|
178 |
+
'_um_max_users' => '',
|
179 |
+
'_um_profiles_per_page' => 12,
|
180 |
+
'_um_profiles_per_page_mobile' => 6,
|
181 |
+
'_um_directory_header' => __( '{total_users} Members', 'ultimate-member' ),
|
182 |
+
'_um_directory_header_single' => __( '{total_users} Member', 'ultimate-member' ),
|
183 |
+
'_um_directory_no_users' => __( 'We are sorry. We cannot find any users who match your search criteria.', 'ultimate-member' ),
|
184 |
+
);
|
185 |
+
|
186 |
+
$this->core_global_meta_all = array(
|
187 |
+
'_um_primary_btn_color',
|
188 |
+
'_um_primary_btn_hover',
|
189 |
+
'_um_primary_btn_text',
|
190 |
+
'_um_secondary_btn_color',
|
191 |
+
'_um_secondary_btn_hover',
|
192 |
+
'_um_secondary_btn_text',
|
193 |
+
'_um_form_border',
|
194 |
+
'_um_form_border_hover',
|
195 |
+
'_um_form_bg_color',
|
196 |
+
'_um_form_bg_color_focus',
|
197 |
+
'_um_form_placeholder',
|
198 |
+
'_um_form_icon_color',
|
199 |
+
'_um_form_asterisk_color',
|
200 |
+
'_um_form_field_label',
|
201 |
+
'_um_form_text_color',
|
202 |
+
'_um_active_color',
|
203 |
+
'_um_help_tip_color',
|
204 |
+
'_um_secondary_color',
|
205 |
+
);
|
206 |
+
|
207 |
+
|
208 |
+
/**
|
209 |
+
* UM hook
|
210 |
+
*
|
211 |
+
* @type filter
|
212 |
+
* @title um_core_form_meta_all
|
213 |
+
* @description Extend UM forms meta keys
|
214 |
+
* @input_vars
|
215 |
+
* [{"var":"$meta","type":"array","desc":"UM forms meta"}]
|
216 |
+
* @change_log
|
217 |
+
* ["Since: 2.0"]
|
218 |
+
* @usage
|
219 |
+
* <?php add_filter( 'um_core_form_meta_all', 'function_name', 10, 1 ); ?>
|
220 |
+
* @example
|
221 |
+
* <?php
|
222 |
+
* add_filter( 'um_core_form_meta_all', 'my_core_form_meta', 10, 1 );
|
223 |
+
* function my_core_form_meta( $meta ) {
|
224 |
+
* // your code here
|
225 |
+
* $meta['my_meta_key'] = 'my_meta_value';
|
226 |
+
* return $meta;
|
227 |
+
* }
|
228 |
+
* ?>
|
229 |
+
*/
|
230 |
+
$this->core_form_meta_all = apply_filters( 'um_core_form_meta_all', array(
|
231 |
+
/*Profile Form*/
|
232 |
+
'_um_profile_show_name' => 1,
|
233 |
+
'_um_profile_show_social_links' => 0,
|
234 |
+
'_um_profile_show_bio' => 1,
|
235 |
+
'_um_profile_bio_maxchars' => 180,
|
236 |
+
'_um_profile_header_menu' => 'bc',
|
237 |
+
'_um_profile_empty_text' => 1,
|
238 |
+
'_um_profile_empty_text_emo' => 1,
|
239 |
+
'_um_profile_role' => array(),
|
240 |
+
'_um_profile_template' => 'profile',
|
241 |
+
'_um_profile_max_width' => '1000px',
|
242 |
+
'_um_profile_area_max_width' => '600px',
|
243 |
+
'_um_profile_align' => 'center',
|
244 |
+
'_um_profile_icons' => 'label',
|
245 |
+
'_um_profile_disable_photo_upload' => 0,
|
246 |
+
'_um_profile_photosize' => '190',
|
247 |
+
'_um_profile_cover_enabled' => 1,
|
248 |
+
'_um_profile_coversize' => 'original',
|
249 |
+
'_um_profile_cover_ratio' => '2.7:1',
|
250 |
+
'_um_profile_photocorner' => '1',
|
251 |
+
'_um_profile_header_bg' => '',
|
252 |
+
'_um_profile_primary_btn_word' => __( 'Update Profile', 'ultimate-member' ),
|
253 |
+
'_um_profile_secondary_btn' => '1',
|
254 |
+
'_um_profile_secondary_btn_word' => __( 'Cancel', 'ultimate-member' ),
|
255 |
+
|
256 |
+
/*Registration Form*/
|
257 |
+
'_um_register_role' => '0',
|
258 |
+
'_um_register_template' => 'register',
|
259 |
+
'_um_register_max_width' => '450px',
|
260 |
+
'_um_register_align' => 'center',
|
261 |
+
'_um_register_icons' => 'label',
|
262 |
+
'_um_register_primary_btn_word' => __( 'Register', 'ultimate-member' ),
|
263 |
+
'_um_register_secondary_btn' => 1,
|
264 |
+
'_um_register_secondary_btn_word' => __( 'Login', 'ultimate-member' ),
|
265 |
+
'_um_register_secondary_btn_url' => '',
|
266 |
+
|
267 |
+
/*Login Form*/
|
268 |
+
'_um_login_template' => 'login',
|
269 |
+
'_um_login_max_width' => '450px',
|
270 |
+
'_um_login_align' => 'center',
|
271 |
+
'_um_login_icons' => 'label',
|
272 |
+
'_um_login_primary_btn_word' => __( 'Login', 'ultimate-member' ),
|
273 |
+
'_um_login_forgot_pass_link' => 1,
|
274 |
+
'_um_login_show_rememberme' => 1,
|
275 |
+
'_um_login_secondary_btn' => 1,
|
276 |
+
'_um_login_secondary_btn_word' => __( 'Register', 'ultimate-member' ),
|
277 |
+
'_um_login_secondary_btn_url' => '',
|
278 |
+
|
279 |
+
/*Member Directory*/
|
280 |
+
'_um_directory_template' => 'members',
|
281 |
+
'_um_directory_header' => __( '{total_users} Members', 'ultimate-member' ),
|
282 |
+
'_um_directory_header_single' => __( '{total_users} Member', 'ultimate-member' ),
|
283 |
+
) );
|
284 |
+
|
285 |
+
$this->core_form_meta['register'] = array(
|
286 |
+
'_um_custom_fields' => 'a:6:{s:10:"user_login";a:15:{s:5:"title";s:8:"Username";s:7:"metakey";s:10:"user_login";s:4:"type";s:4:"text";s:5:"label";s:8:"Username";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:0;s:8:"validate";s:15:"unique_username";s:9:"min_chars";i:3;s:9:"max_chars";i:24;s:8:"position";s:1:"1";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:10:"user_email";a:13:{s:5:"title";s:14:"E-mail Address";s:7:"metakey";s:10:"user_email";s:4:"type";s:4:"text";s:5:"label";s:14:"E-mail Address";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"validate";s:12:"unique_email";s:8:"position";s:1:"4";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:13:"user_password";a:16:{s:5:"title";s:8:"Password";s:7:"metakey";s:13:"user_password";s:4:"type";s:8:"password";s:5:"label";s:8:"Password";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:1;s:9:"min_chars";i:8;s:9:"max_chars";i:30;s:15:"force_good_pass";i:1;s:18:"force_confirm_pass";i:1;s:8:"position";s:1:"5";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:10:"first_name";a:12:{s:5:"title";s:10:"First Name";s:7:"metakey";s:10:"first_name";s:4:"type";s:4:"text";s:5:"label";s:10:"First Name";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"position";s:1:"2";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"last_name";a:12:{s:5:"title";s:9:"Last Name";s:7:"metakey";s:9:"last_name";s:4:"type";s:4:"text";s:5:"label";s:9:"Last Name";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"position";s:1:"3";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
287 |
+
'_um_mode' => 'register',
|
288 |
+
'_um_core' => 'register',
|
289 |
+
'_um_register_use_custom_settings' => 0,
|
290 |
+
);
|
291 |
+
|
292 |
+
$this->core_form_meta['login'] = array(
|
293 |
+
'_um_custom_fields' => 'a:3:{s:8:"username";a:13:{s:5:"title";s:18:"Username or E-mail";s:7:"metakey";s:8:"username";s:4:"type";s:4:"text";s:5:"label";s:18:"Username or E-mail";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:0;s:8:"validate";s:24:"unique_username_or_email";s:8:"position";s:1:"1";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:13:"user_password";a:16:{s:5:"title";s:8:"Password";s:7:"metakey";s:13:"user_password";s:4:"type";s:8:"password";s:5:"label";s:8:"Password";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:1;s:9:"min_chars";i:8;s:9:"max_chars";i:30;s:15:"force_good_pass";i:1;s:18:"force_confirm_pass";i:1;s:8:"position";s:1:"2";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
294 |
+
'_um_mode' => 'login',
|
295 |
+
'_um_core' => 'login',
|
296 |
+
'_um_login_use_custom_settings' => 0,
|
297 |
+
);
|
298 |
+
|
299 |
+
$this->core_form_meta['profile'] = array(
|
300 |
+
'_um_custom_fields' => 'a:1:{s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
301 |
+
'_um_mode' => 'profile',
|
302 |
+
'_um_core' => 'profile',
|
303 |
+
'_um_profile_use_custom_settings' => 0,
|
304 |
+
);
|
305 |
+
|
306 |
+
|
307 |
+
/**
|
308 |
+
* UM hook
|
309 |
+
*
|
310 |
+
* @type filter
|
311 |
+
* @title um_email_notifications
|
312 |
+
* @description Extend UM email notifications
|
313 |
+
* @input_vars
|
314 |
+
* [{"var":"$emails","type":"array","desc":"UM email notifications"}]
|
315 |
+
* @change_log
|
316 |
+
* ["Since: 2.0"]
|
317 |
+
* @usage
|
318 |
+
* <?php add_filter( 'um_email_notifications', 'function_name', 10, 1 ); ?>
|
319 |
+
* @example
|
320 |
+
* <?php
|
321 |
+
* add_filter( 'um_email_notifications', 'my_email_notifications', 10, 1 );
|
322 |
+
* function my_email_notifications( $emails ) {
|
323 |
+
* // your code here
|
324 |
+
* $emails['my_email'] = array(
|
325 |
+
* 'key' => 'my_email',
|
326 |
+
* 'title' => __( 'my_email_title','ultimate-member' ),
|
327 |
+
* 'subject' => 'my_email_subject',
|
328 |
+
* 'body' => 'my_email_body',
|
329 |
+
* 'description' => 'my_email_description',
|
330 |
+
* 'recipient' => 'user', // set 'admin' for make administrator as recipient
|
331 |
+
* 'default_active' => true // can be false for make disabled by default
|
332 |
+
* );
|
333 |
+
*
|
334 |
+
* return $emails;
|
335 |
+
* }
|
336 |
+
* ?>
|
337 |
+
*/
|
338 |
+
$this->email_notifications = apply_filters( 'um_email_notifications', array(
|
339 |
+
'welcome_email' => array(
|
340 |
+
'key' => 'welcome_email',
|
341 |
+
'title' => __( 'Account Welcome Email','ultimate-member' ),
|
342 |
+
'subject' => 'Welcome to {site_name}!',
|
343 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
344 |
+
'Thank you for signing up with {site_name}! Your account is now active.<br /><br />' .
|
345 |
+
'To login please visit the following url:<br /><br />' .
|
346 |
+
'{login_url} <br /><br />' .
|
347 |
+
'Your account e-mail: {email} <br />' .
|
348 |
+
'Your account username: {username} <br /><br />' .
|
349 |
+
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
350 |
+
'Thanks,<br />' .
|
351 |
+
'{site_name}',
|
352 |
+
'description' => __('Whether to send the user an email when his account is automatically approved','ultimate-member'),
|
353 |
+
'recipient' => 'user',
|
354 |
+
'default_active' => true
|
355 |
+
),
|
356 |
+
'checkmail_email' => array(
|
357 |
+
'key' => 'checkmail_email',
|
358 |
+
'title' => __( 'Account Activation Email','ultimate-member' ),
|
359 |
+
'subject' => 'Please activate your account',
|
360 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
361 |
+
'Thank you for signing up with {site_name}! To activate your account, please click the link below to confirm your email address:<br /><br />' .
|
362 |
+
'{account_activation_link} <br /><br />' .
|
363 |
+
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
364 |
+
'Thanks, <br />' .
|
365 |
+
'{site_name}',
|
366 |
+
'description' => __('Whether to send the user an email when his account needs e-mail activation','ultimate-member'),
|
367 |
+
'recipient' => 'user'
|
368 |
+
),
|
369 |
+
'pending_email' => array(
|
370 |
+
'key' => 'pending_email',
|
371 |
+
'title' => __( 'Your account is pending review','ultimate-member' ),
|
372 |
+
'subject' => '[{site_name}] New user account',
|
373 |
+
'body' => 'Hi {display_name}, <br /><br />' .
|
374 |
+
'Thank you for signing up with {site_name}! Your account is currently being reviewed by a member of our team.<br /><br />' .
|
375 |
+
'Please allow us some time to process your request.<br /><br />' .
|
376 |
+
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
377 |
+
'Thanks,<br />' .
|
378 |
+
'{site_name}',
|
379 |
+
'description' => __('Whether to send the user an email when his account needs admin review','ultimate-member'),
|
380 |
+
'recipient' => 'user'
|
381 |
+
),
|
382 |
+
'approved_email' => array(
|
383 |
+
'key' => 'approved_email',
|
384 |
+
'title' => __( 'Account Approved Email','ultimate-member' ),
|
385 |
+
'subject' => 'Your account at {site_name} is now active',
|
386 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
387 |
+
'Thank you for signing up with {site_name}! Your account has been approved and is now active.<br /><br />' .
|
388 |
+
'To login please visit the following url:<br /><br />' .
|
389 |
+
'{login_url}<br /><br />' .
|
390 |
+
'Your account e-mail: {email}<br />' .
|
391 |
+
'Your account username: {username}<br />' .
|
392 |
+
'Set your account password: {password_reset_link}<br /><br />' .
|
393 |
+
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
394 |
+
'Thanks,<br />' .
|
395 |
+
'{site_name}',
|
396 |
+
'description' => __('Whether to send the user an email when his account is approved','ultimate-member'),
|
397 |
+
'recipient' => 'user'
|
398 |
+
),
|
399 |
+
'rejected_email' => array(
|
400 |
+
'key' => 'rejected_email',
|
401 |
+
'title' => __( 'Account Rejected Email','ultimate-member' ),
|
402 |
+
'subject' => 'Your account has been rejected',
|
403 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
404 |
+
'Thank you for applying for membership to {site_name}! We have reviewed your information and unfortunately we are unable to accept you as a member at this moment.<br /><br />' .
|
405 |
+
'Please feel free to apply again at a future date.<br /><br />' .
|
406 |
+
'Thanks,<br />' .
|
407 |
+
'{site_name}',
|
408 |
+
'description' => __('Whether to send the user an email when his account is rejected','ultimate-member'),
|
409 |
+
'recipient' => 'user'
|
410 |
+
),
|
411 |
+
'inactive_email' => array(
|
412 |
+
'key' => 'inactive_email',
|
413 |
+
'title' => __( 'Account Deactivated Email','ultimate-member' ),
|
414 |
+
'subject' => 'Your account has been deactivated',
|
415 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
416 |
+
'This is an automated email to let you know your {site_name} account has been deactivated.<br /><br />' .
|
417 |
+
'If you would like your account to be reactivated please contact us at {admin_email}<br /><br />' .
|
418 |
+
'Thanks,<br />' .
|
419 |
+
'{site_name}',
|
420 |
+
'description' => __('Whether to send the user an email when his account is deactivated','ultimate-member'),
|
421 |
+
'recipient' => 'user',
|
422 |
+
'default_active' => true
|
423 |
+
),
|
424 |
+
'deletion_email' => array(
|
425 |
+
'key' => 'deletion_email',
|
426 |
+
'title' => __( 'Account Deleted Email','ultimate-member' ),
|
427 |
+
'subject' => 'Your account has been deleted',
|
428 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
429 |
+
'This is an automated email to let you know your {site_name} account has been deleted. All of your personal information has been permanently deleted and you will no longer be able to login to {site_name}.<br /><br />' .
|
430 |
+
'If your account has been deleted by accident please contact us at {admin_email} <br />' .
|
431 |
+
'Thanks,<br />' .
|
432 |
+
'{site_name}',
|
433 |
+
'description' => __('Whether to send the user an email when his account is deleted','ultimate-member'),
|
434 |
+
'recipient' => 'user',
|
435 |
+
'default_active' => true
|
436 |
+
),
|
437 |
+
'resetpw_email' => array(
|
438 |
+
'key' => 'resetpw_email',
|
439 |
+
'title' => __( 'Password Reset Email','ultimate-member' ),
|
440 |
+
'subject' => 'Reset your password',
|
441 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
442 |
+
'We received a request to reset the password for your account. If you made this request, click the link below to change your password:<br /><br />' .
|
443 |
+
'{password_reset_link}<br /><br />' .
|
444 |
+
'If you didn\'t make this request, you can ignore this email <br /><br />' .
|
445 |
+
'Thanks,<br />' .
|
446 |
+
'{site_name}',
|
447 |
+
'description' => __('Whether to send an email when users changed their password (Recommended, please keep on)','ultimate-member'),
|
448 |
+
'recipient' => 'user',
|
449 |
+
'default_active' => true
|
450 |
+
),
|
451 |
+
'changedpw_email' => array(
|
452 |
+
'key' => 'changedpw_email',
|
453 |
+
'title' => __( 'Password Changed Email','ultimate-member' ),
|
454 |
+
'subject' => 'Your {site_name} password has been changed',
|
455 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
456 |
+
'You recently changed the password associated with your {site_name} account.<br /><br />' .
|
457 |
+
'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}<br /><br />' .
|
458 |
+
'Thanks,<br />' .
|
459 |
+
'{site_name}',
|
460 |
+
'description' => __('Whether to send the user an email when he request to reset password (Recommended, please keep on)','ultimate-member'),
|
461 |
+
'recipient' => 'user',
|
462 |
+
'default_active' => true
|
463 |
+
),
|
464 |
+
'changedaccount_email' => array(
|
465 |
+
'key' => 'changedaccount_email',
|
466 |
+
'title' => __( 'Account Updated Email','ultimate-member' ),
|
467 |
+
'subject' => 'Your account at {site_name} was updated',
|
468 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
469 |
+
'You recently updated your {site_name} account.<br /><br />' .
|
470 |
+
'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}<br /><br />' .
|
471 |
+
'Thanks,<br />' .
|
472 |
+
'{site_name}',
|
473 |
+
'description' => __('Whether to send the user an email when he updated their account','ultimate-member'),
|
474 |
+
'recipient' => 'user',
|
475 |
+
'default_active'=> true
|
476 |
+
),
|
477 |
+
'notification_new_user' => array(
|
478 |
+
'key' => 'notification_new_user',
|
479 |
+
'title' => __( 'New User Notification','ultimate-member' ),
|
480 |
+
'subject' => '[{site_name}] New user account',
|
481 |
+
'body' => '{display_name} has just created an account on {site_name}. To view their profile click here:<br /><br />' .
|
482 |
+
'{user_profile_link}<br /><br />' .
|
483 |
+
'Here is the submitted registration form:<br /><br />' .
|
484 |
+
'{submitted_registration}',
|
485 |
+
'description' => __('Whether to receive notification when a new user account is approved','ultimate-member'),
|
486 |
+
'recipient' => 'admin',
|
487 |
+
'default_active' => true
|
488 |
+
),
|
489 |
+
'notification_review' => array(
|
490 |
+
'key' => 'notification_review',
|
491 |
+
'title' => __( 'Account Needs Review Notification','ultimate-member' ),
|
492 |
+
'subject' => '[{site_name}] New user awaiting review',
|
493 |
+
'body' => '{display_name} has just applied for membership to {site_name} and is waiting to be reviewed.<br /><br />' .
|
494 |
+
'To review this member please click the following link:<br /><br />' .
|
495 |
+
'{user_profile_link}<br /><br />' .
|
496 |
+
'Here is the submitted registration form:<br /><br />' .
|
497 |
+
'{submitted_registration}',
|
498 |
+
'description' => __('Whether to receive notification when an account needs admin review','ultimate-member'),
|
499 |
+
'recipient' => 'admin'
|
500 |
+
),
|
501 |
+
'notification_deletion' => array(
|
502 |
+
'key' => 'notification_deletion',
|
503 |
+
'title' => __( 'Account Deletion Notification','ultimate-member' ),
|
504 |
+
'subject' => '[{site_name}] Account deleted',
|
505 |
+
'body' => '{display_name} has just deleted their {site_name} account.',
|
506 |
+
'description' => __('Whether to receive notification when an account is deleted','ultimate-member'),
|
507 |
+
'recipient' => 'admin'
|
508 |
+
)
|
509 |
+
) );
|
510 |
+
|
511 |
+
|
512 |
+
//settings defaults
|
513 |
+
$this->settings_defaults = array(
|
514 |
+
'restricted_access_post_metabox' => array( 'post' => 1, 'page' => 1 ),
|
515 |
+
'disable_restriction_pre_queries' => 0,
|
516 |
+
'uninstall_on_delete' => 0,
|
517 |
+
'permalink_base' => 'user_login',
|
518 |
+
'display_name' => 'full_name',
|
519 |
+
'display_name_field' => '',
|
520 |
+
'author_redirect' => 1,
|
521 |
+
'members_page' => 1,
|
522 |
+
'use_gravatars' => 0,
|
523 |
+
'use_um_gravatar_default_builtin_image' => 'default',
|
524 |
+
'use_um_gravatar_default_image' => 0,
|
525 |
+
'require_strongpass' => 0,
|
526 |
+
'password_min_chars' => 8,
|
527 |
+
'password_max_chars' => 30,
|
528 |
+
'account_tab_password' => 1,
|
529 |
+
'account_tab_privacy' => 1,
|
530 |
+
'account_tab_notifications' => 1,
|
531 |
+
'account_tab_delete' => 1,
|
532 |
+
'delete_account_text' => __( 'Are you sure you want to delete your account? This will erase all of your account data from the site. To delete your account enter your password below.', 'ultimate-member' ),
|
533 |
+
'delete_account_no_pass_required_text' => __( 'Are you sure you want to delete your account? This will erase all of your account data from the site. To delete your account, click on the button below.', 'ultimate-member' ),
|
534 |
+
'account_name' => 1,
|
535 |
+
'account_name_disable' => 0,
|
536 |
+
'account_name_require' => 1,
|
537 |
+
'account_email' => 1,
|
538 |
+
'account_general_password' => 0,
|
539 |
+
'account_hide_in_directory' => 1,
|
540 |
+
'account_hide_in_directory_default' => 'No',
|
541 |
+
'photo_thumb_sizes' => array( 40, 80, 190 ),
|
542 |
+
'cover_thumb_sizes' => array( 300, 600 ),
|
543 |
+
'accessible' => 0,
|
544 |
+
'access_redirect' => '',
|
545 |
+
'access_exclude_uris' => array(),
|
546 |
+
'home_page_accessible' => 1,
|
547 |
+
'category_page_accessible' => 1,
|
548 |
+
'restricted_post_title_replace' => 1,
|
549 |
+
'restricted_access_post_title' => __( 'Restricted content', 'ultimate-member' ),
|
550 |
+
'restricted_access_message' => '',
|
551 |
+
'restricted_blocks' => 0,
|
552 |
+
'enable_blocks' => 0,
|
553 |
+
'restricted_block_message' => '',
|
554 |
+
'enable_reset_password_limit' => 1,
|
555 |
+
'reset_password_limit_number' => 3,
|
556 |
+
'blocked_emails' => '',
|
557 |
+
'blocked_words' => 'admin' . "\r\n" . 'administrator' . "\r\n" . 'webmaster' . "\r\n" . 'support' . "\r\n" . 'staff',
|
558 |
+
'default_avatar' => '',
|
559 |
+
'default_cover' => '',
|
560 |
+
'disable_profile_photo_upload' => 0,
|
561 |
+
'profile_show_metaicon' => 0,
|
562 |
+
'profile_menu' => 1,
|
563 |
+
'profile_menu_default_tab' => 'main',
|
564 |
+
'profile_menu_icons' => 1,
|
565 |
+
'form_asterisk' => 0,
|
566 |
+
'profile_title' => '{display_name} | {site_name}',
|
567 |
+
'profile_desc' => '{display_name} is on {site_name}. Join {site_name} to view {display_name}\'s profile',
|
568 |
+
'admin_email' => get_bloginfo('admin_email'),
|
569 |
+
'mail_from' => get_bloginfo('name'),
|
570 |
+
'mail_from_addr' => get_bloginfo('admin_email'),
|
571 |
+
'email_html' => 1,
|
572 |
+
'image_orientation_by_exif' => 0,
|
573 |
+
'image_compression' => 60,
|
574 |
+
'image_max_width' => 1000,
|
575 |
+
'cover_min_width' => 1000,
|
576 |
+
'profile_photo_max_size' => 999999999,
|
577 |
+
'cover_photo_max_size' => 999999999,
|
578 |
+
'custom_roles_increment' => 1,
|
579 |
+
'um_profile_object_cache_stop' => 0,
|
580 |
+
'rest_api_version' => '2.0',
|
581 |
+
'member_directory_own_table' => 0,
|
582 |
+
'profile_show_html_bio' => 0,
|
583 |
+
'profile_noindex' => 0,
|
584 |
+
'activation_link_expiry_time' => '',
|
585 |
+
);
|
586 |
+
|
587 |
+
add_filter( 'um_get_tabs_from_config', '__return_true' );
|
588 |
+
|
589 |
+
$tabs = UM()->profile()->tabs();
|
590 |
+
|
591 |
+
foreach ( $tabs as $id => $tab ) {
|
592 |
+
|
593 |
+
if ( ! empty( $tab['hidden'] ) ) {
|
594 |
+
continue;
|
595 |
+
}
|
596 |
+
|
597 |
+
$this->settings_defaults[ 'profile_tab_' . $id ] = 1;
|
598 |
+
|
599 |
+
if ( ! isset( $tab['default_privacy'] ) ) {
|
600 |
+
$this->settings_defaults[ 'profile_tab_' . $id . '_privacy' ] = 0;
|
601 |
+
$this->settings_defaults[ 'profile_tab_' . $id . '_roles' ] = '';
|
602 |
+
}
|
603 |
+
}
|
604 |
+
|
605 |
+
foreach ( $this->email_notifications as $key => $notification ) {
|
606 |
+
$this->settings_defaults[ $key . '_on' ] = ! empty( $notification['default_active'] );
|
607 |
+
$this->settings_defaults[ $key . '_sub' ] = $notification['subject'];
|
608 |
+
$this->settings_defaults[ $key ] = $notification['body'];
|
609 |
+
}
|
610 |
+
|
611 |
+
foreach ( $this->core_pages as $page_s => $page ) {
|
612 |
+
$page_id = UM()->options()->get_core_page_id( $page_s );
|
613 |
+
$this->settings_defaults[ $page_id ] = '';
|
614 |
+
}
|
615 |
+
|
616 |
+
foreach( $this->core_form_meta_all as $key => $value ) {
|
617 |
+
$this->settings_defaults[ str_replace( '_um_', '', $key ) ] = $value;
|
618 |
+
}
|
619 |
+
|
620 |
+
|
621 |
+
/**
|
622 |
+
* UM hook
|
623 |
+
*
|
624 |
+
* @type filter
|
625 |
+
* @title um_default_settings_values
|
626 |
+
* @description Extend UM default settings
|
627 |
+
* @input_vars
|
628 |
+
* [{"var":"$settings","type":"array","desc":"UM default settings"}]
|
629 |
+
* @change_log
|
630 |
+
* ["Since: 2.0"]
|
631 |
+
* @usage
|
632 |
+
* <?php add_filter( 'um_default_settings_values', 'function_name', 10, 1 ); ?>
|
633 |
+
* @example
|
634 |
+
* <?php
|
635 |
+
* add_filter( 'um_default_settings_values', 'my_default_settings_values', 10, 1 );
|
636 |
+
* function my_default_settings_values( $settings ) {
|
637 |
+
* // your code here
|
638 |
+
* return $settings;
|
639 |
+
* }
|
640 |
+
* ?>
|
641 |
+
*/
|
642 |
+
$this->settings_defaults = apply_filters( 'um_default_settings_values', $this->settings_defaults );
|
643 |
+
|
644 |
+
$this->permalinks = $this->get_core_pages();
|
645 |
+
|
646 |
+
|
647 |
+
|
648 |
+
$this->default_roles_metadata = array(
|
649 |
+
/*
|
650 |
+
* All caps map
|
651 |
+
*
|
652 |
+
* '_um_can_access_wpadmin' => 1,
|
653 |
+
'_um_can_not_see_adminbar' => 0,
|
654 |
+
'_um_can_edit_everyone' => 1,
|
655 |
+
'_um_can_edit_roles' => '',
|
656 |
+
'_um_can_delete_everyone' => 1,
|
657 |
+
'_um_can_delete_roles' => '',
|
658 |
+
'_um_after_delete' => '',
|
659 |
+
'_um_delete_redirect_url' => '',
|
660 |
+
'_um_can_edit_profile' => 1,
|
661 |
+
'_um_can_delete_profile' => 1,
|
662 |
+
'_um_default_homepage' => 1,
|
663 |
+
'_um_redirect_homepage' => '',
|
664 |
+
'_um_after_login' => 'redirect_admin',
|
665 |
+
'_um_login_redirect_url' => '',
|
666 |
+
'_um_after_logout' => 'redirect_home',
|
667 |
+
'_um_logout_redirect_url' => '',
|
668 |
+
'_um_can_view_all' => 1,
|
669 |
+
'_um_can_view_roles' => '',
|
670 |
+
'_um_can_make_private_profile' => 1,
|
671 |
+
'_um_can_access_private_profile' => 1,
|
672 |
+
'_um_status' => 'approved',
|
673 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
674 |
+
'_um_auto_approve_url' => '',
|
675 |
+
'_um_login_email_activate' => '',
|
676 |
+
'_um_checkmail_action' => '',
|
677 |
+
'_um_checkmail_message' => '',
|
678 |
+
'_um_checkmail_url' => '',
|
679 |
+
'_um_url_email_activate' => '',
|
680 |
+
'_um_pending_action' => '',
|
681 |
+
'_um_pending_message' => '',
|
682 |
+
'_um_pending_url' => '',
|
683 |
+
*
|
684 |
+
* */
|
685 |
+
|
686 |
+
|
687 |
+
'subscriber' => array(
|
688 |
+
'_um_can_access_wpadmin' => 0,
|
689 |
+
'_um_can_not_see_adminbar' => 1,
|
690 |
+
'_um_can_edit_everyone' => 0,
|
691 |
+
'_um_can_delete_everyone' => 0,
|
692 |
+
'_um_can_edit_profile' => 1,
|
693 |
+
'_um_can_delete_profile' => 1,
|
694 |
+
'_um_after_login' => 'redirect_profile',
|
695 |
+
'_um_after_logout' => 'redirect_home',
|
696 |
+
'_um_default_homepage' => 1,
|
697 |
+
'_um_can_view_all' => 1,
|
698 |
+
'_um_can_make_private_profile' => 0,
|
699 |
+
'_um_can_access_private_profile' => 0,
|
700 |
+
'_um_status' => 'approved',
|
701 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
702 |
+
),
|
703 |
+
'author' => array(
|
704 |
+
'_um_can_access_wpadmin' => 0,
|
705 |
+
'_um_can_not_see_adminbar' => 1,
|
706 |
+
'_um_can_edit_everyone' => 0,
|
707 |
+
'_um_can_delete_everyone' => 0,
|
708 |
+
'_um_can_edit_profile' => 1,
|
709 |
+
'_um_can_delete_profile' => 1,
|
710 |
+
'_um_after_login' => 'redirect_profile',
|
711 |
+
'_um_after_logout' => 'redirect_home',
|
712 |
+
'_um_default_homepage' => 1,
|
713 |
+
'_um_can_view_all' => 1,
|
714 |
+
'_um_can_make_private_profile' => 0,
|
715 |
+
'_um_can_access_private_profile' => 0,
|
716 |
+
'_um_status' => 'approved',
|
717 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
718 |
+
),
|
719 |
+
'contributor' => array(
|
720 |
+
'_um_can_access_wpadmin' => 0,
|
721 |
+
'_um_can_not_see_adminbar' => 1,
|
722 |
+
'_um_can_edit_everyone' => 0,
|
723 |
+
'_um_can_delete_everyone' => 0,
|
724 |
+
'_um_can_edit_profile' => 1,
|
725 |
+
'_um_can_delete_profile' => 1,
|
726 |
+
'_um_after_login' => 'redirect_profile',
|
727 |
+
'_um_after_logout' => 'redirect_home',
|
728 |
+
'_um_default_homepage' => 1,
|
729 |
+
'_um_can_view_all' => 1,
|
730 |
+
'_um_can_make_private_profile' => 0,
|
731 |
+
'_um_can_access_private_profile' => 0,
|
732 |
+
'_um_status' => 'approved',
|
733 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
734 |
+
),
|
735 |
+
'editor' => array(
|
736 |
+
'_um_can_access_wpadmin' => 0,
|
737 |
+
'_um_can_not_see_adminbar' => 1,
|
738 |
+
'_um_can_edit_everyone' => 0,
|
739 |
+
'_um_can_delete_everyone' => 0,
|
740 |
+
'_um_can_edit_profile' => 1,
|
741 |
+
'_um_can_delete_profile' => 1,
|
742 |
+
'_um_after_login' => 'redirect_profile',
|
743 |
+
'_um_after_logout' => 'redirect_home',
|
744 |
+
'_um_default_homepage' => 1,
|
745 |
+
'_um_can_view_all' => 1,
|
746 |
+
'_um_can_make_private_profile' => 0,
|
747 |
+
'_um_can_access_private_profile' => 0,
|
748 |
+
'_um_status' => 'approved',
|
749 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
750 |
+
),
|
751 |
+
'administrator' => array(
|
752 |
+
'_um_can_access_wpadmin' => 1,
|
753 |
+
'_um_can_not_see_adminbar' => 0,
|
754 |
+
'_um_can_edit_everyone' => 1,
|
755 |
+
'_um_can_delete_everyone' => 1,
|
756 |
+
'_um_can_edit_profile' => 1,
|
757 |
+
'_um_can_delete_profile' => 1,
|
758 |
+
'_um_default_homepage' => 1,
|
759 |
+
'_um_after_login' => 'redirect_admin',
|
760 |
+
'_um_after_logout' => 'redirect_home',
|
761 |
+
'_um_can_view_all' => 1,
|
762 |
+
'_um_can_make_private_profile' => 1,
|
763 |
+
'_um_can_access_private_profile' => 1,
|
764 |
+
'_um_status' => 'approved',
|
765 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
766 |
+
),
|
767 |
+
);
|
768 |
+
}
|
769 |
+
|
770 |
+
|
771 |
+
/**
|
772 |
+
* Get UM Pages
|
773 |
+
*
|
774 |
+
* @return array
|
775 |
+
*/
|
776 |
+
function get_core_pages() {
|
777 |
+
$permalink = array();
|
778 |
+
$core_pages = array_keys( $this->core_pages );
|
779 |
+
if ( empty( $core_pages ) ) {
|
780 |
+
return $permalink;
|
781 |
+
}
|
782 |
+
|
783 |
+
foreach ( $core_pages as $page_key ) {
|
784 |
+
$page_option_key = UM()->options()->get_core_page_id( $page_key );
|
785 |
+
$permalink[ $page_key ] = UM()->options()->get( $page_option_key );
|
786 |
+
}
|
787 |
+
|
788 |
+
return $permalink;
|
789 |
+
}
|
790 |
+
|
791 |
+
|
792 |
+
/**
|
793 |
+
* @todo make config class not cycled
|
794 |
+
*/
|
795 |
+
function set_core_page() {
|
796 |
+
$this->core_pages = apply_filters( 'um_core_pages', array(
|
797 |
+
'user' => array( 'title' => __( 'User', 'ultimate-member' ) ),
|
798 |
+
'login' => array( 'title' => __( 'Login', 'ultimate-member' ) ),
|
799 |
+
'register' => array( 'title' => __( 'Register', 'ultimate-member' ) ),
|
800 |
+
'members' => array( 'title' => __( 'Members', 'ultimate-member' ) ),
|
801 |
+
'logout' => array( 'title' => __( 'Logout', 'ultimate-member' ) ),
|
802 |
+
'account' => array( 'title' => __( 'Account', 'ultimate-member' ) ),
|
803 |
+
'password-reset' => array( 'title' => __( 'Password Reset', 'ultimate-member' ) ),
|
804 |
+
) );
|
805 |
+
}
|
806 |
+
//end class
|
807 |
+
}
|
808 |
+
}
|
|
includes/class-functions.php
CHANGED
@@ -1,410 +1,410 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
2 |
-
|
3 |
-
|
4 |
-
if ( ! class_exists( 'UM_Functions' ) ) {
|
5 |
-
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Class UM_Functions
|
9 |
-
*/
|
10 |
-
class UM_Functions {
|
11 |
-
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Store URL
|
15 |
-
*
|
16 |
-
* @var string
|
17 |
-
*/
|
18 |
-
var $store_url = 'https://ultimatemember.com/';
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* WP remote Post timeout
|
23 |
-
* @var int
|
24 |
-
*/
|
25 |
-
var $request_timeout = 60;
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* UM_Functions constructor.
|
30 |
-
*/
|
31 |
-
function __construct() {
|
32 |
-
}
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Check if AJAX now
|
37 |
-
*
|
38 |
-
* @return bool
|
39 |
-
*/
|
40 |
-
function is_ajax() {
|
41 |
-
return function_exists( 'wp_doing_ajax' ) ? wp_doing_ajax() : defined( 'DOING_AJAX' );
|
42 |
-
}
|
43 |
-
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Check frontend nonce
|
47 |
-
*
|
48 |
-
* @param bool $action
|
49 |
-
*/
|
50 |
-
function check_ajax_nonce( $action = false ) {
|
51 |
-
$nonce = isset( $_REQUEST['nonce'] ) ? sanitize_text_field( $_REQUEST['nonce'] ) : '';
|
52 |
-
$action = empty( $action ) ? 'um-frontend-nonce' : $action;
|
53 |
-
|
54 |
-
if ( ! wp_verify_nonce( $nonce, $action ) ) {
|
55 |
-
wp_send_json_error( esc_js( __( 'Wrong Nonce', 'ultimate-member' ) ) );
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
|
60 |
-
/**
|
61 |
-
* What type of request is this?
|
62 |
-
*
|
63 |
-
* @param string $type String containing name of request type (ajax, frontend, cron or admin)
|
64 |
-
*
|
65 |
-
* @return bool
|
66 |
-
*/
|
67 |
-
public function is_request( $type ) {
|
68 |
-
switch ( $type ) {
|
69 |
-
case 'admin' :
|
70 |
-
return is_admin();
|
71 |
-
case 'ajax' :
|
72 |
-
return defined( 'DOING_AJAX' );
|
73 |
-
case 'cron' :
|
74 |
-
return defined( 'DOING_CRON' );
|
75 |
-
case 'frontend' :
|
76 |
-
return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' );
|
77 |
-
}
|
78 |
-
|
79 |
-
return false;
|
80 |
-
}
|
81 |
-
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Help Tip displaying
|
85 |
-
*
|
86 |
-
* Function for render/displaying UltimateMember help tip
|
87 |
-
*
|
88 |
-
* @since 2.0.0
|
89 |
-
*
|
90 |
-
* @param string $tip Help tip text
|
91 |
-
* @param bool $allow_html Allow sanitized HTML if true or escape
|
92 |
-
* @param bool $echo Return HTML or echo
|
93 |
-
* @return string
|
94 |
-
*/
|
95 |
-
function tooltip( $tip, $allow_html = false, $echo = true ) {
|
96 |
-
if ( $allow_html ) {
|
97 |
-
|
98 |
-
$tip = htmlspecialchars( wp_kses( html_entity_decode( $tip ), array(
|
99 |
-
'br' => array(),
|
100 |
-
'em' => array(),
|
101 |
-
'strong' => array(),
|
102 |
-
'small' => array(),
|
103 |
-
'span' => array(),
|
104 |
-
'ul' => array(),
|
105 |
-
'li' => array(),
|
106 |
-
'ol' => array(),
|
107 |
-
'p' => array(),
|
108 |
-
) ) );
|
109 |
-
|
110 |
-
} else {
|
111 |
-
$tip = esc_attr( $tip );
|
112 |
-
}
|
113 |
-
|
114 |
-
ob_start(); ?>
|
115 |
-
|
116 |
-
<span class="um_tooltip dashicons dashicons-editor-help" title="<?php echo $tip ?>"></span>
|
117 |
-
|
118 |
-
<?php if ( $echo ) {
|
119 |
-
ob_get_flush();
|
120 |
-
return '';
|
121 |
-
} else {
|
122 |
-
return ob_get_clean();
|
123 |
-
}
|
124 |
-
|
125 |
-
}
|
126 |
-
|
127 |
-
|
128 |
-
/**
|
129 |
-
* @return mixed|void
|
130 |
-
*/
|
131 |
-
function excluded_taxonomies() {
|
132 |
-
$taxes = array(
|
133 |
-
'nav_menu',
|
134 |
-
'link_category',
|
135 |
-
'post_format',
|
136 |
-
);
|
137 |
-
|
138 |
-
/**
|
139 |
-
* UM hook
|
140 |
-
*
|
141 |
-
* @type filter
|
142 |
-
* @title um_excluded_taxonomies
|
143 |
-
* @description Exclude taxonomies for UM
|
144 |
-
* @input_vars
|
145 |
-
* [{"var":"$taxes","type":"array","desc":"Taxonomies keys"}]
|
146 |
-
* @change_log
|
147 |
-
* ["Since: 2.0"]
|
148 |
-
* @usage
|
149 |
-
* <?php add_filter( 'um_excluded_taxonomies', 'function_name', 10, 1 ); ?>
|
150 |
-
* @example
|
151 |
-
* <?php
|
152 |
-
* add_filter( 'um_excluded_taxonomies', 'my_excluded_taxonomies', 10, 1 );
|
153 |
-
* function my_excluded_taxonomies( $taxes ) {
|
154 |
-
* // your code here
|
155 |
-
* return $taxes;
|
156 |
-
* }
|
157 |
-
* ?>
|
158 |
-
*/
|
159 |
-
return apply_filters( 'um_excluded_taxonomies', $taxes );
|
160 |
-
}
|
161 |
-
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Output templates
|
165 |
-
*
|
166 |
-
* @access public
|
167 |
-
* @param string $template_name
|
168 |
-
* @param string $basename (default: '')
|
169 |
-
* @param array $t_args (default: array())
|
170 |
-
* @param bool $echo
|
171 |
-
*
|
172 |
-
* @return string|void
|
173 |
-
*/
|
174 |
-
function get_template( $template_name, $basename = '', $t_args = array(), $echo = false ) {
|
175 |
-
if ( ! empty( $t_args ) && is_array( $t_args ) ) {
|
176 |
-
extract( $t_args );
|
177 |
-
}
|
178 |
-
|
179 |
-
$path = '';
|
180 |
-
if ( $basename ) {
|
181 |
-
// use '/' instead of "DIRECTORY_SEPARATOR", because wp_normalize_path makes the correct replace
|
182 |
-
$array = explode( '/', wp_normalize_path( trim( $basename ) ) );
|
183 |
-
$path = $array[0];
|
184 |
-
}
|
185 |
-
|
186 |
-
$located = $this->locate_template( $template_name, $path );
|
187 |
-
if ( ! file_exists( $located ) ) {
|
188 |
-
_doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
|
189 |
-
return;
|
190 |
-
}
|
191 |
-
|
192 |
-
|
193 |
-
/**
|
194 |
-
* UM hook
|
195 |
-
*
|
196 |
-
* @type filter
|
197 |
-
* @title um_get_template
|
198 |
-
* @description Change template location
|
199 |
-
* @input_vars
|
200 |
-
* [{"var":"$located","type":"string","desc":"template Located"},
|
201 |
-
* {"var":"$template_name","type":"string","desc":"Template Name"},
|
202 |
-
* {"var":"$path","type":"string","desc":"Template Path at server"},
|
203 |
-
* {"var":"$t_args","type":"array","desc":"Template Arguments"}]
|
204 |
-
* @change_log
|
205 |
-
* ["Since: 2.0"]
|
206 |
-
* @usage add_filter( 'um_get_template', 'function_name', 10, 4 );
|
207 |
-
* @example
|
208 |
-
* <?php
|
209 |
-
* add_filter( 'um_get_template', 'my_get_template', 10, 4 );
|
210 |
-
* function my_get_template( $located, $template_name, $path, $t_args ) {
|
211 |
-
* // your code here
|
212 |
-
* return $located;
|
213 |
-
* }
|
214 |
-
* ?>
|
215 |
-
*/
|
216 |
-
$located = apply_filters( 'um_get_template', $located, $template_name, $path, $t_args );
|
217 |
-
|
218 |
-
ob_start();
|
219 |
-
|
220 |
-
/**
|
221 |
-
* UM hook
|
222 |
-
*
|
223 |
-
* @type action
|
224 |
-
* @title um_before_template_part
|
225 |
-
* @description Make some action before include template file
|
226 |
-
* @input_vars
|
227 |
-
* [{"var":"$template_name","type":"string","desc":"Template Name"},
|
228 |
-
* {"var":"$path","type":"string","desc":"Template Path at server"},
|
229 |
-
* {"var":"$located","type":"string","desc":"template Located"},
|
230 |
-
* {"var":"$t_args","type":"array","desc":"Template Arguments"}]
|
231 |
-
* @change_log
|
232 |
-
* ["Since: 2.0"]
|
233 |
-
* @usage add_action( 'um_before_template_part', 'function_name', 10, 4 );
|
234 |
-
* @example
|
235 |
-
* <?php
|
236 |
-
* add_action( 'um_before_template_part', 'my_before_template_part', 10, 4 );
|
237 |
-
* function my_before_template_part( $template_name, $path, $located, $t_args ) {
|
238 |
-
* // your code here
|
239 |
-
* }
|
240 |
-
* ?>
|
241 |
-
*/
|
242 |
-
do_action( 'um_before_template_part', $template_name, $path, $located, $t_args );
|
243 |
-
include( $located );
|
244 |
-
|
245 |
-
/**
|
246 |
-
* UM hook
|
247 |
-
*
|
248 |
-
* @type action
|
249 |
-
* @title um_after_template_part
|
250 |
-
* @description Make some action after include template file
|
251 |
-
* @input_vars
|
252 |
-
* [{"var":"$template_name","type":"string","desc":"Template Name"},
|
253 |
-
* {"var":"$path","type":"string","desc":"Template Path at server"},
|
254 |
-
* {"var":"$located","type":"string","desc":"template Located"},
|
255 |
-
* {"var":"$t_args","type":"array","desc":"Template Arguments"}]
|
256 |
-
* @change_log
|
257 |
-
* ["Since: 2.0"]
|
258 |
-
* @usage add_action( 'um_after_template_part', 'function_name', 10, 4 );
|
259 |
-
* @example
|
260 |
-
* <?php
|
261 |
-
* add_action( 'um_after_template_part', 'my_after_template_part', 10, 4 );
|
262 |
-
* function my_after_template_part( $template_name, $path, $located, $t_args ) {
|
263 |
-
* // your code here
|
264 |
-
* }
|
265 |
-
* ?>
|
266 |
-
*/
|
267 |
-
do_action( 'um_after_template_part', $template_name, $path, $located, $t_args );
|
268 |
-
$html = ob_get_clean();
|
269 |
-
|
270 |
-
if ( ! $echo ) {
|
271 |
-
return $html;
|
272 |
-
} else {
|
273 |
-
echo $html;
|
274 |
-
return;
|
275 |
-
}
|
276 |
-
}
|
277 |
-
|
278 |
-
|
279 |
-
/**
|
280 |
-
* Locate a template and return the path for inclusion.
|
281 |
-
*
|
282 |
-
* @access public
|
283 |
-
* @param string $template_name
|
284 |
-
* @param string $path (default: '')
|
285 |
-
* @return string
|
286 |
-
*/
|
287 |
-
function locate_template( $template_name, $path = '' ) {
|
288 |
-
// check if there is template at theme folder
|
289 |
-
$template = locate_template( array(
|
290 |
-
trailingslashit( 'ultimate-member' . DIRECTORY_SEPARATOR . $path ) . $template_name
|
291 |
-
) );
|
292 |
-
|
293 |
-
if ( ! $template ) {
|
294 |
-
if ( $path ) {
|
295 |
-
$template = trailingslashit( trailingslashit( WP_PLUGIN_DIR ) . $path );
|
296 |
-
} else {
|
297 |
-
$template = trailingslashit( um_path );
|
298 |
-
}
|
299 |
-
$template .= 'templates' . DIRECTORY_SEPARATOR . $template_name;
|
300 |
-
}
|
301 |
-
|
302 |
-
|
303 |
-
/**
|
304 |
-
* UM hook
|
305 |
-
*
|
306 |
-
* @type filter
|
307 |
-
* @title um_locate_template
|
308 |
-
* @description Change template locate
|
309 |
-
* @input_vars
|
310 |
-
* [{"var":"$template","type":"string","desc":"Template locate"},
|
311 |
-
* {"var":"$template_name","type":"string","desc":"Template Name"},
|
312 |
-
* {"var":"$path","type":"string","desc":"Template Path at server"}]
|
313 |
-
* @change_log
|
314 |
-
* ["Since: 2.0"]
|
315 |
-
* @usage add_filter( 'um_locate_template', 'function_name', 10, 3 );
|
316 |
-
* @example
|
317 |
-
* <?php
|
318 |
-
* add_filter( 'um_locate_template', 'my_locate_template', 10, 3 );
|
319 |
-
* function my_locate_template( $template, $template_name, $path ) {
|
320 |
-
* // your code here
|
321 |
-
* return $template;
|
322 |
-
* }
|
323 |
-
* ?>
|
324 |
-
*/
|
325 |
-
return apply_filters( 'um_locate_template', $template, $template_name, $path );
|
326 |
-
}
|
327 |
-
|
328 |
-
|
329 |
-
/**
|
330 |
-
* @return mixed|void
|
331 |
-
*/
|
332 |
-
function cpt_list() {
|
333 |
-
/**
|
334 |
-
* UM hook
|
335 |
-
*
|
336 |
-
* @type filter
|
337 |
-
* @title um_cpt_list
|
338 |
-
* @description Extend UM Custom Post Types
|
339 |
-
* @input_vars
|
340 |
-
* [{"var":"$list","type":"array","desc":"Custom Post Types list"}]
|
341 |
-
* @change_log
|
342 |
-
* ["Since: 2.0"]
|
343 |
-
* @usage
|
344 |
-
* <?php add_filter( 'um_cpt_list', 'function_name', 10, 1 ); ?>
|
345 |
-
* @example
|
346 |
-
* <?php
|
347 |
-
* add_filter( 'um_cpt_list', 'my_cpt_list', 10, 1 );
|
348 |
-
* function my_admin_pending_queue( $list ) {
|
349 |
-
* // your code here
|
350 |
-
* return $list;
|
351 |
-
* }
|
352 |
-
* ?>
|
353 |
-
*/
|
354 |
-
$cpt = apply_filters( 'um_cpt_list', array( 'um_form', 'um_directory' ) );
|
355 |
-
return $cpt;
|
356 |
-
}
|
357 |
-
|
358 |
-
|
359 |
-
/**
|
360 |
-
* @param array $array
|
361 |
-
* @param string $key
|
362 |
-
* @param array $insert_array
|
363 |
-
*
|
364 |
-
* @return array
|
365 |
-
*/
|
366 |
-
function array_insert_before( $array, $key, $insert_array ) {
|
367 |
-
$index = array_search( $key, array_keys( $array ) );
|
368 |
-
if ( $index === false ) {
|
369 |
-
return $array;
|
370 |
-
}
|
371 |
-
|
372 |
-
$array = array_slice( $array, 0, $index, true ) +
|
373 |
-
$insert_array +
|
374 |
-
array_slice( $array, $index, count( $array ) - 1, true );
|
375 |
-
|
376 |
-
return $array;
|
377 |
-
}
|
378 |
-
|
379 |
-
|
380 |
-
/**
|
381 |
-
* @since 2.1.0
|
382 |
-
*
|
383 |
-
* @param $var
|
384 |
-
* @return array|string
|
385 |
-
*/
|
386 |
-
function clean_array( $var ) {
|
387 |
-
if ( is_array( $var ) ) {
|
388 |
-
return array_map( array( $this, 'clean_array' ), $var );
|
389 |
-
} else {
|
390 |
-
return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
|
391 |
-
}
|
392 |
-
}
|
393 |
-
|
394 |
-
|
395 |
-
/**
|
396 |
-
* Replace the first match in the string, alternative for the `str_replace()` function
|
397 |
-
*
|
398 |
-
* @param string $search
|
399 |
-
* @param string $replace
|
400 |
-
* @param string $subject
|
401 |
-
*
|
402 |
-
* @return string
|
403 |
-
*/
|
404 |
-
function str_replace_first( $search, $replace, $subject ) {
|
405 |
-
$search = '/' . preg_quote( $search, '/' ) . '/';
|
406 |
-
return preg_replace( $search, $replace, $subject, 1 );
|
407 |
-
}
|
408 |
-
|
409 |
-
}
|
410 |
-
}
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
2 |
+
|
3 |
+
|
4 |
+
if ( ! class_exists( 'UM_Functions' ) ) {
|
5 |
+
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class UM_Functions
|
9 |
+
*/
|
10 |
+
class UM_Functions {
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Store URL
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
var $store_url = 'https://ultimatemember.com/';
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* WP remote Post timeout
|
23 |
+
* @var int
|
24 |
+
*/
|
25 |
+
var $request_timeout = 60;
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* UM_Functions constructor.
|
30 |
+
*/
|
31 |
+
function __construct() {
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Check if AJAX now
|
37 |
+
*
|
38 |
+
* @return bool
|
39 |
+
*/
|
40 |
+
function is_ajax() {
|
41 |
+
return function_exists( 'wp_doing_ajax' ) ? wp_doing_ajax() : defined( 'DOING_AJAX' );
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Check frontend nonce
|
47 |
+
*
|
48 |
+
* @param bool $action
|
49 |
+
*/
|
50 |
+
function check_ajax_nonce( $action = false ) {
|
51 |
+
$nonce = isset( $_REQUEST['nonce'] ) ? sanitize_text_field( $_REQUEST['nonce'] ) : '';
|
52 |
+
$action = empty( $action ) ? 'um-frontend-nonce' : $action;
|
53 |
+
|
54 |
+
if ( ! wp_verify_nonce( $nonce, $action ) ) {
|
55 |
+
wp_send_json_error( esc_js( __( 'Wrong Nonce', 'ultimate-member' ) ) );
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
/**
|
61 |
+
* What type of request is this?
|
62 |
+
*
|
63 |
+
* @param string $type String containing name of request type (ajax, frontend, cron or admin)
|
64 |
+
*
|
65 |
+
* @return bool
|
66 |
+
*/
|
67 |
+
public function is_request( $type ) {
|
68 |
+
switch ( $type ) {
|
69 |
+
case 'admin' :
|
70 |
+
return is_admin();
|
71 |
+
case 'ajax' :
|
72 |
+
return defined( 'DOING_AJAX' );
|
73 |
+
case 'cron' :
|
74 |
+
return defined( 'DOING_CRON' );
|
75 |
+
case 'frontend' :
|
76 |
+
return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' );
|
77 |
+
}
|
78 |
+
|
79 |
+
return false;
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Help Tip displaying
|
85 |
+
*
|
86 |
+
* Function for render/displaying UltimateMember help tip
|
87 |
+
*
|
88 |
+
* @since 2.0.0
|
89 |
+
*
|
90 |
+
* @param string $tip Help tip text
|
91 |
+
* @param bool $allow_html Allow sanitized HTML if true or escape
|
92 |
+
* @param bool $echo Return HTML or echo
|
93 |
+
* @return string
|
94 |
+
*/
|
95 |
+
function tooltip( $tip, $allow_html = false, $echo = true ) {
|
96 |
+
if ( $allow_html ) {
|
97 |
+
|
98 |
+
$tip = htmlspecialchars( wp_kses( html_entity_decode( $tip ), array(
|
99 |
+
'br' => array(),
|
100 |
+
'em' => array(),
|
101 |
+
'strong' => array(),
|
102 |
+
'small' => array(),
|
103 |
+
'span' => array(),
|
104 |
+
'ul' => array(),
|
105 |
+
'li' => array(),
|
106 |
+
'ol' => array(),
|
107 |
+
'p' => array(),
|
108 |
+
) ) );
|
109 |
+
|
110 |
+
} else {
|
111 |
+
$tip = esc_attr( $tip );
|
112 |
+
}
|
113 |
+
|
114 |
+
ob_start(); ?>
|
115 |
+
|
116 |
+
<span class="um_tooltip dashicons dashicons-editor-help" title="<?php echo $tip ?>"></span>
|
117 |
+
|
118 |
+
<?php if ( $echo ) {
|
119 |
+
ob_get_flush();
|
120 |
+
return '';
|
121 |
+
} else {
|
122 |
+
return ob_get_clean();
|
123 |
+
}
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
+
|
128 |
+
/**
|
129 |
+
* @return mixed|void
|
130 |
+
*/
|
131 |
+
function excluded_taxonomies() {
|
132 |
+
$taxes = array(
|
133 |
+
'nav_menu',
|
134 |
+
'link_category',
|
135 |
+
'post_format',
|
136 |
+
);
|
137 |
+
|
138 |
+
/**
|
139 |
+
* UM hook
|
140 |
+
*
|
141 |
+
* @type filter
|
142 |
+
* @title um_excluded_taxonomies
|
143 |
+
* @description Exclude taxonomies for UM
|
144 |
+
* @input_vars
|
145 |
+
* [{"var":"$taxes","type":"array","desc":"Taxonomies keys"}]
|
146 |
+
* @change_log
|
147 |
+
* ["Since: 2.0"]
|
148 |
+
* @usage
|
149 |
+
* <?php add_filter( 'um_excluded_taxonomies', 'function_name', 10, 1 ); ?>
|
150 |
+
* @example
|
151 |
+
* <?php
|
152 |
+
* add_filter( 'um_excluded_taxonomies', 'my_excluded_taxonomies', 10, 1 );
|
153 |
+
* function my_excluded_taxonomies( $taxes ) {
|
154 |
+
* // your code here
|
155 |
+
* return $taxes;
|
156 |
+
* }
|
157 |
+
* ?>
|
158 |
+
*/
|
159 |
+
return apply_filters( 'um_excluded_taxonomies', $taxes );
|
160 |
+
}
|
161 |
+
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Output templates
|
165 |
+
*
|
166 |
+
* @access public
|
167 |
+
* @param string $template_name
|
168 |
+
* @param string $basename (default: '')
|
169 |
+
* @param array $t_args (default: array())
|
170 |
+
* @param bool $echo
|
171 |
+
*
|
172 |
+
* @return string|void
|
173 |
+
*/
|
174 |
+
function get_template( $template_name, $basename = '', $t_args = array(), $echo = false ) {
|
175 |
+
if ( ! empty( $t_args ) && is_array( $t_args ) ) {
|
176 |
+
extract( $t_args );
|
177 |
+
}
|
178 |
+
|
179 |
+
$path = '';
|
180 |
+
if ( $basename ) {
|
181 |
+
// use '/' instead of "DIRECTORY_SEPARATOR", because wp_normalize_path makes the correct replace
|
182 |
+
$array = explode( '/', wp_normalize_path( trim( $basename ) ) );
|
183 |
+
$path = $array[0];
|
184 |
+
}
|
185 |
+
|
186 |
+
$located = $this->locate_template( $template_name, $path );
|
187 |
+
if ( ! file_exists( $located ) ) {
|
188 |
+
_doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
|
189 |
+
return;
|
190 |
+
}
|
191 |
+
|
192 |
+
|
193 |
+
/**
|
194 |
+
* UM hook
|
195 |
+
*
|
196 |
+
* @type filter
|
197 |
+
* @title um_get_template
|
198 |
+
* @description Change template location
|
199 |
+
* @input_vars
|
200 |
+
* [{"var":"$located","type":"string","desc":"template Located"},
|
201 |
+
* {"var":"$template_name","type":"string","desc":"Template Name"},
|
202 |
+
* {"var":"$path","type":"string","desc":"Template Path at server"},
|
203 |
+
* {"var":"$t_args","type":"array","desc":"Template Arguments"}]
|
204 |
+
* @change_log
|
205 |
+
* ["Since: 2.0"]
|
206 |
+
* @usage add_filter( 'um_get_template', 'function_name', 10, 4 );
|
207 |
+
* @example
|
208 |
+
* <?php
|
209 |
+
* add_filter( 'um_get_template', 'my_get_template', 10, 4 );
|
210 |
+
* function my_get_template( $located, $template_name, $path, $t_args ) {
|
211 |
+
* // your code here
|
212 |
+
* return $located;
|
213 |
+
* }
|
214 |
+
* ?>
|
215 |
+
*/
|
216 |
+
$located = apply_filters( 'um_get_template', $located, $template_name, $path, $t_args );
|
217 |
+
|
218 |
+
ob_start();
|
219 |
+
|
220 |
+
/**
|
221 |
+
* UM hook
|
222 |
+
*
|
223 |
+
* @type action
|
224 |
+
* @title um_before_template_part
|
225 |
+
* @description Make some action before include template file
|
226 |
+
* @input_vars
|
227 |
+
* [{"var":"$template_name","type":"string","desc":"Template Name"},
|
228 |
+
* {"var":"$path","type":"string","desc":"Template Path at server"},
|
229 |
+
* {"var":"$located","type":"string","desc":"template Located"},
|
230 |
+
* {"var":"$t_args","type":"array","desc":"Template Arguments"}]
|
231 |
+
* @change_log
|
232 |
+
* ["Since: 2.0"]
|
233 |
+
* @usage add_action( 'um_before_template_part', 'function_name', 10, 4 );
|
234 |
+
* @example
|
235 |
+
* <?php
|
236 |
+
* add_action( 'um_before_template_part', 'my_before_template_part', 10, 4 );
|
237 |
+
* function my_before_template_part( $template_name, $path, $located, $t_args ) {
|
238 |
+
* // your code here
|
239 |
+
* }
|
240 |
+
* ?>
|
241 |
+
*/
|
242 |
+
do_action( 'um_before_template_part', $template_name, $path, $located, $t_args );
|
243 |
+
include( $located );
|
244 |
+
|
245 |
+
/**
|
246 |
+
* UM hook
|
247 |
+
*
|
248 |
+
* @type action
|
249 |
+
* @title um_after_template_part
|
250 |
+
* @description Make some action after include template file
|
251 |
+
* @input_vars
|
252 |
+
* [{"var":"$template_name","type":"string","desc":"Template Name"},
|
253 |
+
* {"var":"$path","type":"string","desc":"Template Path at server"},
|
254 |
+
* {"var":"$located","type":"string","desc":"template Located"},
|
255 |
+
* {"var":"$t_args","type":"array","desc":"Template Arguments"}]
|
256 |
+
* @change_log
|
257 |
+
* ["Since: 2.0"]
|
258 |
+
* @usage add_action( 'um_after_template_part', 'function_name', 10, 4 );
|
259 |
+
* @example
|
260 |
+
* <?php
|
261 |
+
* add_action( 'um_after_template_part', 'my_after_template_part', 10, 4 );
|
262 |
+
* function my_after_template_part( $template_name, $path, $located, $t_args ) {
|
263 |
+
* // your code here
|
264 |
+
* }
|
265 |
+
* ?>
|
266 |
+
*/
|
267 |
+
do_action( 'um_after_template_part', $template_name, $path, $located, $t_args );
|
268 |
+
$html = ob_get_clean();
|
269 |
+
|
270 |
+
if ( ! $echo ) {
|
271 |
+
return $html;
|
272 |
+
} else {
|
273 |
+
echo $html;
|
274 |
+
return;
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Locate a template and return the path for inclusion.
|
281 |
+
*
|
282 |
+
* @access public
|
283 |
+
* @param string $template_name
|
284 |
+
* @param string $path (default: '')
|
285 |
+
* @return string
|
286 |
+
*/
|
287 |
+
function locate_template( $template_name, $path = '' ) {
|
288 |
+
// check if there is template at theme folder
|
289 |
+
$template = locate_template( array(
|
290 |
+
trailingslashit( 'ultimate-member' . DIRECTORY_SEPARATOR . $path ) . $template_name
|
291 |
+
) );
|
292 |
+
|
293 |
+
if ( ! $template ) {
|
294 |
+
if ( $path ) {
|
295 |
+
$template = trailingslashit( trailingslashit( WP_PLUGIN_DIR ) . $path );
|
296 |
+
} else {
|
297 |
+
$template = trailingslashit( um_path );
|
298 |
+
}
|
299 |
+
$template .= 'templates' . DIRECTORY_SEPARATOR . $template_name;
|
300 |
+
}
|
301 |
+
|
302 |
+
|
303 |
+
/**
|
304 |
+
* UM hook
|
305 |
+
*
|
306 |
+
* @type filter
|
307 |
+
* @title um_locate_template
|
308 |
+
* @description Change template locate
|
309 |
+
* @input_vars
|
310 |
+
* [{"var":"$template","type":"string","desc":"Template locate"},
|
311 |
+
* {"var":"$template_name","type":"string","desc":"Template Name"},
|
312 |
+
* {"var":"$path","type":"string","desc":"Template Path at server"}]
|
313 |
+
* @change_log
|
314 |
+
* ["Since: 2.0"]
|
315 |
+
* @usage add_filter( 'um_locate_template', 'function_name', 10, 3 );
|
316 |
+
* @example
|
317 |
+
* <?php
|
318 |
+
* add_filter( 'um_locate_template', 'my_locate_template', 10, 3 );
|
319 |
+
* function my_locate_template( $template, $template_name, $path ) {
|
320 |
+
* // your code here
|
321 |
+
* return $template;
|
322 |
+
* }
|
323 |
+
* ?>
|
324 |
+
*/
|
325 |
+
return apply_filters( 'um_locate_template', $template, $template_name, $path );
|
326 |
+
}
|
327 |
+
|
328 |
+
|
329 |
+
/**
|
330 |
+
* @return mixed|void
|
331 |
+
*/
|
332 |
+
function cpt_list() {
|
333 |
+
/**
|
334 |
+
* UM hook
|
335 |
+
*
|
336 |
+
* @type filter
|
337 |
+
* @title um_cpt_list
|
338 |
+
* @description Extend UM Custom Post Types
|
339 |
+
* @input_vars
|
340 |
+
* [{"var":"$list","type":"array","desc":"Custom Post Types list"}]
|
341 |
+
* @change_log
|
342 |
+
* ["Since: 2.0"]
|
343 |
+
* @usage
|
344 |
+
* <?php add_filter( 'um_cpt_list', 'function_name', 10, 1 ); ?>
|
345 |
+
* @example
|
346 |
+
* <?php
|
347 |
+
* add_filter( 'um_cpt_list', 'my_cpt_list', 10, 1 );
|
348 |
+
* function my_admin_pending_queue( $list ) {
|
349 |
+
* // your code here
|
350 |
+
* return $list;
|
351 |
+
* }
|
352 |
+
* ?>
|
353 |
+
*/
|
354 |
+
$cpt = apply_filters( 'um_cpt_list', array( 'um_form', 'um_directory' ) );
|
355 |
+
return $cpt;
|
356 |
+
}
|
357 |
+
|
358 |
+
|
359 |
+
/**
|
360 |
+
* @param array $array
|
361 |
+
* @param string $key
|
362 |
+
* @param array $insert_array
|
363 |
+
*
|
364 |
+
* @return array
|
365 |
+
*/
|
366 |
+
function array_insert_before( $array, $key, $insert_array ) {
|
367 |
+
$index = array_search( $key, array_keys( $array ) );
|
368 |
+
if ( $index === false ) {
|
369 |
+
return $array;
|
370 |
+
}
|
371 |
+
|
372 |
+
$array = array_slice( $array, 0, $index, true ) +
|
373 |
+
$insert_array +
|
374 |
+
array_slice( $array, $index, count( $array ) - 1, true );
|
375 |
+
|
376 |
+
return $array;
|
377 |
+
}
|
378 |
+
|
379 |
+
|
380 |
+
/**
|
381 |
+
* @since 2.1.0
|
382 |
+
*
|
383 |
+
* @param $var
|
384 |
+
* @return array|string
|
385 |
+
*/
|
386 |
+
function clean_array( $var ) {
|
387 |
+
if ( is_array( $var ) ) {
|
388 |
+
return array_map( array( $this, 'clean_array' ), $var );
|
389 |
+
} else {
|
390 |
+
return ! is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
|
391 |
+
}
|
392 |
+
}
|
393 |
+
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Replace the first match in the string, alternative for the `str_replace()` function
|
397 |
+
*
|
398 |
+
* @param string $search
|
399 |
+
* @param string $replace
|
400 |
+
* @param string $subject
|
401 |
+
*
|
402 |
+
* @return string
|
403 |
+
*/
|
404 |
+
function str_replace_first( $search, $replace, $subject ) {
|
405 |
+
$search = '/' . preg_quote( $search, '/' ) . '/';
|
406 |
+
return preg_replace( $search, $replace, $subject, 1 );
|
407 |
+
}
|
408 |
+
|
409 |
+
}
|
410 |
+
}
|
includes/core/class-builtin.php
CHANGED
@@ -930,7 +930,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
|
930 |
'url_text' => 'LinkedIn',
|
931 |
'advanced' => 'social',
|
932 |
'color' => '#0976b4',
|
933 |
-
'match' => 'https://linkedin.com/
|
934 |
),
|
935 |
|
936 |
'googleplus' => array(
|
@@ -972,7 +972,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
|
972 |
'skype' => array(
|
973 |
'title' => __('Skype ID','ultimate-member'),
|
974 |
'metakey' => 'skype',
|
975 |
-
'type' => '
|
976 |
'label' => __('Skype ID','ultimate-member'),
|
977 |
'required' => 0,
|
978 |
'public' => 1,
|
@@ -981,7 +981,64 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
|
981 |
'url_rel' => 'nofollow',
|
982 |
'icon' => 'um-faicon-skype',
|
983 |
'validate' => 'skype',
|
984 |
-
'url_text' => '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
985 |
),
|
986 |
|
987 |
'youtube' => array(
|
@@ -1409,6 +1466,8 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
|
1409 |
$array['unique_username_or_email'] = __('Unique Username/E-mail','ultimate-member');
|
1410 |
$array['url'] = __('Website URL','ultimate-member');
|
1411 |
$array['youtube_url'] = __('YouTube Profile','ultimate-member');
|
|
|
|
|
1412 |
$array['custom'] = __('Custom Validation','ultimate-member');
|
1413 |
|
1414 |
/**
|
@@ -1524,7 +1583,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
|
1524 |
"iu" => __("Inuktitut",'ultimate-member'),
|
1525 |
"ja" => __("Japanese",'ultimate-member'),
|
1526 |
"jv" => __("Javanese",'ultimate-member'),
|
1527 |
-
"ka" => __("
|
1528 |
"kg" => __("Kongo",'ultimate-member'),
|
1529 |
"ki" => __("Kikuyu",'ultimate-member'),
|
1530 |
"kj" => __("Kwanyama",'ultimate-member'),
|
@@ -1716,7 +1775,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
|
1716 |
'TF' => __('French Southern Territories','ultimate-member'),
|
1717 |
'GA' => __('Gabon','ultimate-member'),
|
1718 |
'GM' => __('Gambia','ultimate-member'),
|
1719 |
-
'GE' => __('
|
1720 |
'DE' => __('Germany','ultimate-member'),
|
1721 |
'GH' => __('Ghana','ultimate-member'),
|
1722 |
'GI' => __('Gibraltar','ultimate-member'),
|
930 |
'url_text' => 'LinkedIn',
|
931 |
'advanced' => 'social',
|
932 |
'color' => '#0976b4',
|
933 |
+
'match' => 'https://linkedin.com/',
|
934 |
),
|
935 |
|
936 |
'googleplus' => array(
|
972 |
'skype' => array(
|
973 |
'title' => __('Skype ID','ultimate-member'),
|
974 |
'metakey' => 'skype',
|
975 |
+
'type' => 'text',
|
976 |
'label' => __('Skype ID','ultimate-member'),
|
977 |
'required' => 0,
|
978 |
'public' => 1,
|
981 |
'url_rel' => 'nofollow',
|
982 |
'icon' => 'um-faicon-skype',
|
983 |
'validate' => 'skype',
|
984 |
+
'url_text' => __( 'Join chat', 'ultimate-member' ),
|
985 |
+
),
|
986 |
+
|
987 |
+
'viber' => array(
|
988 |
+
'title' => __('Viber number','ultimate-member'),
|
989 |
+
'metakey' => 'viber',
|
990 |
+
'type' => 'text',
|
991 |
+
'label' => __('Viber number','ultimate-member'),
|
992 |
+
'required' => 0,
|
993 |
+
'public' => 1,
|
994 |
+
'editable' => 1,
|
995 |
+
'url_target' => '_blank',
|
996 |
+
'url_rel' => 'nofollow',
|
997 |
+
'icon' => 'um-icon-ios-telephone',
|
998 |
+
'validate' => 'phone_number',
|
999 |
+
),
|
1000 |
+
|
1001 |
+
'whatsapp' => array(
|
1002 |
+
'title' => __('WhatsApp number','ultimate-member'),
|
1003 |
+
'metakey' => 'whatsapp',
|
1004 |
+
'type' => 'text',
|
1005 |
+
'label' => __('WhatsApp number','ultimate-member'),
|
1006 |
+
'required' => 0,
|
1007 |
+
'public' => 1,
|
1008 |
+
'editable' => 1,
|
1009 |
+
'url_target' => '_blank',
|
1010 |
+
'url_rel' => 'nofollow',
|
1011 |
+
'icon' => 'um-icon-social-whatsapp',
|
1012 |
+
'validate' => 'phone_number',
|
1013 |
+
),
|
1014 |
+
|
1015 |
+
'telegram' => array(
|
1016 |
+
'title' => __('Telegram','ultimate-member'),
|
1017 |
+
'metakey' => 'telegram',
|
1018 |
+
'type' => 'url',
|
1019 |
+
'label' => __('Telegram','ultimate-member'),
|
1020 |
+
'required' => 0,
|
1021 |
+
'public' => 1,
|
1022 |
+
'editable' => 1,
|
1023 |
+
'url_target' => '_blank',
|
1024 |
+
'url_rel' => 'nofollow',
|
1025 |
+
'icon' => 'um-faicon-paper-plane',
|
1026 |
+
'validate' => 'telegram_url',
|
1027 |
+
'url_text' => 'Telegram',
|
1028 |
+
'match' => 'https://t.me/',
|
1029 |
+
),
|
1030 |
+
|
1031 |
+
'discord' => array(
|
1032 |
+
'title' => __('Discord','ultimate-member'),
|
1033 |
+
'metakey' => 'discord',
|
1034 |
+
'type' => 'text',
|
1035 |
+
'label' => __('Discord ID','ultimate-member'),
|
1036 |
+
'required' => 0,
|
1037 |
+
'public' => 1,
|
1038 |
+
'editable' => 1,
|
1039 |
+
'url_target' => '_blank',
|
1040 |
+
'url_rel' => 'nofollow',
|
1041 |
+
'validate' => 'discord',
|
1042 |
),
|
1043 |
|
1044 |
'youtube' => array(
|
1466 |
$array['unique_username_or_email'] = __('Unique Username/E-mail','ultimate-member');
|
1467 |
$array['url'] = __('Website URL','ultimate-member');
|
1468 |
$array['youtube_url'] = __('YouTube Profile','ultimate-member');
|
1469 |
+
$array['telegram_url'] = __('Telegram URL','ultimate-member');
|
1470 |
+
$array['discord'] = __('Discord ID','ultimate-member');
|
1471 |
$array['custom'] = __('Custom Validation','ultimate-member');
|
1472 |
|
1473 |
/**
|
1583 |
"iu" => __("Inuktitut",'ultimate-member'),
|
1584 |
"ja" => __("Japanese",'ultimate-member'),
|
1585 |
"jv" => __("Javanese",'ultimate-member'),
|
1586 |
+
"ka" => __("Kartuli",'ultimate-member'),
|
1587 |
"kg" => __("Kongo",'ultimate-member'),
|
1588 |
"ki" => __("Kikuyu",'ultimate-member'),
|
1589 |
"kj" => __("Kwanyama",'ultimate-member'),
|
1775 |
'TF' => __('French Southern Territories','ultimate-member'),
|
1776 |
'GA' => __('Gabon','ultimate-member'),
|
1777 |
'GM' => __('Gambia','ultimate-member'),
|
1778 |
+
'GE' => __('Sakartvelo','ultimate-member'),
|
1779 |
'DE' => __('Germany','ultimate-member'),
|
1780 |
'GH' => __('Ghana','ultimate-member'),
|
1781 |
'GI' => __('Gibraltar','ultimate-member'),
|
includes/core/class-fields.php
CHANGED
@@ -264,6 +264,51 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
|
264 |
unset( $form_fields[ $id ] );
|
265 |
update_post_meta( $form_id, '_um_custom_fields', $form_fields );
|
266 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
}
|
268 |
}
|
269 |
|
264 |
unset( $form_fields[ $id ] );
|
265 |
update_post_meta( $form_id, '_um_custom_fields', $form_fields );
|
266 |
}
|
267 |
+
|
268 |
+
$directories = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'um_directory'" );
|
269 |
+
foreach ( $directories as $directory_id ) {
|
270 |
+
// Frontend filters
|
271 |
+
$directory_search_fields = get_post_meta( $directory_id, '_um_search_fields', true );
|
272 |
+
$directory_search_fields = array_values( array_diff( $directory_search_fields, array( $id ) ) );
|
273 |
+
update_post_meta( $directory_id, '_um_search_fields', $directory_search_fields );
|
274 |
+
|
275 |
+
// Admin filtering
|
276 |
+
$directory_search_filters = get_post_meta( $directory_id, '_um_search_filters', true );
|
277 |
+
unset( $directory_search_filters[ $id ] );
|
278 |
+
update_post_meta( $directory_id, '_um_search_filters', $directory_search_filters );
|
279 |
+
|
280 |
+
// display in tagline
|
281 |
+
$directory_reveal_fields = get_post_meta( $directory_id, '_um_reveal_fields', true );
|
282 |
+
$directory_reveal_fields = array_values( array_diff( $directory_reveal_fields, array( $id ) ) );
|
283 |
+
update_post_meta( $directory_id, '_um_reveal_fields', $directory_reveal_fields );
|
284 |
+
|
285 |
+
// extra user information section
|
286 |
+
$directory_tagline_fields = get_post_meta( $directory_id, '_um_tagline_fields', true );
|
287 |
+
$directory_tagline_fields = array_values( array_diff( $directory_tagline_fields, array( $id ) ) );
|
288 |
+
update_post_meta( $directory_id, '_um_tagline_fields', $directory_tagline_fields );
|
289 |
+
|
290 |
+
// Custom fields selected in "Choose field(s) to enable in sorting"
|
291 |
+
$directory_sorting_fields = get_post_meta( $directory_id, '_um_sorting_fields', true );
|
292 |
+
foreach ( $directory_sorting_fields as $key => $sorting_data ) {
|
293 |
+
if ( is_array( $sorting_data ) && array_key_exists( $id, $sorting_data ) ) {
|
294 |
+
unset( $directory_sorting_fields[ $key ] );
|
295 |
+
}
|
296 |
+
}
|
297 |
+
$directory_sorting_fields = array_values( $directory_sorting_fields );
|
298 |
+
update_post_meta( $directory_id, '_um_sorting_fields', $directory_sorting_fields );
|
299 |
+
|
300 |
+
// If "Default sort users by" = "Other (Custom Field)" is selected when delete this custom field and set default sorting
|
301 |
+
$directory_sortby_custom = get_post_meta( $directory_id, '_um_sortby_custom', true );
|
302 |
+
if ( $directory_sortby_custom === $id ) {
|
303 |
+
$directory_sortby = get_post_meta( $directory_id, '_um_sortby', true );
|
304 |
+
if ( 'other' === $directory_sortby ) {
|
305 |
+
update_post_meta( $directory_id, '_um_sortby', 'user_registered_desc' );
|
306 |
+
}
|
307 |
+
update_post_meta( $directory_id, '_um_sortby_custom', '' );
|
308 |
+
update_post_meta( $directory_id, '_um_sortby_custom_label', '' );
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
}
|
313 |
}
|
314 |
|
includes/core/class-form.php
CHANGED
@@ -114,7 +114,9 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
|
114 |
$arr_options['status'] = 'success';
|
115 |
$arr_options['post'] = $_POST;
|
116 |
|
117 |
-
|
|
|
|
|
118 |
UM()->fields()->set_mode = 'profile';
|
119 |
$form_fields = UM()->fields()->get_fields();
|
120 |
$arr_options['fields'] = $form_fields;
|
@@ -122,8 +124,6 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
|
122 |
if ( isset( $arr_options['post']['members_directory'] ) && 'yes' === $arr_options['post']['members_directory'] ) {
|
123 |
$ajax_source_func = $_POST['child_callback'];
|
124 |
if ( function_exists( $ajax_source_func ) ) {
|
125 |
-
$arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
|
126 |
-
|
127 |
global $wpdb;
|
128 |
|
129 |
$values_array = $wpdb->get_col(
|
@@ -137,7 +137,16 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
|
137 |
);
|
138 |
|
139 |
if ( ! empty( $values_array ) ) {
|
140 |
-
$arr_options['
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
} else {
|
142 |
$arr_options['items'] = array();
|
143 |
}
|
114 |
$arr_options['status'] = 'success';
|
115 |
$arr_options['post'] = $_POST;
|
116 |
|
117 |
+
if ( isset( $_POST['form_id'] ) ) {
|
118 |
+
UM()->fields()->set_id = absint( $_POST['form_id'] );
|
119 |
+
}
|
120 |
UM()->fields()->set_mode = 'profile';
|
121 |
$form_fields = UM()->fields()->get_fields();
|
122 |
$arr_options['fields'] = $form_fields;
|
124 |
if ( isset( $arr_options['post']['members_directory'] ) && 'yes' === $arr_options['post']['members_directory'] ) {
|
125 |
$ajax_source_func = $_POST['child_callback'];
|
126 |
if ( function_exists( $ajax_source_func ) ) {
|
|
|
|
|
127 |
global $wpdb;
|
128 |
|
129 |
$values_array = $wpdb->get_col(
|
137 |
);
|
138 |
|
139 |
if ( ! empty( $values_array ) ) {
|
140 |
+
$parent_dropdown = isset( $arr_options['field']['parent_dropdown_relationship'] ) ? $arr_options['field']['parent_dropdown_relationship'] : '';
|
141 |
+
$arr_options['items'] = call_user_func( $ajax_source_func, $parent_dropdown );
|
142 |
+
|
143 |
+
if ( array_keys( $arr_options['items'] ) !== range( 0, count( $arr_options['items'] ) - 1 ) ) {
|
144 |
+
// array with dropdown items is associative
|
145 |
+
$arr_options['items'] = array_intersect_key( array_map( 'trim', $arr_options['items'] ), array_flip( $values_array ) );
|
146 |
+
} else {
|
147 |
+
// array with dropdown items has sequential numeric keys, starting from 0 and there are intersected values with $values_array
|
148 |
+
$arr_options['items'] = array_intersect( $arr_options['items'], $values_array );
|
149 |
+
}
|
150 |
} else {
|
151 |
$arr_options['items'] = array();
|
152 |
}
|
includes/core/class-member-directory.php
CHANGED
@@ -876,7 +876,8 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
|
876 |
function slider_range_placeholder( $filter, $attrs ) {
|
877 |
switch ( $filter ) {
|
878 |
default: {
|
879 |
-
$label =
|
|
|
880 |
$placeholders = apply_filters( 'um_member_directory_filter_slider_range_placeholder', false, $filter );
|
881 |
|
882 |
if ( ! $placeholders ) {
|
876 |
function slider_range_placeholder( $filter, $attrs ) {
|
877 |
switch ( $filter ) {
|
878 |
default: {
|
879 |
+
$label = ! empty( $attrs['label'] ) ? $attrs['label'] : $filter;
|
880 |
+
$label = ucwords( str_replace( array( 'um_', '_' ), array( '', ' ' ), $label ) );
|
881 |
$placeholders = apply_filters( 'um_member_directory_filter_slider_range_placeholder', false, $filter );
|
882 |
|
883 |
if ( ! $placeholders ) {
|
includes/core/class-password.php
CHANGED
@@ -1,721 +1,719 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
|
5 |
-
// Exit if accessed directly
|
6 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
7 |
-
|
8 |
-
|
9 |
-
if ( ! class_exists( 'um\core\Password' ) ) {
|
10 |
-
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class Password
|
14 |
-
* @package um\core
|
15 |
-
*/
|
16 |
-
class Password {
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Password constructor.
|
21 |
-
*/
|
22 |
-
function __construct() {
|
23 |
-
add_shortcode( 'ultimatemember_password', array( &$this, 'ultimatemember_password' ) );
|
24 |
-
|
25 |
-
add_action( 'template_redirect', array( &$this, 'form_init' ), 10001 );
|
26 |
-
|
27 |
-
add_action( 'um_reset_password_errors_hook', array( &$this, 'um_reset_password_errors_hook' ) );
|
28 |
-
add_action( 'um_reset_password_process_hook', array( &$this,'um_reset_password_process_hook' ) );
|
29 |
-
|
30 |
-
add_action( 'um_change_password_errors_hook', array( &$this, 'um_change_password_errors_hook' ) );
|
31 |
-
add_action( 'um_change_password_process_hook', array( &$this,'um_change_password_process_hook' ) );
|
32 |
-
}
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Get Reset URL
|
37 |
-
*
|
38 |
-
* @return bool|string
|
39 |
-
*/
|
40 |
-
function reset_url() {
|
41 |
-
$user_id = um_user( 'ID' );
|
42 |
-
|
43 |
-
delete_option( "um_cache_userdata_{$user_id}" );
|
44 |
-
|
45 |
-
//new reset password key via WP native field
|
46 |
-
$user_data = get_userdata( $user_id );
|
47 |
-
$key = UM()->user()->maybe_generate_password_reset_key( $user_data );
|
48 |
-
|
49 |
-
$url = add_query_arg( array( 'act' => 'reset_password', 'hash' => $key, 'user_id' => $user_id ), um_get_core_page( 'password-reset' ) );
|
50 |
-
return $url;
|
51 |
-
}
|
52 |
-
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Add class based on shortcode
|
56 |
-
*
|
57 |
-
* @param string $mode
|
58 |
-
*
|
59 |
-
* @return string
|
60 |
-
*/
|
61 |
-
function get_class( $mode ) {
|
62 |
-
|
63 |
-
$classes = 'um-'.$mode;
|
64 |
-
|
65 |
-
if ( is_admin() ) {
|
66 |
-
$classes .= ' um-in-admin';
|
67 |
-
}
|
68 |
-
|
69 |
-
if ( UM()->fields()->editing == true ) {
|
70 |
-
$classes .= ' um-editing';
|
71 |
-
}
|
72 |
-
|
73 |
-
if ( UM()->fields()->viewing == true ) {
|
74 |
-
$classes .= ' um-viewing';
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* UM hook
|
79 |
-
*
|
80 |
-
* @type filter
|
81 |
-
* @title um_form_official_classes__hook
|
82 |
-
* @description Change form additional classes
|
83 |
-
* @input_vars
|
84 |
-
* [{"var":"$classes","type":"string","desc":"Form additional classes"}]
|
85 |
-
* @change_log
|
86 |
-
* ["Since: 2.0"]
|
87 |
-
* @usage
|
88 |
-
* <?php add_filter( 'um_form_official_classes__hook', 'function_name', 10, 1 ); ?>
|
89 |
-
* @example
|
90 |
-
* <?php
|
91 |
-
* add_filter( 'um_form_official_classes__hook', 'my_form_official_classes', 10, 1 );
|
92 |
-
* function my_form_official_classes( $classes ) {
|
93 |
-
* // your code here
|
94 |
-
* return $classes;
|
95 |
-
* }
|
96 |
-
* ?>
|
97 |
-
*/
|
98 |
-
$classes = apply_filters( 'um_form_official_classes__hook', $classes );
|
99 |
-
return $classes;
|
100 |
-
}
|
101 |
-
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Shortcode
|
105 |
-
*
|
106 |
-
* @param array $args
|
107 |
-
*
|
108 |
-
* @return string
|
109 |
-
*/
|
110 |
-
function ultimatemember_password( $args = array() ) {
|
111 |
-
ob_start();
|
112 |
-
|
113 |
-
$defaults = array(
|
114 |
-
'template' => 'password-reset',
|
115 |
-
'mode' => 'password',
|
116 |
-
'form_id' => 'um_password_id',
|
117 |
-
'max_width' => '450px',
|
118 |
-
'align' => 'center',
|
119 |
-
);
|
120 |
-
$args = wp_parse_args( $args, $defaults );
|
121 |
-
|
122 |
-
if ( empty( $args['use_custom_settings'] ) ) {
|
123 |
-
$args = array_merge( $args, UM()->shortcodes()->get_css_args( $args ) );
|
124 |
-
} else {
|
125 |
-
$args = array_merge( UM()->shortcodes()->get_css_args( $args ), $args );
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
* UM hook
|
130 |
-
*
|
131 |
-
* @type filter
|
132 |
-
* @title um_reset_password_shortcode_args_filter
|
133 |
-
* @description Extend Reset Password Arguments
|
134 |
-
* @input_vars
|
135 |
-
* [{"var":"$args","type":"array","desc":"Shortcode arguments"}]
|
136 |
-
* @change_log
|
137 |
-
* ["Since: 2.0"]
|
138 |
-
* @usage
|
139 |
-
* <?php add_filter( 'um_reset_password_shortcode_args_filter', 'function_name', 10, 1 ); ?>
|
140 |
-
* @example
|
141 |
-
* <?php
|
142 |
-
* add_filter( 'um_reset_password_shortcode_args_filter', 'my_reset_password_shortcode_args', 10, 1 );
|
143 |
-
* function my_reset_password_shortcode_args( $args ) {
|
144 |
-
* // your code here
|
145 |
-
* return $args;
|
146 |
-
* }
|
147 |
-
* ?>
|
148 |
-
*/
|
149 |
-
$args = apply_filters( 'um_reset_password_shortcode_args_filter', $args );
|
150 |
-
|
151 |
-
if ( isset( $this->change_password ) ) {
|
152 |
-
$args['template'] = 'password-change';
|
153 |
-
$args['rp_key'] = '';
|
154 |
-
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
155 |
-
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
|
156 |
-
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
|
157 |
-
|
158 |
-
$user = get_user_by( 'login', $rp_login );
|
159 |
-
$args['user_id'] = $user->ID;
|
160 |
-
$args['rp_key'] = $rp_key;
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
UM()->fields()->set_id = 'um_password_id';
|
165 |
-
|
166 |
-
/**
|
167 |
-
* @var $mode
|
168 |
-
* @var $template
|
169 |
-
*/
|
170 |
-
extract( $args, EXTR_SKIP );
|
171 |
-
|
172 |
-
/**
|
173 |
-
* UM hook
|
174 |
-
*
|
175 |
-
* @type action
|
176 |
-
* @title um_pre_{$mode}_shortcode
|
177 |
-
* @description Action pre-load password form shortcode
|
178 |
-
* @input_vars
|
179 |
-
* [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}]
|
180 |
-
* @change_log
|
181 |
-
* ["Since: 2.0"]
|
182 |
-
* @usage add_action( 'um_pre_{$mode}_shortcode', 'function_name', 10, 1 );
|
183 |
-
* @example
|
184 |
-
* <?php
|
185 |
-
* add_action( 'um_pre_{$mode}_shortcode', 'my_pre_password_shortcode', 10, 1 );
|
186 |
-
* function my_pre_password_shortcode( $args ) {
|
187 |
-
* // your code here
|
188 |
-
* }
|
189 |
-
* ?>
|
190 |
-
*/
|
191 |
-
do_action( "um_pre_{$mode}_shortcode", $args );
|
192 |
-
/**
|
193 |
-
* UM hook
|
194 |
-
*
|
195 |
-
* @type action
|
196 |
-
* @title um_before_form_is_loaded
|
197 |
-
* @description Action pre-load password form shortcode
|
198 |
-
* @input_vars
|
199 |
-
* [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}]
|
200 |
-
* @change_log
|
201 |
-
* ["Since: 2.0"]
|
202 |
-
* @usage add_action( 'um_before_form_is_loaded', 'function_name', 10, 1 );
|
203 |
-
* @example
|
204 |
-
* <?php
|
205 |
-
* add_action( 'um_before_form_is_loaded', 'my_before_form_is_loaded', 10, 1 );
|
206 |
-
* function my_before_form_is_loaded( $args ) {
|
207 |
-
* // your code here
|
208 |
-
* }
|
209 |
-
* ?>
|
210 |
-
*/
|
211 |
-
do_action( "um_before_form_is_loaded", $args );
|
212 |
-
/**
|
213 |
-
* UM hook
|
214 |
-
*
|
215 |
-
* @type action
|
216 |
-
* @title um_before_{$mode}_form_is_loaded
|
217 |
-
* @description Action pre-load password form shortcode
|
218 |
-
* @input_vars
|
219 |
-
* [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}]
|
220 |
-
* @change_log
|
221 |
-
* ["Since: 2.0"]
|
222 |
-
* @usage add_action( 'um_before_{$mode}_form_is_loaded', 'function_name', 10, 1 );
|
223 |
-
* @example
|
224 |
-
* <?php
|
225 |
-
* add_action( 'um_before_{$mode}_form_is_loaded', 'my_before_form_is_loaded', 10, 1 );
|
226 |
-
* function my_before_form_is_loaded( $args ) {
|
227 |
-
* // your code here
|
228 |
-
* }
|
229 |
-
* ?>
|
230 |
-
*/
|
231 |
-
do_action( "um_before_{$mode}_form_is_loaded", $args );
|
232 |
-
|
233 |
-
UM()->shortcodes()->template_load( $template, $args );
|
234 |
-
|
235 |
-
if ( ! is_admin() && ! defined( 'DOING_AJAX' ) ) {
|
236 |
-
UM()->shortcodes()->dynamic_css( $args );
|
237 |
-
}
|
238 |
-
|
239 |
-
$output = ob_get_clean();
|
240 |
-
return $output;
|
241 |
-
}
|
242 |
-
|
243 |
-
|
244 |
-
/**
|
245 |
-
* Check if a legitimate password reset request is in action
|
246 |
-
*
|
247 |
-
* @return bool
|
248 |
-
*/
|
249 |
-
function is_reset_request() {
|
250 |
-
if ( um_is_core_page( 'password-reset' ) && isset( $_POST['_um_password_reset'] ) ) {
|
251 |
-
return true;
|
252 |
-
}
|
253 |
-
|
254 |
-
return false;
|
255 |
-
}
|
256 |
-
|
257 |
-
|
258 |
-
/**
|
259 |
-
* Check if a legitimate password change request is in action
|
260 |
-
*
|
261 |
-
*
|
262 |
-
* @return bool
|
263 |
-
*/
|
264 |
-
function is_change_request() {
|
265 |
-
if ( isset( $_POST['_um_account'] ) == 1 && isset( $_POST['_um_account_tab'] ) && sanitize_key( $_POST['_um_account_tab'] ) === 'password' ) {
|
266 |
-
return true;
|
267 |
-
} elseif ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
|
268 |
-
return true;
|
269 |
-
}
|
270 |
-
|
271 |
-
return false;
|
272 |
-
}
|
273 |
-
|
274 |
-
|
275 |
-
/**
|
276 |
-
* Password page form
|
277 |
-
*/
|
278 |
-
public function form_init() {
|
279 |
-
if ( um_is_core_page( 'password-reset' ) ) {
|
280 |
-
UM()->fields()->set_mode = 'password';
|
281 |
-
}
|
282 |
-
|
283 |
-
if ( um_is_core_page( 'password-reset' ) && isset( $_REQUEST['act'] ) && 'reset_password' === sanitize_key( $_REQUEST['act'] ) ) {
|
284 |
-
wp_fix_server_vars();
|
285 |
-
|
286 |
-
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
287 |
-
|
288 |
-
if ( isset( $_GET['hash'] ) ) {
|
289 |
-
$userdata = get_userdata( wp_unslash( absint( $_GET['user_id'] ) ) );
|
290 |
-
if ( ! $userdata || is_wp_error( $userdata ) ) {
|
291 |
-
wp_redirect( add_query_arg( array( 'act' => 'reset_password', 'error' => 'invalidkey' ), get_permalink() ) );
|
292 |
-
exit;
|
293 |
-
}
|
294 |
-
$rp_login = $userdata->user_login;
|
295 |
-
$rp_key = wp_unslash( sanitize_text_field( $_GET['hash'] ) );
|
296 |
-
|
297 |
-
$user = check_password_reset_key( $rp_key, $rp_login );
|
298 |
-
|
299 |
-
if ( is_wp_error( $user ) ) {
|
300 |
-
$this->setcookie( $rp_cookie, false );
|
301 |
-
wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
|
302 |
-
} else {
|
303 |
-
$value = sprintf( '%s:%s', $rp_login, wp_unslash( sanitize_text_field( $_GET['hash'] ) ) );
|
304 |
-
$this->setcookie( $rp_cookie, $value );
|
305 |
-
wp_safe_redirect( remove_query_arg( array( 'hash', 'user_id' ) ) );
|
306 |
-
}
|
307 |
-
|
308 |
-
exit;
|
309 |
-
}
|
310 |
-
|
311 |
-
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
|
312 |
-
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
|
313 |
-
$user = check_password_reset_key( $rp_key, $rp_login );
|
314 |
-
} else {
|
315 |
-
$user = false;
|
316 |
-
}
|
317 |
-
|
318 |
-
if ( ( ! $user || is_wp_error( $user ) ) && ! isset( $_GET['updated'] ) ) {
|
319 |
-
$this->setcookie( $rp_cookie, false );
|
320 |
-
if ( $user && $user->get_error_code() === 'expired_key' ) {
|
321 |
-
wp_redirect( add_query_arg( array( 'updated' => 'expiredkey' ), get_permalink() ) );
|
322 |
-
} else {
|
323 |
-
wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
|
324 |
-
}
|
325 |
-
exit;
|
326 |
-
}
|
327 |
-
|
328 |
-
$this->change_password = true;
|
329 |
-
}
|
330 |
-
|
331 |
-
if ( $this->is_reset_request() ) {
|
332 |
-
|
333 |
-
UM()->form()->post_form = $_POST;
|
334 |
-
|
335 |
-
if ( empty( UM()->form()->post_form['mode'] ) ) {
|
336 |
-
UM()->form()->post_form['mode'] = 'password';
|
337 |
-
}
|
338 |
-
|
339 |
-
/**
|
340 |
-
* UM hook
|
341 |
-
*
|
342 |
-
* @type action
|
343 |
-
* @title um_reset_password_errors_hook
|
344 |
-
* @description Action on reset password submit form
|
345 |
-
* @input_vars
|
346 |
-
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
347 |
-
* @change_log
|
348 |
-
* ["Since: 2.0"]
|
349 |
-
* @usage add_action( 'um_reset_password_errors_hook', 'function_name', 10, 1 );
|
350 |
-
* @example
|
351 |
-
* <?php
|
352 |
-
* add_action( 'um_reset_password_errors_hook', 'my_reset_password_errors', 10, 1 );
|
353 |
-
* function my_reset_password_errors( $post ) {
|
354 |
-
* // your code here
|
355 |
-
* }
|
356 |
-
* ?>
|
357 |
-
*/
|
358 |
-
do_action( 'um_reset_password_errors_hook', UM()->form()->post_form );
|
359 |
-
|
360 |
-
if ( ! isset( UM()->form()->errors ) ) {
|
361 |
-
|
362 |
-
/**
|
363 |
-
* UM hook
|
364 |
-
*
|
365 |
-
* @type action
|
366 |
-
* @title um_reset_password_process_hook
|
367 |
-
* @description Action on reset password success submit form
|
368 |
-
* @input_vars
|
369 |
-
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
370 |
-
* @change_log
|
371 |
-
* ["Since: 2.0"]
|
372 |
-
* @usage add_action( 'um_reset_password_process_hook', 'function_name', 10, 1 );
|
373 |
-
* @example
|
374 |
-
* <?php
|
375 |
-
* add_action( 'um_reset_password_process_hook', 'my_reset_password_process', 10, 1 );
|
376 |
-
* function my_reset_password_process( $post ) {
|
377 |
-
* // your code here
|
378 |
-
* }
|
379 |
-
* ?>
|
380 |
-
*/
|
381 |
-
do_action( 'um_reset_password_process_hook', UM()->form()->post_form );
|
382 |
-
|
383 |
-
}
|
384 |
-
}
|
385 |
-
|
386 |
-
if ( $this->is_change_request() ) {
|
387 |
-
UM()->form()->post_form = $_POST;
|
388 |
-
|
389 |
-
/**
|
390 |
-
* UM hook
|
391 |
-
*
|
392 |
-
* @type action
|
393 |
-
* @title um_change_password_errors_hook
|
394 |
-
* @description Action on change password submit form
|
395 |
-
* @input_vars
|
396 |
-
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
397 |
-
* @change_log
|
398 |
-
* ["Since: 2.0"]
|
399 |
-
* @usage add_action( 'um_change_password_errors_hook', 'function_name', 10, 1 );
|
400 |
-
* @example
|
401 |
-
* <?php
|
402 |
-
* add_action( 'um_change_password_errors_hook', 'my_change_password_errors', 10, 1 );
|
403 |
-
* function my_change_password_errors( $post ) {
|
404 |
-
* // your code here
|
405 |
-
* }
|
406 |
-
* ?>
|
407 |
-
*/
|
408 |
-
do_action( 'um_change_password_errors_hook', UM()->form()->post_form );
|
409 |
-
|
410 |
-
if ( ! isset( UM()->form()->errors ) ) {
|
411 |
-
|
412 |
-
/**
|
413 |
-
* UM hook
|
414 |
-
*
|
415 |
-
* @type action
|
416 |
-
* @title um_change_password_process_hook
|
417 |
-
* @description Action on change password success submit form
|
418 |
-
* @input_vars
|
419 |
-
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
420 |
-
* @change_log
|
421 |
-
* ["Since: 2.0"]
|
422 |
-
* @usage add_action( 'um_change_password_process_hook', 'function_name', 10, 1 );
|
423 |
-
* @example
|
424 |
-
* <?php
|
425 |
-
* add_action( 'um_change_password_process_hook', 'my_change_password_process', 10, 1 );
|
426 |
-
* function my_change_password_process( $post ) {
|
427 |
-
* // your code here
|
428 |
-
* }
|
429 |
-
* ?>
|
430 |
-
*/
|
431 |
-
do_action( 'um_change_password_process_hook', UM()->form()->post_form );
|
432 |
-
|
433 |
-
}
|
434 |
-
}
|
435 |
-
}
|
436 |
-
|
437 |
-
|
438 |
-
/**
|
439 |
-
* Error handler: reset password
|
440 |
-
*
|
441 |
-
* @param $args
|
442 |
-
*/
|
443 |
-
public function um_reset_password_errors_hook( $args ) {
|
444 |
-
if ( '' !== $args[ UM()->honeypot ] ) {
|
445 |
-
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
|
446 |
-
}
|
447 |
-
|
448 |
-
$user = '';
|
449 |
-
|
450 |
-
foreach ( $args as $key => $val ) {
|
451 |
-
if ( strstr( $key, 'username_b' ) ) {
|
452 |
-
$user = trim( sanitize_text_field( $val ) );
|
453 |
-
}
|
454 |
-
}
|
455 |
-
|
456 |
-
if ( empty( $user ) ) {
|
457 |
-
UM()->form()->add_error( 'username_b', __( 'Please provide your username or email', 'ultimate-member' ) );
|
458 |
-
}
|
459 |
-
|
460 |
-
if ( ( ! is_email( $user ) &&
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
*
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
$
|
547 |
-
$
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
*
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
$user =
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
}
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
wp_redirect( add_query_arg( array( 'updated' => '
|
605 |
-
}
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
*
|
615 |
-
*
|
616 |
-
* @
|
617 |
-
*
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
*
|
643 |
-
*
|
644 |
-
* @
|
645 |
-
* @
|
646 |
-
*
|
647 |
-
* @
|
648 |
-
* [
|
649 |
-
* @
|
650 |
-
*
|
651 |
-
*
|
652 |
-
*
|
653 |
-
*
|
654 |
-
*
|
655 |
-
*
|
656 |
-
*
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
*
|
670 |
-
*
|
671 |
-
* @param
|
672 |
-
* @param string $
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
*
|
696 |
-
*
|
697 |
-
* @
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
$placeholders
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
*
|
710 |
-
*
|
711 |
-
* @
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
$replace_placeholders
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
}
|
721 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
|
5 |
+
// Exit if accessed directly
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
7 |
+
|
8 |
+
|
9 |
+
if ( ! class_exists( 'um\core\Password' ) ) {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class Password
|
14 |
+
* @package um\core
|
15 |
+
*/
|
16 |
+
class Password {
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Password constructor.
|
21 |
+
*/
|
22 |
+
function __construct() {
|
23 |
+
add_shortcode( 'ultimatemember_password', array( &$this, 'ultimatemember_password' ) );
|
24 |
+
|
25 |
+
add_action( 'template_redirect', array( &$this, 'form_init' ), 10001 );
|
26 |
+
|
27 |
+
add_action( 'um_reset_password_errors_hook', array( &$this, 'um_reset_password_errors_hook' ) );
|
28 |
+
add_action( 'um_reset_password_process_hook', array( &$this,'um_reset_password_process_hook' ) );
|
29 |
+
|
30 |
+
add_action( 'um_change_password_errors_hook', array( &$this, 'um_change_password_errors_hook' ) );
|
31 |
+
add_action( 'um_change_password_process_hook', array( &$this,'um_change_password_process_hook' ) );
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Get Reset URL
|
37 |
+
*
|
38 |
+
* @return bool|string
|
39 |
+
*/
|
40 |
+
function reset_url() {
|
41 |
+
$user_id = um_user( 'ID' );
|
42 |
+
|
43 |
+
delete_option( "um_cache_userdata_{$user_id}" );
|
44 |
+
|
45 |
+
//new reset password key via WP native field
|
46 |
+
$user_data = get_userdata( $user_id );
|
47 |
+
$key = UM()->user()->maybe_generate_password_reset_key( $user_data );
|
48 |
+
|
49 |
+
$url = add_query_arg( array( 'act' => 'reset_password', 'hash' => $key, 'user_id' => $user_id ), um_get_core_page( 'password-reset' ) );
|
50 |
+
return $url;
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Add class based on shortcode
|
56 |
+
*
|
57 |
+
* @param string $mode
|
58 |
+
*
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
function get_class( $mode ) {
|
62 |
+
|
63 |
+
$classes = 'um-'.$mode;
|
64 |
+
|
65 |
+
if ( is_admin() ) {
|
66 |
+
$classes .= ' um-in-admin';
|
67 |
+
}
|
68 |
+
|
69 |
+
if ( UM()->fields()->editing == true ) {
|
70 |
+
$classes .= ' um-editing';
|
71 |
+
}
|
72 |
+
|
73 |
+
if ( UM()->fields()->viewing == true ) {
|
74 |
+
$classes .= ' um-viewing';
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* UM hook
|
79 |
+
*
|
80 |
+
* @type filter
|
81 |
+
* @title um_form_official_classes__hook
|
82 |
+
* @description Change form additional classes
|
83 |
+
* @input_vars
|
84 |
+
* [{"var":"$classes","type":"string","desc":"Form additional classes"}]
|
85 |
+
* @change_log
|
86 |
+
* ["Since: 2.0"]
|
87 |
+
* @usage
|
88 |
+
* <?php add_filter( 'um_form_official_classes__hook', 'function_name', 10, 1 ); ?>
|
89 |
+
* @example
|
90 |
+
* <?php
|
91 |
+
* add_filter( 'um_form_official_classes__hook', 'my_form_official_classes', 10, 1 );
|
92 |
+
* function my_form_official_classes( $classes ) {
|
93 |
+
* // your code here
|
94 |
+
* return $classes;
|
95 |
+
* }
|
96 |
+
* ?>
|
97 |
+
*/
|
98 |
+
$classes = apply_filters( 'um_form_official_classes__hook', $classes );
|
99 |
+
return $classes;
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Shortcode
|
105 |
+
*
|
106 |
+
* @param array $args
|
107 |
+
*
|
108 |
+
* @return string
|
109 |
+
*/
|
110 |
+
function ultimatemember_password( $args = array() ) {
|
111 |
+
ob_start();
|
112 |
+
|
113 |
+
$defaults = array(
|
114 |
+
'template' => 'password-reset',
|
115 |
+
'mode' => 'password',
|
116 |
+
'form_id' => 'um_password_id',
|
117 |
+
'max_width' => '450px',
|
118 |
+
'align' => 'center',
|
119 |
+
);
|
120 |
+
$args = wp_parse_args( $args, $defaults );
|
121 |
+
|
122 |
+
if ( empty( $args['use_custom_settings'] ) ) {
|
123 |
+
$args = array_merge( $args, UM()->shortcodes()->get_css_args( $args ) );
|
124 |
+
} else {
|
125 |
+
$args = array_merge( UM()->shortcodes()->get_css_args( $args ), $args );
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* UM hook
|
130 |
+
*
|
131 |
+
* @type filter
|
132 |
+
* @title um_reset_password_shortcode_args_filter
|
133 |
+
* @description Extend Reset Password Arguments
|
134 |
+
* @input_vars
|
135 |
+
* [{"var":"$args","type":"array","desc":"Shortcode arguments"}]
|
136 |
+
* @change_log
|
137 |
+
* ["Since: 2.0"]
|
138 |
+
* @usage
|
139 |
+
* <?php add_filter( 'um_reset_password_shortcode_args_filter', 'function_name', 10, 1 ); ?>
|
140 |
+
* @example
|
141 |
+
* <?php
|
142 |
+
* add_filter( 'um_reset_password_shortcode_args_filter', 'my_reset_password_shortcode_args', 10, 1 );
|
143 |
+
* function my_reset_password_shortcode_args( $args ) {
|
144 |
+
* // your code here
|
145 |
+
* return $args;
|
146 |
+
* }
|
147 |
+
* ?>
|
148 |
+
*/
|
149 |
+
$args = apply_filters( 'um_reset_password_shortcode_args_filter', $args );
|
150 |
+
|
151 |
+
if ( isset( $this->change_password ) ) {
|
152 |
+
$args['template'] = 'password-change';
|
153 |
+
$args['rp_key'] = '';
|
154 |
+
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
155 |
+
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
|
156 |
+
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
|
157 |
+
|
158 |
+
$user = get_user_by( 'login', $rp_login );
|
159 |
+
$args['user_id'] = $user->ID;
|
160 |
+
$args['rp_key'] = $rp_key;
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
UM()->fields()->set_id = 'um_password_id';
|
165 |
+
|
166 |
+
/**
|
167 |
+
* @var $mode
|
168 |
+
* @var $template
|
169 |
+
*/
|
170 |
+
extract( $args, EXTR_SKIP );
|
171 |
+
|
172 |
+
/**
|
173 |
+
* UM hook
|
174 |
+
*
|
175 |
+
* @type action
|
176 |
+
* @title um_pre_{$mode}_shortcode
|
177 |
+
* @description Action pre-load password form shortcode
|
178 |
+
* @input_vars
|
179 |
+
* [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}]
|
180 |
+
* @change_log
|
181 |
+
* ["Since: 2.0"]
|
182 |
+
* @usage add_action( 'um_pre_{$mode}_shortcode', 'function_name', 10, 1 );
|
183 |
+
* @example
|
184 |
+
* <?php
|
185 |
+
* add_action( 'um_pre_{$mode}_shortcode', 'my_pre_password_shortcode', 10, 1 );
|
186 |
+
* function my_pre_password_shortcode( $args ) {
|
187 |
+
* // your code here
|
188 |
+
* }
|
189 |
+
* ?>
|
190 |
+
*/
|
191 |
+
do_action( "um_pre_{$mode}_shortcode", $args );
|
192 |
+
/**
|
193 |
+
* UM hook
|
194 |
+
*
|
195 |
+
* @type action
|
196 |
+
* @title um_before_form_is_loaded
|
197 |
+
* @description Action pre-load password form shortcode
|
198 |
+
* @input_vars
|
199 |
+
* [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}]
|
200 |
+
* @change_log
|
201 |
+
* ["Since: 2.0"]
|
202 |
+
* @usage add_action( 'um_before_form_is_loaded', 'function_name', 10, 1 );
|
203 |
+
* @example
|
204 |
+
* <?php
|
205 |
+
* add_action( 'um_before_form_is_loaded', 'my_before_form_is_loaded', 10, 1 );
|
206 |
+
* function my_before_form_is_loaded( $args ) {
|
207 |
+
* // your code here
|
208 |
+
* }
|
209 |
+
* ?>
|
210 |
+
*/
|
211 |
+
do_action( "um_before_form_is_loaded", $args );
|
212 |
+
/**
|
213 |
+
* UM hook
|
214 |
+
*
|
215 |
+
* @type action
|
216 |
+
* @title um_before_{$mode}_form_is_loaded
|
217 |
+
* @description Action pre-load password form shortcode
|
218 |
+
* @input_vars
|
219 |
+
* [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}]
|
220 |
+
* @change_log
|
221 |
+
* ["Since: 2.0"]
|
222 |
+
* @usage add_action( 'um_before_{$mode}_form_is_loaded', 'function_name', 10, 1 );
|
223 |
+
* @example
|
224 |
+
* <?php
|
225 |
+
* add_action( 'um_before_{$mode}_form_is_loaded', 'my_before_form_is_loaded', 10, 1 );
|
226 |
+
* function my_before_form_is_loaded( $args ) {
|
227 |
+
* // your code here
|
228 |
+
* }
|
229 |
+
* ?>
|
230 |
+
*/
|
231 |
+
do_action( "um_before_{$mode}_form_is_loaded", $args );
|
232 |
+
|
233 |
+
UM()->shortcodes()->template_load( $template, $args );
|
234 |
+
|
235 |
+
if ( ! is_admin() && ! defined( 'DOING_AJAX' ) ) {
|
236 |
+
UM()->shortcodes()->dynamic_css( $args );
|
237 |
+
}
|
238 |
+
|
239 |
+
$output = ob_get_clean();
|
240 |
+
return $output;
|
241 |
+
}
|
242 |
+
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Check if a legitimate password reset request is in action
|
246 |
+
*
|
247 |
+
* @return bool
|
248 |
+
*/
|
249 |
+
function is_reset_request() {
|
250 |
+
if ( um_is_core_page( 'password-reset' ) && isset( $_POST['_um_password_reset'] ) ) {
|
251 |
+
return true;
|
252 |
+
}
|
253 |
+
|
254 |
+
return false;
|
255 |
+
}
|
256 |
+
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Check if a legitimate password change request is in action
|
260 |
+
*
|
261 |
+
*
|
262 |
+
* @return bool
|
263 |
+
*/
|
264 |
+
function is_change_request() {
|
265 |
+
if ( isset( $_POST['_um_account'] ) == 1 && isset( $_POST['_um_account_tab'] ) && sanitize_key( $_POST['_um_account_tab'] ) === 'password' ) {
|
266 |
+
return true;
|
267 |
+
} elseif ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
|
268 |
+
return true;
|
269 |
+
}
|
270 |
+
|
271 |
+
return false;
|
272 |
+
}
|
273 |
+
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Password page form
|
277 |
+
*/
|
278 |
+
public function form_init() {
|
279 |
+
if ( um_is_core_page( 'password-reset' ) ) {
|
280 |
+
UM()->fields()->set_mode = 'password';
|
281 |
+
}
|
282 |
+
|
283 |
+
if ( um_is_core_page( 'password-reset' ) && isset( $_REQUEST['act'] ) && 'reset_password' === sanitize_key( $_REQUEST['act'] ) ) {
|
284 |
+
wp_fix_server_vars();
|
285 |
+
|
286 |
+
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
287 |
+
|
288 |
+
if ( isset( $_GET['hash'] ) ) {
|
289 |
+
$userdata = get_userdata( wp_unslash( absint( $_GET['user_id'] ) ) );
|
290 |
+
if ( ! $userdata || is_wp_error( $userdata ) ) {
|
291 |
+
wp_redirect( add_query_arg( array( 'act' => 'reset_password', 'error' => 'invalidkey' ), get_permalink() ) );
|
292 |
+
exit;
|
293 |
+
}
|
294 |
+
$rp_login = $userdata->user_login;
|
295 |
+
$rp_key = wp_unslash( sanitize_text_field( $_GET['hash'] ) );
|
296 |
+
|
297 |
+
$user = check_password_reset_key( $rp_key, $rp_login );
|
298 |
+
|
299 |
+
if ( is_wp_error( $user ) ) {
|
300 |
+
$this->setcookie( $rp_cookie, false );
|
301 |
+
wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
|
302 |
+
} else {
|
303 |
+
$value = sprintf( '%s:%s', $rp_login, wp_unslash( sanitize_text_field( $_GET['hash'] ) ) );
|
304 |
+
$this->setcookie( $rp_cookie, $value );
|
305 |
+
wp_safe_redirect( remove_query_arg( array( 'hash', 'user_id' ) ) );
|
306 |
+
}
|
307 |
+
|
308 |
+
exit;
|
309 |
+
}
|
310 |
+
|
311 |
+
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
|
312 |
+
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
|
313 |
+
$user = check_password_reset_key( $rp_key, $rp_login );
|
314 |
+
} else {
|
315 |
+
$user = false;
|
316 |
+
}
|
317 |
+
|
318 |
+
if ( ( ! $user || is_wp_error( $user ) ) && ! isset( $_GET['updated'] ) ) {
|
319 |
+
$this->setcookie( $rp_cookie, false );
|
320 |
+
if ( $user && $user->get_error_code() === 'expired_key' ) {
|
321 |
+
wp_redirect( add_query_arg( array( 'updated' => 'expiredkey' ), get_permalink() ) );
|
322 |
+
} else {
|
323 |
+
wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
|
324 |
+
}
|
325 |
+
exit;
|
326 |
+
}
|
327 |
+
|
328 |
+
$this->change_password = true;
|
329 |
+
}
|
330 |
+
|
331 |
+
if ( $this->is_reset_request() ) {
|
332 |
+
|
333 |
+
UM()->form()->post_form = $_POST;
|
334 |
+
|
335 |
+
if ( empty( UM()->form()->post_form['mode'] ) ) {
|
336 |
+
UM()->form()->post_form['mode'] = 'password';
|
337 |
+
}
|
338 |
+
|
339 |
+
/**
|
340 |
+
* UM hook
|
341 |
+
*
|
342 |
+
* @type action
|
343 |
+
* @title um_reset_password_errors_hook
|
344 |
+
* @description Action on reset password submit form
|
345 |
+
* @input_vars
|
346 |
+
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
347 |
+
* @change_log
|
348 |
+
* ["Since: 2.0"]
|
349 |
+
* @usage add_action( 'um_reset_password_errors_hook', 'function_name', 10, 1 );
|
350 |
+
* @example
|
351 |
+
* <?php
|
352 |
+
* add_action( 'um_reset_password_errors_hook', 'my_reset_password_errors', 10, 1 );
|
353 |
+
* function my_reset_password_errors( $post ) {
|
354 |
+
* // your code here
|
355 |
+
* }
|
356 |
+
* ?>
|
357 |
+
*/
|
358 |
+
do_action( 'um_reset_password_errors_hook', UM()->form()->post_form );
|
359 |
+
|
360 |
+
if ( ! isset( UM()->form()->errors ) ) {
|
361 |
+
|
362 |
+
/**
|
363 |
+
* UM hook
|
364 |
+
*
|
365 |
+
* @type action
|
366 |
+
* @title um_reset_password_process_hook
|
367 |
+
* @description Action on reset password success submit form
|
368 |
+
* @input_vars
|
369 |
+
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
370 |
+
* @change_log
|
371 |
+
* ["Since: 2.0"]
|
372 |
+
* @usage add_action( 'um_reset_password_process_hook', 'function_name', 10, 1 );
|
373 |
+
* @example
|
374 |
+
* <?php
|
375 |
+
* add_action( 'um_reset_password_process_hook', 'my_reset_password_process', 10, 1 );
|
376 |
+
* function my_reset_password_process( $post ) {
|
377 |
+
* // your code here
|
378 |
+
* }
|
379 |
+
* ?>
|
380 |
+
*/
|
381 |
+
do_action( 'um_reset_password_process_hook', UM()->form()->post_form );
|
382 |
+
|
383 |
+
}
|
384 |
+
}
|
385 |
+
|
386 |
+
if ( $this->is_change_request() ) {
|
387 |
+
UM()->form()->post_form = $_POST;
|
388 |
+
|
389 |
+
/**
|
390 |
+
* UM hook
|
391 |
+
*
|
392 |
+
* @type action
|
393 |
+
* @title um_change_password_errors_hook
|
394 |
+
* @description Action on change password submit form
|
395 |
+
* @input_vars
|
396 |
+
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
397 |
+
* @change_log
|
398 |
+
* ["Since: 2.0"]
|
399 |
+
* @usage add_action( 'um_change_password_errors_hook', 'function_name', 10, 1 );
|
400 |
+
* @example
|
401 |
+
* <?php
|
402 |
+
* add_action( 'um_change_password_errors_hook', 'my_change_password_errors', 10, 1 );
|
403 |
+
* function my_change_password_errors( $post ) {
|
404 |
+
* // your code here
|
405 |
+
* }
|
406 |
+
* ?>
|
407 |
+
*/
|
408 |
+
do_action( 'um_change_password_errors_hook', UM()->form()->post_form );
|
409 |
+
|
410 |
+
if ( ! isset( UM()->form()->errors ) ) {
|
411 |
+
|
412 |
+
/**
|
413 |
+
* UM hook
|
414 |
+
*
|
415 |
+
* @type action
|
416 |
+
* @title um_change_password_process_hook
|
417 |
+
* @description Action on change password success submit form
|
418 |
+
* @input_vars
|
419 |
+
* [{"var":"$post","type":"array","desc":"Form submitted"}]
|
420 |
+
* @change_log
|
421 |
+
* ["Since: 2.0"]
|
422 |
+
* @usage add_action( 'um_change_password_process_hook', 'function_name', 10, 1 );
|
423 |
+
* @example
|
424 |
+
* <?php
|
425 |
+
* add_action( 'um_change_password_process_hook', 'my_change_password_process', 10, 1 );
|
426 |
+
* function my_change_password_process( $post ) {
|
427 |
+
* // your code here
|
428 |
+
* }
|
429 |
+
* ?>
|
430 |
+
*/
|
431 |
+
do_action( 'um_change_password_process_hook', UM()->form()->post_form );
|
432 |
+
|
433 |
+
}
|
434 |
+
}
|
435 |
+
}
|
436 |
+
|
437 |
+
|
438 |
+
/**
|
439 |
+
* Error handler: reset password
|
440 |
+
*
|
441 |
+
* @param $args
|
442 |
+
*/
|
443 |
+
public function um_reset_password_errors_hook( $args ) {
|
444 |
+
if ( '' !== $args[ UM()->honeypot ] ) {
|
445 |
+
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
|
446 |
+
}
|
447 |
+
|
448 |
+
$user = '';
|
449 |
+
|
450 |
+
foreach ( $args as $key => $val ) {
|
451 |
+
if ( strstr( $key, 'username_b' ) ) {
|
452 |
+
$user = trim( sanitize_text_field( $val ) );
|
453 |
+
}
|
454 |
+
}
|
455 |
+
|
456 |
+
if ( empty( $user ) ) {
|
457 |
+
UM()->form()->add_error( 'username_b', __( 'Please provide your username or email', 'ultimate-member' ) );
|
458 |
+
}
|
459 |
+
|
460 |
+
if ( ( ! is_email( $user ) && username_exists( $user ) ) || ( is_email( $user ) && email_exists( $user ) ) ) {
|
461 |
+
if ( is_email( $user ) ) {
|
462 |
+
$user_id = email_exists( $user );
|
463 |
+
} else {
|
464 |
+
$user_id = username_exists( $user );
|
465 |
+
}
|
466 |
+
|
467 |
+
$attempts = (int) get_user_meta( $user_id, 'password_rst_attempts', true );
|
468 |
+
$is_admin = user_can( absint( $user_id ), 'manage_options' );
|
469 |
+
|
470 |
+
if ( UM()->options()->get( 'enable_reset_password_limit' ) ) { // if reset password limit is set
|
471 |
+
|
472 |
+
if ( ! ( UM()->options()->get( 'disable_admin_reset_password_limit' ) && $is_admin ) ) {
|
473 |
+
// Doesn't trigger this when a user has admin capabilities and when reset password limit is disabled for admins
|
474 |
+
$limit = UM()->options()->get( 'reset_password_limit_number' );
|
475 |
+
if ( $attempts >= $limit ) {
|
476 |
+
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' ) );
|
477 |
+
} else {
|
478 |
+
update_user_meta( $user_id, 'password_rst_attempts', $attempts + 1 );
|
479 |
+
}
|
480 |
+
}
|
481 |
+
}
|
482 |
+
}
|
483 |
+
|
484 |
+
}
|
485 |
+
|
486 |
+
|
487 |
+
/**
|
488 |
+
* Process a new request
|
489 |
+
*
|
490 |
+
* @param $args
|
491 |
+
*/
|
492 |
+
public function um_reset_password_process_hook( $args ) {
|
493 |
+
$user = null;
|
494 |
+
|
495 |
+
foreach ( $args as $key => $val ) {
|
496 |
+
if ( strstr( $key, 'username_b' ) ) {
|
497 |
+
$user = trim( sanitize_text_field( $val ) );
|
498 |
+
}
|
499 |
+
}
|
500 |
+
|
501 |
+
if ( username_exists( $user ) ) {
|
502 |
+
$data = get_user_by( 'login', $user );
|
503 |
+
} elseif ( email_exists( $user ) ) {
|
504 |
+
$data = get_user_by( 'email', $user );
|
505 |
+
}
|
506 |
+
|
507 |
+
if ( isset( $data ) && is_a( $data, '\WP_User' ) ) {
|
508 |
+
um_fetch_user( $data->ID );
|
509 |
+
UM()->user()->password_reset();
|
510 |
+
}
|
511 |
+
|
512 |
+
exit( wp_redirect( um_get_core_page('password-reset', 'checkemail' ) ) );
|
513 |
+
}
|
514 |
+
|
515 |
+
|
516 |
+
/**
|
517 |
+
* Error handler: changing password
|
518 |
+
*
|
519 |
+
* @param $args
|
520 |
+
*/
|
521 |
+
public function um_change_password_errors_hook( $args ) {
|
522 |
+
if ( isset( $args[ UM()->honeypot ] ) && '' !== $args[ UM()->honeypot ] ) {
|
523 |
+
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
|
524 |
+
}
|
525 |
+
|
526 |
+
if ( ! is_user_logged_in() && isset( $args ) && ! um_is_core_page( 'password-reset' ) ||
|
527 |
+
is_user_logged_in() && isset( $args['user_id'] ) && absint( $args['user_id'] ) !== get_current_user_id() ) {
|
528 |
+
wp_die( esc_html__( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
529 |
+
}
|
530 |
+
|
531 |
+
if ( isset( $args['user_password'] ) && empty( $args['user_password'] ) ) {
|
532 |
+
UM()->form()->add_error( 'user_password', __( 'You must enter a new password', 'ultimate-member' ) );
|
533 |
+
}
|
534 |
+
|
535 |
+
if ( isset( $args['user_password'] ) ) {
|
536 |
+
$args['user_password'] = sanitize_text_field( $args['user_password'] );
|
537 |
+
}
|
538 |
+
if ( isset( $args['confirm_user_password'] ) ) {
|
539 |
+
$args['confirm_user_password'] = sanitize_text_field( $args['confirm_user_password'] );
|
540 |
+
}
|
541 |
+
|
542 |
+
if ( UM()->options()->get( 'require_strongpass' ) ) {
|
543 |
+
|
544 |
+
$min_length = UM()->options()->get( 'password_min_chars' );
|
545 |
+
$min_length = ! empty( $min_length ) ? $min_length : 8;
|
546 |
+
$max_length = UM()->options()->get( 'password_max_chars' );
|
547 |
+
$max_length = ! empty( $max_length ) ? $max_length : 30;
|
548 |
+
|
549 |
+
if ( mb_strlen( $args['user_password'] ) < $min_length ) {
|
550 |
+
UM()->form()->add_error( 'user_password', sprintf( __( 'Your password must contain at least %d characters', 'ultimate-member' ), $min_length ) );
|
551 |
+
}
|
552 |
+
|
553 |
+
if ( mb_strlen( $args['user_password'] ) > $max_length ) {
|
554 |
+
UM()->form()->add_error( 'user_password', sprintf( __( 'Your password must contain less than %d characters', 'ultimate-member' ), $max_length ) );
|
555 |
+
}
|
556 |
+
|
557 |
+
if ( ! UM()->validation()->strong_pass( $args['user_password'] ) ) {
|
558 |
+
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
|
559 |
+
}
|
560 |
+
}
|
561 |
+
|
562 |
+
if ( isset( $args['confirm_user_password'] ) && empty( $args['confirm_user_password'] ) ) {
|
563 |
+
UM()->form()->add_error( 'confirm_user_password', __( 'You must confirm your new password', 'ultimate-member' ) );
|
564 |
+
}
|
565 |
+
|
566 |
+
if ( isset( $args['user_password'] ) && isset( $args['confirm_user_password'] ) && $args['user_password'] !== $args['confirm_user_password'] ) {
|
567 |
+
UM()->form()->add_error( 'confirm_user_password', __( 'Your passwords do not match', 'ultimate-member' ) );
|
568 |
+
}
|
569 |
+
|
570 |
+
}
|
571 |
+
|
572 |
+
|
573 |
+
/**
|
574 |
+
* Process a change request
|
575 |
+
*
|
576 |
+
* @param $args
|
577 |
+
*/
|
578 |
+
public function um_change_password_process_hook( $args ) {
|
579 |
+
if ( isset( $args['_um_password_change'] ) && $args['_um_password_change'] == 1 ) {
|
580 |
+
|
581 |
+
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
582 |
+
$user = get_userdata( absint( $args['user_id'] ) );
|
583 |
+
|
584 |
+
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
|
585 |
+
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
|
586 |
+
|
587 |
+
if ( $user->user_login != $rp_login ) {
|
588 |
+
$user = false;
|
589 |
+
} else {
|
590 |
+
$user = check_password_reset_key( $rp_key, $rp_login );
|
591 |
+
if ( isset( $args['user_password'] ) && ! hash_equals( $rp_key, $args['rp_key'] ) ) {
|
592 |
+
$user = false;
|
593 |
+
}
|
594 |
+
}
|
595 |
+
} else {
|
596 |
+
$user = false;
|
597 |
+
}
|
598 |
+
|
599 |
+
if ( ! $user || is_wp_error( $user ) ) {
|
600 |
+
$this->setcookie( $rp_cookie, false );
|
601 |
+
if ( $user && $user->get_error_code() === 'expired_key' ) {
|
602 |
+
wp_redirect( add_query_arg( array( 'updated' => 'expiredkey' ), get_permalink() ) );
|
603 |
+
} else {
|
604 |
+
wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
|
605 |
+
}
|
606 |
+
exit;
|
607 |
+
}
|
608 |
+
|
609 |
+
|
610 |
+
$errors = new \WP_Error();
|
611 |
+
/**
|
612 |
+
* Fires before the password reset procedure is validated.
|
613 |
+
*
|
614 |
+
* @since 3.5.0
|
615 |
+
*
|
616 |
+
* @param object $errors WP Error object.
|
617 |
+
* @param \WP_User|\WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise.
|
618 |
+
*/
|
619 |
+
do_action( 'validate_password_reset', $errors, $user );
|
620 |
+
|
621 |
+
if ( ( ! $errors->get_error_code() ) ) {
|
622 |
+
reset_password( $user, sanitize_text_field( $args['user_password'] ) );
|
623 |
+
|
624 |
+
// send the Password Changed Email
|
625 |
+
UM()->user()->password_changed();
|
626 |
+
|
627 |
+
// clear temporary data
|
628 |
+
$attempts = (int) get_user_meta( $user->ID, 'password_rst_attempts', true );
|
629 |
+
if ( $attempts ) {
|
630 |
+
update_user_meta( $user->ID, 'password_rst_attempts', 0 );
|
631 |
+
}
|
632 |
+
$this->setcookie( $rp_cookie, false );
|
633 |
+
|
634 |
+
// logout
|
635 |
+
if ( is_user_logged_in() ) {
|
636 |
+
wp_logout();
|
637 |
+
}
|
638 |
+
|
639 |
+
/**
|
640 |
+
* UM hook
|
641 |
+
*
|
642 |
+
* @type action
|
643 |
+
* @title um_after_changing_user_password
|
644 |
+
* @description Hook that runs after user change their password
|
645 |
+
* @input_vars
|
646 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
647 |
+
* @change_log
|
648 |
+
* ["Since: 2.0"]
|
649 |
+
* @usage add_action( 'um_after_changing_user_password', 'function_name', 10, 1 );
|
650 |
+
* @example
|
651 |
+
* <?php
|
652 |
+
* add_action( 'um_after_changing_user_password', 'my_after_changing_user_password', 10, 1 );
|
653 |
+
* function my_user_login_extra( $user_id ) {
|
654 |
+
* // your code here
|
655 |
+
* }
|
656 |
+
* ?>
|
657 |
+
*/
|
658 |
+
do_action( 'um_after_changing_user_password', absint( $args['user_id'] ) );
|
659 |
+
|
660 |
+
exit( wp_redirect( um_get_core_page( 'login', 'password_changed' ) ) );
|
661 |
+
}
|
662 |
+
}
|
663 |
+
}
|
664 |
+
|
665 |
+
|
666 |
+
/**
|
667 |
+
* Disable page caching and set or clear cookie
|
668 |
+
*
|
669 |
+
* @param string $name
|
670 |
+
* @param string $value
|
671 |
+
* @param int $expire
|
672 |
+
* @param string $path
|
673 |
+
*/
|
674 |
+
public function setcookie( $name, $value = '', $expire = 0, $path = '' ) {
|
675 |
+
if ( empty( $value ) ) {
|
676 |
+
$expire = time() - YEAR_IN_SECONDS;
|
677 |
+
}
|
678 |
+
if ( empty( $path ) ) {
|
679 |
+
list( $path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) );
|
680 |
+
}
|
681 |
+
|
682 |
+
$levels = ob_get_level();
|
683 |
+
for ( $i = 0; $i < $levels; $i++ ) {
|
684 |
+
@ob_end_clean();
|
685 |
+
}
|
686 |
+
|
687 |
+
nocache_headers();
|
688 |
+
setcookie( $name, $value, $expire, $path, COOKIE_DOMAIN, is_ssl(), true );
|
689 |
+
}
|
690 |
+
|
691 |
+
|
692 |
+
/**
|
693 |
+
* UM Placeholders for reset password
|
694 |
+
*
|
695 |
+
* @param $placeholders
|
696 |
+
*
|
697 |
+
* @return array
|
698 |
+
*/
|
699 |
+
function add_placeholder( $placeholders ) {
|
700 |
+
$placeholders[] = '{password_reset_link}';
|
701 |
+
$placeholders[] = '{password}';
|
702 |
+
return $placeholders;
|
703 |
+
}
|
704 |
+
|
705 |
+
|
706 |
+
/**
|
707 |
+
* UM Replace Placeholders for reset password
|
708 |
+
*
|
709 |
+
* @param $replace_placeholders
|
710 |
+
*
|
711 |
+
* @return array
|
712 |
+
*/
|
713 |
+
function add_replace_placeholder( $replace_placeholders ) {
|
714 |
+
$replace_placeholders[] = um_user( 'password_reset_link' );
|
715 |
+
$replace_placeholders[] = esc_html__( 'Your set password', 'ultimate-member' );
|
716 |
+
return $replace_placeholders;
|
717 |
+
}
|
718 |
+
}
|
719 |
+
}
|
|
|
|
includes/core/class-profile.php
CHANGED
@@ -422,7 +422,7 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
|
422 |
$data['in_profile_meta'] = true;
|
423 |
|
424 |
$value = um_filtered_value( $key, $data );
|
425 |
-
if ( ! $value && ! in_array( $data['type'], $fields_without_metakey ) ) {
|
426 |
continue;
|
427 |
}
|
428 |
|
422 |
$data['in_profile_meta'] = true;
|
423 |
|
424 |
$value = um_filtered_value( $key, $data );
|
425 |
+
if ( ! $value && ( ! array_key_exists( 'type', $data ) || ! in_array( $data['type'], $fields_without_metakey ) ) ) {
|
426 |
continue;
|
427 |
}
|
428 |
|
includes/core/class-roles-capabilities.php
CHANGED
@@ -21,6 +21,23 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
|
|
21 |
function __construct() {
|
22 |
add_action( 'wp_roles_init', array( &$this, 'um_roles_init' ), 99999 );
|
23 |
add_action( 'update_option', array( &$this, 'um_on_roles_update' ), 10, 3 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
|
21 |
function __construct() {
|
22 |
add_action( 'wp_roles_init', array( &$this, 'um_roles_init' ), 99999 );
|
23 |
add_action( 'update_option', array( &$this, 'um_on_roles_update' ), 10, 3 );
|
24 |
+
add_action( 'set_user_role', array( &$this, 'remove_user_cache' ), 10, 1 );
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Flush the Cache User Profile on set new user role(s)
|
30 |
+
*
|
31 |
+
* @param int $user_id
|
32 |
+
*/
|
33 |
+
function remove_user_cache( $user_id ) {
|
34 |
+
$user = get_userdata( $user_id );
|
35 |
+
|
36 |
+
if ( ! is_a( $user, '\WP_User' ) ) {
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
|
40 |
+
UM()->user()->remove_cache( $user_id );
|
41 |
}
|
42 |
|
43 |
|
includes/core/class-user.php
CHANGED
@@ -1,2185 +1,2185 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
// Exit if accessed directly
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\core\User' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class User
|
13 |
-
* @package um\core
|
14 |
-
*/
|
15 |
-
class User {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Data that we will set before the update profile to compare it after update
|
20 |
-
*
|
21 |
-
* @var null
|
22 |
-
*/
|
23 |
-
public $previous_data = null;
|
24 |
-
|
25 |
-
|
26 |
-
/**
|
27 |
-
* User constructor.
|
28 |
-
*/
|
29 |
-
function __construct() {
|
30 |
-
|
31 |
-
$this->id = 0;
|
32 |
-
$this->usermeta = null;
|
33 |
-
$this->data = null;
|
34 |
-
$this->profile = null;
|
35 |
-
$this->cannot_edit = null;
|
36 |
-
$this->password_reset_key = null;
|
37 |
-
|
38 |
-
global $wpdb;
|
39 |
-
|
40 |
-
$this->banned_keys = array(
|
41 |
-
'metabox','postbox','meta-box',
|
42 |
-
'dismissed_wp_pointers', 'session_tokens',
|
43 |
-
'screen_layout', 'wp_user-', 'dismissed',
|
44 |
-
'cap_key', $wpdb->get_blog_prefix(). 'capabilities',
|
45 |
-
'managenav', 'nav_menu', 'user_activation_key',
|
46 |
-
'level_', $wpdb->get_blog_prefix() . 'user_level'
|
47 |
-
);
|
48 |
-
|
49 |
-
add_action( 'init', array( &$this, 'set' ), 1 );
|
50 |
-
|
51 |
-
$this->preview = false;
|
52 |
-
$this->send_mail_on_delete = true;
|
53 |
-
|
54 |
-
// a list of keys that should never be in wp_usermeta
|
55 |
-
$this->update_user_keys = array(
|
56 |
-
'user_email',
|
57 |
-
'user_pass',
|
58 |
-
'user_password',
|
59 |
-
'display_name',
|
60 |
-
'user_url',
|
61 |
-
'role',
|
62 |
-
);
|
63 |
-
|
64 |
-
$this->target_id = null;
|
65 |
-
|
66 |
-
// When the cache should be cleared
|
67 |
-
add_action( 'um_delete_user_hook', array( &$this, 'remove_cached_queue' ) );
|
68 |
-
add_action( 'um_delete_user', array( &$this, 'remove_cache' ), 10, 1 );
|
69 |
-
|
70 |
-
add_action( 'um_after_user_status_is_changed_hook', array( &$this, 'remove_cached_queue' ) );
|
71 |
-
|
72 |
-
// When user cache should be cleared
|
73 |
-
add_action( 'um_after_user_updated', array( &$this, 'remove_cache' ) );
|
74 |
-
add_action( 'um_after_user_account_updated', array( &$this, 'remove_cache' ) );
|
75 |
-
add_action( 'personal_options_update', array( &$this, 'remove_cache' ) );
|
76 |
-
//add_action('edit_user_profile_update', array(&$this, 'remove_cache') );
|
77 |
-
add_action( 'um_when_role_is_set', array( &$this, 'remove_cache' ) );
|
78 |
-
add_action( 'um_when_status_is_set', array( &$this, 'remove_cache' ) );
|
79 |
-
|
80 |
-
add_action( 'show_user_profile', array( $this, 'profile_form_additional_section' ), 10 );
|
81 |
-
add_action( 'user_new_form', array( $this, 'profile_form_additional_section' ), 10 );
|
82 |
-
add_action( 'edit_user_profile', array( $this, 'profile_form_additional_section' ), 10 );
|
83 |
-
add_filter( 'um_user_profile_additional_fields', array( $this, 'secondary_role_field' ), 1, 2 );
|
84 |
-
|
85 |
-
//on every update of user profile (hook from wp_update_user)
|
86 |
-
add_action( 'profile_update', array( &$this, 'profile_update' ), 10, 2 ); // user_id and old_user_data
|
87 |
-
|
88 |
-
//on user update profile page
|
89 |
-
//add_action( 'edit_user_profile_update', array( &$this, 'profile_update' ), 10, 1 );
|
90 |
-
|
91 |
-
add_action( 'user_register', array( &$this, 'user_register_via_admin' ), 10, 1 );
|
92 |
-
add_action( 'user_register', array( &$this, 'set_gravatar' ), 11, 1 );
|
93 |
-
|
94 |
-
|
95 |
-
if ( is_multisite() ) {
|
96 |
-
add_action( 'added_existing_user', array( &$this, 'add_um_role_existing_user' ), 10, 2 );
|
97 |
-
add_action( 'wpmu_activate_user', array( &$this, 'add_um_role_wpmu_new_user' ), 10, 1 );
|
98 |
-
}
|
99 |
-
|
100 |
-
add_action( 'init', array( &$this, 'check_membership' ), 10 );
|
101 |
-
|
102 |
-
if ( is_multisite() ) {
|
103 |
-
add_action( 'wpmu_delete_user', array( &$this, 'delete_user_handler' ), 10, 1 );
|
104 |
-
} else {
|
105 |
-
add_action( 'delete_user', array( &$this, 'delete_user_handler' ), 10, 1 );
|
106 |
-
}
|
107 |
-
|
108 |
-
|
109 |
-
add_action( 'updated_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
|
110 |
-
add_action( 'added_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
|
111 |
-
|
112 |
-
add_action( 'deleted_user_meta', array( &$this, 'on_delete_usermeta' ), 10, 4 );
|
113 |
-
}
|
114 |
-
|
115 |
-
|
116 |
-
/**
|
117 |
-
* When you delete usermeta connected with member directory - reset it to default value
|
118 |
-
*
|
119 |
-
* @param int|array $meta_ids
|
120 |
-
* @param int $object_id
|
121 |
-
* @param string $meta_key
|
122 |
-
* @param mixed $_meta_value
|
123 |
-
*/
|
124 |
-
function on_delete_usermeta( $meta_ids, $object_id, $meta_key, $_meta_value ) {
|
125 |
-
$metakeys = array( 'account_status', 'hide_in_members', 'synced_gravatar_hashed_id', 'synced_profile_photo', 'profile_photo', 'cover_photo', '_um_verified' );
|
126 |
-
if ( ! in_array( $meta_key, $metakeys ) ) {
|
127 |
-
return;
|
128 |
-
}
|
129 |
-
|
130 |
-
$md_data = get_user_meta( $object_id, 'um_member_directory_data', true );
|
131 |
-
if ( empty( $md_data ) ) {
|
132 |
-
$md_data = array(
|
133 |
-
'account_status' => 'approved',
|
134 |
-
'hide_in_members' => UM()->member_directory()->get_hide_in_members_default(),
|
135 |
-
'profile_photo' => false,
|
136 |
-
'cover_photo' => false,
|
137 |
-
'verified' => false,
|
138 |
-
);
|
139 |
-
}
|
140 |
-
|
141 |
-
switch ( $meta_key ) {
|
142 |
-
case 'account_status':
|
143 |
-
$md_data['account_status'] = 'approved';
|
144 |
-
break;
|
145 |
-
case 'hide_in_members':
|
146 |
-
$md_data['hide_in_members'] = UM()->member_directory()->get_hide_in_members_default();
|
147 |
-
break;
|
148 |
-
case 'synced_gravatar_hashed_id':
|
149 |
-
if ( UM()->options()->get( 'use_gravatars' ) ) {
|
150 |
-
$profile_photo = get_user_meta( $object_id, 'profile_photo', true );
|
151 |
-
$synced_profile_photo = get_user_meta( $object_id, 'synced_profile_photo', true );
|
152 |
-
|
153 |
-
$md_data['profile_photo'] = ! empty( $profile_photo ) || ! empty( $synced_profile_photo );
|
154 |
-
}
|
155 |
-
|
156 |
-
break;
|
157 |
-
case 'synced_profile_photo':
|
158 |
-
$profile_photo = get_user_meta( $object_id, 'profile_photo', true );
|
159 |
-
|
160 |
-
$synced_gravatar_hashed_id = false;
|
161 |
-
if ( UM()->options()->get( 'use_gravatars' ) ) {
|
162 |
-
$synced_gravatar_hashed_id = get_user_meta( $object_id, 'synced_gravatar_hashed_id', true );
|
163 |
-
}
|
164 |
-
|
165 |
-
$md_data['profile_photo'] = ! empty( $profile_photo ) || ! empty( $synced_gravatar_hashed_id );
|
166 |
-
break;
|
167 |
-
case 'profile_photo':
|
168 |
-
$synced_profile_photo = get_user_meta( $object_id, 'synced_profile_photo', true );
|
169 |
-
|
170 |
-
$synced_gravatar_hashed_id = false;
|
171 |
-
if ( UM()->options()->get( 'use_gravatars' ) ) {
|
172 |
-
$synced_gravatar_hashed_id = get_user_meta( $object_id, 'synced_gravatar_hashed_id', true );
|
173 |
-
}
|
174 |
-
|
175 |
-
$md_data['profile_photo'] = ! empty( $synced_profile_photo ) || ! empty( $synced_gravatar_hashed_id );
|
176 |
-
break;
|
177 |
-
case 'cover_photo':
|
178 |
-
$md_data['cover_photo'] = false;
|
179 |
-
break;
|
180 |
-
case '_um_verified':
|
181 |
-
$md_data['verified'] = false;
|
182 |
-
break;
|
183 |
-
}
|
184 |
-
|
185 |
-
update_user_meta( $object_id, 'um_member_directory_data', $md_data );
|
186 |
-
}
|
187 |
-
|
188 |
-
|
189 |
-
/**
|
190 |
-
* When you add/update usermeta connected with member directories - set this data to member directory metakey
|
191 |
-
*
|
192 |
-
* @param int $meta_id
|
193 |
-
* @param int $object_id
|
194 |
-
* @param string $meta_key
|
195 |
-
* @param mixed $_meta_value
|
196 |
-
*/
|
197 |
-
function on_update_usermeta( $meta_id, $object_id, $meta_key, $_meta_value ) {
|
198 |
-
|
199 |
-
$metakeys = array( 'account_status', 'hide_in_members', 'synced_gravatar_hashed_id', 'synced_profile_photo', 'profile_photo', 'cover_photo', '_um_verified' );
|
200 |
-
if ( ! in_array( $meta_key, $metakeys ) ) {
|
201 |
-
return;
|
202 |
-
}
|
203 |
-
|
204 |
-
$md_data = get_user_meta( $object_id, 'um_member_directory_data', true );
|
205 |
-
if ( empty( $md_data ) ) {
|
206 |
-
$md_data = array(
|
207 |
-
'account_status' => 'approved',
|
208 |
-
'hide_in_members' => UM()->member_directory()->get_hide_in_members_default(),
|
209 |
-
'profile_photo' => false,
|
210 |
-
'cover_photo' => false,
|
211 |
-
'verified' => false,
|
212 |
-
);
|
213 |
-
}
|
214 |
-
|
215 |
-
switch ( $meta_key ) {
|
216 |
-
case 'account_status':
|
217 |
-
$md_data['account_status'] = $_meta_value;
|
218 |
-
break;
|
219 |
-
case 'hide_in_members':
|
220 |
-
|
221 |
-
$hide_in_members = UM()->member_directory()->get_hide_in_members_default();
|
222 |
-
if ( ! empty( $_meta_value ) ) {
|
223 |
-
if ( $_meta_value == 'Yes' || $_meta_value == __( 'Yes', 'ultimate-member' ) ||
|
224 |
-
array_intersect( array( 'Yes', __( 'Yes', 'ultimate-member' ) ), $_meta_value ) ) {
|
225 |
-
$hide_in_members = true;
|
226 |
-
} else {
|
227 |
-
$hide_in_members = false;
|
228 |
-
}
|
229 |
-
}
|
230 |
-
|
231 |
-
$md_data['hide_in_members'] = $hide_in_members;
|
232 |
-
|
233 |
-
break;
|
234 |
-
case 'synced_gravatar_hashed_id':
|
235 |
-
if ( UM()->options()->get( 'use_gravatars' ) ) {
|
236 |
-
if ( empty( $md_data['profile_photo'] ) ) {
|
237 |
-
$md_data['profile_photo'] = ! empty( $_meta_value );
|
238 |
-
}
|
239 |
-
}
|
240 |
-
|
241 |
-
break;
|
242 |
-
case 'synced_profile_photo':
|
243 |
-
case 'profile_photo':
|
244 |
-
if ( empty( $md_data['profile_photo'] ) ) {
|
245 |
-
$md_data['profile_photo'] = ! empty( $_meta_value );
|
246 |
-
}
|
247 |
-
break;
|
248 |
-
case 'cover_photo':
|
249 |
-
$md_data['cover_photo'] = ! empty( $_meta_value );
|
250 |
-
break;
|
251 |
-
case '_um_verified':
|
252 |
-
$md_data['verified'] = $_meta_value == 'verified' ? true : false;
|
253 |
-
break;
|
254 |
-
}
|
255 |
-
|
256 |
-
update_user_meta( $object_id, 'um_member_directory_data', $md_data );
|
257 |
-
}
|
258 |
-
|
259 |
-
|
260 |
-
/**
|
261 |
-
* @param $user_id
|
262 |
-
*/
|
263 |
-
function delete_user_handler( $user_id ) {
|
264 |
-
um_fetch_user( $user_id );
|
265 |
-
|
266 |
-
/**
|
267 |
-
* UM hook
|
268 |
-
*
|
269 |
-
* @type action
|
270 |
-
* @title um_delete_user_hook
|
271 |
-
* @description On delete user
|
272 |
-
* @change_log
|
273 |
-
* ["Since: 2.0"]
|
274 |
-
* @usage add_action( 'um_delete_user_hook', 'function_name', 10 );
|
275 |
-
* @example
|
276 |
-
* <?php
|
277 |
-
* add_action( 'um_delete_user_hook', 'my_delete_user', 10 );
|
278 |
-
* function my_delete_user() {
|
279 |
-
* // your code here
|
280 |
-
* }
|
281 |
-
* ?>
|
282 |
-
*/
|
283 |
-
do_action( 'um_delete_user_hook' );
|
284 |
-
|
285 |
-
/**
|
286 |
-
* UM hook
|
287 |
-
*
|
288 |
-
* @type action
|
289 |
-
* @title um_delete_user
|
290 |
-
* @description On delete user
|
291 |
-
* @input_vars
|
292 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
293 |
-
* @change_log
|
294 |
-
* ["Since: 2.0"]
|
295 |
-
* @usage add_action( 'um_delete_user', 'function_name', 10, 1 );
|
296 |
-
* @example
|
297 |
-
* <?php
|
298 |
-
* add_action( 'um_delete_user', 'my_delete_user', 10, 1 );
|
299 |
-
* function my_delete_user( $user_id ) {
|
300 |
-
* // your code here
|
301 |
-
* }
|
302 |
-
* ?>
|
303 |
-
*/
|
304 |
-
do_action( 'um_delete_user', um_user( 'ID' ) );
|
305 |
-
|
306 |
-
// send email notifications
|
307 |
-
if ( $this->send_mail_on_delete ) {
|
308 |
-
UM()->mail()->send( um_user( 'user_email' ), 'deletion_email' );
|
309 |
-
|
310 |
-
$emails = um_multi_admin_email();
|
311 |
-
if ( ! empty( $emails ) ) {
|
312 |
-
foreach ( $emails as $email ) {
|
313 |
-
UM()->mail()->send( $email, 'notification_deletion', array( 'admin' => true ) );
|
314 |
-
}
|
315 |
-
}
|
316 |
-
}
|
317 |
-
|
318 |
-
// remove uploads
|
319 |
-
UM()->files()->remove_dir( UM()->files()->upload_temp );
|
320 |
-
UM()->files()->remove_dir( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR );
|
321 |
-
}
|
322 |
-
|
323 |
-
|
324 |
-
/**
|
325 |
-
*
|
326 |
-
*/
|
327 |
-
function check_membership() {
|
328 |
-
if ( ! is_user_logged_in() ) {
|
329 |
-
return;
|
330 |
-
}
|
331 |
-
|
332 |
-
um_fetch_user( get_current_user_id() );
|
333 |
-
$status = um_user( 'account_status' );
|
334 |
-
|
335 |
-
if ( 'rejected' == $status ) {
|
336 |
-
wp_logout();
|
337 |
-
session_unset();
|
338 |
-
exit( wp_redirect( um_get_core_page( 'login' ) ) );
|
339 |
-
}
|
340 |
-
|
341 |
-
um_reset_user();
|
342 |
-
}
|
343 |
-
|
344 |
-
|
345 |
-
/**
|
346 |
-
* Multisite add existing user
|
347 |
-
*
|
348 |
-
* @param $user_id
|
349 |
-
* @param $result
|
350 |
-
*/
|
351 |
-
function add_um_role_existing_user( $user_id, $result ) {
|
352 |
-
// Bail if no user ID was passed
|
353 |
-
if ( empty( $user_id ) ) {
|
354 |
-
return;
|
355 |
-
}
|
356 |
-
|
357 |
-
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
358 |
-
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
|
359 |
-
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
|
360 |
-
}
|
361 |
-
}
|
362 |
-
|
363 |
-
$this->remove_cache( $user_id );
|
364 |
-
}
|
365 |
-
|
366 |
-
|
367 |
-
/**
|
368 |
-
* Multisite add existing user
|
369 |
-
*
|
370 |
-
* @param $user_id
|
371 |
-
*/
|
372 |
-
function add_um_role_wpmu_new_user( $user_id ) {
|
373 |
-
// Bail if no user ID was passed
|
374 |
-
if ( empty( $user_id ) ) {
|
375 |
-
return;
|
376 |
-
}
|
377 |
-
|
378 |
-
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
379 |
-
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
|
380 |
-
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
|
381 |
-
}
|
382 |
-
}
|
383 |
-
|
384 |
-
$this->remove_cache( $user_id );
|
385 |
-
}
|
386 |
-
|
387 |
-
|
388 |
-
/**
|
389 |
-
* Get pending users (in queue)
|
390 |
-
*/
|
391 |
-
function get_pending_users_count() {
|
392 |
-
|
393 |
-
$cached_users_queue = get_option( 'um_cached_users_queue' );
|
394 |
-
if ( $cached_users_queue > 0 && ! isset( $_REQUEST['delete_count'] ) ) {
|
395 |
-
return $cached_users_queue;
|
396 |
-
}
|
397 |
-
|
398 |
-
$args = array( 'fields' => 'ID', 'number' => 1 );
|
399 |
-
$args['meta_query']['relation'] = 'OR';
|
400 |
-
$args['meta_query'][] = array(
|
401 |
-
'key' => 'account_status',
|
402 |
-
'value' => 'awaiting_email_confirmation',
|
403 |
-
'compare' => '='
|
404 |
-
);
|
405 |
-
$args['meta_query'][] = array(
|
406 |
-
'key' => 'account_status',
|
407 |
-
'value' => 'awaiting_admin_review',
|
408 |
-
'compare' => '='
|
409 |
-
);
|
410 |
-
|
411 |
-
/**
|
412 |
-
* UM hook
|
413 |
-
*
|
414 |
-
* @type filter
|
415 |
-
* @title um_admin_pending_queue_filter
|
416 |
-
* @description Change user query arguments when get pending users
|
417 |
-
* @input_vars
|
418 |
-
* [{"var":"$args","type":"array","desc":"WP_Users query arguments"}]
|
419 |
-
* @change_log
|
420 |
-
* ["Since: 2.0"]
|
421 |
-
* @usage
|
422 |
-
* <?php add_filter( 'um_admin_pending_queue_filter', 'function_name', 10, 1 ); ?>
|
423 |
-
* @example
|
424 |
-
* <?php
|
425 |
-
* add_filter( 'um_admin_pending_queue_filter', 'my_admin_pending_queue', 10, 1 );
|
426 |
-
* function my_admin_pending_queue( $args ) {
|
427 |
-
* // your code here
|
428 |
-
* return $args;
|
429 |
-
* }
|
430 |
-
* ?>
|
431 |
-
*/
|
432 |
-
$args = apply_filters( 'um_admin_pending_queue_filter', $args );
|
433 |
-
$users = new \WP_User_Query( $args );
|
434 |
-
|
435 |
-
delete_option( 'um_cached_users_queue' );
|
436 |
-
add_option( 'um_cached_users_queue', $users->get_total(), '', 'no' );
|
437 |
-
|
438 |
-
return $users->get_total();
|
439 |
-
}
|
440 |
-
|
441 |
-
|
442 |
-
/**
|
443 |
-
* @param $user_id
|
444 |
-
*
|
445 |
-
* @return bool|mixed
|
446 |
-
*/
|
447 |
-
function get_profile_slug( $user_id ) {
|
448 |
-
// Permalink base
|
449 |
-
$permalink_base = UM()->options()->get( 'permalink_base' );
|
450 |
-
$profile_slug = get_user_meta( $user_id, "um_user_profile_url_slug_{$permalink_base}", true );
|
451 |
-
|
452 |
-
//get default username permalink if it's empty then return false
|
453 |
-
if ( empty( $profile_slug ) ) {
|
454 |
-
if ( $permalink_base != 'user_login' ) {
|
455 |
-
$profile_slug = get_user_meta( $user_id, 'um_user_profile_url_slug_user_login', true );
|
456 |
-
}
|
457 |
-
|
458 |
-
if ( empty( $profile_slug ) ) {
|
459 |
-
return false;
|
460 |
-
}
|
461 |
-
}
|
462 |
-
|
463 |
-
return $profile_slug;
|
464 |
-
}
|
465 |
-
|
466 |
-
|
467 |
-
/**
|
468 |
-
* @param $user_id
|
469 |
-
*
|
470 |
-
* @return bool|string
|
471 |
-
*/
|
472 |
-
function get_profile_link( $user_id ) {
|
473 |
-
$profile_slug = $this->get_profile_slug( $user_id );
|
474 |
-
|
475 |
-
if ( empty( $profile_slug ) ) {
|
476 |
-
return false;
|
477 |
-
}
|
478 |
-
|
479 |
-
return UM()->permalinks()->profile_permalink( $profile_slug );
|
480 |
-
}
|
481 |
-
|
482 |
-
|
483 |
-
/**
|
484 |
-
* Generate User Profile Slug and save to meta
|
485 |
-
*
|
486 |
-
* @param int $user_id
|
487 |
-
* @param bool $force
|
488 |
-
*/
|
489 |
-
function generate_profile_slug( $user_id, $force = false ) {
|
490 |
-
$userdata = get_userdata( $user_id );
|
491 |
-
|
492 |
-
if ( empty( $userdata ) ) {
|
493 |
-
return;
|
494 |
-
}
|
495 |
-
|
496 |
-
delete_option( "um_cache_userdata_{$user_id}" );
|
497 |
-
|
498 |
-
$current_profile_slug = $this->get_profile_slug( $user_id );
|
499 |
-
|
500 |
-
$user_in_url = '';
|
501 |
-
$permalink_base = UM()->options()->get( 'permalink_base' );
|
502 |
-
|
503 |
-
// User ID
|
504 |
-
if ( $permalink_base == 'user_id' ) {
|
505 |
-
$user_in_url = $user_id;
|
506 |
-
}
|
507 |
-
|
508 |
-
// Username
|
509 |
-
if ( $permalink_base == 'user_login' ) {
|
510 |
-
|
511 |
-
$user_in_url = $userdata->user_login;
|
512 |
-
|
513 |
-
if ( is_email( $user_in_url ) ) {
|
514 |
-
|
515 |
-
$user_email = $user_in_url;
|
516 |
-
$user_in_url = str_replace( '@', '', $user_in_url );
|
517 |
-
|
518 |
-
if ( ( $pos = strrpos( $user_in_url, '.' ) ) !== false ) {
|
519 |
-
$search_length = strlen( '.' );
|
520 |
-
$user_in_url = substr_replace( $user_in_url, '-', $pos, $search_length );
|
521 |
-
}
|
522 |
-
update_user_meta( $user_id, "um_email_as_username_{$user_in_url}", $user_email );
|
523 |
-
|
524 |
-
} else {
|
525 |
-
|
526 |
-
$user_in_url = urlencode( $user_in_url );
|
527 |
-
|
528 |
-
}
|
529 |
-
}
|
530 |
-
|
531 |
-
// Fisrt and Last name
|
532 |
-
$full_name_permalinks = array( 'name', 'name_dash', 'name_plus' );
|
533 |
-
if ( in_array( $permalink_base, $full_name_permalinks ) ) {
|
534 |
-
$separated = array( 'name' => '.', 'name_dash' => '-', 'name_plus' => '+' );
|
535 |
-
$separate = $separated[ $permalink_base ];
|
536 |
-
$first_name = $userdata->first_name;
|
537 |
-
$last_name = $userdata->last_name;
|
538 |
-
$full_name = trim( sprintf( '%s %s', $first_name, $last_name ) );
|
539 |
-
$full_name = preg_replace( '/\s+/', ' ', $full_name ); // Remove double spaces
|
540 |
-
$profile_slug = UM()->permalinks()->profile_slug( $full_name, $first_name, $last_name );
|
541 |
-
|
542 |
-
$append = 0;
|
543 |
-
$username = $full_name;
|
544 |
-
$_username = $full_name;
|
545 |
-
|
546 |
-
while ( 1 ) {
|
547 |
-
$username = $_username . ( empty( $append ) ? '' : " $append" );
|
548 |
-
$slug_exists_user_id = UM()->permalinks()->slug_exists_user_id( $profile_slug . ( empty( $append ) ? '' : "{$separate}{$append}" ) );
|
549 |
-
if ( empty( $slug_exists_user_id ) || $user_id == $slug_exists_user_id ) {
|
550 |
-
break;
|
551 |
-
}
|
552 |
-
$append++;
|
553 |
-
}
|
554 |
-
|
555 |
-
$user_in_url = UM()->permalinks()->profile_slug( $username, $first_name, $last_name );
|
556 |
-
if ( empty( $user_in_url ) ) {
|
557 |
-
$user_in_url = $userdata->user_login;
|
558 |
-
|
559 |
-
if ( is_email( $user_in_url ) ) {
|
560 |
-
|
561 |
-
$user_email = $user_in_url;
|
562 |
-
$user_in_url = str_replace( '@', '', $user_in_url );
|
563 |
-
|
564 |
-
if ( ( $pos = strrpos( $user_in_url, '.' ) ) !== false ) {
|
565 |
-
$search_length = strlen( '.' );
|
566 |
-
$user_in_url = substr_replace( $user_in_url, '-', $pos, $search_length );
|
567 |
-
}
|
568 |
-
update_user_meta( $user_id, "um_email_as_username_{$user_in_url}", $user_email );
|
569 |
-
|
570 |
-
} else {
|
571 |
-
|
572 |
-
$user_in_url = sanitize_title( $user_in_url );
|
573 |
-
|
574 |
-
}
|
575 |
-
}
|
576 |
-
|
577 |
-
$user_in_url = trim( $user_in_url, $separate );
|
578 |
-
}
|
579 |
-
|
580 |
-
$user_in_url = apply_filters( 'um_change_user_profile_slug', $user_in_url, $user_id );
|
581 |
-
|
582 |
-
if ( $force || empty( $current_profile_slug ) || $current_profile_slug != $user_in_url ) {
|
583 |
-
update_user_meta( $user_id, "um_user_profile_url_slug_{$permalink_base}", $user_in_url );
|
584 |
-
}
|
585 |
-
}
|
586 |
-
|
587 |
-
|
588 |
-
/**
|
589 |
-
* Backend user creation
|
590 |
-
*
|
591 |
-
* @param $user_id
|
592 |
-
*/
|
593 |
-
function user_register_via_admin( $user_id ) {
|
594 |
-
|
595 |
-
if ( empty( $user_id ) ) {
|
596 |
-
return;
|
597 |
-
}
|
598 |
-
|
599 |
-
if ( is_admin() ) {
|
600 |
-
//if there custom 2 role not empty
|
601 |
-
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
602 |
-
$user = get_userdata( $user_id );
|
603 |
-
$user->add_role( sanitize_key( $_POST['um-role'] ) );
|
604 |
-
UM()->user()->profile['role'] = sanitize_key( $_POST['um-role'] );
|
605 |
-
UM()->user()->update_usermeta_info( 'role' );
|
606 |
-
}
|
607 |
-
|
608 |
-
/**
|
609 |
-
* UM hook
|
610 |
-
*
|
611 |
-
* @type action
|
612 |
-
* @title um_user_register
|
613 |
-
* @description Action on user registration
|
614 |
-
* @input_vars
|
615 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
616 |
-
* {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
|
617 |
-
* @change_log
|
618 |
-
* ["Since: 2.0"]
|
619 |
-
* @usage add_action( 'um_user_register', 'function_name', 10, 2 );
|
620 |
-
* @example
|
621 |
-
* <?php
|
622 |
-
* add_action( 'um_user_register', 'my_user_register', 10, 2 );
|
623 |
-
* function my_user_register( $user_id, $submitted ) {
|
624 |
-
* // your code here
|
625 |
-
* }
|
626 |
-
* ?>
|
627 |
-
*/
|
628 |
-
do_action( 'um_user_register', $user_id, $_POST );
|
629 |
-
}
|
630 |
-
|
631 |
-
}
|
632 |
-
|
633 |
-
|
634 |
-
/**
|
635 |
-
* On wp_update_user function complete
|
636 |
-
*
|
637 |
-
* @param int $user_id
|
638 |
-
* @param \WP_User $old_data
|
639 |
-
*/
|
640 |
-
function profile_update( $user_id, $old_data ) {
|
641 |
-
// Bail if no user ID was passed
|
642 |
-
if ( empty( $user_id ) ) {
|
643 |
-
return;
|
644 |
-
}
|
645 |
-
|
646 |
-
$old_roles = $old_data->roles;
|
647 |
-
$userdata = get_userdata( $user_id );
|
648 |
-
$new_roles = $userdata->roles;
|
649 |
-
|
650 |
-
if ( is_admin() ) {
|
651 |
-
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
652 |
-
$new_roles = array_merge( $new_roles, array( sanitize_key( $_POST['um-role'] ) ) );
|
653 |
-
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
|
654 |
-
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
|
655 |
-
}
|
656 |
-
}
|
657 |
-
}
|
658 |
-
|
659 |
-
/**
|
660 |
-
* UM hook
|
661 |
-
*
|
662 |
-
* @type action
|
663 |
-
* @title um_after_member_role_upgrade
|
664 |
-
* @description Action on user registration
|
665 |
-
* @input_vars
|
666 |
-
* [{"var":"$new_roles","type":"array","desc":"User new roles"},
|
667 |
-
* {"var":"$old_roles","type":"array","desc":"Old roles"}]
|
668 |
-
* @change_log
|
669 |
-
* ["Since: 2.0"]
|
670 |
-
* @usage add_action( 'um_after_member_role_upgrade', 'function_name', 10, 2 );
|
671 |
-
* @example
|
672 |
-
* <?php
|
673 |
-
* add_action( 'um_after_member_role_upgrade', 'my_after_member_role_upgrade', 10, 2 );
|
674 |
-
* function my_after_member_role_upgrade( $new_roles, $old_roles ) {
|
675 |
-
* // your code here
|
676 |
-
* }
|
677 |
-
* ?>
|
678 |
-
*/
|
679 |
-
do_action( 'um_after_member_role_upgrade', $new_roles, $old_roles, $user_id );
|
680 |
-
|
681 |
-
//Update permalink
|
682 |
-
$this->generate_profile_slug( $user_id, true );
|
683 |
-
|
684 |
-
$this->remove_cache( $user_id );
|
685 |
-
}
|
686 |
-
|
687 |
-
|
688 |
-
/**
|
689 |
-
* Additional section for WP Profile page with UM data fields
|
690 |
-
*
|
691 |
-
* @param \WP_User $userdata User data
|
692 |
-
* @return void
|
693 |
-
*/
|
694 |
-
function profile_form_additional_section( $userdata ) {
|
695 |
-
|
696 |
-
/**
|
697 |
-
* UM hook
|
698 |
-
*
|
699 |
-
* @type filter
|
700 |
-
* @title um_user_profile_additional_fields
|
701 |
-
* @description Make additional content section
|
702 |
-
* @input_vars
|
703 |
-
* [{"var":"$content","type":"array","desc":"Additional section content"},
|
704 |
-
* {"var":"$userdata","type":"array","desc":"Userdata"}]
|
705 |
-
* @change_log
|
706 |
-
* ["Since: 2.0"]
|
707 |
-
* @usage
|
708 |
-
* <?php add_filter( 'um_user_profile_additional_fields', 'function_name', 10, 2 ); ?>
|
709 |
-
* @example
|
710 |
-
* <?php
|
711 |
-
* add_filter( 'um_user_profile_additional_fields', 'my_admin_pending_queue', 10, 2 );
|
712 |
-
* function my_admin_pending_queue( $content, $userdata ) {
|
713 |
-
* // your code here
|
714 |
-
* return $content;
|
715 |
-
* }
|
716 |
-
* ?>
|
717 |
-
*/
|
718 |
-
$section_content = apply_filters( 'um_user_profile_additional_fields', '', $userdata );
|
719 |
-
|
720 |
-
if ( ! empty( $section_content ) && ! ( is_multisite() && is_network_admin() ) ) {
|
721 |
-
|
722 |
-
if ( $userdata !== 'add-new-user' && $userdata !== 'add-existing-user' ) { ?>
|
723 |
-
<h3 id="um_user_screen_block"><?php esc_html_e( 'Ultimate Member', 'ultimate-member' ); ?></h3>
|
724 |
-
<?php }
|
725 |
-
|
726 |
-
echo $section_content;
|
727 |
-
}
|
728 |
-
}
|
729 |
-
|
730 |
-
|
731 |
-
/**
|
732 |
-
* Default interface for setting a ultimatemember role
|
733 |
-
*
|
734 |
-
* @param string $content Section HTML
|
735 |
-
* @param \WP_User $userdata User data
|
736 |
-
* @return string
|
737 |
-
*/
|
738 |
-
public function secondary_role_field( $content, $userdata ) {
|
739 |
-
$roles = array();
|
740 |
-
|
741 |
-
$role_keys = get_option( 'um_roles', array() );
|
742 |
-
if ( $role_keys ) {
|
743 |
-
foreach ( $role_keys as $role_key ) {
|
744 |
-
$role_meta = get_option( "um_role_{$role_key}_meta" );
|
745 |
-
|
746 |
-
if ( $role_meta ) {
|
747 |
-
$roles[ 'um_' . $role_key ] = $role_meta;
|
748 |
-
}
|
749 |
-
}
|
750 |
-
}
|
751 |
-
|
752 |
-
if ( empty( $roles ) ) {
|
753 |
-
return $content;
|
754 |
-
}
|
755 |
-
|
756 |
-
global $pagenow;
|
757 |
-
if ( 'profile.php' == $pagenow ) {
|
758 |
-
return $content;
|
759 |
-
}
|
760 |
-
|
761 |
-
$style = '';
|
762 |
-
$user_role = false;
|
763 |
-
if ( $userdata !== 'add-new-user' && $userdata !== 'add-existing-user' ) {
|
764 |
-
// Bail if current user cannot edit users
|
765 |
-
if ( ! current_user_can( 'edit_user', $userdata->ID ) ) {
|
766 |
-
return $content;
|
767 |
-
}
|
768 |
-
|
769 |
-
$user_role = UM()->roles()->get_um_user_role( $userdata->ID );
|
770 |
-
if ( $user_role && ! empty( $userdata->roles ) && count( $userdata->roles ) == 1 ) {
|
771 |
-
$style = 'style="display:none;"';
|
772 |
-
}
|
773 |
-
|
774 |
-
}
|
775 |
-
|
776 |
-
$class = ( $userdata == 'add-existing-user' ) ? 'um_role_existing_selector_wrapper' : 'um_role_selector_wrapper';
|
777 |
-
|
778 |
-
ob_start(); ?>
|
779 |
-
|
780 |
-
<div id="<?php echo esc_attr( $class ) ?>" <?php echo $style ?>>
|
781 |
-
<table class="form-table">
|
782 |
-
<tbody>
|
783 |
-
<tr>
|
784 |
-
<th><label for="um-role"><?php esc_html_e( 'Ultimate Member Role', 'ultimate-member' ); ?></label></th>
|
785 |
-
<td>
|
786 |
-
<select name="um-role" id="um-role">
|
787 |
-
<option value="" <?php selected( empty( $user_role ) ) ?>><?php esc_html_e( '— No role for Ultimate Member —', 'ultimate-member' ); ?></option>
|
788 |
-
<?php foreach ( $roles as $role_id => $details ) { ?>
|
789 |
-
<option <?php selected( $user_role, $role_id ); ?> value="<?php echo esc_attr( $role_id ); ?>"><?php echo esc_html( $details['name'] ); ?></option>
|
790 |
-
<?php } ?>
|
791 |
-
</select>
|
792 |
-
</td>
|
793 |
-
</tr>
|
794 |
-
</tbody>
|
795 |
-
</table>
|
796 |
-
</div>
|
797 |
-
|
798 |
-
<?php $content .= ob_get_clean();
|
799 |
-
|
800 |
-
return $content;
|
801 |
-
}
|
802 |
-
|
803 |
-
|
804 |
-
/**
|
805 |
-
* Remove cached queue from Users backend
|
806 |
-
*/
|
807 |
-
function remove_cached_queue() {
|
808 |
-
delete_option( 'um_cached_users_queue' );
|
809 |
-
}
|
810 |
-
|
811 |
-
|
812 |
-
/**
|
813 |
-
* Converts object to array
|
814 |
-
*
|
815 |
-
* @param $obj
|
816 |
-
*
|
817 |
-
* @return array
|
818 |
-
*/
|
819 |
-
function toArray( $obj ) {
|
820 |
-
if ( is_object( $obj ) ) {
|
821 |
-
$obj = (array) $obj;
|
822 |
-
}
|
823 |
-
if ( is_array( $obj ) ) {
|
824 |
-
$new = array();
|
825 |
-
foreach ( $obj as $key => $val ) {
|
826 |
-
$new[ $key ] = $this->toArray( $val );
|
827 |
-
}
|
828 |
-
} else {
|
829 |
-
$new = $obj;
|
830 |
-
}
|
831 |
-
|
832 |
-
return $new;
|
833 |
-
}
|
834 |
-
|
835 |
-
|
836 |
-
/**
|
837 |
-
* @param $user_id
|
838 |
-
*
|
839 |
-
* @return mixed|string
|
840 |
-
*/
|
841 |
-
function get_cached_data( $user_id ) {
|
842 |
-
|
843 |
-
$disallow_cache = UM()->options()->get( 'um_profile_object_cache_stop' );
|
844 |
-
if ( $disallow_cache ) {
|
845 |
-
return '';
|
846 |
-
}
|
847 |
-
|
848 |
-
if ( is_numeric( $user_id ) && $user_id > 0 ) {
|
849 |
-
$find_user = get_option( "um_cache_userdata_{$user_id}" );
|
850 |
-
if ( $find_user ) {
|
851 |
-
/**
|
852 |
-
* UM hook
|
853 |
-
*
|
854 |
-
* @type filter
|
855 |
-
* @title um_user_permissions_filter
|
856 |
-
* @description Change User Permissions
|
857 |
-
* @input_vars
|
858 |
-
* [{"var":"$permissions","type":"array","desc":"User Permissions"},
|
859 |
-
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
860 |
-
* @change_log
|
861 |
-
* ["Since: 2.0"]
|
862 |
-
* @usage
|
863 |
-
* <?php add_filter( 'um_user_permissions_filter', 'function_name', 10, 2 ); ?>
|
864 |
-
* @example
|
865 |
-
* <?php
|
866 |
-
* add_filter( 'um_user_permissions_filter', 'my_user_permissions', 10, 2 );
|
867 |
-
* function my_user_permissions( $permissions, $user_id ) {
|
868 |
-
* // your code here
|
869 |
-
* return $permissions;
|
870 |
-
* }
|
871 |
-
* ?>
|
872 |
-
*/
|
873 |
-
$find_user = apply_filters( 'um_user_permissions_filter', $find_user, $user_id );
|
874 |
-
return $find_user;
|
875 |
-
}
|
876 |
-
}
|
877 |
-
return '';
|
878 |
-
}
|
879 |
-
|
880 |
-
|
881 |
-
/**
|
882 |
-
* @param $user_id
|
883 |
-
* @param $profile
|
884 |
-
*/
|
885 |
-
function setup_cache( $user_id, $profile ) {
|
886 |
-
|
887 |
-
$disallow_cache = UM()->options()->get( 'um_profile_object_cache_stop' );
|
888 |
-
if ( $disallow_cache ) {
|
889 |
-
return;
|
890 |
-
}
|
891 |
-
|
892 |
-
update_option( "um_cache_userdata_{$user_id}", $profile, false );
|
893 |
-
}
|
894 |
-
|
895 |
-
|
896 |
-
/**
|
897 |
-
* @param $user_id
|
898 |
-
*/
|
899 |
-
function remove_cache( $user_id ) {
|
900 |
-
delete_option( "um_cache_userdata_{$user_id}" );
|
901 |
-
}
|
902 |
-
|
903 |
-
|
904 |
-
/**
|
905 |
-
* Remove cache for all users
|
906 |
-
*/
|
907 |
-
function remove_cache_all_users() {
|
908 |
-
global $wpdb;
|
909 |
-
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
|
910 |
-
}
|
911 |
-
|
912 |
-
|
913 |
-
/**
|
914 |
-
* This method lets you set a user. For example, to retrieve a profile or anything related to that user.
|
915 |
-
*
|
916 |
-
* @usage <?php UM()->user()->set( $user_id, $clean = false ); ?>
|
917 |
-
*
|
918 |
-
* @param null|int $user_id Which user to retrieve. A numeric user ID
|
919 |
-
* @param bool $clean Should be true or false. Basically, if you did not provide a user ID It will set the current logged in user as a profile
|
920 |
-
*
|
921 |
-
* @example The following example makes you set a user and retrieve their display name after that using the user API.
|
922 |
-
|
923 |
-
<?php
|
924 |
-
|
925 |
-
UM()->user()->set( 12 );
|
926 |
-
$display_name = UM()->user()->profile['display_name']; // Should print user display name
|
927 |
-
|
928 |
-
?>
|
929 |
-
*
|
930 |
-
*/
|
931 |
-
function set( $user_id = null, $clean = false ) {
|
932 |
-
if ( isset( $this->profile ) ) {
|
933 |
-
unset( $this->profile );
|
934 |
-
}
|
935 |
-
|
936 |
-
if ( $user_id ) {
|
937 |
-
$this->id = $user_id;
|
938 |
-
} elseif ( is_user_logged_in() && $clean == false ) {
|
939 |
-
$this->id = get_current_user_id();
|
940 |
-
} else {
|
941 |
-
$this->id = 0;
|
942 |
-
}
|
943 |
-
|
944 |
-
if ( $this->get_cached_data( $this->id ) ) {
|
945 |
-
$this->profile = $this->get_cached_data( $this->id );
|
946 |
-
} else {
|
947 |
-
|
948 |
-
if ( $user_id ) {
|
949 |
-
|
950 |
-
$this->id = $user_id;
|
951 |
-
$this->usermeta = get_user_meta( $user_id );
|
952 |
-
$this->data = get_userdata( $this->id );
|
953 |
-
|
954 |
-
} elseif ( is_user_logged_in() && $clean == false ) {
|
955 |
-
|
956 |
-
$this->id = get_current_user_id();
|
957 |
-
$this->usermeta = get_user_meta($this->id);
|
958 |
-
$this->data = get_userdata($this->id);
|
959 |
-
|
960 |
-
} else {
|
961 |
-
|
962 |
-
$this->id = 0;
|
963 |
-
$this->usermeta = null;
|
964 |
-
$this->data = null;
|
965 |
-
|
966 |
-
}
|
967 |
-
|
968 |
-
// we have a user, populate a profile
|
969 |
-
if ( $this->id && $this->toArray( $this->data ) ) {
|
970 |
-
|
971 |
-
// add user data
|
972 |
-
$this->data = $this->toArray( $this->data );
|
973 |
-
|
974 |
-
foreach ( $this->data as $k=>$v ) {
|
975 |
-
if ( $k == 'roles') {
|
976 |
-
$this->profile['wp_roles'] = implode(',',$v);
|
977 |
-
} else if ( is_array( $v ) ) {
|
978 |
-
foreach($v as $k2 => $v2){
|
979 |
-
$this->profile[$k2] = $v2;
|
980 |
-
}
|
981 |
-
} else {
|
982 |
-
$this->profile[$k] = $v;
|
983 |
-
}
|
984 |
-
}
|
985 |
-
|
986 |
-
// add account status
|
987 |
-
if ( !isset( $this->usermeta['account_status'][0] ) ) {
|
988 |
-
$this->usermeta['account_status'][0] = 'approved';
|
989 |
-
}
|
990 |
-
|
991 |
-
if ( $this->usermeta['account_status'][0] == 'approved' ) {
|
992 |
-
$this->usermeta['account_status_name'][0] = __('Approved','ultimate-member');
|
993 |
-
}
|
994 |
-
|
995 |
-
if ( $this->usermeta['account_status'][0] == 'awaiting_email_confirmation' ) {
|
996 |
-
$this->usermeta['account_status_name'][0] = __('Awaiting E-mail Confirmation','ultimate-member');
|
997 |
-
}
|
998 |
-
|
999 |
-
if ( $this->usermeta['account_status'][0] == 'awaiting_admin_review' ) {
|
1000 |
-
$this->usermeta['account_status_name'][0] = __('Pending Review','ultimate-member');
|
1001 |
-
}
|
1002 |
-
|
1003 |
-
if ( $this->usermeta['account_status'][0] == 'rejected' ) {
|
1004 |
-
$this->usermeta['account_status_name'][0] = __('Membership Rejected','ultimate-member');
|
1005 |
-
}
|
1006 |
-
|
1007 |
-
if ( $this->usermeta['account_status'][0] == 'inactive' ) {
|
1008 |
-
$this->usermeta['account_status_name'][0] = __('Membership Inactive','ultimate-member');
|
1009 |
-
}
|
1010 |
-
|
1011 |
-
// add user meta
|
1012 |
-
foreach ( $this->usermeta as $k => $v ) {
|
1013 |
-
if ( $k == 'display_name') {
|
1014 |
-
continue;
|
1015 |
-
}
|
1016 |
-
$this->profile[ $k ] = $v[0];
|
1017 |
-
}
|
1018 |
-
|
1019 |
-
// add permissions
|
1020 |
-
$user_role = UM()->roles()->get_priority_user_role( $this->id );
|
1021 |
-
$this->profile['role'] = $user_role;
|
1022 |
-
$this->profile['roles'] = UM()->roles()->get_all_user_roles( $this->id );
|
1023 |
-
|
1024 |
-
$role_meta = UM()->roles()->role_data( $user_role );
|
1025 |
-
/**
|
1026 |
-
* UM hook
|
1027 |
-
*
|
1028 |
-
* @type filter
|
1029 |
-
* @title um_user_permissions_filter
|
1030 |
-
* @description Change User Permissions
|
1031 |
-
* @input_vars
|
1032 |
-
* [{"var":"$permissions","type":"array","desc":"User Permissions"},
|
1033 |
-
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
1034 |
-
* @change_log
|
1035 |
-
* ["Since: 2.0"]
|
1036 |
-
* @usage
|
1037 |
-
* <?php add_filter( 'um_user_permissions_filter', 'function_name', 10, 2 ); ?>
|
1038 |
-
* @example
|
1039 |
-
* <?php
|
1040 |
-
* add_filter( 'um_user_permissions_filter', 'my_user_permissions', 10, 2 );
|
1041 |
-
* function my_user_permissions( $permissions, $user_id ) {
|
1042 |
-
* // your code here
|
1043 |
-
* return $permissions;
|
1044 |
-
* }
|
1045 |
-
* ?>
|
1046 |
-
*/
|
1047 |
-
$role_meta = apply_filters( 'um_user_permissions_filter', $role_meta, $this->id );
|
1048 |
-
|
1049 |
-
/*$role_meta = array_map( function( $key, $item ) {
|
1050 |
-
if ( strpos( $key, '_um_' ) === 0 )
|
1051 |
-
$key = str_replace( '_um_', '', $key );
|
1052 |
-
|
1053 |
-
return array( $key => $item );
|
1054 |
-
}, array_keys( $role_meta ), $role_meta );*/
|
1055 |
-
|
1056 |
-
$this->profile = array_merge( $this->profile, (array)$role_meta );
|
1057 |
-
|
1058 |
-
$this->profile['super_admin'] = ( is_super_admin( $this->id ) ) ? 1 : 0;
|
1059 |
-
|
1060 |
-
// clean profile
|
1061 |
-
$this->clean();
|
1062 |
-
|
1063 |
-
// Setup cache
|
1064 |
-
$this->setup_cache( $this->id, $this->profile );
|
1065 |
-
|
1066 |
-
}
|
1067 |
-
|
1068 |
-
}
|
1069 |
-
|
1070 |
-
}
|
1071 |
-
|
1072 |
-
|
1073 |
-
/**
|
1074 |
-
* Reset user data
|
1075 |
-
*
|
1076 |
-
* @param bool $clean
|
1077 |
-
*/
|
1078 |
-
function reset( $clean = false ){
|
1079 |
-
$this->set(0, $clean);
|
1080 |
-
}
|
1081 |
-
|
1082 |
-
|
1083 |
-
/**
|
1084 |
-
* Clean user profile
|
1085 |
-
*/
|
1086 |
-
function clean() {
|
1087 |
-
foreach ( $this->profile as $key => $value ) {
|
1088 |
-
foreach ( $this->banned_keys as $ban ) {
|
1089 |
-
if ( strstr( $key, $ban ) || is_numeric( $key ) ) {
|
1090 |
-
unset( $this->profile[ $key ] );
|
1091 |
-
}
|
1092 |
-
}
|
1093 |
-
}
|
1094 |
-
}
|
1095 |
-
|
1096 |
-
|
1097 |
-
/**
|
1098 |
-
* This method lets you auto sign-in a user to your site.
|
1099 |
-
*
|
1100 |
-
* @usage <?php UM()->user()->auto_login( $user_id, $rememberme = false ); ?>
|
1101 |
-
*
|
1102 |
-
* @param int $user_id Which user ID to sign in automatically
|
1103 |
-
* @param int|bool $rememberme Should be true or false. If you want the user sign in session to use cookies, use true
|
1104 |
-
*
|
1105 |
-
* @example The following example lets you sign in a user automatically by their ID.
|
1106 |
-
|
1107 |
-
<?php UM()->user()->auto_login( 2 ); ?>
|
1108 |
-
*
|
1109 |
-
*
|
1110 |
-
* @example The following example lets you sign in a user automatically by their ID and makes the plugin remember their session.
|
1111 |
-
|
1112 |
-
<?php UM()->user()->auto_login( 10, true ); ?>
|
1113 |
-
*
|
1114 |
-
*/
|
1115 |
-
function auto_login( $user_id, $rememberme = 0 ) {
|
1116 |
-
|
1117 |
-
wp_set_current_user( $user_id );
|
1118 |
-
|
1119 |
-
wp_set_auth_cookie( $user_id, $rememberme );
|
1120 |
-
|
1121 |
-
$user = get_user_by( 'ID', $user_id );
|
1122 |
-
|
1123 |
-
do_action( 'wp_login', $user->user_login, $user );
|
1124 |
-
|
1125 |
-
}
|
1126 |
-
|
1127 |
-
|
1128 |
-
/**
|
1129 |
-
* Set user's registration details
|
1130 |
-
*
|
1131 |
-
* @param array $submitted
|
1132 |
-
* @param array $args
|
1133 |
-
*/
|
1134 |
-
function set_registration_details( $submitted, $args ) {
|
1135 |
-
|
1136 |
-
if ( isset( $submitted['user_pass'] ) ) {
|
1137 |
-
unset( $submitted['user_pass'] );
|
1138 |
-
}
|
1139 |
-
|
1140 |
-
if ( isset( $submitted['user_password'] ) ) {
|
1141 |
-
unset( $submitted['user_password'] );
|
1142 |
-
}
|
1143 |
-
|
1144 |
-
if ( isset( $submitted['confirm_user_password'] ) ) {
|
1145 |
-
unset( $submitted['confirm_user_password'] );
|
1146 |
-
}
|
1147 |
-
|
1148 |
-
//remove all password field values from submitted details
|
1149 |
-
$password_fields = array();
|
1150 |
-
foreach ( $submitted as $k => $v ) {
|
1151 |
-
if ( UM()->fields()->get_field_type( $k ) == 'password' ) {
|
1152 |
-
$password_fields[] = $k;
|
1153 |
-
$password_fields[] = 'confirm_' . $k;
|
1154 |
-
}
|
1155 |
-
}
|
1156 |
-
|
1157 |
-
foreach ( $password_fields as $pw_field ) {
|
1158 |
-
unset( $submitted[ $pw_field ] );
|
1159 |
-
}
|
1160 |
-
|
1161 |
-
|
1162 |
-
/**
|
1163 |
-
* UM hook
|
1164 |
-
*
|
1165 |
-
* @type filter
|
1166 |
-
* @title um_before_save_filter_submitted
|
1167 |
-
* @description Change submitted data before save usermeta "submitted" on registration process
|
1168 |
-
* @input_vars
|
1169 |
-
* [{"var":"$submitted","type":"array","desc":"Submitted data"},
|
1170 |
-
* {"var":"$args","type":"array","desc":"Form Args"}]
|
1171 |
-
* @change_log
|
1172 |
-
* ["Since: 2.0"]
|
1173 |
-
* @usage
|
1174 |
-
* <?php add_filter( 'um_before_save_filter_submitted', 'function_name', 10, 2 ); ?>
|
1175 |
-
* @example
|
1176 |
-
* <?php
|
1177 |
-
* add_filter( 'um_before_save_filter_submitted', 'my_before_save_filter_submitted', 10, 2 );
|
1178 |
-
* function my_before_save_filter_submitted( $submitted, $args ) {
|
1179 |
-
* // your code here
|
1180 |
-
* return $submitted;
|
1181 |
-
* }
|
1182 |
-
* ?>
|
1183 |
-
*/
|
1184 |
-
$submitted = apply_filters( 'um_before_save_filter_submitted', $submitted, $args );
|
1185 |
-
|
1186 |
-
/**
|
1187 |
-
* UM hook
|
1188 |
-
*
|
1189 |
-
* @type action
|
1190 |
-
* @title um_before_save_registration_details
|
1191 |
-
* @description Action on user registration before save details
|
1192 |
-
* @input_vars
|
1193 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
1194 |
-
* {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
|
1195 |
-
* @change_log
|
1196 |
-
* ["Since: 2.0"]
|
1197 |
-
* @usage add_action( 'um_before_save_registration_details', 'function_name', 10, 2 );
|
1198 |
-
* @example
|
1199 |
-
* <?php
|
1200 |
-
* add_action( 'um_before_save_registration_details', 'my_before_save_registration_details', 10, 2 );
|
1201 |
-
* function my_before_save_registration_details( $user_id, $submitted ) {
|
1202 |
-
* // your code here
|
1203 |
-
* }
|
1204 |
-
* ?>
|
1205 |
-
*/
|
1206 |
-
do_action( 'um_before_save_registration_details', $this->id, $submitted );
|
1207 |
-
|
1208 |
-
update_user_meta( $this->id, 'submitted', $submitted );
|
1209 |
-
|
1210 |
-
$this->update_profile( $submitted );
|
1211 |
-
/**
|
1212 |
-
* UM hook
|
1213 |
-
*
|
1214 |
-
* @type action
|
1215 |
-
* @title um_after_save_registration_details
|
1216 |
-
* @description Action on user registration after save details
|
1217 |
-
* @input_vars
|
1218 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
1219 |
-
* {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
|
1220 |
-
* @change_log
|
1221 |
-
* ["Since: 2.0"]
|
1222 |
-
* @usage add_action( 'um_after_save_registration_details', 'function_name', 10, 2 );
|
1223 |
-
* @example
|
1224 |
-
* <?php
|
1225 |
-
* add_action( 'um_after_save_registration_details', 'my_after_save_registration_details', 10, 2 );
|
1226 |
-
* function my_after_save_registration_details( $user_id, $submitted ) {
|
1227 |
-
* // your code here
|
1228 |
-
* }
|
1229 |
-
* ?>
|
1230 |
-
*/
|
1231 |
-
do_action( 'um_after_save_registration_details', $this->id, $submitted );
|
1232 |
-
|
1233 |
-
}
|
1234 |
-
|
1235 |
-
|
1236 |
-
/**
|
1237 |
-
* Set last login for new registered users
|
1238 |
-
*/
|
1239 |
-
function set_last_login() {
|
1240 |
-
update_user_meta( $this->id, '_um_last_login', current_time( 'timestamp' ) );
|
1241 |
-
}
|
1242 |
-
|
1243 |
-
|
1244 |
-
/**
|
1245 |
-
* Set user's account status
|
1246 |
-
*
|
1247 |
-
* @param $status
|
1248 |
-
*/
|
1249 |
-
function set_status( $status ) {
|
1250 |
-
|
1251 |
-
/**
|
1252 |
-
* UM hook
|
1253 |
-
*
|
1254 |
-
* @type action
|
1255 |
-
* @title um_when_status_is_set
|
1256 |
-
* @description Action on user status changed
|
1257 |
-
* @input_vars
|
1258 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
1259 |
-
* @change_log
|
1260 |
-
* ["Since: 2.0"]
|
1261 |
-
* @usage add_action( 'um_when_status_is_set', 'function_name', 10, 1 );
|
1262 |
-
* @example
|
1263 |
-
* <?php
|
1264 |
-
* add_action( 'um_when_status_is_set', 'my_when_status_is_set', 10, 1 );
|
1265 |
-
* function my_when_status_is_set( $user_id ) {
|
1266 |
-
* // your code here
|
1267 |
-
* }
|
1268 |
-
* ?>
|
1269 |
-
*/
|
1270 |
-
do_action( 'um_when_status_is_set', um_user( 'ID' ) );
|
1271 |
-
|
1272 |
-
$this->profile['account_status'] = $status;
|
1273 |
-
|
1274 |
-
$this->update_usermeta_info( 'account_status' );
|
1275 |
-
|
1276 |
-
/**
|
1277 |
-
* UM hook
|
1278 |
-
*
|
1279 |
-
* @type action
|
1280 |
-
* @title um_after_user_status_is_changed_hook
|
1281 |
-
* @description Action after user status changed
|
1282 |
-
* @input_vars
|
1283 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
1284 |
-
* @change_log
|
1285 |
-
* ["Since: 2.0"]
|
1286 |
-
* @usage add_action( 'um_after_user_status_is_changed_hook', 'function_name', 10 );
|
1287 |
-
* @example
|
1288 |
-
* <?php
|
1289 |
-
* add_action( 'um_after_user_status_is_changed_hook', 'my_after_user_status_is_changed', 10 );
|
1290 |
-
* function my_after_user_status_is_changed() {
|
1291 |
-
* // your code here
|
1292 |
-
* }
|
1293 |
-
* ?>
|
1294 |
-
*/
|
1295 |
-
do_action( 'um_after_user_status_is_changed_hook', um_user( 'ID' ) );
|
1296 |
-
|
1297 |
-
/**
|
1298 |
-
* UM hook
|
1299 |
-
*
|
1300 |
-
* @type action
|
1301 |
-
* @title um_after_user_status_is_changed
|
1302 |
-
* @description Action after user status changed
|
1303 |
-
* @input_vars
|
1304 |
-
* [{"var":"$status","type":"string","desc":"User Status"},
|
1305 |
-
* {"var":"$user_id","type":"integer","desc":"User ID"}]
|
1306 |
-
* @change_log
|
1307 |
-
* ["Since: 2.0"]
|
1308 |
-
* @usage add_action( 'um_after_user_status_is_changed', 'function_name', 10, 1 );
|
1309 |
-
* @example
|
1310 |
-
* <?php
|
1311 |
-
* add_action( 'um_after_user_status_is_changed', 'my_after_user_status_is_changed', 10, 1 );
|
1312 |
-
* function my_after_user_status_is_changed( $status ) {
|
1313 |
-
* // your code here
|
1314 |
-
* }
|
1315 |
-
* ?>
|
1316 |
-
*/
|
1317 |
-
do_action( 'um_after_user_status_is_changed', $status, um_user( 'ID' ) );
|
1318 |
-
|
1319 |
-
}
|
1320 |
-
|
1321 |
-
|
1322 |
-
/**
|
1323 |
-
* Set user's hash
|
1324 |
-
*/
|
1325 |
-
function assign_secretkey() {
|
1326 |
-
/**
|
1327 |
-
* UM hook
|
1328 |
-
*
|
1329 |
-
* @type action
|
1330 |
-
* @title um_before_user_hash_is_changed
|
1331 |
-
* @description Action before user hash is changed
|
1332 |
-
* @change_log
|
1333 |
-
* ["Since: 2.0"]
|
1334 |
-
* @usage add_action( 'um_before_user_hash_is_changed', 'function_name', 10 );
|
1335 |
-
* @example
|
1336 |
-
* <?php
|
1337 |
-
* add_action( 'um_before_user_hash_is_changed', 'my_before_user_hash_is_changed', 10 );
|
1338 |
-
* function my_before_user_hash_is_changed() {
|
1339 |
-
* // your code here
|
1340 |
-
* }
|
1341 |
-
* ?>
|
1342 |
-
*/
|
1343 |
-
do_action( 'um_before_user_hash_is_changed' );
|
1344 |
-
|
1345 |
-
$this->profile['account_secret_hash'] = UM()->validation()->generate();
|
1346 |
-
$this->update_usermeta_info( 'account_secret_hash' );
|
1347 |
-
|
1348 |
-
$expiry_time = UM()->options()->get( 'activation_link_expiry_time' );
|
1349 |
-
if ( ! empty( $expiry_time ) && is_numeric( $expiry_time ) ) {
|
1350 |
-
$this->profile['account_secret_hash_expiry'] = time() + $expiry_time;
|
1351 |
-
$this->update_usermeta_info( 'account_secret_hash_expiry' );
|
1352 |
-
}
|
1353 |
-
|
1354 |
-
/**
|
1355 |
-
* UM hook
|
1356 |
-
*
|
1357 |
-
* @type action
|
1358 |
-
* @title um_after_user_hash_is_changed
|
1359 |
-
* @description Action after user hash is changed
|
1360 |
-
* @change_log
|
1361 |
-
* ["Since: 2.0"]
|
1362 |
-
* @usage add_action( 'um_after_user_hash_is_changed', 'function_name', 10 );
|
1363 |
-
* @example
|
1364 |
-
* <?php
|
1365 |
-
* add_action( 'um_after_user_hash_is_changed', 'my_after_user_hash_is_changed', 10 );
|
1366 |
-
* function my_after_user_hash_is_changed() {
|
1367 |
-
* // your code here
|
1368 |
-
* }
|
1369 |
-
* ?>
|
1370 |
-
*/
|
1371 |
-
do_action( 'um_after_user_hash_is_changed' );
|
1372 |
-
}
|
1373 |
-
|
1374 |
-
|
1375 |
-
/**
|
1376 |
-
* @param \WP_User $userdata
|
1377 |
-
*
|
1378 |
-
* @return string|\WP_Error
|
1379 |
-
*/
|
1380 |
-
function maybe_generate_password_reset_key( $userdata ) {
|
1381 |
-
if ( empty( $this->password_reset_key ) ) {
|
1382 |
-
$this->password_reset_key = get_password_reset_key( $userdata );
|
1383 |
-
}
|
1384 |
-
|
1385 |
-
return $this->password_reset_key ;
|
1386 |
-
}
|
1387 |
-
|
1388 |
-
|
1389 |
-
/**
|
1390 |
-
* Password reset email
|
1391 |
-
*/
|
1392 |
-
function password_reset() {
|
1393 |
-
$userdata = get_userdata( um_user( 'ID' ) );
|
1394 |
-
|
1395 |
-
$this->maybe_generate_password_reset_key( $userdata );
|
1396 |
-
|
1397 |
-
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
|
1398 |
-
add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ), 10, 1 );
|
1399 |
-
|
1400 |
-
UM()->mail()->send( um_user( 'user_email' ), 'resetpw_email' );
|
1401 |
-
}
|
1402 |
-
|
1403 |
-
|
1404 |
-
/**
|
1405 |
-
* Password changed email
|
1406 |
-
*/
|
1407 |
-
function password_changed() {
|
1408 |
-
UM()->mail()->send( um_user( 'user_email' ), 'changedpw_email' );
|
1409 |
-
}
|
1410 |
-
|
1411 |
-
|
1412 |
-
/**
|
1413 |
-
* This method approves a user membership and sends them an optional welcome/approval e-mail.
|
1414 |
-
*
|
1415 |
-
* @usage <?php UM()->user()->approve(); ?>
|
1416 |
-
*
|
1417 |
-
* @example Approve a pending user and allow him to sign-in to your site.
|
1418 |
-
|
1419 |
-
<?php
|
1420 |
-
|
1421 |
-
um_fetch_user( 352 );
|
1422 |
-
UM()->user()->approve();
|
1423 |
-
|
1424 |
-
?>
|
1425 |
-
*
|
1426 |
-
*/
|
1427 |
-
function approve( $repeat = true ) {
|
1428 |
-
$user_id = um_user('ID');
|
1429 |
-
|
1430 |
-
if ( ! $repeat ) {
|
1431 |
-
$status = get_user_meta( $user_id, 'account_status', true );
|
1432 |
-
if ( 'approved' === $status ) {
|
1433 |
-
return;
|
1434 |
-
}
|
1435 |
-
}
|
1436 |
-
|
1437 |
-
delete_option( "um_cache_userdata_{$user_id}" );
|
1438 |
-
|
1439 |
-
if ( um_user( 'account_status' ) == 'awaiting_admin_review' ) {
|
1440 |
-
$userdata = get_userdata( $user_id );
|
1441 |
-
|
1442 |
-
$this->maybe_generate_password_reset_key( $userdata );
|
1443 |
-
|
1444 |
-
UM()->mail()->send( um_user( 'user_email' ), 'approved_email' );
|
1445 |
-
|
1446 |
-
} else {
|
1447 |
-
//$userdata = get_userdata( $user_id );
|
1448 |
-
//get_password_reset_key( $userdata );
|
1449 |
-
UM()->mail()->send( um_user( 'user_email' ), 'welcome_email' );
|
1450 |
-
}
|
1451 |
-
|
1452 |
-
$this->set_status( 'approved' );
|
1453 |
-
$this->delete_meta( 'account_secret_hash' );
|
1454 |
-
$this->delete_meta( 'account_secret_hash_expiry' );
|
1455 |
-
|
1456 |
-
/**
|
1457 |
-
* UM hook
|
1458 |
-
*
|
1459 |
-
* @type action
|
1460 |
-
* @title um_after_user_is_approved
|
1461 |
-
* @description Action after user was approved
|
1462 |
-
* @input_vars
|
1463 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
1464 |
-
* @change_log
|
1465 |
-
* ["Since: 2.0"]
|
1466 |
-
* @usage add_action( 'um_after_user_is_approved', 'function_name', 10, 1 );
|
1467 |
-
* @example
|
1468 |
-
* <?php
|
1469 |
-
* add_action( 'um_after_user_is_approved', 'my_after_user_is_approved', 10, 1 );
|
1470 |
-
* function my_after_user_hash_is_changed( $user_id ) {
|
1471 |
-
* // your code here
|
1472 |
-
* }
|
1473 |
-
* ?>
|
1474 |
-
*/
|
1475 |
-
do_action( 'um_after_user_is_approved', um_user( 'ID' ) );
|
1476 |
-
}
|
1477 |
-
|
1478 |
-
|
1479 |
-
/**
|
1480 |
-
* Pending email
|
1481 |
-
*/
|
1482 |
-
function email_pending() {
|
1483 |
-
$this->assign_secretkey();
|
1484 |
-
$this->set_status( 'awaiting_email_confirmation' );
|
1485 |
-
UM()->mail()->send( um_user( 'user_email' ), 'checkmail_email' );
|
1486 |
-
}
|
1487 |
-
|
1488 |
-
|
1489 |
-
/**
|
1490 |
-
* This method puts a user under manual review by administrator and sends them an optional e-mail.
|
1491 |
-
*
|
1492 |
-
* @usage <?php UM()->user()->pending(); ?>
|
1493 |
-
*
|
1494 |
-
* @example An example of putting a user pending manual review
|
1495 |
-
|
1496 |
-
<?php
|
1497 |
-
|
1498 |
-
um_fetch_user( 54 );
|
1499 |
-
UM()->user()->pending();
|
1500 |
-
|
1501 |
-
?>
|
1502 |
-
*
|
1503 |
-
*/
|
1504 |
-
function pending() {
|
1505 |
-
$this->set_status( 'awaiting_admin_review' );
|
1506 |
-
UM()->mail()->send( um_user( 'user_email' ), 'pending_email' );
|
1507 |
-
}
|
1508 |
-
|
1509 |
-
|
1510 |
-
/**
|
1511 |
-
* This method rejects a user membership and sends them an optional e-mail.
|
1512 |
-
*
|
1513 |
-
* @usage <?php UM()->user()->reject(); ?>
|
1514 |
-
*
|
1515 |
-
* @example Reject a user membership example
|
1516 |
-
|
1517 |
-
<?php
|
1518 |
-
|
1519 |
-
um_fetch_user( 114 );
|
1520 |
-
UM()->user()->reject();
|
1521 |
-
|
1522 |
-
?>
|
1523 |
-
|
1524 |
-
*
|
1525 |
-
*/
|
1526 |
-
function reject() {
|
1527 |
-
$this->set_status( 'rejected' );
|
1528 |
-
UM()->mail()->send( um_user( 'user_email' ), 'rejected_email' );
|
1529 |
-
}
|
1530 |
-
|
1531 |
-
|
1532 |
-
/**
|
1533 |
-
* This method deactivates a user membership and sends them an optional e-mail.
|
1534 |
-
*
|
1535 |
-
* @usage <?php UM()->user()->deactivate(); ?>
|
1536 |
-
*
|
1537 |
-
* @example Deactivate a user membership with the following example
|
1538 |
-
|
1539 |
-
<?php
|
1540 |
-
|
1541 |
-
um_fetch_user( 32 );
|
1542 |
-
$ultimatemember->user->deactivate();
|
1543 |
-
|
1544 |
-
?>
|
1545 |
-
*
|
1546 |
-
*/
|
1547 |
-
function deactivate() {
|
1548 |
-
$this->set_status( 'inactive' );
|
1549 |
-
/**
|
1550 |
-
* UM hook
|
1551 |
-
*
|
1552 |
-
* @type action
|
1553 |
-
* @title um_after_user_is_inactive
|
1554 |
-
* @description Action after user was inactive
|
1555 |
-
* @input_vars
|
1556 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
1557 |
-
* @change_log
|
1558 |
-
* ["Since: 2.0"]
|
1559 |
-
* @usage add_action( 'um_after_user_is_inactive', 'function_name', 10, 1 );
|
1560 |
-
* @example
|
1561 |
-
* <?php
|
1562 |
-
* add_action( 'um_after_user_is_inactive', 'my_after_user_is_inactive', 10, 1 );
|
1563 |
-
* function my_after_user_is_inactive( $user_id ) {
|
1564 |
-
* // your code here
|
1565 |
-
* }
|
1566 |
-
* ?>
|
1567 |
-
*/
|
1568 |
-
do_action( 'um_after_user_is_inactive', um_user( 'ID' ) );
|
1569 |
-
|
1570 |
-
UM()->mail()->send( um_user( 'user_email' ), 'inactive_email' );
|
1571 |
-
}
|
1572 |
-
|
1573 |
-
|
1574 |
-
/**
|
1575 |
-
* Delete user
|
1576 |
-
*
|
1577 |
-
* @param bool $send_mail
|
1578 |
-
*/
|
1579 |
-
function delete( $send_mail = true ) {
|
1580 |
-
|
1581 |
-
$this->send_mail_on_delete = $send_mail;
|
1582 |
-
//don't send email notification to not approved user
|
1583 |
-
if ( 'approved' != um_user( 'account_status' ) ) {
|
1584 |
-
$this->send_mail_on_delete = false;
|
1585 |
-
}
|
1586 |
-
|
1587 |
-
// remove user
|
1588 |
-
if ( is_multisite() ) {
|
1589 |
-
|
1590 |
-
if ( ! function_exists( 'wpmu_delete_user' ) ) {
|
1591 |
-
require_once( ABSPATH . 'wp-admin/includes/ms.php' );
|
1592 |
-
}
|
1593 |
-
|
1594 |
-
wpmu_delete_user( $this->id );
|
1595 |
-
|
1596 |
-
} else {
|
1597 |
-
|
1598 |
-
if ( ! function_exists( 'wp_delete_user' ) ) {
|
1599 |
-
require_once( ABSPATH . 'wp-admin/includes/user.php' );
|
1600 |
-
}
|
1601 |
-
|
1602 |
-
wp_delete_user( $this->id );
|
1603 |
-
|
1604 |
-
}
|
1605 |
-
|
1606 |
-
}
|
1607 |
-
|
1608 |
-
|
1609 |
-
/**
|
1610 |
-
* This method gets a user role in slug format. e.g. member
|
1611 |
-
*
|
1612 |
-
* @usage <?php UM()->user()->get_role(); ?>
|
1613 |
-
*
|
1614 |
-
* @return string
|
1615 |
-
*
|
1616 |
-
* @example Do something if the user's role is paid-member
|
1617 |
-
|
1618 |
-
<?php
|
1619 |
-
|
1620 |
-
um_fetch_user( 12 );
|
1621 |
-
|
1622 |
-
if ( UM()->user()->get_role() == 'paid-member' ) {
|
1623 |
-
// Show this to paid customers
|
1624 |
-
} else {
|
1625 |
-
// You are a free member
|
1626 |
-
}
|
1627 |
-
|
1628 |
-
?>
|
1629 |
-
*
|
1630 |
-
*/
|
1631 |
-
function get_role() {
|
1632 |
-
if ( ! empty( $this->profile['role'] ) ) {
|
1633 |
-
return $this->profile['role'];
|
1634 |
-
} else {
|
1635 |
-
if ( ! empty( $this->profile['wp_roles'] ) && $this->profile['wp_roles'] == 'administrator' ) {
|
1636 |
-
return 'admin';
|
1637 |
-
} else {
|
1638 |
-
return 'member';
|
1639 |
-
}
|
1640 |
-
}
|
1641 |
-
}
|
1642 |
-
|
1643 |
-
|
1644 |
-
/**
|
1645 |
-
* Update one key in user meta
|
1646 |
-
*
|
1647 |
-
* @param $key
|
1648 |
-
*/
|
1649 |
-
function update_usermeta_info( $key ) {
|
1650 |
-
// delete the key first just in case
|
1651 |
-
delete_user_meta( $this->id, $key );
|
1652 |
-
update_user_meta( $this->id, $key, $this->profile[ $key ] );
|
1653 |
-
}
|
1654 |
-
|
1655 |
-
|
1656 |
-
/**
|
1657 |
-
* This method can be used to delete user's meta key.
|
1658 |
-
*
|
1659 |
-
* @usage <?php UM()->user()->delete_meta( $key ); ?>
|
1660 |
-
*
|
1661 |
-
* @param string $key The meta field key to remove from user
|
1662 |
-
*
|
1663 |
-
* @example Delete user's age field
|
1664 |
-
|
1665 |
-
<?php
|
1666 |
-
|
1667 |
-
um_fetch_user( 15 );
|
1668 |
-
UM()->user()->delete_meta( 'age' );
|
1669 |
-
|
1670 |
-
?>
|
1671 |
-
|
1672 |
-
*
|
1673 |
-
*/
|
1674 |
-
function delete_meta( $key ) {
|
1675 |
-
delete_user_meta( $this->id, $key );
|
1676 |
-
}
|
1677 |
-
|
1678 |
-
|
1679 |
-
/**
|
1680 |
-
* Get admin actions for individual user
|
1681 |
-
*
|
1682 |
-
* @return array|bool
|
1683 |
-
*/
|
1684 |
-
function get_admin_actions() {
|
1685 |
-
$items = array();
|
1686 |
-
|
1687 |
-
/**
|
1688 |
-
* UM hook
|
1689 |
-
*
|
1690 |
-
* @type filter
|
1691 |
-
* @title um_admin_user_actions_hook
|
1692 |
-
* @description Extend admin actions for each user
|
1693 |
-
* @input_vars
|
1694 |
-
* [{"var":"$actions","type":"array","desc":"Actions for user"}]
|
1695 |
-
* @change_log
|
1696 |
-
* ["Since: 2.0"]
|
1697 |
-
* @usage
|
1698 |
-
* <?php add_filter( 'um_admin_user_actions_hook', 'function_name', 10, 1 ); ?>
|
1699 |
-
* @example
|
1700 |
-
* <?php
|
1701 |
-
* add_filter( 'um_admin_user_actions_hook', 'my_admin_user_actions', 10, 1 );
|
1702 |
-
* function my_admin_user_actions( $actions ) {
|
1703 |
-
* // your code here
|
1704 |
-
* return $actions;
|
1705 |
-
* }
|
1706 |
-
* ?>
|
1707 |
-
*/
|
1708 |
-
$actions = apply_filters( 'um_admin_user_actions_hook', array(), um_profile_id() );
|
1709 |
-
if ( empty( $actions ) ) {
|
1710 |
-
return $items;
|
1711 |
-
}
|
1712 |
-
|
1713 |
-
foreach ( $actions as $id => $arr ) {
|
1714 |
-
$url = add_query_arg( array( 'um_action' => $id, 'uid' => um_profile_id() ) );
|
1715 |
-
/*$url = add_query_arg( 'um_action', $id );
|
1716 |
-
$url = add_query_arg( 'uid', um_profile_id(), $url );*/
|
1717 |
-
$items[] = '<a href="' . esc_url( $url ) .'" class="real_url ' . esc_attr( $id ) . '-item">' . esc_html( $arr['label'] ) . '</a>';
|
1718 |
-
}
|
1719 |
-
return $items;
|
1720 |
-
}
|
1721 |
-
|
1722 |
-
|
1723 |
-
/**
|
1724 |
-
* This method checks if the profile indexing is disabled
|
1725 |
-
*
|
1726 |
-
* @param int $user_id
|
1727 |
-
*
|
1728 |
-
* @since 2.1.16
|
1729 |
-
* @usage <?php UM()->user()->is_profile_noindex( $user_id ); ?>
|
1730 |
-
*
|
1731 |
-
* @return boolean Is the profile indexing disabled?
|
1732 |
-
*/
|
1733 |
-
function is_profile_noindex( $user_id ) {
|
1734 |
-
$profile_noindex = false;
|
1735 |
-
|
1736 |
-
if ( ! get_option( 'blog_public' ) ) {
|
1737 |
-
// Option "Search engine visibility" in [wp-admin > Settings > Reading]
|
1738 |
-
$profile_noindex = true;
|
1739 |
-
|
1740 |
-
} elseif ( $this->is_private_profile( $user_id ) ) {
|
1741 |
-
// Setting "Profile Privacy" in [Account > Privacy]
|
1742 |
-
$profile_noindex = true;
|
1743 |
-
|
1744 |
-
} elseif ( get_user_meta( $user_id, 'profile_noindex', true ) === '1' ) {
|
1745 |
-
// Setting "Avoid indexing my profile by search engines in [Account > Privacy]
|
1746 |
-
$profile_noindex = true;
|
1747 |
-
|
1748 |
-
}
|
1749 |
-
|
1750 |
-
if ( ! $profile_noindex ) {
|
1751 |
-
$role = UM()->roles()->get_priority_user_role( $user_id );
|
1752 |
-
$permissions = UM()->roles()->role_data( $role );
|
1753 |
-
|
1754 |
-
if ( isset( $permissions['profile_noindex'] ) && (bool) $permissions['profile_noindex'] ) {
|
1755 |
-
// Setting "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > User Roles > Edit Role]
|
1756 |
-
$profile_noindex = true;
|
1757 |
-
|
1758 |
-
} elseif ( ( ! isset( $permissions['profile_noindex'] ) || $permissions['profile_noindex'] === '' ) && (bool) UM()->options()->get( 'profile_noindex' ) ) {
|
1759 |
-
// Setting "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > Settings > General > Users]
|
1760 |
-
$profile_noindex = true;
|
1761 |
-
|
1762 |
-
}
|
1763 |
-
}
|
1764 |
-
|
1765 |
-
return apply_filters( 'um_user_is_profile_noindex', $profile_noindex, $user_id, $this );
|
1766 |
-
}
|
1767 |
-
|
1768 |
-
|
1769 |
-
/**
|
1770 |
-
* This method checks if give user profile is private.
|
1771 |
-
*
|
1772 |
-
* @usage <?php UM()->user()->is_private_profile( $user_id ); ?>
|
1773 |
-
*
|
1774 |
-
* @param int $user_id A user ID must be passed to check if the user profile is private
|
1775 |
-
*
|
1776 |
-
* @return bool
|
1777 |
-
*
|
1778 |
-
* @example This example display a specific user's name If his profile is public
|
1779 |
-
|
1780 |
-
<?php
|
1781 |
-
|
1782 |
-
um_fetch_user( 60 );
|
1783 |
-
$is_private = UM()->user()->is_private_profile( 60 );
|
1784 |
-
if ( ! $is_private ) {
|
1785 |
-
echo 'User is public and his name is ' . um_user('display_name');
|
1786 |
-
}
|
1787 |
-
|
1788 |
-
?>
|
1789 |
-
*
|
1790 |
-
*/
|
1791 |
-
function is_private_profile( $user_id ) {
|
1792 |
-
$privacy = get_user_meta( $user_id, 'profile_privacy', true );
|
1793 |
-
if ( $privacy == __( 'Only me', 'ultimate-member' ) || $privacy == 'Only me' ) {
|
1794 |
-
return true;
|
1795 |
-
}
|
1796 |
-
return $this->is_private_case( $user_id, $privacy );
|
1797 |
-
}
|
1798 |
-
|
1799 |
-
|
1800 |
-
/**
|
1801 |
-
* This method can be used to determine If a certain user is approved or not.
|
1802 |
-
*
|
1803 |
-
* @usage <?php UM()->user()->is_approved( $user_id ); ?>
|
1804 |
-
*
|
1805 |
-
* @param int $user_id The user ID to check approval status for
|
1806 |
-
*
|
1807 |
-
* @return bool
|
1808 |
-
*
|
1809 |
-
* @example Do something If a user's membership is approved
|
1810 |
-
|
1811 |
-
<?php
|
1812 |
-
|
1813 |
-
if ( UM()->user()->is_approved( 55 ) {
|
1814 |
-
// User account is approved
|
1815 |
-
} else {
|
1816 |
-
// User account is not approved
|
1817 |
-
}
|
1818 |
-
|
1819 |
-
?>
|
1820 |
-
*
|
1821 |
-
*/
|
1822 |
-
function is_approved( $user_id ) {
|
1823 |
-
$status = get_user_meta( $user_id, 'account_status', true );
|
1824 |
-
if ( $status == 'approved' || $status == '' ) {
|
1825 |
-
return true;
|
1826 |
-
}
|
1827 |
-
return false;
|
1828 |
-
}
|
1829 |
-
|
1830 |
-
|
1831 |
-
/**
|
1832 |
-
* Is private
|
1833 |
-
*
|
1834 |
-
* @param $user_id
|
1835 |
-
* @param $case
|
1836 |
-
*
|
1837 |
-
* @return bool
|
1838 |
-
*/
|
1839 |
-
function is_private_case( $user_id, $case ) {
|
1840 |
-
$privacy = get_user_meta( $user_id, 'profile_privacy', true );
|
1841 |
-
|
1842 |
-
if ( $privacy == $case ) {
|
1843 |
-
/**
|
1844 |
-
* UM hook
|
1845 |
-
*
|
1846 |
-
* @type filter
|
1847 |
-
* @title um_is_private_filter_hook
|
1848 |
-
* @description Change user privacy
|
1849 |
-
* @input_vars
|
1850 |
-
* [{"var":"$is_private","type":"bool","desc":"Is user private"},
|
1851 |
-
* {"var":"$privacy","type":"bool","desc":"Profile Privacy"},
|
1852 |
-
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
1853 |
-
* @change_log
|
1854 |
-
* ["Since: 2.0"]
|
1855 |
-
* @usage
|
1856 |
-
* <?php add_filter( 'um_is_private_filter_hook', 'function_name', 10, 3 ); ?>
|
1857 |
-
* @example
|
1858 |
-
* <?php
|
1859 |
-
* add_filter( 'um_is_private_filter_hook', 'my_is_private_filter', 10, 3 );
|
1860 |
-
* function my_is_private_filter( $is_private ) {
|
1861 |
-
* // your code here
|
1862 |
-
* return $is_private;
|
1863 |
-
* }
|
1864 |
-
* ?>
|
1865 |
-
*/
|
1866 |
-
$bool = apply_filters( 'um_is_private_filter_hook', false, $privacy, $user_id );
|
1867 |
-
return $bool;
|
1868 |
-
}
|
1869 |
-
|
1870 |
-
return false;
|
1871 |
-
}
|
1872 |
-
|
1873 |
-
|
1874 |
-
/**
|
1875 |
-
* Update files
|
1876 |
-
*
|
1877 |
-
* @param $changes
|
1878 |
-
*
|
1879 |
-
* @deprecated 2.1.0
|
1880 |
-
*/
|
1881 |
-
function update_files( $changes ) {
|
1882 |
-
um_deprecated_function( 'update_files', '2.1.0', '' );
|
1883 |
-
}
|
1884 |
-
|
1885 |
-
|
1886 |
-
/**
|
1887 |
-
* Update profile
|
1888 |
-
*
|
1889 |
-
* @param $changes
|
1890 |
-
*/
|
1891 |
-
function update_profile( $changes ) {
|
1892 |
-
|
1893 |
-
$args['ID'] = $this->id;
|
1894 |
-
|
1895 |
-
/**
|
1896 |
-
* UM hook
|
1897 |
-
*
|
1898 |
-
* @type filter
|
1899 |
-
* @title um_before_update_profile
|
1900 |
-
* @description Change update profile changes data
|
1901 |
-
* @input_vars
|
1902 |
-
* [{"var":"$changes","type":"array","desc":"User Profile Changes"},
|
1903 |
-
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
1904 |
-
* @change_log
|
1905 |
-
* ["Since: 2.0"]
|
1906 |
-
* @usage
|
1907 |
-
* <?php add_filter( 'um_before_update_profile', 'function_name', 10, 2 ); ?>
|
1908 |
-
* @example
|
1909 |
-
* <?php
|
1910 |
-
* add_filter( 'um_before_update_profile', 'my_before_update_profile', 10, 2 );
|
1911 |
-
* function my_before_update_profile( $changes, $user_id ) {
|
1912 |
-
* // your code here
|
1913 |
-
* return $changes;
|
1914 |
-
* }
|
1915 |
-
* ?>
|
1916 |
-
*/
|
1917 |
-
$changes = apply_filters( 'um_before_update_profile', $changes, $args['ID'] );
|
1918 |
-
|
1919 |
-
foreach ( $changes as $key => $value ) {
|
1920 |
-
if ( in_array( $key, $this->banned_keys ) ) {
|
1921 |
-
continue;
|
1922 |
-
}
|
1923 |
-
|
1924 |
-
if ( ! in_array( $key, $this->update_user_keys ) ) {
|
1925 |
-
if ( $value === 0 ) {
|
1926 |
-
update_user_meta( $this->id, $key, '0' );
|
1927 |
-
} else {
|
1928 |
-
update_user_meta( $this->id, $key, $value );
|
1929 |
-
}
|
1930 |
-
} else {
|
1931 |
-
$args[ $key ] = esc_attr( $changes[ $key ] );
|
1932 |
-
}
|
1933 |
-
}
|
1934 |
-
|
1935 |
-
|
1936 |
-
// update user
|
1937 |
-
if ( count( $args ) > 1 ) {
|
1938 |
-
//if isset roles argument validate role to properly for security reasons
|
1939 |
-
if ( isset( $args['role'] ) ) {
|
1940 |
-
global $wp_roles;
|
1941 |
-
$um_roles = get_option( 'um_roles', array() );
|
1942 |
-
|
1943 |
-
if ( ! empty( $um_roles ) ) {
|
1944 |
-
$role_keys = array_map( function( $item ) {
|
1945 |
-
return 'um_' . $item;
|
1946 |
-
}, $um_roles );
|
1947 |
-
} else {
|
1948 |
-
$role_keys = array();
|
1949 |
-
}
|
1950 |
-
|
1951 |
-
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
1952 |
-
|
1953 |
-
if ( in_array( $args['role'], $exclude_roles ) ) {
|
1954 |
-
unset( $args['role'] );
|
1955 |
-
}
|
1956 |
-
}
|
1957 |
-
|
1958 |
-
wp_update_user( $args );
|
1959 |
-
}
|
1960 |
-
|
1961 |
-
}
|
1962 |
-
|
1963 |
-
|
1964 |
-
/**
|
1965 |
-
* User exists by meta key and value
|
1966 |
-
*
|
1967 |
-
* @param $key
|
1968 |
-
* @param $value
|
1969 |
-
*
|
1970 |
-
* @return bool|int
|
1971 |
-
*/
|
1972 |
-
function user_has_metadata( $key, $value ) {
|
1973 |
-
|
1974 |
-
$value = UM()->validation()->safe_name_in_url( $value );
|
1975 |
-
|
1976 |
-
$ids = get_users( array( 'fields' => 'ID', 'meta_key' => $key, 'meta_value' => $value, 'meta_compare' => '=' ) );
|
1977 |
-
if ( ! isset( $ids ) || empty( $ids ) ) {
|
1978 |
-
return false;
|
1979 |
-
}
|
1980 |
-
|
1981 |
-
foreach ( $ids as $k => $id ) {
|
1982 |
-
|
1983 |
-
if ( $id == um_user('ID') ) {
|
1984 |
-
unset( $ids[ $k ] );
|
1985 |
-
} else {
|
1986 |
-
$duplicates[] = $id;
|
1987 |
-
}
|
1988 |
-
|
1989 |
-
}
|
1990 |
-
|
1991 |
-
if ( ! empty( $duplicates ) ) {
|
1992 |
-
return count( $duplicates );
|
1993 |
-
}
|
1994 |
-
return false;
|
1995 |
-
}
|
1996 |
-
|
1997 |
-
|
1998 |
-
/**
|
1999 |
-
* User exists by name
|
2000 |
-
*
|
2001 |
-
* @param $value
|
2002 |
-
*
|
2003 |
-
* @return bool
|
2004 |
-
*/
|
2005 |
-
function user_exists_by_name( $value ) {
|
2006 |
-
|
2007 |
-
// Permalink base
|
2008 |
-
$permalink_base = UM()->options()->get( 'permalink_base' );
|
2009 |
-
|
2010 |
-
$raw_value = $value;
|
2011 |
-
$value = UM()->validation()->safe_name_in_url( $value );
|
2012 |
-
$value = um_clean_user_basename( $value );
|
2013 |
-
|
2014 |
-
// Search by Profile Slug
|
2015 |
-
$args = array(
|
2016 |
-
'fields' => array( 'ID' ),
|
2017 |
-
'meta_query' => array(
|
2018 |
-
'relation' => 'OR',
|
2019 |
-
array(
|
2020 |
-
'key' => 'um_user_profile_url_slug_' . $permalink_base,
|
2021 |
-
'value' => strtolower( $raw_value ),
|
2022 |
-
'compare' => '=',
|
2023 |
-
),
|
2024 |
-
),
|
2025 |
-
);
|
2026 |
-
|
2027 |
-
|
2028 |
-
$ids = new \WP_User_Query( $args );
|
2029 |
-
|
2030 |
-
if ( $ids->total_users > 0 ) {
|
2031 |
-
$um_user_query = current( $ids->get_results() );
|
2032 |
-
return $um_user_query->ID;
|
2033 |
-
}
|
2034 |
-
|
2035 |
-
// Search by Display Name or ID
|
2036 |
-
$args = array(
|
2037 |
-
'fields' => array( 'ID' ),
|
2038 |
-
'search' => $value,
|
2039 |
-
'search_columns' => array( 'display_name', 'ID' ),
|
2040 |
-
);
|
2041 |
-
|
2042 |
-
$ids = new \WP_User_Query( $args );
|
2043 |
-
|
2044 |
-
if ( $ids->total_users > 0 ) {
|
2045 |
-
$um_user_query = current( $ids->get_results() );
|
2046 |
-
return $um_user_query->ID;
|
2047 |
-
}
|
2048 |
-
|
2049 |
-
|
2050 |
-
// Search By User Login
|
2051 |
-
$value = str_replace( ".", "_", $value );
|
2052 |
-
$value = str_replace( " ", "", $value );
|
2053 |
-
|
2054 |
-
$args = array(
|
2055 |
-
'fields' => array( 'ID' ),
|
2056 |
-
'search' => $value,
|
2057 |
-
'search_columns' => array(
|
2058 |
-
'user_login',
|
2059 |
-
)
|
2060 |
-
);
|
2061 |
-
|
2062 |
-
$ids = new \WP_User_Query( $args );
|
2063 |
-
|
2064 |
-
if ( $ids->total_users > 0 ) {
|
2065 |
-
$um_user_query = current( $ids->get_results() );
|
2066 |
-
return $um_user_query->ID;
|
2067 |
-
}
|
2068 |
-
|
2069 |
-
return false;
|
2070 |
-
}
|
2071 |
-
|
2072 |
-
|
2073 |
-
/**
|
2074 |
-
* This method checks if a user exists or not in your site based on the user ID.
|
2075 |
-
*
|
2076 |
-
* @usage <?php UM()->user()->user_exists_by_id( $user_id ); ?>
|
2077 |
-
*
|
2078 |
-
* @param int $user_id A user ID must be passed to check if the user exists
|
2079 |
-
*
|
2080 |
-
* @return bool|int
|
2081 |
-
*
|
2082 |
-
* @example Basic Usage
|
2083 |
-
|
2084 |
-
<?php
|
2085 |
-
|
2086 |
-
$boolean = UM()->user()->user_exists_by_id( 15 );
|
2087 |
-
if ( $boolean ) {
|
2088 |
-
// That user exists
|
2089 |
-
}
|
2090 |
-
|
2091 |
-
?>
|
2092 |
-
|
2093 |
-
*
|
2094 |
-
*/
|
2095 |
-
function user_exists_by_id( $user_id ) {
|
2096 |
-
$aux = get_userdata( absint( $user_id ) );
|
2097 |
-
if ( $aux == false ) {
|
2098 |
-
return false;
|
2099 |
-
} else {
|
2100 |
-
return $user_id;
|
2101 |
-
}
|
2102 |
-
}
|
2103 |
-
|
2104 |
-
|
2105 |
-
/**
|
2106 |
-
* This method checks if a user exists or not in your site based on the user email as username
|
2107 |
-
*
|
2108 |
-
* @param string $slug A user slug must be passed to check if the user exists
|
2109 |
-
*
|
2110 |
-
* @usage <?php UM()->user()->user_exists_by_email_as_username( $slug ); ?>
|
2111 |
-
*
|
2112 |
-
* @return bool
|
2113 |
-
*
|
2114 |
-
* @example Basic Usage
|
2115 |
-
|
2116 |
-
<?php
|
2117 |
-
|
2118 |
-
$boolean = UM()->user()->user_exists_by_email_as_username( 'calumgmail-com' );
|
2119 |
-
if ( $boolean ) {
|
2120 |
-
// That user exists
|
2121 |
-
}
|
2122 |
-
|
2123 |
-
?>
|
2124 |
-
*/
|
2125 |
-
function user_exists_by_email_as_username( $slug ) {
|
2126 |
-
|
2127 |
-
$user_id = false;
|
2128 |
-
|
2129 |
-
$ids = get_users( array( 'fields' => 'ID', 'meta_key' => 'um_email_as_username_' . $slug ) );
|
2130 |
-
if ( ! empty( $ids[0] ) ) {
|
2131 |
-
$user_id = $ids[0];
|
2132 |
-
}
|
2133 |
-
|
2134 |
-
return $user_id;
|
2135 |
-
}
|
2136 |
-
|
2137 |
-
|
2138 |
-
/**
|
2139 |
-
* Set gravatar hash id
|
2140 |
-
*
|
2141 |
-
* @param $user_id
|
2142 |
-
* @return string
|
2143 |
-
*/
|
2144 |
-
function set_gravatar( $user_id ) {
|
2145 |
-
|
2146 |
-
um_fetch_user( $user_id );
|
2147 |
-
$email_address = um_user( 'user_email' );
|
2148 |
-
$hash_email_address = '';
|
2149 |
-
|
2150 |
-
if ( $email_address ) {
|
2151 |
-
$hash_email_address = md5( $email_address );
|
2152 |
-
$this->profile['synced_gravatar_hashed_id'] = $hash_email_address;
|
2153 |
-
$this->update_usermeta_info( 'synced_gravatar_hashed_id' );
|
2154 |
-
}
|
2155 |
-
|
2156 |
-
return $hash_email_address;
|
2157 |
-
}
|
2158 |
-
|
2159 |
-
|
2160 |
-
/**
|
2161 |
-
* UM Placeholders for activation link in email
|
2162 |
-
*
|
2163 |
-
* @param $placeholders
|
2164 |
-
*
|
2165 |
-
* @return array
|
2166 |
-
*/
|
2167 |
-
function add_activation_placeholder( $placeholders ) {
|
2168 |
-
$placeholders[] = '{account_activation_link}';
|
2169 |
-
return $placeholders;
|
2170 |
-
}
|
2171 |
-
|
2172 |
-
|
2173 |
-
/**
|
2174 |
-
* UM Replace Placeholders for activation link in email
|
2175 |
-
*
|
2176 |
-
* @param $replace_placeholders
|
2177 |
-
*
|
2178 |
-
* @return array
|
2179 |
-
*/
|
2180 |
-
function add_activation_replace_placeholder( $replace_placeholders ) {
|
2181 |
-
$replace_placeholders[] = um_user( 'account_activation_link' );
|
2182 |
-
return $replace_placeholders;
|
2183 |
-
}
|
2184 |
-
}
|
2185 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
// Exit if accessed directly
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\core\User' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class User
|
13 |
+
* @package um\core
|
14 |
+
*/
|
15 |
+
class User {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Data that we will set before the update profile to compare it after update
|
20 |
+
*
|
21 |
+
* @var null
|
22 |
+
*/
|
23 |
+
public $previous_data = null;
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* User constructor.
|
28 |
+
*/
|
29 |
+
function __construct() {
|
30 |
+
|
31 |
+
$this->id = 0;
|
32 |
+
$this->usermeta = null;
|
33 |
+
$this->data = null;
|
34 |
+
$this->profile = null;
|
35 |
+
$this->cannot_edit = null;
|
36 |
+
$this->password_reset_key = null;
|
37 |
+
|
38 |
+
global $wpdb;
|
39 |
+
|
40 |
+
$this->banned_keys = array(
|
41 |
+
'metabox','postbox','meta-box',
|
42 |
+
'dismissed_wp_pointers', 'session_tokens',
|
43 |
+
'screen_layout', 'wp_user-', 'dismissed',
|
44 |
+
'cap_key', $wpdb->get_blog_prefix(). 'capabilities',
|
45 |
+
'managenav', 'nav_menu', 'user_activation_key',
|
46 |
+
'level_', $wpdb->get_blog_prefix() . 'user_level'
|
47 |
+
);
|
48 |
+
|
49 |
+
add_action( 'init', array( &$this, 'set' ), 1 );
|
50 |
+
|
51 |
+
$this->preview = false;
|
52 |
+
$this->send_mail_on_delete = true;
|
53 |
+
|
54 |
+
// a list of keys that should never be in wp_usermeta
|
55 |
+
$this->update_user_keys = array(
|
56 |
+
'user_email',
|
57 |
+
'user_pass',
|
58 |
+
'user_password',
|
59 |
+
'display_name',
|
60 |
+
'user_url',
|
61 |
+
'role',
|
62 |
+
);
|
63 |
+
|
64 |
+
$this->target_id = null;
|
65 |
+
|
66 |
+
// When the cache should be cleared
|
67 |
+
add_action( 'um_delete_user_hook', array( &$this, 'remove_cached_queue' ) );
|
68 |
+
add_action( 'um_delete_user', array( &$this, 'remove_cache' ), 10, 1 );
|
69 |
+
|
70 |
+
add_action( 'um_after_user_status_is_changed_hook', array( &$this, 'remove_cached_queue' ) );
|
71 |
+
|
72 |
+
// When user cache should be cleared
|
73 |
+
add_action( 'um_after_user_updated', array( &$this, 'remove_cache' ) );
|
74 |
+
add_action( 'um_after_user_account_updated', array( &$this, 'remove_cache' ) );
|
75 |
+
add_action( 'personal_options_update', array( &$this, 'remove_cache' ) );
|
76 |
+
//add_action('edit_user_profile_update', array(&$this, 'remove_cache') );
|
77 |
+
add_action( 'um_when_role_is_set', array( &$this, 'remove_cache' ) );
|
78 |
+
add_action( 'um_when_status_is_set', array( &$this, 'remove_cache' ) );
|
79 |
+
|
80 |
+
add_action( 'show_user_profile', array( $this, 'profile_form_additional_section' ), 10 );
|
81 |
+
add_action( 'user_new_form', array( $this, 'profile_form_additional_section' ), 10 );
|
82 |
+
add_action( 'edit_user_profile', array( $this, 'profile_form_additional_section' ), 10 );
|
83 |
+
add_filter( 'um_user_profile_additional_fields', array( $this, 'secondary_role_field' ), 1, 2 );
|
84 |
+
|
85 |
+
//on every update of user profile (hook from wp_update_user)
|
86 |
+
add_action( 'profile_update', array( &$this, 'profile_update' ), 10, 2 ); // user_id and old_user_data
|
87 |
+
|
88 |
+
//on user update profile page
|
89 |
+
//add_action( 'edit_user_profile_update', array( &$this, 'profile_update' ), 10, 1 );
|
90 |
+
|
91 |
+
add_action( 'user_register', array( &$this, 'user_register_via_admin' ), 10, 1 );
|
92 |
+
add_action( 'user_register', array( &$this, 'set_gravatar' ), 11, 1 );
|
93 |
+
|
94 |
+
|
95 |
+
if ( is_multisite() ) {
|
96 |
+
add_action( 'added_existing_user', array( &$this, 'add_um_role_existing_user' ), 10, 2 );
|
97 |
+
add_action( 'wpmu_activate_user', array( &$this, 'add_um_role_wpmu_new_user' ), 10, 1 );
|
98 |
+
}
|
99 |
+
|
100 |
+
add_action( 'init', array( &$this, 'check_membership' ), 10 );
|
101 |
+
|
102 |
+
if ( is_multisite() ) {
|
103 |
+
add_action( 'wpmu_delete_user', array( &$this, 'delete_user_handler' ), 10, 1 );
|
104 |
+
} else {
|
105 |
+
add_action( 'delete_user', array( &$this, 'delete_user_handler' ), 10, 1 );
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
add_action( 'updated_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
|
110 |
+
add_action( 'added_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
|
111 |
+
|
112 |
+
add_action( 'deleted_user_meta', array( &$this, 'on_delete_usermeta' ), 10, 4 );
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
/**
|
117 |
+
* When you delete usermeta connected with member directory - reset it to default value
|
118 |
+
*
|
119 |
+
* @param int|array $meta_ids
|
120 |
+
* @param int $object_id
|
121 |
+
* @param string $meta_key
|
122 |
+
* @param mixed $_meta_value
|
123 |
+
*/
|
124 |
+
function on_delete_usermeta( $meta_ids, $object_id, $meta_key, $_meta_value ) {
|
125 |
+
$metakeys = array( 'account_status', 'hide_in_members', 'synced_gravatar_hashed_id', 'synced_profile_photo', 'profile_photo', 'cover_photo', '_um_verified' );
|
126 |
+
if ( ! in_array( $meta_key, $metakeys ) ) {
|
127 |
+
return;
|
128 |
+
}
|
129 |
+
|
130 |
+
$md_data = get_user_meta( $object_id, 'um_member_directory_data', true );
|
131 |
+
if ( empty( $md_data ) ) {
|
132 |
+
$md_data = array(
|
133 |
+
'account_status' => 'approved',
|
134 |
+
'hide_in_members' => UM()->member_directory()->get_hide_in_members_default(),
|
135 |
+
'profile_photo' => false,
|
136 |
+
'cover_photo' => false,
|
137 |
+
'verified' => false,
|
138 |
+
);
|
139 |
+
}
|
140 |
+
|
141 |
+
switch ( $meta_key ) {
|
142 |
+
case 'account_status':
|
143 |
+
$md_data['account_status'] = 'approved';
|
144 |
+
break;
|
145 |
+
case 'hide_in_members':
|
146 |
+
$md_data['hide_in_members'] = UM()->member_directory()->get_hide_in_members_default();
|
147 |
+
break;
|
148 |
+
case 'synced_gravatar_hashed_id':
|
149 |
+
if ( UM()->options()->get( 'use_gravatars' ) ) {
|
150 |
+
$profile_photo = get_user_meta( $object_id, 'profile_photo', true );
|
151 |
+
$synced_profile_photo = get_user_meta( $object_id, 'synced_profile_photo', true );
|
152 |
+
|
153 |
+
$md_data['profile_photo'] = ! empty( $profile_photo ) || ! empty( $synced_profile_photo );
|
154 |
+
}
|
155 |
+
|
156 |
+
break;
|
157 |
+
case 'synced_profile_photo':
|
158 |
+
$profile_photo = get_user_meta( $object_id, 'profile_photo', true );
|
159 |
+
|
160 |
+
$synced_gravatar_hashed_id = false;
|
161 |
+
if ( UM()->options()->get( 'use_gravatars' ) ) {
|
162 |
+
$synced_gravatar_hashed_id = get_user_meta( $object_id, 'synced_gravatar_hashed_id', true );
|
163 |
+
}
|
164 |
+
|
165 |
+
$md_data['profile_photo'] = ! empty( $profile_photo ) || ! empty( $synced_gravatar_hashed_id );
|
166 |
+
break;
|
167 |
+
case 'profile_photo':
|
168 |
+
$synced_profile_photo = get_user_meta( $object_id, 'synced_profile_photo', true );
|
169 |
+
|
170 |
+
$synced_gravatar_hashed_id = false;
|
171 |
+
if ( UM()->options()->get( 'use_gravatars' ) ) {
|
172 |
+
$synced_gravatar_hashed_id = get_user_meta( $object_id, 'synced_gravatar_hashed_id', true );
|
173 |
+
}
|
174 |
+
|
175 |
+
$md_data['profile_photo'] = ! empty( $synced_profile_photo ) || ! empty( $synced_gravatar_hashed_id );
|
176 |
+
break;
|
177 |
+
case 'cover_photo':
|
178 |
+
$md_data['cover_photo'] = false;
|
179 |
+
break;
|
180 |
+
case '_um_verified':
|
181 |
+
$md_data['verified'] = false;
|
182 |
+
break;
|
183 |
+
}
|
184 |
+
|
185 |
+
update_user_meta( $object_id, 'um_member_directory_data', $md_data );
|
186 |
+
}
|
187 |
+
|
188 |
+
|
189 |
+
/**
|
190 |
+
* When you add/update usermeta connected with member directories - set this data to member directory metakey
|
191 |
+
*
|
192 |
+
* @param int $meta_id
|
193 |
+
* @param int $object_id
|
194 |
+
* @param string $meta_key
|
195 |
+
* @param mixed $_meta_value
|
196 |
+
*/
|
197 |
+
function on_update_usermeta( $meta_id, $object_id, $meta_key, $_meta_value ) {
|
198 |
+
|
199 |
+
$metakeys = array( 'account_status', 'hide_in_members', 'synced_gravatar_hashed_id', 'synced_profile_photo', 'profile_photo', 'cover_photo', '_um_verified' );
|
200 |
+
if ( ! in_array( $meta_key, $metakeys ) ) {
|
201 |
+
return;
|
202 |
+
}
|
203 |
+
|
204 |
+
$md_data = get_user_meta( $object_id, 'um_member_directory_data', true );
|
205 |
+
if ( empty( $md_data ) ) {
|
206 |
+
$md_data = array(
|
207 |
+
'account_status' => 'approved',
|
208 |
+
'hide_in_members' => UM()->member_directory()->get_hide_in_members_default(),
|
209 |
+
'profile_photo' => false,
|
210 |
+
'cover_photo' => false,
|
211 |
+
'verified' => false,
|
212 |
+
);
|
213 |
+
}
|
214 |
+
|
215 |
+
switch ( $meta_key ) {
|
216 |
+
case 'account_status':
|
217 |
+
$md_data['account_status'] = $_meta_value;
|
218 |
+
break;
|
219 |
+
case 'hide_in_members':
|
220 |
+
|
221 |
+
$hide_in_members = UM()->member_directory()->get_hide_in_members_default();
|
222 |
+
if ( ! empty( $_meta_value ) ) {
|
223 |
+
if ( $_meta_value == 'Yes' || $_meta_value == __( 'Yes', 'ultimate-member' ) ||
|
224 |
+
array_intersect( array( 'Yes', __( 'Yes', 'ultimate-member' ) ), $_meta_value ) ) {
|
225 |
+
$hide_in_members = true;
|
226 |
+
} else {
|
227 |
+
$hide_in_members = false;
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
$md_data['hide_in_members'] = $hide_in_members;
|
232 |
+
|
233 |
+
break;
|
234 |
+
case 'synced_gravatar_hashed_id':
|
235 |
+
if ( UM()->options()->get( 'use_gravatars' ) ) {
|
236 |
+
if ( empty( $md_data['profile_photo'] ) ) {
|
237 |
+
$md_data['profile_photo'] = ! empty( $_meta_value );
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
+
break;
|
242 |
+
case 'synced_profile_photo':
|
243 |
+
case 'profile_photo':
|
244 |
+
if ( empty( $md_data['profile_photo'] ) ) {
|
245 |
+
$md_data['profile_photo'] = ! empty( $_meta_value );
|
246 |
+
}
|
247 |
+
break;
|
248 |
+
case 'cover_photo':
|
249 |
+
$md_data['cover_photo'] = ! empty( $_meta_value );
|
250 |
+
break;
|
251 |
+
case '_um_verified':
|
252 |
+
$md_data['verified'] = $_meta_value == 'verified' ? true : false;
|
253 |
+
break;
|
254 |
+
}
|
255 |
+
|
256 |
+
update_user_meta( $object_id, 'um_member_directory_data', $md_data );
|
257 |
+
}
|
258 |
+
|
259 |
+
|
260 |
+
/**
|
261 |
+
* @param $user_id
|
262 |
+
*/
|
263 |
+
function delete_user_handler( $user_id ) {
|
264 |
+
um_fetch_user( $user_id );
|
265 |
+
|
266 |
+
/**
|
267 |
+
* UM hook
|
268 |
+
*
|
269 |
+
* @type action
|
270 |
+
* @title um_delete_user_hook
|
271 |
+
* @description On delete user
|
272 |
+
* @change_log
|
273 |
+
* ["Since: 2.0"]
|
274 |
+
* @usage add_action( 'um_delete_user_hook', 'function_name', 10 );
|
275 |
+
* @example
|
276 |
+
* <?php
|
277 |
+
* add_action( 'um_delete_user_hook', 'my_delete_user', 10 );
|
278 |
+
* function my_delete_user() {
|
279 |
+
* // your code here
|
280 |
+
* }
|
281 |
+
* ?>
|
282 |
+
*/
|
283 |
+
do_action( 'um_delete_user_hook' );
|
284 |
+
|
285 |
+
/**
|
286 |
+
* UM hook
|
287 |
+
*
|
288 |
+
* @type action
|
289 |
+
* @title um_delete_user
|
290 |
+
* @description On delete user
|
291 |
+
* @input_vars
|
292 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
293 |
+
* @change_log
|
294 |
+
* ["Since: 2.0"]
|
295 |
+
* @usage add_action( 'um_delete_user', 'function_name', 10, 1 );
|
296 |
+
* @example
|
297 |
+
* <?php
|
298 |
+
* add_action( 'um_delete_user', 'my_delete_user', 10, 1 );
|
299 |
+
* function my_delete_user( $user_id ) {
|
300 |
+
* // your code here
|
301 |
+
* }
|
302 |
+
* ?>
|
303 |
+
*/
|
304 |
+
do_action( 'um_delete_user', um_user( 'ID' ) );
|
305 |
+
|
306 |
+
// send email notifications
|
307 |
+
if ( $this->send_mail_on_delete ) {
|
308 |
+
UM()->mail()->send( um_user( 'user_email' ), 'deletion_email' );
|
309 |
+
|
310 |
+
$emails = um_multi_admin_email();
|
311 |
+
if ( ! empty( $emails ) ) {
|
312 |
+
foreach ( $emails as $email ) {
|
313 |
+
UM()->mail()->send( $email, 'notification_deletion', array( 'admin' => true ) );
|
314 |
+
}
|
315 |
+
}
|
316 |
+
}
|
317 |
+
|
318 |
+
// remove uploads
|
319 |
+
UM()->files()->remove_dir( UM()->files()->upload_temp );
|
320 |
+
UM()->files()->remove_dir( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR );
|
321 |
+
}
|
322 |
+
|
323 |
+
|
324 |
+
/**
|
325 |
+
*
|
326 |
+
*/
|
327 |
+
function check_membership() {
|
328 |
+
if ( ! is_user_logged_in() ) {
|
329 |
+
return;
|
330 |
+
}
|
331 |
+
|
332 |
+
um_fetch_user( get_current_user_id() );
|
333 |
+
$status = um_user( 'account_status' );
|
334 |
+
|
335 |
+
if ( 'rejected' == $status ) {
|
336 |
+
wp_logout();
|
337 |
+
session_unset();
|
338 |
+
exit( wp_redirect( um_get_core_page( 'login' ) ) );
|
339 |
+
}
|
340 |
+
|
341 |
+
um_reset_user();
|
342 |
+
}
|
343 |
+
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Multisite add existing user
|
347 |
+
*
|
348 |
+
* @param $user_id
|
349 |
+
* @param $result
|
350 |
+
*/
|
351 |
+
function add_um_role_existing_user( $user_id, $result ) {
|
352 |
+
// Bail if no user ID was passed
|
353 |
+
if ( empty( $user_id ) ) {
|
354 |
+
return;
|
355 |
+
}
|
356 |
+
|
357 |
+
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
358 |
+
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
|
359 |
+
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
$this->remove_cache( $user_id );
|
364 |
+
}
|
365 |
+
|
366 |
+
|
367 |
+
/**
|
368 |
+
* Multisite add existing user
|
369 |
+
*
|
370 |
+
* @param $user_id
|
371 |
+
*/
|
372 |
+
function add_um_role_wpmu_new_user( $user_id ) {
|
373 |
+
// Bail if no user ID was passed
|
374 |
+
if ( empty( $user_id ) ) {
|
375 |
+
return;
|
376 |
+
}
|
377 |
+
|
378 |
+
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
379 |
+
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
|
380 |
+
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
|
381 |
+
}
|
382 |
+
}
|
383 |
+
|
384 |
+
$this->remove_cache( $user_id );
|
385 |
+
}
|
386 |
+
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Get pending users (in queue)
|
390 |
+
*/
|
391 |
+
function get_pending_users_count() {
|
392 |
+
|
393 |
+
$cached_users_queue = get_option( 'um_cached_users_queue' );
|
394 |
+
if ( $cached_users_queue > 0 && ! isset( $_REQUEST['delete_count'] ) ) {
|
395 |
+
return $cached_users_queue;
|
396 |
+
}
|
397 |
+
|
398 |
+
$args = array( 'fields' => 'ID', 'number' => 1 );
|
399 |
+
$args['meta_query']['relation'] = 'OR';
|
400 |
+
$args['meta_query'][] = array(
|
401 |
+
'key' => 'account_status',
|
402 |
+
'value' => 'awaiting_email_confirmation',
|
403 |
+
'compare' => '='
|
404 |
+
);
|
405 |
+
$args['meta_query'][] = array(
|
406 |
+
'key' => 'account_status',
|
407 |
+
'value' => 'awaiting_admin_review',
|
408 |
+
'compare' => '='
|
409 |
+
);
|
410 |
+
|
411 |
+
/**
|
412 |
+
* UM hook
|
413 |
+
*
|
414 |
+
* @type filter
|
415 |
+
* @title um_admin_pending_queue_filter
|
416 |
+
* @description Change user query arguments when get pending users
|
417 |
+
* @input_vars
|
418 |
+
* [{"var":"$args","type":"array","desc":"WP_Users query arguments"}]
|
419 |
+
* @change_log
|
420 |
+
* ["Since: 2.0"]
|
421 |
+
* @usage
|
422 |
+
* <?php add_filter( 'um_admin_pending_queue_filter', 'function_name', 10, 1 ); ?>
|
423 |
+
* @example
|
424 |
+
* <?php
|
425 |
+
* add_filter( 'um_admin_pending_queue_filter', 'my_admin_pending_queue', 10, 1 );
|
426 |
+
* function my_admin_pending_queue( $args ) {
|
427 |
+
* // your code here
|
428 |
+
* return $args;
|
429 |
+
* }
|
430 |
+
* ?>
|
431 |
+
*/
|
432 |
+
$args = apply_filters( 'um_admin_pending_queue_filter', $args );
|
433 |
+
$users = new \WP_User_Query( $args );
|
434 |
+
|
435 |
+
delete_option( 'um_cached_users_queue' );
|
436 |
+
add_option( 'um_cached_users_queue', $users->get_total(), '', 'no' );
|
437 |
+
|
438 |
+
return $users->get_total();
|
439 |
+
}
|
440 |
+
|
441 |
+
|
442 |
+
/**
|
443 |
+
* @param $user_id
|
444 |
+
*
|
445 |
+
* @return bool|mixed
|
446 |
+
*/
|
447 |
+
function get_profile_slug( $user_id ) {
|
448 |
+
// Permalink base
|
449 |
+
$permalink_base = UM()->options()->get( 'permalink_base' );
|
450 |
+
$profile_slug = get_user_meta( $user_id, "um_user_profile_url_slug_{$permalink_base}", true );
|
451 |
+
|
452 |
+
//get default username permalink if it's empty then return false
|
453 |
+
if ( empty( $profile_slug ) ) {
|
454 |
+
if ( $permalink_base != 'user_login' ) {
|
455 |
+
$profile_slug = get_user_meta( $user_id, 'um_user_profile_url_slug_user_login', true );
|
456 |
+
}
|
457 |
+
|
458 |
+
if ( empty( $profile_slug ) ) {
|
459 |
+
return false;
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
return $profile_slug;
|
464 |
+
}
|
465 |
+
|
466 |
+
|
467 |
+
/**
|
468 |
+
* @param $user_id
|
469 |
+
*
|
470 |
+
* @return bool|string
|
471 |
+
*/
|
472 |
+
function get_profile_link( $user_id ) {
|
473 |
+
$profile_slug = $this->get_profile_slug( $user_id );
|
474 |
+
|
475 |
+
if ( empty( $profile_slug ) ) {
|
476 |
+
return false;
|
477 |
+
}
|
478 |
+
|
479 |
+
return UM()->permalinks()->profile_permalink( $profile_slug );
|
480 |
+
}
|
481 |
+
|
482 |
+
|
483 |
+
/**
|
484 |
+
* Generate User Profile Slug and save to meta
|
485 |
+
*
|
486 |
+
* @param int $user_id
|
487 |
+
* @param bool $force
|
488 |
+
*/
|
489 |
+
function generate_profile_slug( $user_id, $force = false ) {
|
490 |
+
$userdata = get_userdata( $user_id );
|
491 |
+
|
492 |
+
if ( empty( $userdata ) ) {
|
493 |
+
return;
|
494 |
+
}
|
495 |
+
|
496 |
+
delete_option( "um_cache_userdata_{$user_id}" );
|
497 |
+
|
498 |
+
$current_profile_slug = $this->get_profile_slug( $user_id );
|
499 |
+
|
500 |
+
$user_in_url = '';
|
501 |
+
$permalink_base = UM()->options()->get( 'permalink_base' );
|
502 |
+
|
503 |
+
// User ID
|
504 |
+
if ( $permalink_base == 'user_id' ) {
|
505 |
+
$user_in_url = $user_id;
|
506 |
+
}
|
507 |
+
|
508 |
+
// Username
|
509 |
+
if ( $permalink_base == 'user_login' ) {
|
510 |
+
|
511 |
+
$user_in_url = $userdata->user_login;
|
512 |
+
|
513 |
+
if ( is_email( $user_in_url ) ) {
|
514 |
+
|
515 |
+
$user_email = $user_in_url;
|
516 |
+
$user_in_url = str_replace( '@', '', $user_in_url );
|
517 |
+
|
518 |
+
if ( ( $pos = strrpos( $user_in_url, '.' ) ) !== false ) {
|
519 |
+
$search_length = strlen( '.' );
|
520 |
+
$user_in_url = substr_replace( $user_in_url, '-', $pos, $search_length );
|
521 |
+
}
|
522 |
+
update_user_meta( $user_id, "um_email_as_username_{$user_in_url}", $user_email );
|
523 |
+
|
524 |
+
} else {
|
525 |
+
|
526 |
+
$user_in_url = urlencode( $user_in_url );
|
527 |
+
|
528 |
+
}
|
529 |
+
}
|
530 |
+
|
531 |
+
// Fisrt and Last name
|
532 |
+
$full_name_permalinks = array( 'name', 'name_dash', 'name_plus' );
|
533 |
+
if ( in_array( $permalink_base, $full_name_permalinks ) ) {
|
534 |
+
$separated = array( 'name' => '.', 'name_dash' => '-', 'name_plus' => '+' );
|
535 |
+
$separate = $separated[ $permalink_base ];
|
536 |
+
$first_name = $userdata->first_name;
|
537 |
+
$last_name = $userdata->last_name;
|
538 |
+
$full_name = trim( sprintf( '%s %s', $first_name, $last_name ) );
|
539 |
+
$full_name = preg_replace( '/\s+/', ' ', $full_name ); // Remove double spaces
|
540 |
+
$profile_slug = UM()->permalinks()->profile_slug( $full_name, $first_name, $last_name );
|
541 |
+
|
542 |
+
$append = 0;
|
543 |
+
$username = $full_name;
|
544 |
+
$_username = $full_name;
|
545 |
+
|
546 |
+
while ( 1 ) {
|
547 |
+
$username = $_username . ( empty( $append ) ? '' : " $append" );
|
548 |
+
$slug_exists_user_id = UM()->permalinks()->slug_exists_user_id( $profile_slug . ( empty( $append ) ? '' : "{$separate}{$append}" ) );
|
549 |
+
if ( empty( $slug_exists_user_id ) || $user_id == $slug_exists_user_id ) {
|
550 |
+
break;
|
551 |
+
}
|
552 |
+
$append++;
|
553 |
+
}
|
554 |
+
|
555 |
+
$user_in_url = UM()->permalinks()->profile_slug( $username, $first_name, $last_name );
|
556 |
+
if ( empty( $user_in_url ) ) {
|
557 |
+
$user_in_url = $userdata->user_login;
|
558 |
+
|
559 |
+
if ( is_email( $user_in_url ) ) {
|
560 |
+
|
561 |
+
$user_email = $user_in_url;
|
562 |
+
$user_in_url = str_replace( '@', '', $user_in_url );
|
563 |
+
|
564 |
+
if ( ( $pos = strrpos( $user_in_url, '.' ) ) !== false ) {
|
565 |
+
$search_length = strlen( '.' );
|
566 |
+
$user_in_url = substr_replace( $user_in_url, '-', $pos, $search_length );
|
567 |
+
}
|
568 |
+
update_user_meta( $user_id, "um_email_as_username_{$user_in_url}", $user_email );
|
569 |
+
|
570 |
+
} else {
|
571 |
+
|
572 |
+
$user_in_url = sanitize_title( $user_in_url );
|
573 |
+
|
574 |
+
}
|
575 |
+
}
|
576 |
+
|
577 |
+
$user_in_url = trim( $user_in_url, $separate );
|
578 |
+
}
|
579 |
+
|
580 |
+
$user_in_url = apply_filters( 'um_change_user_profile_slug', $user_in_url, $user_id );
|
581 |
+
|
582 |
+
if ( $force || empty( $current_profile_slug ) || $current_profile_slug != $user_in_url ) {
|
583 |
+
update_user_meta( $user_id, "um_user_profile_url_slug_{$permalink_base}", $user_in_url );
|
584 |
+
}
|
585 |
+
}
|
586 |
+
|
587 |
+
|
588 |
+
/**
|
589 |
+
* Backend user creation
|
590 |
+
*
|
591 |
+
* @param $user_id
|
592 |
+
*/
|
593 |
+
function user_register_via_admin( $user_id ) {
|
594 |
+
|
595 |
+
if ( empty( $user_id ) ) {
|
596 |
+
return;
|
597 |
+
}
|
598 |
+
|
599 |
+
if ( is_admin() ) {
|
600 |
+
//if there custom 2 role not empty
|
601 |
+
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
602 |
+
$user = get_userdata( $user_id );
|
603 |
+
$user->add_role( sanitize_key( $_POST['um-role'] ) );
|
604 |
+
UM()->user()->profile['role'] = sanitize_key( $_POST['um-role'] );
|
605 |
+
UM()->user()->update_usermeta_info( 'role' );
|
606 |
+
}
|
607 |
+
|
608 |
+
/**
|
609 |
+
* UM hook
|
610 |
+
*
|
611 |
+
* @type action
|
612 |
+
* @title um_user_register
|
613 |
+
* @description Action on user registration
|
614 |
+
* @input_vars
|
615 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
616 |
+
* {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
|
617 |
+
* @change_log
|
618 |
+
* ["Since: 2.0"]
|
619 |
+
* @usage add_action( 'um_user_register', 'function_name', 10, 2 );
|
620 |
+
* @example
|
621 |
+
* <?php
|
622 |
+
* add_action( 'um_user_register', 'my_user_register', 10, 2 );
|
623 |
+
* function my_user_register( $user_id, $submitted ) {
|
624 |
+
* // your code here
|
625 |
+
* }
|
626 |
+
* ?>
|
627 |
+
*/
|
628 |
+
do_action( 'um_user_register', $user_id, $_POST );
|
629 |
+
}
|
630 |
+
|
631 |
+
}
|
632 |
+
|
633 |
+
|
634 |
+
/**
|
635 |
+
* On wp_update_user function complete
|
636 |
+
*
|
637 |
+
* @param int $user_id
|
638 |
+
* @param \WP_User $old_data
|
639 |
+
*/
|
640 |
+
function profile_update( $user_id, $old_data ) {
|
641 |
+
// Bail if no user ID was passed
|
642 |
+
if ( empty( $user_id ) ) {
|
643 |
+
return;
|
644 |
+
}
|
645 |
+
|
646 |
+
$old_roles = $old_data->roles;
|
647 |
+
$userdata = get_userdata( $user_id );
|
648 |
+
$new_roles = $userdata->roles;
|
649 |
+
|
650 |
+
if ( is_admin() ) {
|
651 |
+
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
|
652 |
+
$new_roles = array_merge( $new_roles, array( sanitize_key( $_POST['um-role'] ) ) );
|
653 |
+
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
|
654 |
+
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
|
655 |
+
}
|
656 |
+
}
|
657 |
+
}
|
658 |
+
|
659 |
+
/**
|
660 |
+
* UM hook
|
661 |
+
*
|
662 |
+
* @type action
|
663 |
+
* @title um_after_member_role_upgrade
|
664 |
+
* @description Action on user registration
|
665 |
+
* @input_vars
|
666 |
+
* [{"var":"$new_roles","type":"array","desc":"User new roles"},
|
667 |
+
* {"var":"$old_roles","type":"array","desc":"Old roles"}]
|
668 |
+
* @change_log
|
669 |
+
* ["Since: 2.0"]
|
670 |
+
* @usage add_action( 'um_after_member_role_upgrade', 'function_name', 10, 2 );
|
671 |
+
* @example
|
672 |
+
* <?php
|
673 |
+
* add_action( 'um_after_member_role_upgrade', 'my_after_member_role_upgrade', 10, 2 );
|
674 |
+
* function my_after_member_role_upgrade( $new_roles, $old_roles ) {
|
675 |
+
* // your code here
|
676 |
+
* }
|
677 |
+
* ?>
|
678 |
+
*/
|
679 |
+
do_action( 'um_after_member_role_upgrade', $new_roles, $old_roles, $user_id );
|
680 |
+
|
681 |
+
//Update permalink
|
682 |
+
$this->generate_profile_slug( $user_id, true );
|
683 |
+
|
684 |
+
$this->remove_cache( $user_id );
|
685 |
+
}
|
686 |
+
|
687 |
+
|
688 |
+
/**
|
689 |
+
* Additional section for WP Profile page with UM data fields
|
690 |
+
*
|
691 |
+
* @param \WP_User $userdata User data
|
692 |
+
* @return void
|
693 |
+
*/
|
694 |
+
function profile_form_additional_section( $userdata ) {
|
695 |
+
|
696 |
+
/**
|
697 |
+
* UM hook
|
698 |
+
*
|
699 |
+
* @type filter
|
700 |
+
* @title um_user_profile_additional_fields
|
701 |
+
* @description Make additional content section
|
702 |
+
* @input_vars
|
703 |
+
* [{"var":"$content","type":"array","desc":"Additional section content"},
|
704 |
+
* {"var":"$userdata","type":"array","desc":"Userdata"}]
|
705 |
+
* @change_log
|
706 |
+
* ["Since: 2.0"]
|
707 |
+
* @usage
|
708 |
+
* <?php add_filter( 'um_user_profile_additional_fields', 'function_name', 10, 2 ); ?>
|
709 |
+
* @example
|
710 |
+
* <?php
|
711 |
+
* add_filter( 'um_user_profile_additional_fields', 'my_admin_pending_queue', 10, 2 );
|
712 |
+
* function my_admin_pending_queue( $content, $userdata ) {
|
713 |
+
* // your code here
|
714 |
+
* return $content;
|
715 |
+
* }
|
716 |
+
* ?>
|
717 |
+
*/
|
718 |
+
$section_content = apply_filters( 'um_user_profile_additional_fields', '', $userdata );
|
719 |
+
|
720 |
+
if ( ! empty( $section_content ) && ! ( is_multisite() && is_network_admin() ) ) {
|
721 |
+
|
722 |
+
if ( $userdata !== 'add-new-user' && $userdata !== 'add-existing-user' ) { ?>
|
723 |
+
<h3 id="um_user_screen_block"><?php esc_html_e( 'Ultimate Member', 'ultimate-member' ); ?></h3>
|
724 |
+
<?php }
|
725 |
+
|
726 |
+
echo $section_content;
|
727 |
+
}
|
728 |
+
}
|
729 |
+
|
730 |
+
|
731 |
+
/**
|
732 |
+
* Default interface for setting a ultimatemember role
|
733 |
+
*
|
734 |
+
* @param string $content Section HTML
|
735 |
+
* @param \WP_User $userdata User data
|
736 |
+
* @return string
|
737 |
+
*/
|
738 |
+
public function secondary_role_field( $content, $userdata ) {
|
739 |
+
$roles = array();
|
740 |
+
|
741 |
+
$role_keys = get_option( 'um_roles', array() );
|
742 |
+
if ( $role_keys ) {
|
743 |
+
foreach ( $role_keys as $role_key ) {
|
744 |
+
$role_meta = get_option( "um_role_{$role_key}_meta" );
|
745 |
+
|
746 |
+
if ( $role_meta ) {
|
747 |
+
$roles[ 'um_' . $role_key ] = $role_meta;
|
748 |
+
}
|
749 |
+
}
|
750 |
+
}
|
751 |
+
|
752 |
+
if ( empty( $roles ) ) {
|
753 |
+
return $content;
|
754 |
+
}
|
755 |
+
|
756 |
+
global $pagenow;
|
757 |
+
if ( 'profile.php' == $pagenow ) {
|
758 |
+
return $content;
|
759 |
+
}
|
760 |
+
|
761 |
+
$style = '';
|
762 |
+
$user_role = false;
|
763 |
+
if ( $userdata !== 'add-new-user' && $userdata !== 'add-existing-user' ) {
|
764 |
+
// Bail if current user cannot edit users
|
765 |
+
if ( ! current_user_can( 'edit_user', $userdata->ID ) ) {
|
766 |
+
return $content;
|
767 |
+
}
|
768 |
+
|
769 |
+
$user_role = UM()->roles()->get_um_user_role( $userdata->ID );
|
770 |
+
if ( $user_role && ! empty( $userdata->roles ) && count( $userdata->roles ) == 1 ) {
|
771 |
+
$style = 'style="display:none;"';
|
772 |
+
}
|
773 |
+
|
774 |
+
}
|
775 |
+
|
776 |
+
$class = ( $userdata == 'add-existing-user' ) ? 'um_role_existing_selector_wrapper' : 'um_role_selector_wrapper';
|
777 |
+
|
778 |
+
ob_start(); ?>
|
779 |
+
|
780 |
+
<div id="<?php echo esc_attr( $class ) ?>" <?php echo $style ?>>
|
781 |
+
<table class="form-table">
|
782 |
+
<tbody>
|
783 |
+
<tr>
|
784 |
+
<th><label for="um-role"><?php esc_html_e( 'Ultimate Member Role', 'ultimate-member' ); ?></label></th>
|
785 |
+
<td>
|
786 |
+
<select name="um-role" id="um-role">
|
787 |
+
<option value="" <?php selected( empty( $user_role ) ) ?>><?php esc_html_e( '— No role for Ultimate Member —', 'ultimate-member' ); ?></option>
|
788 |
+
<?php foreach ( $roles as $role_id => $details ) { ?>
|
789 |
+
<option <?php selected( $user_role, $role_id ); ?> value="<?php echo esc_attr( $role_id ); ?>"><?php echo esc_html( $details['name'] ); ?></option>
|
790 |
+
<?php } ?>
|
791 |
+
</select>
|
792 |
+
</td>
|
793 |
+
</tr>
|
794 |
+
</tbody>
|
795 |
+
</table>
|
796 |
+
</div>
|
797 |
+
|
798 |
+
<?php $content .= ob_get_clean();
|
799 |
+
|
800 |
+
return $content;
|
801 |
+
}
|
802 |
+
|
803 |
+
|
804 |
+
/**
|
805 |
+
* Remove cached queue from Users backend
|
806 |
+
*/
|
807 |
+
function remove_cached_queue() {
|
808 |
+
delete_option( 'um_cached_users_queue' );
|
809 |
+
}
|
810 |
+
|
811 |
+
|
812 |
+
/**
|
813 |
+
* Converts object to array
|
814 |
+
*
|
815 |
+
* @param $obj
|
816 |
+
*
|
817 |
+
* @return array
|
818 |
+
*/
|
819 |
+
function toArray( $obj ) {
|
820 |
+
if ( is_object( $obj ) ) {
|
821 |
+
$obj = (array) $obj;
|
822 |
+
}
|
823 |
+
if ( is_array( $obj ) ) {
|
824 |
+
$new = array();
|
825 |
+
foreach ( $obj as $key => $val ) {
|
826 |
+
$new[ $key ] = $this->toArray( $val );
|
827 |
+
}
|
828 |
+
} else {
|
829 |
+
$new = $obj;
|
830 |
+
}
|
831 |
+
|
832 |
+
return $new;
|
833 |
+
}
|
834 |
+
|
835 |
+
|
836 |
+
/**
|
837 |
+
* @param $user_id
|
838 |
+
*
|
839 |
+
* @return mixed|string
|
840 |
+
*/
|
841 |
+
function get_cached_data( $user_id ) {
|
842 |
+
|
843 |
+
$disallow_cache = UM()->options()->get( 'um_profile_object_cache_stop' );
|
844 |
+
if ( $disallow_cache ) {
|
845 |
+
return '';
|
846 |
+
}
|
847 |
+
|
848 |
+
if ( is_numeric( $user_id ) && $user_id > 0 ) {
|
849 |
+
$find_user = get_option( "um_cache_userdata_{$user_id}" );
|
850 |
+
if ( $find_user ) {
|
851 |
+
/**
|
852 |
+
* UM hook
|
853 |
+
*
|
854 |
+
* @type filter
|
855 |
+
* @title um_user_permissions_filter
|
856 |
+
* @description Change User Permissions
|
857 |
+
* @input_vars
|
858 |
+
* [{"var":"$permissions","type":"array","desc":"User Permissions"},
|
859 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
860 |
+
* @change_log
|
861 |
+
* ["Since: 2.0"]
|
862 |
+
* @usage
|
863 |
+
* <?php add_filter( 'um_user_permissions_filter', 'function_name', 10, 2 ); ?>
|
864 |
+
* @example
|
865 |
+
* <?php
|
866 |
+
* add_filter( 'um_user_permissions_filter', 'my_user_permissions', 10, 2 );
|
867 |
+
* function my_user_permissions( $permissions, $user_id ) {
|
868 |
+
* // your code here
|
869 |
+
* return $permissions;
|
870 |
+
* }
|
871 |
+
* ?>
|
872 |
+
*/
|
873 |
+
$find_user = apply_filters( 'um_user_permissions_filter', $find_user, $user_id );
|
874 |
+
return $find_user;
|
875 |
+
}
|
876 |
+
}
|
877 |
+
return '';
|
878 |
+
}
|
879 |
+
|
880 |
+
|
881 |
+
/**
|
882 |
+
* @param $user_id
|
883 |
+
* @param $profile
|
884 |
+
*/
|
885 |
+
function setup_cache( $user_id, $profile ) {
|
886 |
+
|
887 |
+
$disallow_cache = UM()->options()->get( 'um_profile_object_cache_stop' );
|
888 |
+
if ( $disallow_cache ) {
|
889 |
+
return;
|
890 |
+
}
|
891 |
+
|
892 |
+
update_option( "um_cache_userdata_{$user_id}", $profile, false );
|
893 |
+
}
|
894 |
+
|
895 |
+
|
896 |
+
/**
|
897 |
+
* @param $user_id
|
898 |
+
*/
|
899 |
+
function remove_cache( $user_id ) {
|
900 |
+
delete_option( "um_cache_userdata_{$user_id}" );
|
901 |
+
}
|
902 |
+
|
903 |
+
|
904 |
+
/**
|
905 |
+
* Remove cache for all users
|
906 |
+
*/
|
907 |
+
function remove_cache_all_users() {
|
908 |
+
global $wpdb;
|
909 |
+
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
|
910 |
+
}
|
911 |
+
|
912 |
+
|
913 |
+
/**
|
914 |
+
* This method lets you set a user. For example, to retrieve a profile or anything related to that user.
|
915 |
+
*
|
916 |
+
* @usage <?php UM()->user()->set( $user_id, $clean = false ); ?>
|
917 |
+
*
|
918 |
+
* @param null|int $user_id Which user to retrieve. A numeric user ID
|
919 |
+
* @param bool $clean Should be true or false. Basically, if you did not provide a user ID It will set the current logged in user as a profile
|
920 |
+
*
|
921 |
+
* @example The following example makes you set a user and retrieve their display name after that using the user API.
|
922 |
+
|
923 |
+
<?php
|
924 |
+
|
925 |
+
UM()->user()->set( 12 );
|
926 |
+
$display_name = UM()->user()->profile['display_name']; // Should print user display name
|
927 |
+
|
928 |
+
?>
|
929 |
+
*
|
930 |
+
*/
|
931 |
+
function set( $user_id = null, $clean = false ) {
|
932 |
+
if ( isset( $this->profile ) ) {
|
933 |
+
unset( $this->profile );
|
934 |
+
}
|
935 |
+
|
936 |
+
if ( $user_id ) {
|
937 |
+
$this->id = $user_id;
|
938 |
+
} elseif ( is_user_logged_in() && $clean == false ) {
|
939 |
+
$this->id = get_current_user_id();
|
940 |
+
} else {
|
941 |
+
$this->id = 0;
|
942 |
+
}
|
943 |
+
|
944 |
+
if ( $this->get_cached_data( $this->id ) ) {
|
945 |
+
$this->profile = $this->get_cached_data( $this->id );
|
946 |
+
} else {
|
947 |
+
|
948 |
+
if ( $user_id ) {
|
949 |
+
|
950 |
+
$this->id = $user_id;
|
951 |
+
$this->usermeta = get_user_meta( $user_id );
|
952 |
+
$this->data = get_userdata( $this->id );
|
953 |
+
|
954 |
+
} elseif ( is_user_logged_in() && $clean == false ) {
|
955 |
+
|
956 |
+
$this->id = get_current_user_id();
|
957 |
+
$this->usermeta = get_user_meta($this->id);
|
958 |
+
$this->data = get_userdata($this->id);
|
959 |
+
|
960 |
+
} else {
|
961 |
+
|
962 |
+
$this->id = 0;
|
963 |
+
$this->usermeta = null;
|
964 |
+
$this->data = null;
|
965 |
+
|
966 |
+
}
|
967 |
+
|
968 |
+
// we have a user, populate a profile
|
969 |
+
if ( $this->id && $this->toArray( $this->data ) ) {
|
970 |
+
|
971 |
+
// add user data
|
972 |
+
$this->data = $this->toArray( $this->data );
|
973 |
+
|
974 |
+
foreach ( $this->data as $k=>$v ) {
|
975 |
+
if ( $k == 'roles') {
|
976 |
+
$this->profile['wp_roles'] = implode(',',$v);
|
977 |
+
} else if ( is_array( $v ) ) {
|
978 |
+
foreach($v as $k2 => $v2){
|
979 |
+
$this->profile[$k2] = $v2;
|
980 |
+
}
|
981 |
+
} else {
|
982 |
+
$this->profile[$k] = $v;
|
983 |
+
}
|
984 |
+
}
|
985 |
+
|
986 |
+
// add account status
|
987 |
+
if ( !isset( $this->usermeta['account_status'][0] ) ) {
|
988 |
+
$this->usermeta['account_status'][0] = 'approved';
|
989 |
+
}
|
990 |
+
|
991 |
+
if ( $this->usermeta['account_status'][0] == 'approved' ) {
|
992 |
+
$this->usermeta['account_status_name'][0] = __('Approved','ultimate-member');
|
993 |
+
}
|
994 |
+
|
995 |
+
if ( $this->usermeta['account_status'][0] == 'awaiting_email_confirmation' ) {
|
996 |
+
$this->usermeta['account_status_name'][0] = __('Awaiting E-mail Confirmation','ultimate-member');
|
997 |
+
}
|
998 |
+
|
999 |
+
if ( $this->usermeta['account_status'][0] == 'awaiting_admin_review' ) {
|
1000 |
+
$this->usermeta['account_status_name'][0] = __('Pending Review','ultimate-member');
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
if ( $this->usermeta['account_status'][0] == 'rejected' ) {
|
1004 |
+
$this->usermeta['account_status_name'][0] = __('Membership Rejected','ultimate-member');
|
1005 |
+
}
|
1006 |
+
|
1007 |
+
if ( $this->usermeta['account_status'][0] == 'inactive' ) {
|
1008 |
+
$this->usermeta['account_status_name'][0] = __('Membership Inactive','ultimate-member');
|
1009 |
+
}
|
1010 |
+
|
1011 |
+
// add user meta
|
1012 |
+
foreach ( $this->usermeta as $k => $v ) {
|
1013 |
+
if ( $k == 'display_name') {
|
1014 |
+
continue;
|
1015 |
+
}
|
1016 |
+
$this->profile[ $k ] = $v[0];
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
// add permissions
|
1020 |
+
$user_role = UM()->roles()->get_priority_user_role( $this->id );
|
1021 |
+
$this->profile['role'] = $user_role;
|
1022 |
+
$this->profile['roles'] = UM()->roles()->get_all_user_roles( $this->id );
|
1023 |
+
|
1024 |
+
$role_meta = UM()->roles()->role_data( $user_role );
|
1025 |
+
/**
|
1026 |
+
* UM hook
|
1027 |
+
*
|
1028 |
+
* @type filter
|
1029 |
+
* @title um_user_permissions_filter
|
1030 |
+
* @description Change User Permissions
|
1031 |
+
* @input_vars
|
1032 |
+
* [{"var":"$permissions","type":"array","desc":"User Permissions"},
|
1033 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
1034 |
+
* @change_log
|
1035 |
+
* ["Since: 2.0"]
|
1036 |
+
* @usage
|
1037 |
+
* <?php add_filter( 'um_user_permissions_filter', 'function_name', 10, 2 ); ?>
|
1038 |
+
* @example
|
1039 |
+
* <?php
|
1040 |
+
* add_filter( 'um_user_permissions_filter', 'my_user_permissions', 10, 2 );
|
1041 |
+
* function my_user_permissions( $permissions, $user_id ) {
|
1042 |
+
* // your code here
|
1043 |
+
* return $permissions;
|
1044 |
+
* }
|
1045 |
+
* ?>
|
1046 |
+
*/
|
1047 |
+
$role_meta = apply_filters( 'um_user_permissions_filter', $role_meta, $this->id );
|
1048 |
+
|
1049 |
+
/*$role_meta = array_map( function( $key, $item ) {
|
1050 |
+
if ( strpos( $key, '_um_' ) === 0 )
|
1051 |
+
$key = str_replace( '_um_', '', $key );
|
1052 |
+
|
1053 |
+
return array( $key => $item );
|
1054 |
+
}, array_keys( $role_meta ), $role_meta );*/
|
1055 |
+
|
1056 |
+
$this->profile = array_merge( $this->profile, (array)$role_meta );
|
1057 |
+
|
1058 |
+
$this->profile['super_admin'] = ( is_super_admin( $this->id ) ) ? 1 : 0;
|
1059 |
+
|
1060 |
+
// clean profile
|
1061 |
+
$this->clean();
|
1062 |
+
|
1063 |
+
// Setup cache
|
1064 |
+
$this->setup_cache( $this->id, $this->profile );
|
1065 |
+
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
}
|
1069 |
+
|
1070 |
+
}
|
1071 |
+
|
1072 |
+
|
1073 |
+
/**
|
1074 |
+
* Reset user data
|
1075 |
+
*
|
1076 |
+
* @param bool $clean
|
1077 |
+
*/
|
1078 |
+
function reset( $clean = false ){
|
1079 |
+
$this->set(0, $clean);
|
1080 |
+
}
|
1081 |
+
|
1082 |
+
|
1083 |
+
/**
|
1084 |
+
* Clean user profile
|
1085 |
+
*/
|
1086 |
+
function clean() {
|
1087 |
+
foreach ( $this->profile as $key => $value ) {
|
1088 |
+
foreach ( $this->banned_keys as $ban ) {
|
1089 |
+
if ( strstr( $key, $ban ) || is_numeric( $key ) ) {
|
1090 |
+
unset( $this->profile[ $key ] );
|
1091 |
+
}
|
1092 |
+
}
|
1093 |
+
}
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
|
1097 |
+
/**
|
1098 |
+
* This method lets you auto sign-in a user to your site.
|
1099 |
+
*
|
1100 |
+
* @usage <?php UM()->user()->auto_login( $user_id, $rememberme = false ); ?>
|
1101 |
+
*
|
1102 |
+
* @param int $user_id Which user ID to sign in automatically
|
1103 |
+
* @param int|bool $rememberme Should be true or false. If you want the user sign in session to use cookies, use true
|
1104 |
+
*
|
1105 |
+
* @example The following example lets you sign in a user automatically by their ID.
|
1106 |
+
|
1107 |
+
<?php UM()->user()->auto_login( 2 ); ?>
|
1108 |
+
*
|
1109 |
+
*
|
1110 |
+
* @example The following example lets you sign in a user automatically by their ID and makes the plugin remember their session.
|
1111 |
+
|
1112 |
+
<?php UM()->user()->auto_login( 10, true ); ?>
|
1113 |
+
*
|
1114 |
+
*/
|
1115 |
+
function auto_login( $user_id, $rememberme = 0 ) {
|
1116 |
+
|
1117 |
+
wp_set_current_user( $user_id );
|
1118 |
+
|
1119 |
+
wp_set_auth_cookie( $user_id, $rememberme );
|
1120 |
+
|
1121 |
+
$user = get_user_by( 'ID', $user_id );
|
1122 |
+
|
1123 |
+
do_action( 'wp_login', $user->user_login, $user );
|
1124 |
+
|
1125 |
+
}
|
1126 |
+
|
1127 |
+
|
1128 |
+
/**
|
1129 |
+
* Set user's registration details
|
1130 |
+
*
|
1131 |
+
* @param array $submitted
|
1132 |
+
* @param array $args
|
1133 |
+
*/
|
1134 |
+
function set_registration_details( $submitted, $args ) {
|
1135 |
+
|
1136 |
+
if ( isset( $submitted['user_pass'] ) ) {
|
1137 |
+
unset( $submitted['user_pass'] );
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
if ( isset( $submitted['user_password'] ) ) {
|
1141 |
+
unset( $submitted['user_password'] );
|
1142 |
+
}
|
1143 |
+
|
1144 |
+
if ( isset( $submitted['confirm_user_password'] ) ) {
|
1145 |
+
unset( $submitted['confirm_user_password'] );
|
1146 |
+
}
|
1147 |
+
|
1148 |
+
//remove all password field values from submitted details
|
1149 |
+
$password_fields = array();
|
1150 |
+
foreach ( $submitted as $k => $v ) {
|
1151 |
+
if ( UM()->fields()->get_field_type( $k ) == 'password' ) {
|
1152 |
+
$password_fields[] = $k;
|
1153 |
+
$password_fields[] = 'confirm_' . $k;
|
1154 |
+
}
|
1155 |
+
}
|
1156 |
+
|
1157 |
+
foreach ( $password_fields as $pw_field ) {
|
1158 |
+
unset( $submitted[ $pw_field ] );
|
1159 |
+
}
|
1160 |
+
|
1161 |
+
|
1162 |
+
/**
|
1163 |
+
* UM hook
|
1164 |
+
*
|
1165 |
+
* @type filter
|
1166 |
+
* @title um_before_save_filter_submitted
|
1167 |
+
* @description Change submitted data before save usermeta "submitted" on registration process
|
1168 |
+
* @input_vars
|
1169 |
+
* [{"var":"$submitted","type":"array","desc":"Submitted data"},
|
1170 |
+
* {"var":"$args","type":"array","desc":"Form Args"}]
|
1171 |
+
* @change_log
|
1172 |
+
* ["Since: 2.0"]
|
1173 |
+
* @usage
|
1174 |
+
* <?php add_filter( 'um_before_save_filter_submitted', 'function_name', 10, 2 ); ?>
|
1175 |
+
* @example
|
1176 |
+
* <?php
|
1177 |
+
* add_filter( 'um_before_save_filter_submitted', 'my_before_save_filter_submitted', 10, 2 );
|
1178 |
+
* function my_before_save_filter_submitted( $submitted, $args ) {
|
1179 |
+
* // your code here
|
1180 |
+
* return $submitted;
|
1181 |
+
* }
|
1182 |
+
* ?>
|
1183 |
+
*/
|
1184 |
+
$submitted = apply_filters( 'um_before_save_filter_submitted', $submitted, $args );
|
1185 |
+
|
1186 |
+
/**
|
1187 |
+
* UM hook
|
1188 |
+
*
|
1189 |
+
* @type action
|
1190 |
+
* @title um_before_save_registration_details
|
1191 |
+
* @description Action on user registration before save details
|
1192 |
+
* @input_vars
|
1193 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
1194 |
+
* {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
|
1195 |
+
* @change_log
|
1196 |
+
* ["Since: 2.0"]
|
1197 |
+
* @usage add_action( 'um_before_save_registration_details', 'function_name', 10, 2 );
|
1198 |
+
* @example
|
1199 |
+
* <?php
|
1200 |
+
* add_action( 'um_before_save_registration_details', 'my_before_save_registration_details', 10, 2 );
|
1201 |
+
* function my_before_save_registration_details( $user_id, $submitted ) {
|
1202 |
+
* // your code here
|
1203 |
+
* }
|
1204 |
+
* ?>
|
1205 |
+
*/
|
1206 |
+
do_action( 'um_before_save_registration_details', $this->id, $submitted );
|
1207 |
+
|
1208 |
+
update_user_meta( $this->id, 'submitted', $submitted );
|
1209 |
+
|
1210 |
+
$this->update_profile( $submitted );
|
1211 |
+
/**
|
1212 |
+
* UM hook
|
1213 |
+
*
|
1214 |
+
* @type action
|
1215 |
+
* @title um_after_save_registration_details
|
1216 |
+
* @description Action on user registration after save details
|
1217 |
+
* @input_vars
|
1218 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
1219 |
+
* {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
|
1220 |
+
* @change_log
|
1221 |
+
* ["Since: 2.0"]
|
1222 |
+
* @usage add_action( 'um_after_save_registration_details', 'function_name', 10, 2 );
|
1223 |
+
* @example
|
1224 |
+
* <?php
|
1225 |
+
* add_action( 'um_after_save_registration_details', 'my_after_save_registration_details', 10, 2 );
|
1226 |
+
* function my_after_save_registration_details( $user_id, $submitted ) {
|
1227 |
+
* // your code here
|
1228 |
+
* }
|
1229 |
+
* ?>
|
1230 |
+
*/
|
1231 |
+
do_action( 'um_after_save_registration_details', $this->id, $submitted );
|
1232 |
+
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
|
1236 |
+
/**
|
1237 |
+
* Set last login for new registered users
|
1238 |
+
*/
|
1239 |
+
function set_last_login() {
|
1240 |
+
update_user_meta( $this->id, '_um_last_login', current_time( 'timestamp' ) );
|
1241 |
+
}
|
1242 |
+
|
1243 |
+
|
1244 |
+
/**
|
1245 |
+
* Set user's account status
|
1246 |
+
*
|
1247 |
+
* @param $status
|
1248 |
+
*/
|
1249 |
+
function set_status( $status ) {
|
1250 |
+
|
1251 |
+
/**
|
1252 |
+
* UM hook
|
1253 |
+
*
|
1254 |
+
* @type action
|
1255 |
+
* @title um_when_status_is_set
|
1256 |
+
* @description Action on user status changed
|
1257 |
+
* @input_vars
|
1258 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
1259 |
+
* @change_log
|
1260 |
+
* ["Since: 2.0"]
|
1261 |
+
* @usage add_action( 'um_when_status_is_set', 'function_name', 10, 1 );
|
1262 |
+
* @example
|
1263 |
+
* <?php
|
1264 |
+
* add_action( 'um_when_status_is_set', 'my_when_status_is_set', 10, 1 );
|
1265 |
+
* function my_when_status_is_set( $user_id ) {
|
1266 |
+
* // your code here
|
1267 |
+
* }
|
1268 |
+
* ?>
|
1269 |
+
*/
|
1270 |
+
do_action( 'um_when_status_is_set', um_user( 'ID' ) );
|
1271 |
+
|
1272 |
+
$this->profile['account_status'] = $status;
|
1273 |
+
|
1274 |
+
$this->update_usermeta_info( 'account_status' );
|
1275 |
+
|
1276 |
+
/**
|
1277 |
+
* UM hook
|
1278 |
+
*
|
1279 |
+
* @type action
|
1280 |
+
* @title um_after_user_status_is_changed_hook
|
1281 |
+
* @description Action after user status changed
|
1282 |
+
* @input_vars
|
1283 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
1284 |
+
* @change_log
|
1285 |
+
* ["Since: 2.0"]
|
1286 |
+
* @usage add_action( 'um_after_user_status_is_changed_hook', 'function_name', 10 );
|
1287 |
+
* @example
|
1288 |
+
* <?php
|
1289 |
+
* add_action( 'um_after_user_status_is_changed_hook', 'my_after_user_status_is_changed', 10 );
|
1290 |
+
* function my_after_user_status_is_changed() {
|
1291 |
+
* // your code here
|
1292 |
+
* }
|
1293 |
+
* ?>
|
1294 |
+
*/
|
1295 |
+
do_action( 'um_after_user_status_is_changed_hook', um_user( 'ID' ) );
|
1296 |
+
|
1297 |
+
/**
|
1298 |
+
* UM hook
|
1299 |
+
*
|
1300 |
+
* @type action
|
1301 |
+
* @title um_after_user_status_is_changed
|
1302 |
+
* @description Action after user status changed
|
1303 |
+
* @input_vars
|
1304 |
+
* [{"var":"$status","type":"string","desc":"User Status"},
|
1305 |
+
* {"var":"$user_id","type":"integer","desc":"User ID"}]
|
1306 |
+
* @change_log
|
1307 |
+
* ["Since: 2.0"]
|
1308 |
+
* @usage add_action( 'um_after_user_status_is_changed', 'function_name', 10, 1 );
|
1309 |
+
* @example
|
1310 |
+
* <?php
|
1311 |
+
* add_action( 'um_after_user_status_is_changed', 'my_after_user_status_is_changed', 10, 1 );
|
1312 |
+
* function my_after_user_status_is_changed( $status ) {
|
1313 |
+
* // your code here
|
1314 |
+
* }
|
1315 |
+
* ?>
|
1316 |
+
*/
|
1317 |
+
do_action( 'um_after_user_status_is_changed', $status, um_user( 'ID' ) );
|
1318 |
+
|
1319 |
+
}
|
1320 |
+
|
1321 |
+
|
1322 |
+
/**
|
1323 |
+
* Set user's hash
|
1324 |
+
*/
|
1325 |
+
function assign_secretkey() {
|
1326 |
+
/**
|
1327 |
+
* UM hook
|
1328 |
+
*
|
1329 |
+
* @type action
|
1330 |
+
* @title um_before_user_hash_is_changed
|
1331 |
+
* @description Action before user hash is changed
|
1332 |
+
* @change_log
|
1333 |
+
* ["Since: 2.0"]
|
1334 |
+
* @usage add_action( 'um_before_user_hash_is_changed', 'function_name', 10 );
|
1335 |
+
* @example
|
1336 |
+
* <?php
|
1337 |
+
* add_action( 'um_before_user_hash_is_changed', 'my_before_user_hash_is_changed', 10 );
|
1338 |
+
* function my_before_user_hash_is_changed() {
|
1339 |
+
* // your code here
|
1340 |
+
* }
|
1341 |
+
* ?>
|
1342 |
+
*/
|
1343 |
+
do_action( 'um_before_user_hash_is_changed' );
|
1344 |
+
|
1345 |
+
$this->profile['account_secret_hash'] = UM()->validation()->generate();
|
1346 |
+
$this->update_usermeta_info( 'account_secret_hash' );
|
1347 |
+
|
1348 |
+
$expiry_time = UM()->options()->get( 'activation_link_expiry_time' );
|
1349 |
+
if ( ! empty( $expiry_time ) && is_numeric( $expiry_time ) ) {
|
1350 |
+
$this->profile['account_secret_hash_expiry'] = time() + $expiry_time;
|
1351 |
+
$this->update_usermeta_info( 'account_secret_hash_expiry' );
|
1352 |
+
}
|
1353 |
+
|
1354 |
+
/**
|
1355 |
+
* UM hook
|
1356 |
+
*
|
1357 |
+
* @type action
|
1358 |
+
* @title um_after_user_hash_is_changed
|
1359 |
+
* @description Action after user hash is changed
|
1360 |
+
* @change_log
|
1361 |
+
* ["Since: 2.0"]
|
1362 |
+
* @usage add_action( 'um_after_user_hash_is_changed', 'function_name', 10 );
|
1363 |
+
* @example
|
1364 |
+
* <?php
|
1365 |
+
* add_action( 'um_after_user_hash_is_changed', 'my_after_user_hash_is_changed', 10 );
|
1366 |
+
* function my_after_user_hash_is_changed() {
|
1367 |
+
* // your code here
|
1368 |
+
* }
|
1369 |
+
* ?>
|
1370 |
+
*/
|
1371 |
+
do_action( 'um_after_user_hash_is_changed' );
|
1372 |
+
}
|
1373 |
+
|
1374 |
+
|
1375 |
+
/**
|
1376 |
+
* @param \WP_User $userdata
|
1377 |
+
*
|
1378 |
+
* @return string|\WP_Error
|
1379 |
+
*/
|
1380 |
+
function maybe_generate_password_reset_key( $userdata ) {
|
1381 |
+
if ( empty( $this->password_reset_key ) ) {
|
1382 |
+
$this->password_reset_key = get_password_reset_key( $userdata );
|
1383 |
+
}
|
1384 |
+
|
1385 |
+
return $this->password_reset_key ;
|
1386 |
+
}
|
1387 |
+
|
1388 |
+
|
1389 |
+
/**
|
1390 |
+
* Password reset email
|
1391 |
+
*/
|
1392 |
+
function password_reset() {
|
1393 |
+
$userdata = get_userdata( um_user( 'ID' ) );
|
1394 |
+
|
1395 |
+
$this->maybe_generate_password_reset_key( $userdata );
|
1396 |
+
|
1397 |
+
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
|
1398 |
+
add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ), 10, 1 );
|
1399 |
+
|
1400 |
+
UM()->mail()->send( um_user( 'user_email' ), 'resetpw_email' );
|
1401 |
+
}
|
1402 |
+
|
1403 |
+
|
1404 |
+
/**
|
1405 |
+
* Password changed email
|
1406 |
+
*/
|
1407 |
+
function password_changed() {
|
1408 |
+
UM()->mail()->send( um_user( 'user_email' ), 'changedpw_email' );
|
1409 |
+
}
|
1410 |
+
|
1411 |
+
|
1412 |
+
/**
|
1413 |
+
* This method approves a user membership and sends them an optional welcome/approval e-mail.
|
1414 |
+
*
|
1415 |
+
* @usage <?php UM()->user()->approve(); ?>
|
1416 |
+
*
|
1417 |
+
* @example Approve a pending user and allow him to sign-in to your site.
|
1418 |
+
|
1419 |
+
<?php
|
1420 |
+
|
1421 |
+
um_fetch_user( 352 );
|
1422 |
+
UM()->user()->approve();
|
1423 |
+
|
1424 |
+
?>
|
1425 |
+
*
|
1426 |
+
*/
|
1427 |
+
function approve( $repeat = true ) {
|
1428 |
+
$user_id = um_user('ID');
|
1429 |
+
|
1430 |
+
if ( ! $repeat ) {
|
1431 |
+
$status = get_user_meta( $user_id, 'account_status', true );
|
1432 |
+
if ( 'approved' === $status ) {
|
1433 |
+
return;
|
1434 |
+
}
|
1435 |
+
}
|
1436 |
+
|
1437 |
+
delete_option( "um_cache_userdata_{$user_id}" );
|
1438 |
+
|
1439 |
+
if ( um_user( 'account_status' ) == 'awaiting_admin_review' ) {
|
1440 |
+
$userdata = get_userdata( $user_id );
|
1441 |
+
|
1442 |
+
$this->maybe_generate_password_reset_key( $userdata );
|
1443 |
+
|
1444 |
+
UM()->mail()->send( um_user( 'user_email' ), 'approved_email' );
|
1445 |
+
|
1446 |
+
} else {
|
1447 |
+
//$userdata = get_userdata( $user_id );
|
1448 |
+
//get_password_reset_key( $userdata );
|
1449 |
+
UM()->mail()->send( um_user( 'user_email' ), 'welcome_email' );
|
1450 |
+
}
|
1451 |
+
|
1452 |
+
$this->set_status( 'approved' );
|
1453 |
+
$this->delete_meta( 'account_secret_hash' );
|
1454 |
+
$this->delete_meta( 'account_secret_hash_expiry' );
|
1455 |
+
|
1456 |
+
/**
|
1457 |
+
* UM hook
|
1458 |
+
*
|
1459 |
+
* @type action
|
1460 |
+
* @title um_after_user_is_approved
|
1461 |
+
* @description Action after user was approved
|
1462 |
+
* @input_vars
|
1463 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
1464 |
+
* @change_log
|
1465 |
+
* ["Since: 2.0"]
|
1466 |
+
* @usage add_action( 'um_after_user_is_approved', 'function_name', 10, 1 );
|
1467 |
+
* @example
|
1468 |
+
* <?php
|
1469 |
+
* add_action( 'um_after_user_is_approved', 'my_after_user_is_approved', 10, 1 );
|
1470 |
+
* function my_after_user_hash_is_changed( $user_id ) {
|
1471 |
+
* // your code here
|
1472 |
+
* }
|
1473 |
+
* ?>
|
1474 |
+
*/
|
1475 |
+
do_action( 'um_after_user_is_approved', um_user( 'ID' ) );
|
1476 |
+
}
|
1477 |
+
|
1478 |
+
|
1479 |
+
/**
|
1480 |
+
* Pending email
|
1481 |
+
*/
|
1482 |
+
function email_pending() {
|
1483 |
+
$this->assign_secretkey();
|
1484 |
+
$this->set_status( 'awaiting_email_confirmation' );
|
1485 |
+
UM()->mail()->send( um_user( 'user_email' ), 'checkmail_email' );
|
1486 |
+
}
|
1487 |
+
|
1488 |
+
|
1489 |
+
/**
|
1490 |
+
* This method puts a user under manual review by administrator and sends them an optional e-mail.
|
1491 |
+
*
|
1492 |
+
* @usage <?php UM()->user()->pending(); ?>
|
1493 |
+
*
|
1494 |
+
* @example An example of putting a user pending manual review
|
1495 |
+
|
1496 |
+
<?php
|
1497 |
+
|
1498 |
+
um_fetch_user( 54 );
|
1499 |
+
UM()->user()->pending();
|
1500 |
+
|
1501 |
+
?>
|
1502 |
+
*
|
1503 |
+
*/
|
1504 |
+
function pending() {
|
1505 |
+
$this->set_status( 'awaiting_admin_review' );
|
1506 |
+
UM()->mail()->send( um_user( 'user_email' ), 'pending_email' );
|
1507 |
+
}
|
1508 |
+
|
1509 |
+
|
1510 |
+
/**
|
1511 |
+
* This method rejects a user membership and sends them an optional e-mail.
|
1512 |
+
*
|
1513 |
+
* @usage <?php UM()->user()->reject(); ?>
|
1514 |
+
*
|
1515 |
+
* @example Reject a user membership example
|
1516 |
+
|
1517 |
+
<?php
|
1518 |
+
|
1519 |
+
um_fetch_user( 114 );
|
1520 |
+
UM()->user()->reject();
|
1521 |
+
|
1522 |
+
?>
|
1523 |
+
|
1524 |
+
*
|
1525 |
+
*/
|
1526 |
+
function reject() {
|
1527 |
+
$this->set_status( 'rejected' );
|
1528 |
+
UM()->mail()->send( um_user( 'user_email' ), 'rejected_email' );
|
1529 |
+
}
|
1530 |
+
|
1531 |
+
|
1532 |
+
/**
|
1533 |
+
* This method deactivates a user membership and sends them an optional e-mail.
|
1534 |
+
*
|
1535 |
+
* @usage <?php UM()->user()->deactivate(); ?>
|
1536 |
+
*
|
1537 |
+
* @example Deactivate a user membership with the following example
|
1538 |
+
|
1539 |
+
<?php
|
1540 |
+
|
1541 |
+
um_fetch_user( 32 );
|
1542 |
+
$ultimatemember->user->deactivate();
|
1543 |
+
|
1544 |
+
?>
|
1545 |
+
*
|
1546 |
+
*/
|
1547 |
+
function deactivate() {
|
1548 |
+
$this->set_status( 'inactive' );
|
1549 |
+
/**
|
1550 |
+
* UM hook
|
1551 |
+
*
|
1552 |
+
* @type action
|
1553 |
+
* @title um_after_user_is_inactive
|
1554 |
+
* @description Action after user was inactive
|
1555 |
+
* @input_vars
|
1556 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
1557 |
+
* @change_log
|
1558 |
+
* ["Since: 2.0"]
|
1559 |
+
* @usage add_action( 'um_after_user_is_inactive', 'function_name', 10, 1 );
|
1560 |
+
* @example
|
1561 |
+
* <?php
|
1562 |
+
* add_action( 'um_after_user_is_inactive', 'my_after_user_is_inactive', 10, 1 );
|
1563 |
+
* function my_after_user_is_inactive( $user_id ) {
|
1564 |
+
* // your code here
|
1565 |
+
* }
|
1566 |
+
* ?>
|
1567 |
+
*/
|
1568 |
+
do_action( 'um_after_user_is_inactive', um_user( 'ID' ) );
|
1569 |
+
|
1570 |
+
UM()->mail()->send( um_user( 'user_email' ), 'inactive_email' );
|
1571 |
+
}
|
1572 |
+
|
1573 |
+
|
1574 |
+
/**
|
1575 |
+
* Delete user
|
1576 |
+
*
|
1577 |
+
* @param bool $send_mail
|
1578 |
+
*/
|
1579 |
+
function delete( $send_mail = true ) {
|
1580 |
+
|
1581 |
+
$this->send_mail_on_delete = $send_mail;
|
1582 |
+
//don't send email notification to not approved user
|
1583 |
+
if ( 'approved' != um_user( 'account_status' ) ) {
|
1584 |
+
$this->send_mail_on_delete = false;
|
1585 |
+
}
|
1586 |
+
|
1587 |
+
// remove user
|
1588 |
+
if ( is_multisite() ) {
|
1589 |
+
|
1590 |
+
if ( ! function_exists( 'wpmu_delete_user' ) ) {
|
1591 |
+
require_once( ABSPATH . 'wp-admin/includes/ms.php' );
|
1592 |
+
}
|
1593 |
+
|
1594 |
+
wpmu_delete_user( $this->id );
|
1595 |
+
|
1596 |
+
} else {
|
1597 |
+
|
1598 |
+
if ( ! function_exists( 'wp_delete_user' ) ) {
|
1599 |
+
require_once( ABSPATH . 'wp-admin/includes/user.php' );
|
1600 |
+
}
|
1601 |
+
|
1602 |
+
wp_delete_user( $this->id );
|
1603 |
+
|
1604 |
+
}
|
1605 |
+
|
1606 |
+
}
|
1607 |
+
|
1608 |
+
|
1609 |
+
/**
|
1610 |
+
* This method gets a user role in slug format. e.g. member
|
1611 |
+
*
|
1612 |
+
* @usage <?php UM()->user()->get_role(); ?>
|
1613 |
+
*
|
1614 |
+
* @return string
|
1615 |
+
*
|
1616 |
+
* @example Do something if the user's role is paid-member
|
1617 |
+
|
1618 |
+
<?php
|
1619 |
+
|
1620 |
+
um_fetch_user( 12 );
|
1621 |
+
|
1622 |
+
if ( UM()->user()->get_role() == 'paid-member' ) {
|
1623 |
+
// Show this to paid customers
|
1624 |
+
} else {
|
1625 |
+
// You are a free member
|
1626 |
+
}
|
1627 |
+
|
1628 |
+
?>
|
1629 |
+
*
|
1630 |
+
*/
|
1631 |
+
function get_role() {
|
1632 |
+
if ( ! empty( $this->profile['role'] ) ) {
|
1633 |
+
return $this->profile['role'];
|
1634 |
+
} else {
|
1635 |
+
if ( ! empty( $this->profile['wp_roles'] ) && $this->profile['wp_roles'] == 'administrator' ) {
|
1636 |
+
return 'admin';
|
1637 |
+
} else {
|
1638 |
+
return 'member';
|
1639 |
+
}
|
1640 |
+
}
|
1641 |
+
}
|
1642 |
+
|
1643 |
+
|
1644 |
+
/**
|
1645 |
+
* Update one key in user meta
|
1646 |
+
*
|
1647 |
+
* @param $key
|
1648 |
+
*/
|
1649 |
+
function update_usermeta_info( $key ) {
|
1650 |
+
// delete the key first just in case
|
1651 |
+
delete_user_meta( $this->id, $key );
|
1652 |
+
update_user_meta( $this->id, $key, $this->profile[ $key ] );
|
1653 |
+
}
|
1654 |
+
|
1655 |
+
|
1656 |
+
/**
|
1657 |
+
* This method can be used to delete user's meta key.
|
1658 |
+
*
|
1659 |
+
* @usage <?php UM()->user()->delete_meta( $key ); ?>
|
1660 |
+
*
|
1661 |
+
* @param string $key The meta field key to remove from user
|
1662 |
+
*
|
1663 |
+
* @example Delete user's age field
|
1664 |
+
|
1665 |
+
<?php
|
1666 |
+
|
1667 |
+
um_fetch_user( 15 );
|
1668 |
+
UM()->user()->delete_meta( 'age' );
|
1669 |
+
|
1670 |
+
?>
|
1671 |
+
|
1672 |
+
*
|
1673 |
+
*/
|
1674 |
+
function delete_meta( $key ) {
|
1675 |
+
delete_user_meta( $this->id, $key );
|
1676 |
+
}
|
1677 |
+
|
1678 |
+
|
1679 |
+
/**
|
1680 |
+
* Get admin actions for individual user
|
1681 |
+
*
|
1682 |
+
* @return array|bool
|
1683 |
+
*/
|
1684 |
+
function get_admin_actions() {
|
1685 |
+
$items = array();
|
1686 |
+
|
1687 |
+
/**
|
1688 |
+
* UM hook
|
1689 |
+
*
|
1690 |
+
* @type filter
|
1691 |
+
* @title um_admin_user_actions_hook
|
1692 |
+
* @description Extend admin actions for each user
|
1693 |
+
* @input_vars
|
1694 |
+
* [{"var":"$actions","type":"array","desc":"Actions for user"}]
|
1695 |
+
* @change_log
|
1696 |
+
* ["Since: 2.0"]
|
1697 |
+
* @usage
|
1698 |
+
* <?php add_filter( 'um_admin_user_actions_hook', 'function_name', 10, 1 ); ?>
|
1699 |
+
* @example
|
1700 |
+
* <?php
|
1701 |
+
* add_filter( 'um_admin_user_actions_hook', 'my_admin_user_actions', 10, 1 );
|
1702 |
+
* function my_admin_user_actions( $actions ) {
|
1703 |
+
* // your code here
|
1704 |
+
* return $actions;
|
1705 |
+
* }
|
1706 |
+
* ?>
|
1707 |
+
*/
|
1708 |
+
$actions = apply_filters( 'um_admin_user_actions_hook', array(), um_profile_id() );
|
1709 |
+
if ( empty( $actions ) ) {
|
1710 |
+
return $items;
|
1711 |
+
}
|
1712 |
+
|
1713 |
+
foreach ( $actions as $id => $arr ) {
|
1714 |
+
$url = add_query_arg( array( 'um_action' => $id, 'uid' => um_profile_id() ) );
|
1715 |
+
/*$url = add_query_arg( 'um_action', $id );
|
1716 |
+
$url = add_query_arg( 'uid', um_profile_id(), $url );*/
|
1717 |
+
$items[] = '<a href="' . esc_url( $url ) .'" class="real_url ' . esc_attr( $id ) . '-item">' . esc_html( $arr['label'] ) . '</a>';
|
1718 |
+
}
|
1719 |
+
return $items;
|
1720 |
+
}
|
1721 |
+
|
1722 |
+
|
1723 |
+
/**
|
1724 |
+
* This method checks if the profile indexing is disabled
|
1725 |
+
*
|
1726 |
+
* @param int $user_id
|
1727 |
+
*
|
1728 |
+
* @since 2.1.16
|
1729 |
+
* @usage <?php UM()->user()->is_profile_noindex( $user_id ); ?>
|
1730 |
+
*
|
1731 |
+
* @return boolean Is the profile indexing disabled?
|
1732 |
+
*/
|
1733 |
+
function is_profile_noindex( $user_id ) {
|
1734 |
+
$profile_noindex = false;
|
1735 |
+
|
1736 |
+
if ( ! get_option( 'blog_public' ) ) {
|
1737 |
+
// Option "Search engine visibility" in [wp-admin > Settings > Reading]
|
1738 |
+
$profile_noindex = true;
|
1739 |
+
|
1740 |
+
} elseif ( $this->is_private_profile( $user_id ) ) {
|
1741 |
+
// Setting "Profile Privacy" in [Account > Privacy]
|
1742 |
+
$profile_noindex = true;
|
1743 |
+
|
1744 |
+
} elseif ( get_user_meta( $user_id, 'profile_noindex', true ) === '1' ) {
|
1745 |
+
// Setting "Avoid indexing my profile by search engines in [Account > Privacy]
|
1746 |
+
$profile_noindex = true;
|
1747 |
+
|
1748 |
+
}
|
1749 |
+
|
1750 |
+
if ( ! $profile_noindex ) {
|
1751 |
+
$role = UM()->roles()->get_priority_user_role( $user_id );
|
1752 |
+
$permissions = UM()->roles()->role_data( $role );
|
1753 |
+
|
1754 |
+
if ( isset( $permissions['profile_noindex'] ) && (bool) $permissions['profile_noindex'] ) {
|
1755 |
+
// Setting "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > User Roles > Edit Role]
|
1756 |
+
$profile_noindex = true;
|
1757 |
+
|
1758 |
+
} elseif ( ( ! isset( $permissions['profile_noindex'] ) || $permissions['profile_noindex'] === '' ) && (bool) UM()->options()->get( 'profile_noindex' ) ) {
|
1759 |
+
// Setting "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > Settings > General > Users]
|
1760 |
+
$profile_noindex = true;
|
1761 |
+
|
1762 |
+
}
|
1763 |
+
}
|
1764 |
+
|
1765 |
+
return apply_filters( 'um_user_is_profile_noindex', $profile_noindex, $user_id, $this );
|
1766 |
+
}
|
1767 |
+
|
1768 |
+
|
1769 |
+
/**
|
1770 |
+
* This method checks if give user profile is private.
|
1771 |
+
*
|
1772 |
+
* @usage <?php UM()->user()->is_private_profile( $user_id ); ?>
|
1773 |
+
*
|
1774 |
+
* @param int $user_id A user ID must be passed to check if the user profile is private
|
1775 |
+
*
|
1776 |
+
* @return bool
|
1777 |
+
*
|
1778 |
+
* @example This example display a specific user's name If his profile is public
|
1779 |
+
|
1780 |
+
<?php
|
1781 |
+
|
1782 |
+
um_fetch_user( 60 );
|
1783 |
+
$is_private = UM()->user()->is_private_profile( 60 );
|
1784 |
+
if ( ! $is_private ) {
|
1785 |
+
echo 'User is public and his name is ' . um_user('display_name');
|
1786 |
+
}
|
1787 |
+
|
1788 |
+
?>
|
1789 |
+
*
|
1790 |
+
*/
|
1791 |
+
function is_private_profile( $user_id ) {
|
1792 |
+
$privacy = get_user_meta( $user_id, 'profile_privacy', true );
|
1793 |
+
if ( $privacy == __( 'Only me', 'ultimate-member' ) || $privacy == 'Only me' ) {
|
1794 |
+
return true;
|
1795 |
+
}
|
1796 |
+
return $this->is_private_case( $user_id, $privacy );
|
1797 |
+
}
|
1798 |
+
|
1799 |
+
|
1800 |
+
/**
|
1801 |
+
* This method can be used to determine If a certain user is approved or not.
|
1802 |
+
*
|
1803 |
+
* @usage <?php UM()->user()->is_approved( $user_id ); ?>
|
1804 |
+
*
|
1805 |
+
* @param int $user_id The user ID to check approval status for
|
1806 |
+
*
|
1807 |
+
* @return bool
|
1808 |
+
*
|
1809 |
+
* @example Do something If a user's membership is approved
|
1810 |
+
|
1811 |
+
<?php
|
1812 |
+
|
1813 |
+
if ( UM()->user()->is_approved( 55 ) {
|
1814 |
+
// User account is approved
|
1815 |
+
} else {
|
1816 |
+
// User account is not approved
|
1817 |
+
}
|
1818 |
+
|
1819 |
+
?>
|
1820 |
+
*
|
1821 |
+
*/
|
1822 |
+
function is_approved( $user_id ) {
|
1823 |
+
$status = get_user_meta( $user_id, 'account_status', true );
|
1824 |
+
if ( $status == 'approved' || $status == '' ) {
|
1825 |
+
return true;
|
1826 |
+
}
|
1827 |
+
return false;
|
1828 |
+
}
|
1829 |
+
|
1830 |
+
|
1831 |
+
/**
|
1832 |
+
* Is private
|
1833 |
+
*
|
1834 |
+
* @param $user_id
|
1835 |
+
* @param $case
|
1836 |
+
*
|
1837 |
+
* @return bool
|
1838 |
+
*/
|
1839 |
+
function is_private_case( $user_id, $case ) {
|
1840 |
+
$privacy = get_user_meta( $user_id, 'profile_privacy', true );
|
1841 |
+
|
1842 |
+
if ( $privacy == $case ) {
|
1843 |
+
/**
|
1844 |
+
* UM hook
|
1845 |
+
*
|
1846 |
+
* @type filter
|
1847 |
+
* @title um_is_private_filter_hook
|
1848 |
+
* @description Change user privacy
|
1849 |
+
* @input_vars
|
1850 |
+
* [{"var":"$is_private","type":"bool","desc":"Is user private"},
|
1851 |
+
* {"var":"$privacy","type":"bool","desc":"Profile Privacy"},
|
1852 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
1853 |
+
* @change_log
|
1854 |
+
* ["Since: 2.0"]
|
1855 |
+
* @usage
|
1856 |
+
* <?php add_filter( 'um_is_private_filter_hook', 'function_name', 10, 3 ); ?>
|
1857 |
+
* @example
|
1858 |
+
* <?php
|
1859 |
+
* add_filter( 'um_is_private_filter_hook', 'my_is_private_filter', 10, 3 );
|
1860 |
+
* function my_is_private_filter( $is_private ) {
|
1861 |
+
* // your code here
|
1862 |
+
* return $is_private;
|
1863 |
+
* }
|
1864 |
+
* ?>
|
1865 |
+
*/
|
1866 |
+
$bool = apply_filters( 'um_is_private_filter_hook', false, $privacy, $user_id );
|
1867 |
+
return $bool;
|
1868 |
+
}
|
1869 |
+
|
1870 |
+
return false;
|
1871 |
+
}
|
1872 |
+
|
1873 |
+
|
1874 |
+
/**
|
1875 |
+
* Update files
|
1876 |
+
*
|
1877 |
+
* @param $changes
|
1878 |
+
*
|
1879 |
+
* @deprecated 2.1.0
|
1880 |
+
*/
|
1881 |
+
function update_files( $changes ) {
|
1882 |
+
um_deprecated_function( 'update_files', '2.1.0', '' );
|
1883 |
+
}
|
1884 |
+
|
1885 |
+
|
1886 |
+
/**
|
1887 |
+
* Update profile
|
1888 |
+
*
|
1889 |
+
* @param $changes
|
1890 |
+
*/
|
1891 |
+
function update_profile( $changes ) {
|
1892 |
+
|
1893 |
+
$args['ID'] = $this->id;
|
1894 |
+
|
1895 |
+
/**
|
1896 |
+
* UM hook
|
1897 |
+
*
|
1898 |
+
* @type filter
|
1899 |
+
* @title um_before_update_profile
|
1900 |
+
* @description Change update profile changes data
|
1901 |
+
* @input_vars
|
1902 |
+
* [{"var":"$changes","type":"array","desc":"User Profile Changes"},
|
1903 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
1904 |
+
* @change_log
|
1905 |
+
* ["Since: 2.0"]
|
1906 |
+
* @usage
|
1907 |
+
* <?php add_filter( 'um_before_update_profile', 'function_name', 10, 2 ); ?>
|
1908 |
+
* @example
|
1909 |
+
* <?php
|
1910 |
+
* add_filter( 'um_before_update_profile', 'my_before_update_profile', 10, 2 );
|
1911 |
+
* function my_before_update_profile( $changes, $user_id ) {
|
1912 |
+
* // your code here
|
1913 |
+
* return $changes;
|
1914 |
+
* }
|
1915 |
+
* ?>
|
1916 |
+
*/
|
1917 |
+
$changes = apply_filters( 'um_before_update_profile', $changes, $args['ID'] );
|
1918 |
+
|
1919 |
+
foreach ( $changes as $key => $value ) {
|
1920 |
+
if ( in_array( $key, $this->banned_keys ) ) {
|
1921 |
+
continue;
|
1922 |
+
}
|
1923 |
+
|
1924 |
+
if ( ! in_array( $key, $this->update_user_keys ) ) {
|
1925 |
+
if ( $value === 0 ) {
|
1926 |
+
update_user_meta( $this->id, $key, '0' );
|
1927 |
+
} else {
|
1928 |
+
update_user_meta( $this->id, $key, $value );
|
1929 |
+
}
|
1930 |
+
} else {
|
1931 |
+
$args[ $key ] = esc_attr( $changes[ $key ] );
|
1932 |
+
}
|
1933 |
+
}
|
1934 |
+
|
1935 |
+
|
1936 |
+
// update user
|
1937 |
+
if ( count( $args ) > 1 ) {
|
1938 |
+
//if isset roles argument validate role to properly for security reasons
|
1939 |
+
if ( isset( $args['role'] ) ) {
|
1940 |
+
global $wp_roles;
|
1941 |
+
$um_roles = get_option( 'um_roles', array() );
|
1942 |
+
|
1943 |
+
if ( ! empty( $um_roles ) ) {
|
1944 |
+
$role_keys = array_map( function( $item ) {
|
1945 |
+
return 'um_' . $item;
|
1946 |
+
}, $um_roles );
|
1947 |
+
} else {
|
1948 |
+
$role_keys = array();
|
1949 |
+
}
|
1950 |
+
|
1951 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
1952 |
+
|
1953 |
+
if ( in_array( $args['role'], $exclude_roles ) ) {
|
1954 |
+
unset( $args['role'] );
|
1955 |
+
}
|
1956 |
+
}
|
1957 |
+
|
1958 |
+
wp_update_user( $args );
|
1959 |
+
}
|
1960 |
+
|
1961 |
+
}
|
1962 |
+
|
1963 |
+
|
1964 |
+
/**
|
1965 |
+
* User exists by meta key and value
|
1966 |
+
*
|
1967 |
+
* @param $key
|
1968 |
+
* @param $value
|
1969 |
+
*
|
1970 |
+
* @return bool|int
|
1971 |
+
*/
|
1972 |
+
function user_has_metadata( $key, $value ) {
|
1973 |
+
|
1974 |
+
$value = UM()->validation()->safe_name_in_url( $value );
|
1975 |
+
|
1976 |
+
$ids = get_users( array( 'fields' => 'ID', 'meta_key' => $key, 'meta_value' => $value, 'meta_compare' => '=' ) );
|
1977 |
+
if ( ! isset( $ids ) || empty( $ids ) ) {
|
1978 |
+
return false;
|
1979 |
+
}
|
1980 |
+
|
1981 |
+
foreach ( $ids as $k => $id ) {
|
1982 |
+
|
1983 |
+
if ( $id == um_user('ID') ) {
|
1984 |
+
unset( $ids[ $k ] );
|
1985 |
+
} else {
|
1986 |
+
$duplicates[] = $id;
|
1987 |
+
}
|
1988 |
+
|
1989 |
+
}
|
1990 |
+
|
1991 |
+
if ( ! empty( $duplicates ) ) {
|
1992 |
+
return count( $duplicates );
|
1993 |
+
}
|
1994 |
+
return false;
|
1995 |
+
}
|
1996 |
+
|
1997 |
+
|
1998 |
+
/**
|
1999 |
+
* User exists by name
|
2000 |
+
*
|
2001 |
+
* @param $value
|
2002 |
+
*
|
2003 |
+
* @return bool
|
2004 |
+
*/
|
2005 |
+
function user_exists_by_name( $value ) {
|
2006 |
+
|
2007 |
+
// Permalink base
|
2008 |
+
$permalink_base = UM()->options()->get( 'permalink_base' );
|
2009 |
+
|
2010 |
+
$raw_value = $value;
|
2011 |
+
$value = UM()->validation()->safe_name_in_url( $value );
|
2012 |
+
$value = um_clean_user_basename( $value );
|
2013 |
+
|
2014 |
+
// Search by Profile Slug
|
2015 |
+
$args = array(
|
2016 |
+
'fields' => array( 'ID' ),
|
2017 |
+
'meta_query' => array(
|
2018 |
+
'relation' => 'OR',
|
2019 |
+
array(
|
2020 |
+
'key' => 'um_user_profile_url_slug_' . $permalink_base,
|
2021 |
+
'value' => strtolower( $raw_value ),
|
2022 |
+
'compare' => '=',
|
2023 |
+
),
|
2024 |
+
),
|
2025 |
+
);
|
2026 |
+
|
2027 |
+
|
2028 |
+
$ids = new \WP_User_Query( $args );
|
2029 |
+
|
2030 |
+
if ( $ids->total_users > 0 ) {
|
2031 |
+
$um_user_query = current( $ids->get_results() );
|
2032 |
+
return $um_user_query->ID;
|
2033 |
+
}
|
2034 |
+
|
2035 |
+
// Search by Display Name or ID
|
2036 |
+
$args = array(
|
2037 |
+
'fields' => array( 'ID' ),
|
2038 |
+
'search' => $value,
|
2039 |
+
'search_columns' => array( 'display_name', 'ID' ),
|
2040 |
+
);
|
2041 |
+
|
2042 |
+
$ids = new \WP_User_Query( $args );
|
2043 |
+
|
2044 |
+
if ( $ids->total_users > 0 ) {
|
2045 |
+
$um_user_query = current( $ids->get_results() );
|
2046 |
+
return $um_user_query->ID;
|
2047 |
+
}
|
2048 |
+
|
2049 |
+
|
2050 |
+
// Search By User Login
|
2051 |
+
$value = str_replace( ".", "_", $value );
|
2052 |
+
$value = str_replace( " ", "", $value );
|
2053 |
+
|
2054 |
+
$args = array(
|
2055 |
+
'fields' => array( 'ID' ),
|
2056 |
+
'search' => $value,
|
2057 |
+
'search_columns' => array(
|
2058 |
+
'user_login',
|
2059 |
+
)
|
2060 |
+
);
|
2061 |
+
|
2062 |
+
$ids = new \WP_User_Query( $args );
|
2063 |
+
|
2064 |
+
if ( $ids->total_users > 0 ) {
|
2065 |
+
$um_user_query = current( $ids->get_results() );
|
2066 |
+
return $um_user_query->ID;
|
2067 |
+
}
|
2068 |
+
|
2069 |
+
return false;
|
2070 |
+
}
|
2071 |
+
|
2072 |
+
|
2073 |
+
/**
|
2074 |
+
* This method checks if a user exists or not in your site based on the user ID.
|
2075 |
+
*
|
2076 |
+
* @usage <?php UM()->user()->user_exists_by_id( $user_id ); ?>
|
2077 |
+
*
|
2078 |
+
* @param int $user_id A user ID must be passed to check if the user exists
|
2079 |
+
*
|
2080 |
+
* @return bool|int
|
2081 |
+
*
|
2082 |
+
* @example Basic Usage
|
2083 |
+
|
2084 |
+
<?php
|
2085 |
+
|
2086 |
+
$boolean = UM()->user()->user_exists_by_id( 15 );
|
2087 |
+
if ( $boolean ) {
|
2088 |
+
// That user exists
|
2089 |
+
}
|
2090 |
+
|
2091 |
+
?>
|
2092 |
+
|
2093 |
+
*
|
2094 |
+
*/
|
2095 |
+
function user_exists_by_id( $user_id ) {
|
2096 |
+
$aux = get_userdata( absint( $user_id ) );
|
2097 |
+
if ( $aux == false ) {
|
2098 |
+
return false;
|
2099 |
+
} else {
|
2100 |
+
return $user_id;
|
2101 |
+
}
|
2102 |
+
}
|
2103 |
+
|
2104 |
+
|
2105 |
+
/**
|
2106 |
+
* This method checks if a user exists or not in your site based on the user email as username
|
2107 |
+
*
|
2108 |
+
* @param string $slug A user slug must be passed to check if the user exists
|
2109 |
+
*
|
2110 |
+
* @usage <?php UM()->user()->user_exists_by_email_as_username( $slug ); ?>
|
2111 |
+
*
|
2112 |
+
* @return bool
|
2113 |
+
*
|
2114 |
+
* @example Basic Usage
|
2115 |
+
|
2116 |
+
<?php
|
2117 |
+
|
2118 |
+
$boolean = UM()->user()->user_exists_by_email_as_username( 'calumgmail-com' );
|
2119 |
+
if ( $boolean ) {
|
2120 |
+
// That user exists
|
2121 |
+
}
|
2122 |
+
|
2123 |
+
?>
|
2124 |
+
*/
|
2125 |
+
function user_exists_by_email_as_username( $slug ) {
|
2126 |
+
|
2127 |
+
$user_id = false;
|
2128 |
+
|
2129 |
+
$ids = get_users( array( 'fields' => 'ID', 'meta_key' => 'um_email_as_username_' . $slug ) );
|
2130 |
+
if ( ! empty( $ids[0] ) ) {
|
2131 |
+
$user_id = $ids[0];
|
2132 |
+
}
|
2133 |
+
|
2134 |
+
return $user_id;
|
2135 |
+
}
|
2136 |
+
|
2137 |
+
|
2138 |
+
/**
|
2139 |
+
* Set gravatar hash id
|
2140 |
+
*
|
2141 |
+
* @param $user_id
|
2142 |
+
* @return string
|
2143 |
+
*/
|
2144 |
+
function set_gravatar( $user_id ) {
|
2145 |
+
|
2146 |
+
um_fetch_user( $user_id );
|
2147 |
+
$email_address = um_user( 'user_email' );
|
2148 |
+
$hash_email_address = '';
|
2149 |
+
|
2150 |
+
if ( $email_address ) {
|
2151 |
+
$hash_email_address = md5( $email_address );
|
2152 |
+
$this->profile['synced_gravatar_hashed_id'] = $hash_email_address;
|
2153 |
+
$this->update_usermeta_info( 'synced_gravatar_hashed_id' );
|
2154 |
+
}
|
2155 |
+
|
2156 |
+
return $hash_email_address;
|
2157 |
+
}
|
2158 |
+
|
2159 |
+
|
2160 |
+
/**
|
2161 |
+
* UM Placeholders for activation link in email
|
2162 |
+
*
|
2163 |
+
* @param $placeholders
|
2164 |
+
*
|
2165 |
+
* @return array
|
2166 |
+
*/
|
2167 |
+
function add_activation_placeholder( $placeholders ) {
|
2168 |
+
$placeholders[] = '{account_activation_link}';
|
2169 |
+
return $placeholders;
|
2170 |
+
}
|
2171 |
+
|
2172 |
+
|
2173 |
+
/**
|
2174 |
+
* UM Replace Placeholders for activation link in email
|
2175 |
+
*
|
2176 |
+
* @param $replace_placeholders
|
2177 |
+
*
|
2178 |
+
* @return array
|
2179 |
+
*/
|
2180 |
+
function add_activation_replace_placeholder( $replace_placeholders ) {
|
2181 |
+
$replace_placeholders[] = um_user( 'account_activation_link' );
|
2182 |
+
return $replace_placeholders;
|
2183 |
+
}
|
2184 |
+
}
|
2185 |
+
}
|
includes/core/class-validation.php
CHANGED
@@ -284,6 +284,27 @@ if ( ! class_exists( 'um\core\Validation' ) ) {
|
|
284 |
}
|
285 |
|
286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
/**
|
288 |
* Is url
|
289 |
*
|
@@ -396,4 +417,4 @@ if ( ! class_exists( 'um\core\Validation' ) ) {
|
|
396 |
}
|
397 |
|
398 |
}
|
399 |
-
}
|
284 |
}
|
285 |
|
286 |
|
287 |
+
/**
|
288 |
+
* Is Discord ID?
|
289 |
+
*
|
290 |
+
* @param $string
|
291 |
+
*
|
292 |
+
* @return bool
|
293 |
+
*/
|
294 |
+
public function is_discord_id( $string ) {
|
295 |
+
if ( ! $string ) {
|
296 |
+
return true;
|
297 |
+
}
|
298 |
+
if ( substr_count( $string, '#' ) > 1 ) {
|
299 |
+
return false;
|
300 |
+
}
|
301 |
+
if ( ! preg_match( '/^(.+)#(\d+)$/', trim( $string ) ) ) {
|
302 |
+
return false;
|
303 |
+
}
|
304 |
+
return true;
|
305 |
+
}
|
306 |
+
|
307 |
+
|
308 |
/**
|
309 |
* Is url
|
310 |
*
|
417 |
}
|
418 |
|
419 |
}
|
420 |
+
}
|
includes/core/um-actions-account.php
CHANGED
@@ -1,764 +1,768 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) ) {
|
2 |
-
exit;
|
3 |
-
}
|
4 |
-
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Validate for errors in account form
|
8 |
-
*
|
9 |
-
* @param array $args
|
10 |
-
*/
|
11 |
-
function um_submit_account_errors_hook( $args ) {
|
12 |
-
global $current_user;
|
13 |
-
|
14 |
-
if ( ! isset( $args['_um_account'] ) && ! isset( $args['_um_account_tab'] ) ) {
|
15 |
-
return;
|
16 |
-
}
|
17 |
-
|
18 |
-
$tab = sanitize_key( $args['_um_account_tab'] );
|
19 |
-
|
20 |
-
if ( ! wp_verify_nonce( $args[ 'um_account_nonce_' . $tab ], 'um_update_account_' . $tab ) ) {
|
21 |
-
UM()->form()->add_error( 'um_account_security', __( 'Are you hacking? Please try again!', 'ultimate-member' ) );
|
22 |
-
}
|
23 |
-
|
24 |
-
switch ( $tab ) {
|
25 |
-
case 'delete': {
|
26 |
-
// delete account
|
27 |
-
if ( UM()->account()->current_password_is_required( 'delete' ) ) {
|
28 |
-
if ( strlen( trim( sanitize_text_field( $args['single_user_password'] ) ) ) === 0 ) {
|
29 |
-
UM()->form()->add_error( 'single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
|
30 |
-
} else {
|
31 |
-
if ( ! wp_check_password( sanitize_text_field( $args['single_user_password'] ), $current_user->data->user_pass, $current_user->data->ID ) ) {
|
32 |
-
UM()->form()->add_error( 'single_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
33 |
-
}
|
34 |
-
}
|
35 |
-
}
|
36 |
-
|
37 |
-
UM()->account()->current_tab = 'delete';
|
38 |
-
|
39 |
-
break;
|
40 |
-
}
|
41 |
-
|
42 |
-
case 'password': {
|
43 |
-
|
44 |
-
// change password
|
45 |
-
UM()->account()->current_tab = 'password';
|
46 |
-
|
47 |
-
if ( isset( $args['user_password'] ) ) {
|
48 |
-
$args['user_password'] = sanitize_text_field( $args['user_password'] );
|
49 |
-
}
|
50 |
-
|
51 |
-
if ( isset( $args['confirm_user_password'] ) ) {
|
52 |
-
$args['confirm_user_password'] = sanitize_text_field( $args['confirm_user_password'] );
|
53 |
-
}
|
54 |
-
|
55 |
-
if ( empty( $args['user_password'] ) ) {
|
56 |
-
UM()->form()->add_error( 'user_password', __( 'Password is required', 'ultimate-member' ) );
|
57 |
-
return;
|
58 |
-
}
|
59 |
-
|
60 |
-
if ( empty( $args['confirm_user_password'] ) ) {
|
61 |
-
UM()->form()->add_error( 'user_password', __( 'Password confirmation is required', 'ultimate-member' ) );
|
62 |
-
return;
|
63 |
-
}
|
64 |
-
|
65 |
-
if ( ! empty( $args['user_password'] ) && ! empty( $args['confirm_user_password'] ) ) {
|
66 |
-
|
67 |
-
if ( UM()->account()->current_password_is_required( 'password' ) ) {
|
68 |
-
if ( empty( $args['current_user_password'] ) ) {
|
69 |
-
UM()->form()->add_error( 'current_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
70 |
-
return;
|
71 |
-
} else {
|
72 |
-
if ( ! wp_check_password( $args['current_user_password'], $current_user->data->user_pass, $current_user->data->ID ) ) {
|
73 |
-
UM()->form()->add_error( 'current_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
74 |
-
return;
|
75 |
-
}
|
76 |
-
}
|
77 |
-
}
|
78 |
-
|
79 |
-
if ( $args['user_password'] && $args['user_password'] !== $args['confirm_user_password'] ) {
|
80 |
-
UM()->form()->add_error( 'user_password', __( 'Your new password does not match', 'ultimate-member' ) );
|
81 |
-
return;
|
82 |
-
}
|
83 |
-
|
84 |
-
if ( UM()->options()->get( '
|
85 |
-
$min_length = UM()->options()->get( 'password_min_chars' );
|
86 |
-
$min_length = ! empty( $min_length ) ? $min_length : 8;
|
87 |
-
$max_length = UM()->options()->get( 'password_max_chars' );
|
88 |
-
$max_length = ! empty( $max_length ) ? $max_length : 30;
|
89 |
-
|
90 |
-
if ( mb_strlen( $args['user_password'] ) < $min_length ) {
|
91 |
-
UM()->form()->add_error( 'user_password', sprintf( __( 'Your password must contain at least %d characters', 'ultimate-member' ), $min_length ) );
|
92 |
-
}
|
93 |
-
|
94 |
-
if ( mb_strlen( $args['user_password'] ) > $max_length ) {
|
95 |
-
UM()->form()->add_error( 'user_password', sprintf( __( 'Your password must contain less than %d characters', 'ultimate-member' ), $max_length ) );
|
96 |
-
}
|
97 |
-
|
98 |
-
if ( ! UM()->validation()->strong_pass( $args['user_password'] ) ) {
|
99 |
-
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
|
100 |
-
}
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
break;
|
105 |
-
}
|
106 |
-
|
107 |
-
case 'account':
|
108 |
-
case 'general': {
|
109 |
-
// errors on general tab
|
110 |
-
$account_name_require = UM()->options()->get( 'account_name_require' );
|
111 |
-
|
112 |
-
if ( isset( $args['user_login'] ) ) {
|
113 |
-
$args['user_login'] = sanitize_user( $args['user_login'] );
|
114 |
-
}
|
115 |
-
if ( isset( $args['first_name'] ) ) {
|
116 |
-
$args['first_name'] = sanitize_text_field( $args['first_name'] );
|
117 |
-
}
|
118 |
-
if ( isset( $args['last_name'] ) ) {
|
119 |
-
$args['last_name'] = sanitize_text_field( $args['last_name'] );
|
120 |
-
}
|
121 |
-
if ( isset( $args['user_email'] ) ) {
|
122 |
-
$args['user_email'] = sanitize_email( $args['user_email'] );
|
123 |
-
}
|
124 |
-
if ( isset( $args['single_user_password'] ) ) {
|
125 |
-
$args['single_user_password'] = sanitize_text_field( $args['single_user_password'] );
|
126 |
-
}
|
127 |
-
|
128 |
-
if ( isset( $args['first_name'] ) && ( strlen( trim( $args['first_name'] ) ) === 0 && $account_name_require ) ) {
|
129 |
-
UM()->form()->add_error( 'first_name', __( 'You must provide your first name', 'ultimate-member' ) );
|
130 |
-
}
|
131 |
-
|
132 |
-
if ( isset( $args['last_name'] ) && ( strlen( trim( $args['last_name'] ) ) === 0 && $account_name_require ) ) {
|
133 |
-
UM()->form()->add_error( 'last_name', __( 'You must provide your last name', 'ultimate-member' ) );
|
134 |
-
}
|
135 |
-
|
136 |
-
if ( isset( $args['user_email'] ) ) {
|
137 |
-
|
138 |
-
if ( strlen( trim( $args['user_email'] ) ) === 0 ) {
|
139 |
-
UM()->form()->add_error( 'user_email', __( 'You must provide your e-mail', 'ultimate-member' ) );
|
140 |
-
}
|
141 |
-
|
142 |
-
if ( ! is_email( $args['user_email'] ) ) {
|
143 |
-
UM()->form()->add_error( 'user_email', __( 'Please provide a valid e-mail', 'ultimate-member' ) );
|
144 |
-
}
|
145 |
-
|
146 |
-
if ( email_exists( $args['user_email'] ) && email_exists( $args['user_email'] ) !== get_current_user_id() ) {
|
147 |
-
UM()->form()->add_error( 'user_email', __( '
|
148 |
-
}
|
149 |
-
}
|
150 |
-
|
151 |
-
// check account password
|
152 |
-
if ( UM()->account()->current_password_is_required( 'general' ) ) {
|
153 |
-
if ( strlen( trim( $args['single_user_password'] ) ) === 0 ) {
|
154 |
-
UM()->form()->add_error( 'single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
|
155 |
-
} else {
|
156 |
-
if ( ! wp_check_password( $args['single_user_password'], $current_user->data->user_pass, $current_user->data->ID ) ) {
|
157 |
-
UM()->form()->add_error( 'single_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
158 |
-
}
|
159 |
-
}
|
160 |
-
}
|
161 |
-
|
162 |
-
break;
|
163 |
-
}
|
164 |
-
|
165 |
-
default:
|
166 |
-
/**
|
167 |
-
* UM hook
|
168 |
-
*
|
169 |
-
* @type action
|
170 |
-
* @title um_submit_account_{$tab}_tab_errors_hook
|
171 |
-
* @description On submit account current $tab validation
|
172 |
-
* @change_log
|
173 |
-
* ["Since: 2.0"]
|
174 |
-
* @usage add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'function_name', 10 );
|
175 |
-
* @example
|
176 |
-
* <?php
|
177 |
-
* add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'my_submit_account_tab_errors', 10 );
|
178 |
-
* function my_submit_account_tab_errors() {
|
179 |
-
* // your code here
|
180 |
-
* }
|
181 |
-
* ?>
|
182 |
-
*/
|
183 |
-
do_action( 'um_submit_account_' . $tab . '_tab_errors_hook' );
|
184 |
-
break;
|
185 |
-
}
|
186 |
-
|
187 |
-
UM()->account()->current_tab = $tab;
|
188 |
-
}
|
189 |
-
add_action( 'um_submit_account_errors_hook', 'um_submit_account_errors_hook' );
|
190 |
-
|
191 |
-
|
192 |
-
/**
|
193 |
-
* Submit account page changes
|
194 |
-
*
|
195 |
-
* @param $args
|
196 |
-
*/
|
197 |
-
function um_submit_account_details( $args ) {
|
198 |
-
$tab = ( get_query_var( 'um_tab' ) ) ? get_query_var( 'um_tab' ) : 'general';
|
199 |
-
|
200 |
-
$current_tab = isset( $args['_um_account_tab'] ) ? sanitize_key( $args['_um_account_tab'] ) : '';
|
201 |
-
|
202 |
-
$user_id = um_user( 'ID' );
|
203 |
-
|
204 |
-
//change password account's tab
|
205 |
-
if ( 'password' === $current_tab && $args['user_password'] && $args['confirm_user_password'] ) {
|
206 |
-
|
207 |
-
$changes['user_pass'] = sanitize_text_field( $args['user_password'] );
|
208 |
-
|
209 |
-
$args['user_id'] = $user_id;
|
210 |
-
|
211 |
-
UM()->user()->password_changed();
|
212 |
-
|
213 |
-
add_filter( 'send_password_change_email', '__return_false' );
|
214 |
-
|
215 |
-
//clear all sessions with old passwords
|
216 |
-
$user = WP_Session_Tokens::get_instance( $user_id );
|
217 |
-
$user->destroy_all();
|
218 |
-
|
219 |
-
wp_set_password( $changes['user_pass'], $user_id );
|
220 |
-
|
221 |
-
wp_signon(
|
222 |
-
array(
|
223 |
-
'user_login' => um_user( 'user_login' ),
|
224 |
-
'user_password' => $changes['user_pass'],
|
225 |
-
)
|
226 |
-
);
|
227 |
-
}
|
228 |
-
|
229 |
-
// delete account
|
230 |
-
if ( 'delete' === $current_tab ) {
|
231 |
-
if ( current_user_can( 'delete_users' ) || um_user( 'can_delete_profile' ) ) {
|
232 |
-
UM()->user()->delete();
|
233 |
-
|
234 |
-
if ( um_user( 'after_delete' ) && um_user( 'after_delete' ) === 'redirect_home' ) {
|
235 |
-
um_redirect_home();
|
236 |
-
} elseif ( um_user( 'delete_redirect_url' ) ) {
|
237 |
-
/**
|
238 |
-
* UM hook
|
239 |
-
*
|
240 |
-
* @type filter
|
241 |
-
* @title um_delete_account_redirect_url
|
242 |
-
* @description Change redirect URL after delete account
|
243 |
-
* @input_vars
|
244 |
-
* [{"var":"$url","type":"string","desc":"Redirect URL"},
|
245 |
-
* {"var":"$id","type":"int","desc":"User ID"}]
|
246 |
-
* @change_log
|
247 |
-
* ["Since: 2.0"]
|
248 |
-
* @usage
|
249 |
-
* <?php add_filter( 'um_delete_account_redirect_url', 'function_name', 10, 2 ); ?>
|
250 |
-
* @example
|
251 |
-
* <?php
|
252 |
-
* add_filter( 'um_delete_account_redirect_url', 'my_delete_account_redirect_url', 10, 2 );
|
253 |
-
* function my_delete_account_redirect_url( $url, $id ) {
|
254 |
-
* // your code here
|
255 |
-
* return $url;
|
256 |
-
* }
|
257 |
-
* ?>
|
258 |
-
*/
|
259 |
-
$redirect_url = apply_filters( 'um_delete_account_redirect_url', um_user( 'delete_redirect_url' ), $user_id );
|
260 |
-
exit( wp_redirect( $redirect_url ) );
|
261 |
-
} else {
|
262 |
-
um_redirect_home();
|
263 |
-
}
|
264 |
-
}
|
265 |
-
}
|
266 |
-
|
267 |
-
$arr_fields = array();
|
268 |
-
if ( UM()->account()->is_secure_enabled() ) {
|
269 |
-
$account_fields = get_user_meta( $user_id, 'um_account_secure_fields', true );
|
270 |
-
|
271 |
-
/**
|
272 |
-
* UM hook
|
273 |
-
*
|
274 |
-
* @type filter
|
275 |
-
* @title um_secure_account_fields
|
276 |
-
* @description Change secure account fields
|
277 |
-
* @input_vars
|
278 |
-
* [{"var":"$fields","type":"array","desc":"Secure account fields"},
|
279 |
-
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
280 |
-
* @change_log
|
281 |
-
* ["Since: 2.0"]
|
282 |
-
* @usage
|
283 |
-
* <?php add_filter( 'um_secure_account_fields', 'function_name', 10, 2 ); ?>
|
284 |
-
* @example
|
285 |
-
* <?php
|
286 |
-
* add_filter( 'um_secure_account_fields', 'my_secure_account_fields', 10, 2 );
|
287 |
-
* function my_secure_account_fields( $fields, $user_id ) {
|
288 |
-
* // your code here
|
289 |
-
* return $fields;
|
290 |
-
* }
|
291 |
-
* ?>
|
292 |
-
*/
|
293 |
-
$secure_fields = apply_filters( 'um_secure_account_fields', $account_fields, $user_id );
|
294 |
-
|
295 |
-
if ( isset( $secure_fields[ $current_tab ] ) && is_array( $secure_fields[ $current_tab ] ) ) {
|
296 |
-
$arr_fields = array_merge( $arr_fields, $secure_fields[ $current_tab ] );
|
297 |
-
}
|
298 |
-
}
|
299 |
-
|
300 |
-
$changes = array();
|
301 |
-
foreach ( $args as $k => $v ) {
|
302 |
-
if ( ! in_array( $k, $arr_fields, true ) ) {
|
303 |
-
continue;
|
304 |
-
}
|
305 |
-
|
306 |
-
if ( 'single_user_password' === $k || 'user_login' === $k ) {
|
307 |
-
continue;
|
308 |
-
} elseif ( 'first_name' === $k || 'last_name' === $k || 'user_password' === $k ) {
|
309 |
-
$v = sanitize_text_field( $v );
|
310 |
-
} elseif ( 'user_email' === $k ) {
|
311 |
-
$v = sanitize_email( $v );
|
312 |
-
} elseif ( 'hide_in_members' === $k ) {
|
313 |
-
$v = array_map( 'sanitize_text_field', $v );
|
314 |
-
}
|
315 |
-
|
316 |
-
$changes[ $k ] = $v;
|
317 |
-
}
|
318 |
-
|
319 |
-
if ( isset( $changes['hide_in_members'] ) ) {
|
320 |
-
if ( UM()->member_directory()->get_hide_in_members_default() ) {
|
321 |
-
if ( __( 'Yes', 'ultimate-member' ) === $changes['hide_in_members'] || 'Yes' === $changes['hide_in_members'] || array_intersect( array( 'Yes', __( 'Yes', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
|
322 |
-
delete_user_meta( $user_id, 'hide_in_members' );
|
323 |
-
unset( $changes['hide_in_members'] );
|
324 |
-
}
|
325 |
-
} else {
|
326 |
-
if ( __( 'No', 'ultimate-member' ) === $changes['hide_in_members'] || 'No' === $changes['hide_in_members'] || array_intersect( array( 'No', __( 'No', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
|
327 |
-
delete_user_meta( $user_id, 'hide_in_members' );
|
328 |
-
unset( $changes['hide_in_members'] );
|
329 |
-
}
|
330 |
-
}
|
331 |
-
}
|
332 |
-
|
333 |
-
/**
|
334 |
-
* UM hook
|
335 |
-
*
|
336 |
-
* @type filter
|
337 |
-
* @title um_account_pre_updating_profile_array
|
338 |
-
* @description Change update profile data before saving
|
339 |
-
* @input_vars
|
340 |
-
* [{"var":"$changes","type":"array","desc":"Profile changes array"}]
|
341 |
-
* @change_log
|
342 |
-
* ["Since: 2.0"]
|
343 |
-
* @usage
|
344 |
-
* <?php add_filter( 'um_account_pre_updating_profile_array', 'function_name', 10, 1 ); ?>
|
345 |
-
* @example
|
346 |
-
* <?php
|
347 |
-
* add_filter( 'um_account_pre_updating_profile_array', 'my_account_pre_updating_profile', 10, 1 );
|
348 |
-
* function my_account_pre_updating_profile( $changes ) {
|
349 |
-
* // your code here
|
350 |
-
* return $changes;
|
351 |
-
* }
|
352 |
-
* ?>
|
353 |
-
*/
|
354 |
-
$changes = apply_filters( 'um_account_pre_updating_profile_array', $changes );
|
355 |
-
|
356 |
-
/**
|
357 |
-
* UM hook
|
358 |
-
*
|
359 |
-
* @type action
|
360 |
-
* @title um_account_pre_update_profile
|
361 |
-
* @description Fired on account page, just before updating profile
|
362 |
-
* @input_vars
|
363 |
-
* [{"var":"$changes","type":"array","desc":"Submitted data"},
|
364 |
-
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
365 |
-
* @change_log
|
366 |
-
* ["Since: 2.0"]
|
367 |
-
* @usage add_action( 'um_account_pre_update_profile', 'function_name', 10, 2 );
|
368 |
-
* @example
|
369 |
-
* <?php
|
370 |
-
* add_action( 'um_account_pre_update_profile', 'my_account_pre_update_profile', 10, 2 );
|
371 |
-
* function my_account_pre_update_profile( $changes, $user_id ) {
|
372 |
-
* // your code here
|
373 |
-
* }
|
374 |
-
* ?>
|
375 |
-
*/
|
376 |
-
do_action( 'um_account_pre_update_profile', $changes, $user_id );
|
377 |
-
|
378 |
-
if ( isset( $changes['first_name'] ) || isset( $changes['last_name'] ) || isset( $changes['nickname'] ) ) {
|
379 |
-
$user = get_userdata( $user_id );
|
380 |
-
if ( ! empty( $user ) && ! is_wp_error( $user ) ) {
|
381 |
-
UM()->user()->previous_data['display_name'] = $user->display_name;
|
382 |
-
|
383 |
-
if ( isset( $changes['first_name'] ) ) {
|
384 |
-
UM()->user()->previous_data['first_name'] = $user->first_name;
|
385 |
-
}
|
386 |
-
if ( isset( $changes['last_name'] ) ) {
|
387 |
-
UM()->user()->previous_data['last_name'] = $user->last_name;
|
388 |
-
}
|
389 |
-
if ( isset( $changes['nickname'] ) ) {
|
390 |
-
UM()->user()->previous_data['nickname'] = $user->nickname;
|
391 |
-
}
|
392 |
-
}
|
393 |
-
}
|
394 |
-
|
395 |
-
UM()->user()->update_profile( $changes );
|
396 |
-
|
397 |
-
if ( UM()->account()->is_secure_enabled() ) {
|
398 |
-
update_user_meta( $user_id, 'um_account_secure_fields', array() );
|
399 |
-
}
|
400 |
-
|
401 |
-
/**
|
402 |
-
* UM hook
|
403 |
-
*
|
404 |
-
* @type action
|
405 |
-
* @title um_post_account_update
|
406 |
-
* @description Fired on account page, after updating profile
|
407 |
-
* @change_log
|
408 |
-
* ["Since: 2.0"]
|
409 |
-
* @usage add_action( 'um_post_account_update', 'function_name', 10 );
|
410 |
-
* @example
|
411 |
-
* <?php
|
412 |
-
* add_action( 'um_post_account_update', 'my_post_account_update', 10 );
|
413 |
-
* function my_account_pre_update_profile() {
|
414 |
-
* // your code here
|
415 |
-
* }
|
416 |
-
* ?>
|
417 |
-
*/
|
418 |
-
do_action( 'um_post_account_update' );
|
419 |
-
/**
|
420 |
-
* UM hook
|
421 |
-
*
|
422 |
-
* @type action
|
423 |
-
* @title um_after_user_account_updated
|
424 |
-
* @description Fired on account page, after updating profile
|
425 |
-
* @input_vars
|
426 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
427 |
-
* {"var":"$changes","type":"array","desc":"Submitted data"}]
|
428 |
-
* @change_log
|
429 |
-
* ["Since: 2.0"]
|
430 |
-
* @usage add_action( 'um_after_user_account_updated', 'function_name', 10, 2 );
|
431 |
-
* @example
|
432 |
-
* <?php
|
433 |
-
* add_action( 'um_after_user_account_updated', 'my_after_user_account_updated', 10, 2 );
|
434 |
-
* function my_after_user_account_updated( $user_id, $changes ) {
|
435 |
-
* // your code here
|
436 |
-
* }
|
437 |
-
* ?>
|
438 |
-
*/
|
439 |
-
do_action( 'um_after_user_account_updated', $user_id, $changes );
|
440 |
-
|
441 |
-
$url = '';
|
442 |
-
if ( um_is_core_page( 'account' ) ) {
|
443 |
-
|
444 |
-
$url = UM()->account()->tab_link( $tab );
|
445 |
-
|
446 |
-
$url = add_query_arg( 'updated', 'account', $url );
|
447 |
-
|
448 |
-
if ( function_exists( 'icl_get_current_language' ) ) {
|
449 |
-
if ( icl_get_current_language() != icl_get_default_language() ) {
|
450 |
-
$url = UM()->permalinks()->get_current_url( true );
|
451 |
-
$url = add_query_arg( 'updated', 'account', $url );
|
452 |
-
|
453 |
-
um_js_redirect( $url );
|
454 |
-
}
|
455 |
-
}
|
456 |
-
}
|
457 |
-
|
458 |
-
um_js_redirect( $url );
|
459 |
-
}
|
460 |
-
add_action( 'um_submit_account_details', 'um_submit_account_details' );
|
461 |
-
|
462 |
-
|
463 |
-
/**
|
464 |
-
* Hidden inputs for account form
|
465 |
-
*
|
466 |
-
* @param $args
|
467 |
-
*/
|
468 |
-
function um_account_page_hidden_fields( $args ) {
|
469 |
-
?>
|
470 |
-
|
471 |
-
<input type="hidden" name="_um_account" id="_um_account" value="1" />
|
472 |
-
<input type="hidden" name="_um_account_tab" id="_um_account_tab" value="<?php echo esc_attr( UM()->account()->current_tab ); ?>" />
|
473 |
-
|
474 |
-
<?php
|
475 |
-
}
|
476 |
-
add_action( 'um_account_page_hidden_fields', 'um_account_page_hidden_fields' );
|
477 |
-
|
478 |
-
|
479 |
-
/**
|
480 |
-
* Before delete account tab content
|
481 |
-
*/
|
482 |
-
function um_before_account_delete() {
|
483 |
-
if ( UM()->account()->current_password_is_required( 'delete' ) ) {
|
484 |
-
$text = UM()->options()->get( 'delete_account_text' );
|
485 |
-
} else {
|
486 |
-
$text = UM()->options()->get( 'delete_account_no_pass_required_text' );
|
487 |
-
}
|
488 |
-
|
489 |
-
printf( __( '%s', 'ultimate-member' ), wpautop( htmlspecialchars( $text ) ) );
|
490 |
-
}
|
491 |
-
add_action( 'um_before_account_delete', 'um_before_account_delete' );
|
492 |
-
|
493 |
-
|
494 |
-
/**
|
495 |
-
* Before notifications account tab content
|
496 |
-
*
|
497 |
-
* @param array $args
|
498 |
-
*
|
499 |
-
* @throws Exception
|
500 |
-
*/
|
501 |
-
function um_before_account_notifications( $args = array() ) {
|
502 |
-
$output = UM()->account()->get_tab_fields( 'notifications', $args );
|
503 |
-
if ( substr_count( $output, '_enable_new_' ) ) { ?>
|
504 |
-
|
505 |
-
<p><?php _e( 'Select what email notifications you want to receive', 'ultimate-member' ); ?></p>
|
506 |
-
|
507 |
-
<?php }
|
508 |
-
}
|
509 |
-
add_action( 'um_before_account_notifications', 'um_before_account_notifications' );
|
510 |
-
|
511 |
-
|
512 |
-
/**
|
513 |
-
* Update Profile URL, display name, full name.
|
514 |
-
*
|
515 |
-
* @version 2.2.5
|
516 |
-
*
|
517 |
-
* @param int $user_id The user ID.
|
518 |
-
* @param array $changes An array of fields values.
|
519 |
-
*/
|
520 |
-
function um_after_user_account_updated_permalink( $user_id, $changes ) {
|
521 |
-
if ( isset( $changes['first_name'] ) || isset( $changes['last_name'] ) ) {
|
522 |
-
do_action( 'um_update_profile_full_name', $user_id, $changes );
|
523 |
-
}
|
524 |
-
}
|
525 |
-
add_action( 'um_after_user_account_updated', 'um_after_user_account_updated_permalink', 10, 2 );
|
526 |
-
|
527 |
-
|
528 |
-
/**
|
529 |
-
* Update Account Email Notification
|
530 |
-
*
|
531 |
-
* @param $user_id
|
532 |
-
* @param $changed
|
533 |
-
*/
|
534 |
-
function um_account_updated_notification( $user_id, $changed ) {
|
535 |
-
um_fetch_user( $user_id );
|
536 |
-
UM()->mail()->send( um_user( 'user_email' ), 'changedaccount_email' );
|
537 |
-
}
|
538 |
-
add_action( 'um_after_user_account_updated', 'um_account_updated_notification', 20, 2 );
|
539 |
-
|
540 |
-
|
541 |
-
/**
|
542 |
-
* Disable WP native email notification when change email on user account
|
543 |
-
*
|
544 |
-
* @param $user_id
|
545 |
-
* @param $changed
|
546 |
-
*/
|
547 |
-
function um_disable_native_email_notificatiion( $changed, $user_id ) {
|
548 |
-
add_filter( 'send_email_change_email', '__return_false' );
|
549 |
-
}
|
550 |
-
add_action( 'um_account_pre_update_profile', 'um_disable_native_email_notificatiion', 10, 2 );
|
551 |
-
|
552 |
-
|
553 |
-
/**
|
554 |
-
* Add export and erase user's data in privacy tab
|
555 |
-
*
|
556 |
-
* @param $args
|
557 |
-
*/
|
558 |
-
add_action( 'um_after_account_privacy', 'um_after_account_privacy' );
|
559 |
-
function um_after_account_privacy( $args ) {
|
560 |
-
global $wpdb;
|
561 |
-
$user_id = get_current_user_id();
|
562 |
-
?>
|
563 |
-
|
564 |
-
<div class="um-field um-field-export_data">
|
565 |
-
<div class="um-field-label">
|
566 |
-
<label>
|
567 |
-
<?php esc_html_e( 'Download your data', 'ultimate-member' ); ?>
|
568 |
-
</label>
|
569 |
-
<span class="um-tip um-tip-<?php echo is_rtl() ? 'e' : 'w' ?>" original-title="<?php esc_attr_e( 'You can request a file with the information that we believe is most relevant and useful to you.', 'ultimate-member' ); ?>">
|
570 |
-
<i class="um-icon-help-circled"></i>
|
571 |
-
</span>
|
572 |
-
<div class="um-clear"></div>
|
573 |
-
</div>
|
574 |
-
<?php $completed = $wpdb->get_row(
|
575 |
-
"SELECT ID
|
576 |
-
FROM $wpdb->posts
|
577 |
-
WHERE post_author = $user_id AND
|
578 |
-
post_type = 'user_request' AND
|
579 |
-
post_name = 'export_personal_data' AND
|
580 |
-
post_status = 'request-completed'
|
581 |
-
ORDER BY ID DESC
|
582 |
-
LIMIT 1",
|
583 |
-
ARRAY_A );
|
584 |
-
|
585 |
-
if ( ! empty( $completed ) ) {
|
586 |
-
|
587 |
-
$exports_url = wp_privacy_exports_url();
|
588 |
-
|
589 |
-
echo '<p>' . esc_html__( 'You could download your previous data:', 'ultimate-member' ) . '</p>';
|
590 |
-
echo '<a href="'.esc_attr( $exports_url . get_post_meta( $completed['ID'], '_export_file_name', true ) ) . '">' . esc_html__( 'Download Personal Data', 'ultimate-member' ) . '</a>';
|
591 |
-
echo '<p>' . esc_html__( 'You could send a new request for an export of personal your data.', 'ultimate-member' ) . '</p>';
|
592 |
-
|
593 |
-
}
|
594 |
-
|
595 |
-
$pending = $wpdb->get_row(
|
596 |
-
"SELECT ID, post_status
|
597 |
-
FROM $wpdb->posts
|
598 |
-
WHERE post_author = $user_id AND
|
599 |
-
post_type = 'user_request' AND
|
600 |
-
post_name = 'export_personal_data' AND
|
601 |
-
post_status != 'request-completed'
|
602 |
-
ORDER BY ID DESC
|
603 |
-
LIMIT 1",
|
604 |
-
ARRAY_A );
|
605 |
-
|
606 |
-
if ( ! empty( $pending ) && $pending['post_status'] == 'request-pending' ) {
|
607 |
-
echo '<p>' . esc_html__( 'A confirmation email has been sent to your email. Click the link within the email to confirm your export request.', 'ultimate-member' ) . '</p>';
|
608 |
-
} elseif ( ! empty( $pending ) && $pending['post_status'] == 'request-confirmed' ) {
|
609 |
-
echo '<p>' . esc_html__( 'The administrator has not yet approved downloading the data. Please expect an email with a link to your data.', 'ultimate-member' ) . '</p>';
|
610 |
-
} else {
|
611 |
-
if ( UM()->account()->current_password_is_required( 'privacy_download_data' ) ) { ?>
|
612 |
-
|
613 |
-
<label name="um-export-data">
|
614 |
-
<?php esc_html_e( 'Enter your current password to confirm a new export of your personal data.', 'ultimate-member' ); ?>
|
615 |
-
</label>
|
616 |
-
<div class="um-field-area">
|
617 |
-
<input id="um-export-data" type="password" placeholder="<?php esc_attr_e( 'Password', 'ultimate-member' )?>">
|
618 |
-
<div class="um-field-error um-export-data">
|
619 |
-
<span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span><?php esc_html_e( 'You must enter a password', 'ultimate-member' ); ?>
|
620 |
-
</div>
|
621 |
-
<div class="um-field-area-response um-export-data"></div>
|
622 |
-
</div>
|
623 |
-
|
624 |
-
<?php } else { ?>
|
625 |
-
|
626 |
-
<label name="um-export-data">
|
627 |
-
<?php esc_html_e( 'To export of your personal data, click the button below.', 'ultimate-member' ); ?>
|
628 |
-
</label>
|
629 |
-
<div class="um-field-area-response um-export-data"></div>
|
630 |
-
|
631 |
-
<?php } ?>
|
632 |
-
|
633 |
-
<a class="um-request-button um-export-data-button" data-action="um-export-data" href="javascript:void(0);">
|
634 |
-
<?php esc_html_e( 'Request data', 'ultimate-member' ); ?>
|
635 |
-
</a>
|
636 |
-
<?php } ?>
|
637 |
-
|
638 |
-
</div>
|
639 |
-
|
640 |
-
<div class="um-field um-field-export_data">
|
641 |
-
<div class="um-field-label">
|
642 |
-
<label>
|
643 |
-
<?php esc_html_e( 'Erase of your data', 'ultimate-member' ); ?>
|
644 |
-
</label>
|
645 |
-
<span class="um-tip um-tip-<?php echo is_rtl() ? 'e' : 'w' ?>" original-title="<?php esc_attr_e( 'You can request erasing of the data that we have about you.', 'ultimate-member' ); ?>">
|
646 |
-
<i class="um-icon-help-circled"></i>
|
647 |
-
</span>
|
648 |
-
<div class="um-clear"></div>
|
649 |
-
</div>
|
650 |
-
|
651 |
-
<?php $completed = $wpdb->get_row(
|
652 |
-
"SELECT ID
|
653 |
-
FROM $wpdb->posts
|
654 |
-
WHERE post_author = $user_id AND
|
655 |
-
post_type = 'user_request' AND
|
656 |
-
post_name = 'remove_personal_data' AND
|
657 |
-
post_status = 'request-completed'
|
658 |
-
ORDER BY ID DESC
|
659 |
-
LIMIT 1",
|
660 |
-
ARRAY_A );
|
661 |
-
|
662 |
-
if ( ! empty( $completed ) ) {
|
663 |
-
|
664 |
-
echo '<p>' . esc_html__( 'Your personal data has been deleted.', 'ultimate-member' ) . '</p>';
|
665 |
-
echo '<p>' . esc_html__( 'You could send a new request for deleting your personal data.', 'ultimate-member' ) . '</p>';
|
666 |
-
|
667 |
-
}
|
668 |
-
|
669 |
-
$pending = $wpdb->get_row(
|
670 |
-
"SELECT ID, post_status
|
671 |
-
FROM $wpdb->posts
|
672 |
-
WHERE post_author = $user_id AND
|
673 |
-
post_type = 'user_request' AND
|
674 |
-
post_name = 'remove_personal_data' AND
|
675 |
-
post_status != 'request-completed'
|
676 |
-
ORDER BY ID DESC
|
677 |
-
LIMIT 1",
|
678 |
-
ARRAY_A );
|
679 |
-
|
680 |
-
if ( ! empty( $pending ) && $pending['post_status'] == 'request-pending' ) {
|
681 |
-
echo '<p>' . esc_html__( 'A confirmation email has been sent to your email. Click the link within the email to confirm your
|
682 |
-
} elseif ( ! empty( $pending ) && $pending['post_status'] == 'request-confirmed' ) {
|
683 |
-
echo '<p>' . esc_html__( 'The administrator has not yet approved deleting your data. Please expect an email with a link to your data.', 'ultimate-member' ) . '</p>';
|
684 |
-
} else {
|
685 |
-
if ( UM()->account()->current_password_is_required( 'privacy_erase_data' ) ) { ?>
|
686 |
-
|
687 |
-
<label name="um-erase-data">
|
688 |
-
<?php esc_html_e( 'Enter your current password to confirm the erasure of your personal data.', 'ultimate-member' ); ?>
|
689 |
-
<input id="um-erase-data" type="password" placeholder="<?php esc_attr_e( 'Password', 'ultimate-member' )?>">
|
690 |
-
<div class="um-field-error um-erase-data">
|
691 |
-
<span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span><?php esc_html_e( 'You must enter a password', 'ultimate-member' ); ?>
|
692 |
-
</div>
|
693 |
-
<div class="um-field-area-response um-erase-data"></div>
|
694 |
-
</label>
|
695 |
-
|
696 |
-
<?php } else { ?>
|
697 |
-
|
698 |
-
<label name="um-erase-data">
|
699 |
-
<?php esc_html_e( 'Require erasure of your personal data, click on the button below.', 'ultimate-member' ); ?>
|
700 |
-
<div class="um-field-area-response um-erase-data"></div>
|
701 |
-
</label>
|
702 |
-
|
703 |
-
<?php } ?>
|
704 |
-
|
705 |
-
<a class="um-request-button um-erase-data-button" data-action="um-erase-data" href="javascript:void(0);">
|
706 |
-
<?php esc_html_e( 'Request data erase', 'ultimate-member' ); ?>
|
707 |
-
</a>
|
708 |
-
<?php } ?>
|
709 |
-
|
710 |
-
</div>
|
711 |
-
|
712 |
-
<?php
|
713 |
-
}
|
714 |
-
|
715 |
-
|
716 |
-
function um_request_user_data() {
|
717 |
-
UM()->check_ajax_nonce();
|
718 |
-
|
719 |
-
if ( ! isset( $_POST['request_action'] ) ) {
|
720 |
-
wp_send_json_error( __( 'Wrong request.', 'ultimate-member' ) );
|
721 |
-
}
|
722 |
-
|
723 |
-
$user_id = get_current_user_id();
|
724 |
-
$password = ! empty( $_POST['password'] ) ? sanitize_text_field( $_POST['password'] ) : '';
|
725 |
-
$user = get_userdata( $user_id );
|
726 |
-
$hash = $user->data->user_pass;
|
727 |
-
$request_action = sanitize_key( $_POST['request_action'] );
|
728 |
-
|
729 |
-
if ( 'um-export-data' === $request_action ) {
|
730 |
-
if ( UM()->account()->current_password_is_required( 'privacy_download_data' ) ) {
|
731 |
-
if ( ! wp_check_password( $password, $hash ) ) {
|
732 |
-
$answer = esc_html__( 'The password you entered is incorrect.', 'ultimate-member' );
|
733 |
-
wp_send_json_success( array( 'answer' => $answer ) );
|
734 |
-
}
|
735 |
-
}
|
736 |
-
} elseif ( 'um-erase-data' === $request_action ) {
|
737 |
-
if ( UM()->account()->current_password_is_required( 'privacy_erase_data' ) ) {
|
738 |
-
if ( ! wp_check_password( $password, $hash ) ) {
|
739 |
-
$answer = esc_html__( 'The password you entered is incorrect.', 'ultimate-member' );
|
740 |
-
wp_send_json_success( array( 'answer' => $answer ) );
|
741 |
-
}
|
742 |
-
}
|
743 |
-
}
|
744 |
-
|
745 |
-
if ( 'um-export-data' === $request_action ) {
|
746 |
-
$request_id = wp_create_user_request( $user->data->user_email, 'export_personal_data' );
|
747 |
-
} elseif ( 'um-erase-data' === $request_action ) {
|
748 |
-
$request_id = wp_create_user_request( $user->data->user_email, 'remove_personal_data' );
|
749 |
-
}
|
750 |
-
|
751 |
-
if ( ! isset( $request_id ) || empty( $request_id ) ) {
|
752 |
-
wp_send_json_error( __( 'Wrong request.', 'ultimate-member' ) );
|
753 |
-
}
|
754 |
-
|
755 |
-
if ( is_wp_error( $request_id ) ) {
|
756 |
-
$answer = esc_html( $request_id->get_error_message() );
|
757 |
-
} else {
|
758 |
-
wp_send_user_request( $request_id );
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
}
|
764 |
-
|
|
|
|
|
|
|
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) {
|
2 |
+
exit;
|
3 |
+
}
|
4 |
+
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Validate for errors in account form
|
8 |
+
*
|
9 |
+
* @param array $args
|
10 |
+
*/
|
11 |
+
function um_submit_account_errors_hook( $args ) {
|
12 |
+
global $current_user;
|
13 |
+
|
14 |
+
if ( ! isset( $args['_um_account'] ) && ! isset( $args['_um_account_tab'] ) ) {
|
15 |
+
return;
|
16 |
+
}
|
17 |
+
|
18 |
+
$tab = sanitize_key( $args['_um_account_tab'] );
|
19 |
+
|
20 |
+
if ( ! wp_verify_nonce( $args[ 'um_account_nonce_' . $tab ], 'um_update_account_' . $tab ) ) {
|
21 |
+
UM()->form()->add_error( 'um_account_security', __( 'Are you hacking? Please try again!', 'ultimate-member' ) );
|
22 |
+
}
|
23 |
+
|
24 |
+
switch ( $tab ) {
|
25 |
+
case 'delete': {
|
26 |
+
// delete account
|
27 |
+
if ( UM()->account()->current_password_is_required( 'delete' ) ) {
|
28 |
+
if ( strlen( trim( sanitize_text_field( $args['single_user_password'] ) ) ) === 0 ) {
|
29 |
+
UM()->form()->add_error( 'single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
|
30 |
+
} else {
|
31 |
+
if ( ! wp_check_password( sanitize_text_field( $args['single_user_password'] ), $current_user->data->user_pass, $current_user->data->ID ) ) {
|
32 |
+
UM()->form()->add_error( 'single_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
33 |
+
}
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
UM()->account()->current_tab = 'delete';
|
38 |
+
|
39 |
+
break;
|
40 |
+
}
|
41 |
+
|
42 |
+
case 'password': {
|
43 |
+
|
44 |
+
// change password
|
45 |
+
UM()->account()->current_tab = 'password';
|
46 |
+
|
47 |
+
if ( isset( $args['user_password'] ) ) {
|
48 |
+
$args['user_password'] = sanitize_text_field( $args['user_password'] );
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( isset( $args['confirm_user_password'] ) ) {
|
52 |
+
$args['confirm_user_password'] = sanitize_text_field( $args['confirm_user_password'] );
|
53 |
+
}
|
54 |
+
|
55 |
+
if ( empty( $args['user_password'] ) ) {
|
56 |
+
UM()->form()->add_error( 'user_password', __( 'Password is required', 'ultimate-member' ) );
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
|
60 |
+
if ( empty( $args['confirm_user_password'] ) ) {
|
61 |
+
UM()->form()->add_error( 'user_password', __( 'Password confirmation is required', 'ultimate-member' ) );
|
62 |
+
return;
|
63 |
+
}
|
64 |
+
|
65 |
+
if ( ! empty( $args['user_password'] ) && ! empty( $args['confirm_user_password'] ) ) {
|
66 |
+
|
67 |
+
if ( UM()->account()->current_password_is_required( 'password' ) ) {
|
68 |
+
if ( empty( $args['current_user_password'] ) ) {
|
69 |
+
UM()->form()->add_error( 'current_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
70 |
+
return;
|
71 |
+
} else {
|
72 |
+
if ( ! wp_check_password( $args['current_user_password'], $current_user->data->user_pass, $current_user->data->ID ) ) {
|
73 |
+
UM()->form()->add_error( 'current_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
if ( $args['user_password'] && $args['user_password'] !== $args['confirm_user_password'] ) {
|
80 |
+
UM()->form()->add_error( 'user_password', __( 'Your new password does not match', 'ultimate-member' ) );
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
|
84 |
+
if ( UM()->options()->get( 'require_strongpass' ) ) {
|
85 |
+
$min_length = UM()->options()->get( 'password_min_chars' );
|
86 |
+
$min_length = ! empty( $min_length ) ? $min_length : 8;
|
87 |
+
$max_length = UM()->options()->get( 'password_max_chars' );
|
88 |
+
$max_length = ! empty( $max_length ) ? $max_length : 30;
|
89 |
+
|
90 |
+
if ( mb_strlen( $args['user_password'] ) < $min_length ) {
|
91 |
+
UM()->form()->add_error( 'user_password', sprintf( __( 'Your password must contain at least %d characters', 'ultimate-member' ), $min_length ) );
|
92 |
+
}
|
93 |
+
|
94 |
+
if ( mb_strlen( $args['user_password'] ) > $max_length ) {
|
95 |
+
UM()->form()->add_error( 'user_password', sprintf( __( 'Your password must contain less than %d characters', 'ultimate-member' ), $max_length ) );
|
96 |
+
}
|
97 |
+
|
98 |
+
if ( ! UM()->validation()->strong_pass( $args['user_password'] ) ) {
|
99 |
+
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
break;
|
105 |
+
}
|
106 |
+
|
107 |
+
case 'account':
|
108 |
+
case 'general': {
|
109 |
+
// errors on general tab
|
110 |
+
$account_name_require = UM()->options()->get( 'account_name_require' );
|
111 |
+
|
112 |
+
if ( isset( $args['user_login'] ) ) {
|
113 |
+
$args['user_login'] = sanitize_user( $args['user_login'] );
|
114 |
+
}
|
115 |
+
if ( isset( $args['first_name'] ) ) {
|
116 |
+
$args['first_name'] = sanitize_text_field( $args['first_name'] );
|
117 |
+
}
|
118 |
+
if ( isset( $args['last_name'] ) ) {
|
119 |
+
$args['last_name'] = sanitize_text_field( $args['last_name'] );
|
120 |
+
}
|
121 |
+
if ( isset( $args['user_email'] ) ) {
|
122 |
+
$args['user_email'] = sanitize_email( $args['user_email'] );
|
123 |
+
}
|
124 |
+
if ( isset( $args['single_user_password'] ) ) {
|
125 |
+
$args['single_user_password'] = sanitize_text_field( $args['single_user_password'] );
|
126 |
+
}
|
127 |
+
|
128 |
+
if ( isset( $args['first_name'] ) && ( strlen( trim( $args['first_name'] ) ) === 0 && $account_name_require ) ) {
|
129 |
+
UM()->form()->add_error( 'first_name', __( 'You must provide your first name', 'ultimate-member' ) );
|
130 |
+
}
|
131 |
+
|
132 |
+
if ( isset( $args['last_name'] ) && ( strlen( trim( $args['last_name'] ) ) === 0 && $account_name_require ) ) {
|
133 |
+
UM()->form()->add_error( 'last_name', __( 'You must provide your last name', 'ultimate-member' ) );
|
134 |
+
}
|
135 |
+
|
136 |
+
if ( isset( $args['user_email'] ) ) {
|
137 |
+
|
138 |
+
if ( strlen( trim( $args['user_email'] ) ) === 0 ) {
|
139 |
+
UM()->form()->add_error( 'user_email', __( 'You must provide your e-mail', 'ultimate-member' ) );
|
140 |
+
}
|
141 |
+
|
142 |
+
if ( ! is_email( $args['user_email'] ) ) {
|
143 |
+
UM()->form()->add_error( 'user_email', __( 'Please provide a valid e-mail', 'ultimate-member' ) );
|
144 |
+
}
|
145 |
+
|
146 |
+
if ( email_exists( $args['user_email'] ) && email_exists( $args['user_email'] ) !== get_current_user_id() ) {
|
147 |
+
UM()->form()->add_error( 'user_email', __( 'Please provide a valid e-mail', 'ultimate-member' ) );
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
// check account password
|
152 |
+
if ( UM()->account()->current_password_is_required( 'general' ) ) {
|
153 |
+
if ( strlen( trim( $args['single_user_password'] ) ) === 0 ) {
|
154 |
+
UM()->form()->add_error( 'single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
|
155 |
+
} else {
|
156 |
+
if ( ! wp_check_password( $args['single_user_password'], $current_user->data->user_pass, $current_user->data->ID ) ) {
|
157 |
+
UM()->form()->add_error( 'single_user_password', __( 'This is not your password', 'ultimate-member' ) );
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
break;
|
163 |
+
}
|
164 |
+
|
165 |
+
default:
|
166 |
+
/**
|
167 |
+
* UM hook
|
168 |
+
*
|
169 |
+
* @type action
|
170 |
+
* @title um_submit_account_{$tab}_tab_errors_hook
|
171 |
+
* @description On submit account current $tab validation
|
172 |
+
* @change_log
|
173 |
+
* ["Since: 2.0"]
|
174 |
+
* @usage add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'function_name', 10 );
|
175 |
+
* @example
|
176 |
+
* <?php
|
177 |
+
* add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'my_submit_account_tab_errors', 10 );
|
178 |
+
* function my_submit_account_tab_errors() {
|
179 |
+
* // your code here
|
180 |
+
* }
|
181 |
+
* ?>
|
182 |
+
*/
|
183 |
+
do_action( 'um_submit_account_' . $tab . '_tab_errors_hook' );
|
184 |
+
break;
|
185 |
+
}
|
186 |
+
|
187 |
+
UM()->account()->current_tab = $tab;
|
188 |
+
}
|
189 |
+
add_action( 'um_submit_account_errors_hook', 'um_submit_account_errors_hook' );
|
190 |
+
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Submit account page changes
|
194 |
+
*
|
195 |
+
* @param $args
|
196 |
+
*/
|
197 |
+
function um_submit_account_details( $args ) {
|
198 |
+
$tab = ( get_query_var( 'um_tab' ) ) ? get_query_var( 'um_tab' ) : 'general';
|
199 |
+
|
200 |
+
$current_tab = isset( $args['_um_account_tab'] ) ? sanitize_key( $args['_um_account_tab'] ) : '';
|
201 |
+
|
202 |
+
$user_id = um_user( 'ID' );
|
203 |
+
|
204 |
+
//change password account's tab
|
205 |
+
if ( 'password' === $current_tab && $args['user_password'] && $args['confirm_user_password'] ) {
|
206 |
+
|
207 |
+
$changes['user_pass'] = sanitize_text_field( $args['user_password'] );
|
208 |
+
|
209 |
+
$args['user_id'] = $user_id;
|
210 |
+
|
211 |
+
UM()->user()->password_changed();
|
212 |
+
|
213 |
+
add_filter( 'send_password_change_email', '__return_false' );
|
214 |
+
|
215 |
+
//clear all sessions with old passwords
|
216 |
+
$user = WP_Session_Tokens::get_instance( $user_id );
|
217 |
+
$user->destroy_all();
|
218 |
+
|
219 |
+
wp_set_password( $changes['user_pass'], $user_id );
|
220 |
+
|
221 |
+
wp_signon(
|
222 |
+
array(
|
223 |
+
'user_login' => um_user( 'user_login' ),
|
224 |
+
'user_password' => $changes['user_pass'],
|
225 |
+
)
|
226 |
+
);
|
227 |
+
}
|
228 |
+
|
229 |
+
// delete account
|
230 |
+
if ( 'delete' === $current_tab ) {
|
231 |
+
if ( current_user_can( 'delete_users' ) || um_user( 'can_delete_profile' ) ) {
|
232 |
+
UM()->user()->delete();
|
233 |
+
|
234 |
+
if ( um_user( 'after_delete' ) && um_user( 'after_delete' ) === 'redirect_home' ) {
|
235 |
+
um_redirect_home();
|
236 |
+
} elseif ( um_user( 'delete_redirect_url' ) ) {
|
237 |
+
/**
|
238 |
+
* UM hook
|
239 |
+
*
|
240 |
+
* @type filter
|
241 |
+
* @title um_delete_account_redirect_url
|
242 |
+
* @description Change redirect URL after delete account
|
243 |
+
* @input_vars
|
244 |
+
* [{"var":"$url","type":"string","desc":"Redirect URL"},
|
245 |
+
* {"var":"$id","type":"int","desc":"User ID"}]
|
246 |
+
* @change_log
|
247 |
+
* ["Since: 2.0"]
|
248 |
+
* @usage
|
249 |
+
* <?php add_filter( 'um_delete_account_redirect_url', 'function_name', 10, 2 ); ?>
|
250 |
+
* @example
|
251 |
+
* <?php
|
252 |
+
* add_filter( 'um_delete_account_redirect_url', 'my_delete_account_redirect_url', 10, 2 );
|
253 |
+
* function my_delete_account_redirect_url( $url, $id ) {
|
254 |
+
* // your code here
|
255 |
+
* return $url;
|
256 |
+
* }
|
257 |
+
* ?>
|
258 |
+
*/
|
259 |
+
$redirect_url = apply_filters( 'um_delete_account_redirect_url', um_user( 'delete_redirect_url' ), $user_id );
|
260 |
+
exit( wp_redirect( $redirect_url ) );
|
261 |
+
} else {
|
262 |
+
um_redirect_home();
|
263 |
+
}
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
$arr_fields = array();
|
268 |
+
if ( UM()->account()->is_secure_enabled() ) {
|
269 |
+
$account_fields = get_user_meta( $user_id, 'um_account_secure_fields', true );
|
270 |
+
|
271 |
+
/**
|
272 |
+
* UM hook
|
273 |
+
*
|
274 |
+
* @type filter
|
275 |
+
* @title um_secure_account_fields
|
276 |
+
* @description Change secure account fields
|
277 |
+
* @input_vars
|
278 |
+
* [{"var":"$fields","type":"array","desc":"Secure account fields"},
|
279 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
280 |
+
* @change_log
|
281 |
+
* ["Since: 2.0"]
|
282 |
+
* @usage
|
283 |
+
* <?php add_filter( 'um_secure_account_fields', 'function_name', 10, 2 ); ?>
|
284 |
+
* @example
|
285 |
+
* <?php
|
286 |
+
* add_filter( 'um_secure_account_fields', 'my_secure_account_fields', 10, 2 );
|
287 |
+
* function my_secure_account_fields( $fields, $user_id ) {
|
288 |
+
* // your code here
|
289 |
+
* return $fields;
|
290 |
+
* }
|
291 |
+
* ?>
|
292 |
+
*/
|
293 |
+
$secure_fields = apply_filters( 'um_secure_account_fields', $account_fields, $user_id );
|
294 |
+
|
295 |
+
if ( isset( $secure_fields[ $current_tab ] ) && is_array( $secure_fields[ $current_tab ] ) ) {
|
296 |
+
$arr_fields = array_merge( $arr_fields, $secure_fields[ $current_tab ] );
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
$changes = array();
|
301 |
+
foreach ( $args as $k => $v ) {
|
302 |
+
if ( ! in_array( $k, $arr_fields, true ) ) {
|
303 |
+
continue;
|
304 |
+
}
|
305 |
+
|
306 |
+
if ( 'single_user_password' === $k || 'user_login' === $k ) {
|
307 |
+
continue;
|
308 |
+
} elseif ( 'first_name' === $k || 'last_name' === $k || 'user_password' === $k ) {
|
309 |
+
$v = sanitize_text_field( $v );
|
310 |
+
} elseif ( 'user_email' === $k ) {
|
311 |
+
$v = sanitize_email( $v );
|
312 |
+
} elseif ( 'hide_in_members' === $k ) {
|
313 |
+
$v = array_map( 'sanitize_text_field', $v );
|
314 |
+
}
|
315 |
+
|
316 |
+
$changes[ $k ] = $v;
|
317 |
+
}
|
318 |
+
|
319 |
+
if ( isset( $changes['hide_in_members'] ) ) {
|
320 |
+
if ( UM()->member_directory()->get_hide_in_members_default() ) {
|
321 |
+
if ( __( 'Yes', 'ultimate-member' ) === $changes['hide_in_members'] || 'Yes' === $changes['hide_in_members'] || array_intersect( array( 'Yes', __( 'Yes', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
|
322 |
+
delete_user_meta( $user_id, 'hide_in_members' );
|
323 |
+
unset( $changes['hide_in_members'] );
|
324 |
+
}
|
325 |
+
} else {
|
326 |
+
if ( __( 'No', 'ultimate-member' ) === $changes['hide_in_members'] || 'No' === $changes['hide_in_members'] || array_intersect( array( 'No', __( 'No', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
|
327 |
+
delete_user_meta( $user_id, 'hide_in_members' );
|
328 |
+
unset( $changes['hide_in_members'] );
|
329 |
+
}
|
330 |
+
}
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* UM hook
|
335 |
+
*
|
336 |
+
* @type filter
|
337 |
+
* @title um_account_pre_updating_profile_array
|
338 |
+
* @description Change update profile data before saving
|
339 |
+
* @input_vars
|
340 |
+
* [{"var":"$changes","type":"array","desc":"Profile changes array"}]
|
341 |
+
* @change_log
|
342 |
+
* ["Since: 2.0"]
|
343 |
+
* @usage
|
344 |
+
* <?php add_filter( 'um_account_pre_updating_profile_array', 'function_name', 10, 1 ); ?>
|
345 |
+
* @example
|
346 |
+
* <?php
|
347 |
+
* add_filter( 'um_account_pre_updating_profile_array', 'my_account_pre_updating_profile', 10, 1 );
|
348 |
+
* function my_account_pre_updating_profile( $changes ) {
|
349 |
+
* // your code here
|
350 |
+
* return $changes;
|
351 |
+
* }
|
352 |
+
* ?>
|
353 |
+
*/
|
354 |
+
$changes = apply_filters( 'um_account_pre_updating_profile_array', $changes );
|
355 |
+
|
356 |
+
/**
|
357 |
+
* UM hook
|
358 |
+
*
|
359 |
+
* @type action
|
360 |
+
* @title um_account_pre_update_profile
|
361 |
+
* @description Fired on account page, just before updating profile
|
362 |
+
* @input_vars
|
363 |
+
* [{"var":"$changes","type":"array","desc":"Submitted data"},
|
364 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
365 |
+
* @change_log
|
366 |
+
* ["Since: 2.0"]
|
367 |
+
* @usage add_action( 'um_account_pre_update_profile', 'function_name', 10, 2 );
|
368 |
+
* @example
|
369 |
+
* <?php
|
370 |
+
* add_action( 'um_account_pre_update_profile', 'my_account_pre_update_profile', 10, 2 );
|
371 |
+
* function my_account_pre_update_profile( $changes, $user_id ) {
|
372 |
+
* // your code here
|
373 |
+
* }
|
374 |
+
* ?>
|
375 |
+
*/
|
376 |
+
do_action( 'um_account_pre_update_profile', $changes, $user_id );
|
377 |
+
|
378 |
+
if ( isset( $changes['first_name'] ) || isset( $changes['last_name'] ) || isset( $changes['nickname'] ) ) {
|
379 |
+
$user = get_userdata( $user_id );
|
380 |
+
if ( ! empty( $user ) && ! is_wp_error( $user ) ) {
|
381 |
+
UM()->user()->previous_data['display_name'] = $user->display_name;
|
382 |
+
|
383 |
+
if ( isset( $changes['first_name'] ) ) {
|
384 |
+
UM()->user()->previous_data['first_name'] = $user->first_name;
|
385 |
+
}
|
386 |
+
if ( isset( $changes['last_name'] ) ) {
|
387 |
+
UM()->user()->previous_data['last_name'] = $user->last_name;
|
388 |
+
}
|
389 |
+
if ( isset( $changes['nickname'] ) ) {
|
390 |
+
UM()->user()->previous_data['nickname'] = $user->nickname;
|
391 |
+
}
|
392 |
+
}
|
393 |
+
}
|
394 |
+
|
395 |
+
UM()->user()->update_profile( $changes );
|
396 |
+
|
397 |
+
if ( UM()->account()->is_secure_enabled() ) {
|
398 |
+
update_user_meta( $user_id, 'um_account_secure_fields', array() );
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* UM hook
|
403 |
+
*
|
404 |
+
* @type action
|
405 |
+
* @title um_post_account_update
|
406 |
+
* @description Fired on account page, after updating profile
|
407 |
+
* @change_log
|
408 |
+
* ["Since: 2.0"]
|
409 |
+
* @usage add_action( 'um_post_account_update', 'function_name', 10 );
|
410 |
+
* @example
|
411 |
+
* <?php
|
412 |
+
* add_action( 'um_post_account_update', 'my_post_account_update', 10 );
|
413 |
+
* function my_account_pre_update_profile() {
|
414 |
+
* // your code here
|
415 |
+
* }
|
416 |
+
* ?>
|
417 |
+
*/
|
418 |
+
do_action( 'um_post_account_update' );
|
419 |
+
/**
|
420 |
+
* UM hook
|
421 |
+
*
|
422 |
+
* @type action
|
423 |
+
* @title um_after_user_account_updated
|
424 |
+
* @description Fired on account page, after updating profile
|
425 |
+
* @input_vars
|
426 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
427 |
+
* {"var":"$changes","type":"array","desc":"Submitted data"}]
|
428 |
+
* @change_log
|
429 |
+
* ["Since: 2.0"]
|
430 |
+
* @usage add_action( 'um_after_user_account_updated', 'function_name', 10, 2 );
|
431 |
+
* @example
|
432 |
+
* <?php
|
433 |
+
* add_action( 'um_after_user_account_updated', 'my_after_user_account_updated', 10, 2 );
|
434 |
+
* function my_after_user_account_updated( $user_id, $changes ) {
|
435 |
+
* // your code here
|
436 |
+
* }
|
437 |
+
* ?>
|
438 |
+
*/
|
439 |
+
do_action( 'um_after_user_account_updated', $user_id, $changes );
|
440 |
+
|
441 |
+
$url = '';
|
442 |
+
if ( um_is_core_page( 'account' ) ) {
|
443 |
+
|
444 |
+
$url = UM()->account()->tab_link( $tab );
|
445 |
+
|
446 |
+
$url = add_query_arg( 'updated', 'account', $url );
|
447 |
+
|
448 |
+
if ( function_exists( 'icl_get_current_language' ) ) {
|
449 |
+
if ( icl_get_current_language() != icl_get_default_language() ) {
|
450 |
+
$url = UM()->permalinks()->get_current_url( true );
|
451 |
+
$url = add_query_arg( 'updated', 'account', $url );
|
452 |
+
|
453 |
+
um_js_redirect( $url );
|
454 |
+
}
|
455 |
+
}
|
456 |
+
}
|
457 |
+
|
458 |
+
um_js_redirect( $url );
|
459 |
+
}
|
460 |
+
add_action( 'um_submit_account_details', 'um_submit_account_details' );
|
461 |
+
|
462 |
+
|
463 |
+
/**
|
464 |
+
* Hidden inputs for account form
|
465 |
+
*
|
466 |
+
* @param $args
|
467 |
+
*/
|
468 |
+
function um_account_page_hidden_fields( $args ) {
|
469 |
+
?>
|
470 |
+
|
471 |
+
<input type="hidden" name="_um_account" id="_um_account" value="1" />
|
472 |
+
<input type="hidden" name="_um_account_tab" id="_um_account_tab" value="<?php echo esc_attr( UM()->account()->current_tab ); ?>" />
|
473 |
+
|
474 |
+
<?php
|
475 |
+
}
|
476 |
+
add_action( 'um_account_page_hidden_fields', 'um_account_page_hidden_fields' );
|
477 |
+
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Before delete account tab content
|
481 |
+
*/
|
482 |
+
function um_before_account_delete() {
|
483 |
+
if ( UM()->account()->current_password_is_required( 'delete' ) ) {
|
484 |
+
$text = UM()->options()->get( 'delete_account_text' );
|
485 |
+
} else {
|
486 |
+
$text = UM()->options()->get( 'delete_account_no_pass_required_text' );
|
487 |
+
}
|
488 |
+
|
489 |
+
printf( __( '%s', 'ultimate-member' ), wpautop( htmlspecialchars( $text ) ) );
|
490 |
+
}
|
491 |
+
add_action( 'um_before_account_delete', 'um_before_account_delete' );
|
492 |
+
|
493 |
+
|
494 |
+
/**
|
495 |
+
* Before notifications account tab content
|
496 |
+
*
|
497 |
+
* @param array $args
|
498 |
+
*
|
499 |
+
* @throws Exception
|
500 |
+
*/
|
501 |
+
function um_before_account_notifications( $args = array() ) {
|
502 |
+
$output = UM()->account()->get_tab_fields( 'notifications', $args );
|
503 |
+
if ( substr_count( $output, '_enable_new_' ) ) { ?>
|
504 |
+
|
505 |
+
<p><?php _e( 'Select what email notifications you want to receive', 'ultimate-member' ); ?></p>
|
506 |
+
|
507 |
+
<?php }
|
508 |
+
}
|
509 |
+
add_action( 'um_before_account_notifications', 'um_before_account_notifications' );
|
510 |
+
|
511 |
+
|
512 |
+
/**
|
513 |
+
* Update Profile URL, display name, full name.
|
514 |
+
*
|
515 |
+
* @version 2.2.5
|
516 |
+
*
|
517 |
+
* @param int $user_id The user ID.
|
518 |
+
* @param array $changes An array of fields values.
|
519 |
+
*/
|
520 |
+
function um_after_user_account_updated_permalink( $user_id, $changes ) {
|
521 |
+
if ( isset( $changes['first_name'] ) || isset( $changes['last_name'] ) ) {
|
522 |
+
do_action( 'um_update_profile_full_name', $user_id, $changes );
|
523 |
+
}
|
524 |
+
}
|
525 |
+
add_action( 'um_after_user_account_updated', 'um_after_user_account_updated_permalink', 10, 2 );
|
526 |
+
|
527 |
+
|
528 |
+
/**
|
529 |
+
* Update Account Email Notification
|
530 |
+
*
|
531 |
+
* @param $user_id
|
532 |
+
* @param $changed
|
533 |
+
*/
|
534 |
+
function um_account_updated_notification( $user_id, $changed ) {
|
535 |
+
um_fetch_user( $user_id );
|
536 |
+
UM()->mail()->send( um_user( 'user_email' ), 'changedaccount_email' );
|
537 |
+
}
|
538 |
+
add_action( 'um_after_user_account_updated', 'um_account_updated_notification', 20, 2 );
|
539 |
+
|
540 |
+
|
541 |
+
/**
|
542 |
+
* Disable WP native email notification when change email on user account
|
543 |
+
*
|
544 |
+
* @param $user_id
|
545 |
+
* @param $changed
|
546 |
+
*/
|
547 |
+
function um_disable_native_email_notificatiion( $changed, $user_id ) {
|
548 |
+
add_filter( 'send_email_change_email', '__return_false' );
|
549 |
+
}
|
550 |
+
add_action( 'um_account_pre_update_profile', 'um_disable_native_email_notificatiion', 10, 2 );
|
551 |
+
|
552 |
+
|
553 |
+
/**
|
554 |
+
* Add export and erase user's data in privacy tab
|
555 |
+
*
|
556 |
+
* @param $args
|
557 |
+
*/
|
558 |
+
add_action( 'um_after_account_privacy', 'um_after_account_privacy' );
|
559 |
+
function um_after_account_privacy( $args ) {
|
560 |
+
global $wpdb;
|
561 |
+
$user_id = get_current_user_id();
|
562 |
+
?>
|
563 |
+
|
564 |
+
<div class="um-field um-field-export_data">
|
565 |
+
<div class="um-field-label">
|
566 |
+
<label>
|
567 |
+
<?php esc_html_e( 'Download your data', 'ultimate-member' ); ?>
|
568 |
+
</label>
|
569 |
+
<span class="um-tip um-tip-<?php echo is_rtl() ? 'e' : 'w' ?>" original-title="<?php esc_attr_e( 'You can request a file with the information that we believe is most relevant and useful to you.', 'ultimate-member' ); ?>">
|
570 |
+
<i class="um-icon-help-circled"></i>
|
571 |
+
</span>
|
572 |
+
<div class="um-clear"></div>
|
573 |
+
</div>
|
574 |
+
<?php $completed = $wpdb->get_row(
|
575 |
+
"SELECT ID
|
576 |
+
FROM $wpdb->posts
|
577 |
+
WHERE post_author = $user_id AND
|
578 |
+
post_type = 'user_request' AND
|
579 |
+
post_name = 'export_personal_data' AND
|
580 |
+
post_status = 'request-completed'
|
581 |
+
ORDER BY ID DESC
|
582 |
+
LIMIT 1",
|
583 |
+
ARRAY_A );
|
584 |
+
|
585 |
+
if ( ! empty( $completed ) ) {
|
586 |
+
|
587 |
+
$exports_url = wp_privacy_exports_url();
|
588 |
+
|
589 |
+
echo '<p>' . esc_html__( 'You could download your previous data:', 'ultimate-member' ) . '</p>';
|
590 |
+
echo '<a href="'.esc_attr( $exports_url . get_post_meta( $completed['ID'], '_export_file_name', true ) ) . '">' . esc_html__( 'Download Personal Data', 'ultimate-member' ) . '</a>';
|
591 |
+
echo '<p>' . esc_html__( 'You could send a new request for an export of personal your data.', 'ultimate-member' ) . '</p>';
|
592 |
+
|
593 |
+
}
|
594 |
+
|
595 |
+
$pending = $wpdb->get_row(
|
596 |
+
"SELECT ID, post_status
|
597 |
+
FROM $wpdb->posts
|
598 |
+
WHERE post_author = $user_id AND
|
599 |
+
post_type = 'user_request' AND
|
600 |
+
post_name = 'export_personal_data' AND
|
601 |
+
post_status != 'request-completed'
|
602 |
+
ORDER BY ID DESC
|
603 |
+
LIMIT 1",
|
604 |
+
ARRAY_A );
|
605 |
+
|
606 |
+
if ( ! empty( $pending ) && $pending['post_status'] == 'request-pending' ) {
|
607 |
+
echo '<p>' . esc_html__( 'A confirmation email has been sent to your email. Click the link within the email to confirm your export request.', 'ultimate-member' ) . '</p>';
|
608 |
+
} elseif ( ! empty( $pending ) && $pending['post_status'] == 'request-confirmed' ) {
|
609 |
+
echo '<p>' . esc_html__( 'The administrator has not yet approved downloading the data. Please expect an email with a link to your data.', 'ultimate-member' ) . '</p>';
|
610 |
+
} else {
|
611 |
+
if ( UM()->account()->current_password_is_required( 'privacy_download_data' ) ) { ?>
|
612 |
+
|
613 |
+
<label name="um-export-data">
|
614 |
+
<?php esc_html_e( 'Enter your current password to confirm a new export of your personal data.', 'ultimate-member' ); ?>
|
615 |
+
</label>
|
616 |
+
<div class="um-field-area">
|
617 |
+
<input id="um-export-data" type="password" placeholder="<?php esc_attr_e( 'Password', 'ultimate-member' )?>">
|
618 |
+
<div class="um-field-error um-export-data">
|
619 |
+
<span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span><?php esc_html_e( 'You must enter a password', 'ultimate-member' ); ?>
|
620 |
+
</div>
|
621 |
+
<div class="um-field-area-response um-export-data"></div>
|
622 |
+
</div>
|
623 |
+
|
624 |
+
<?php } else { ?>
|
625 |
+
|
626 |
+
<label name="um-export-data">
|
627 |
+
<?php esc_html_e( 'To export of your personal data, click the button below.', 'ultimate-member' ); ?>
|
628 |
+
</label>
|
629 |
+
<div class="um-field-area-response um-export-data"></div>
|
630 |
+
|
631 |
+
<?php } ?>
|
632 |
+
|
633 |
+
<a class="um-request-button um-export-data-button" data-action="um-export-data" href="javascript:void(0);">
|
634 |
+
<?php esc_html_e( 'Request data', 'ultimate-member' ); ?>
|
635 |
+
</a>
|
636 |
+
<?php } ?>
|
637 |
+
|
638 |
+
</div>
|
639 |
+
|
640 |
+
<div class="um-field um-field-export_data">
|
641 |
+
<div class="um-field-label">
|
642 |
+
<label>
|
643 |
+
<?php esc_html_e( 'Erase of your data', 'ultimate-member' ); ?>
|
644 |
+
</label>
|
645 |
+
<span class="um-tip um-tip-<?php echo is_rtl() ? 'e' : 'w' ?>" original-title="<?php esc_attr_e( 'You can request erasing of the data that we have about you.', 'ultimate-member' ); ?>">
|
646 |
+
<i class="um-icon-help-circled"></i>
|
647 |
+
</span>
|
648 |
+
<div class="um-clear"></div>
|
649 |
+
</div>
|
650 |
+
|
651 |
+
<?php $completed = $wpdb->get_row(
|
652 |
+
"SELECT ID
|
653 |
+
FROM $wpdb->posts
|
654 |
+
WHERE post_author = $user_id AND
|
655 |
+
post_type = 'user_request' AND
|
656 |
+
post_name = 'remove_personal_data' AND
|
657 |
+
post_status = 'request-completed'
|
658 |
+
ORDER BY ID DESC
|
659 |
+
LIMIT 1",
|
660 |
+
ARRAY_A );
|
661 |
+
|
662 |
+
if ( ! empty( $completed ) ) {
|
663 |
+
|
664 |
+
echo '<p>' . esc_html__( 'Your personal data has been deleted.', 'ultimate-member' ) . '</p>';
|
665 |
+
echo '<p>' . esc_html__( 'You could send a new request for deleting your personal data.', 'ultimate-member' ) . '</p>';
|
666 |
+
|
667 |
+
}
|
668 |
+
|
669 |
+
$pending = $wpdb->get_row(
|
670 |
+
"SELECT ID, post_status
|
671 |
+
FROM $wpdb->posts
|
672 |
+
WHERE post_author = $user_id AND
|
673 |
+
post_type = 'user_request' AND
|
674 |
+
post_name = 'remove_personal_data' AND
|
675 |
+
post_status != 'request-completed'
|
676 |
+
ORDER BY ID DESC
|
677 |
+
LIMIT 1",
|
678 |
+
ARRAY_A );
|
679 |
+
|
680 |
+
if ( ! empty( $pending ) && $pending['post_status'] == 'request-pending' ) {
|
681 |
+
echo '<p>' . esc_html__( 'A confirmation email has been sent to your email. Click the link within the email to confirm your deletion request.', 'ultimate-member' ) . '</p>';
|
682 |
+
} elseif ( ! empty( $pending ) && $pending['post_status'] == 'request-confirmed' ) {
|
683 |
+
echo '<p>' . esc_html__( 'The administrator has not yet approved deleting your data. Please expect an email with a link to your data.', 'ultimate-member' ) . '</p>';
|
684 |
+
} else {
|
685 |
+
if ( UM()->account()->current_password_is_required( 'privacy_erase_data' ) ) { ?>
|
686 |
+
|
687 |
+
<label name="um-erase-data">
|
688 |
+
<?php esc_html_e( 'Enter your current password to confirm the erasure of your personal data.', 'ultimate-member' ); ?>
|
689 |
+
<input id="um-erase-data" type="password" placeholder="<?php esc_attr_e( 'Password', 'ultimate-member' )?>">
|
690 |
+
<div class="um-field-error um-erase-data">
|
691 |
+
<span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span><?php esc_html_e( 'You must enter a password', 'ultimate-member' ); ?>
|
692 |
+
</div>
|
693 |
+
<div class="um-field-area-response um-erase-data"></div>
|
694 |
+
</label>
|
695 |
+
|
696 |
+
<?php } else { ?>
|
697 |
+
|
698 |
+
<label name="um-erase-data">
|
699 |
+
<?php esc_html_e( 'Require erasure of your personal data, click on the button below.', 'ultimate-member' ); ?>
|
700 |
+
<div class="um-field-area-response um-erase-data"></div>
|
701 |
+
</label>
|
702 |
+
|
703 |
+
<?php } ?>
|
704 |
+
|
705 |
+
<a class="um-request-button um-erase-data-button" data-action="um-erase-data" href="javascript:void(0);">
|
706 |
+
<?php esc_html_e( 'Request data erase', 'ultimate-member' ); ?>
|
707 |
+
</a>
|
708 |
+
<?php } ?>
|
709 |
+
|
710 |
+
</div>
|
711 |
+
|
712 |
+
<?php
|
713 |
+
}
|
714 |
+
|
715 |
+
|
716 |
+
function um_request_user_data() {
|
717 |
+
UM()->check_ajax_nonce();
|
718 |
+
|
719 |
+
if ( ! isset( $_POST['request_action'] ) ) {
|
720 |
+
wp_send_json_error( __( 'Wrong request.', 'ultimate-member' ) );
|
721 |
+
}
|
722 |
+
|
723 |
+
$user_id = get_current_user_id();
|
724 |
+
$password = ! empty( $_POST['password'] ) ? sanitize_text_field( $_POST['password'] ) : '';
|
725 |
+
$user = get_userdata( $user_id );
|
726 |
+
$hash = $user->data->user_pass;
|
727 |
+
$request_action = sanitize_key( $_POST['request_action'] );
|
728 |
+
|
729 |
+
if ( 'um-export-data' === $request_action ) {
|
730 |
+
if ( UM()->account()->current_password_is_required( 'privacy_download_data' ) ) {
|
731 |
+
if ( ! wp_check_password( $password, $hash ) ) {
|
732 |
+
$answer = esc_html__( 'The password you entered is incorrect.', 'ultimate-member' );
|
733 |
+
wp_send_json_success( array( 'answer' => $answer ) );
|
734 |
+
}
|
735 |
+
}
|
736 |
+
} elseif ( 'um-erase-data' === $request_action ) {
|
737 |
+
if ( UM()->account()->current_password_is_required( 'privacy_erase_data' ) ) {
|
738 |
+
if ( ! wp_check_password( $password, $hash ) ) {
|
739 |
+
$answer = esc_html__( 'The password you entered is incorrect.', 'ultimate-member' );
|
740 |
+
wp_send_json_success( array( 'answer' => $answer ) );
|
741 |
+
}
|
742 |
+
}
|
743 |
+
}
|
744 |
+
|
745 |
+
if ( 'um-export-data' === $request_action ) {
|
746 |
+
$request_id = wp_create_user_request( $user->data->user_email, 'export_personal_data' );
|
747 |
+
} elseif ( 'um-erase-data' === $request_action ) {
|
748 |
+
$request_id = wp_create_user_request( $user->data->user_email, 'remove_personal_data' );
|
749 |
+
}
|
750 |
+
|
751 |
+
if ( ! isset( $request_id ) || empty( $request_id ) ) {
|
752 |
+
wp_send_json_error( __( 'Wrong request.', 'ultimate-member' ) );
|
753 |
+
}
|
754 |
+
|
755 |
+
if ( is_wp_error( $request_id ) ) {
|
756 |
+
$answer = esc_html( $request_id->get_error_message() );
|
757 |
+
} else {
|
758 |
+
wp_send_user_request( $request_id );
|
759 |
+
if ( 'um-export-data' === $request_action ) {
|
760 |
+
$answer = esc_html__( 'A confirmation email has been sent to your email. Click the link within the email to confirm your export request.', 'ultimate-member' );
|
761 |
+
} elseif ( 'um-erase-data' === $request_action ) {
|
762 |
+
$answer = esc_html__( 'A confirmation email has been sent to your email. Click the link within the email to confirm your deletion request.', 'ultimate-member' );
|
763 |
+
}
|
764 |
+
}
|
765 |
+
|
766 |
+
wp_send_json_success( array( 'answer' => $answer ) );
|
767 |
+
}
|
768 |
+
add_action( 'wp_ajax_um_request_user_data', 'um_request_user_data' );
|
includes/core/um-actions-form.php
CHANGED
@@ -1,924 +1,936 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
2 |
-
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Error handling: blocked emails
|
6 |
-
*
|
7 |
-
* @param $args
|
8 |
-
*/
|
9 |
-
function um_submit_form_errors_hook__blockedemails( $args ) {
|
10 |
-
$emails = UM()->options()->get( 'blocked_emails' );
|
11 |
-
if ( ! $emails ) {
|
12 |
-
return;
|
13 |
-
}
|
14 |
-
|
15 |
-
$emails = array_map( 'rtrim', explode( "\n", $emails ) );
|
16 |
-
|
17 |
-
if ( isset( $args['user_email'] ) && is_email( $args['user_email'] ) ) {
|
18 |
-
|
19 |
-
$domain = explode( '@', $args['user_email'] );
|
20 |
-
$check_domain = str_replace( $domain[0], '*', $args['user_email'] );
|
21 |
-
|
22 |
-
if ( in_array( $args['user_email'], $emails ) ) {
|
23 |
-
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_email' ) ) ) );
|
24 |
-
}
|
25 |
-
|
26 |
-
if ( in_array( $check_domain, $emails ) ) {
|
27 |
-
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_domain' ) ) ) );
|
28 |
-
}
|
29 |
-
|
30 |
-
}
|
31 |
-
|
32 |
-
if ( isset( $args['username'] ) && is_email( $args['username'] ) ) {
|
33 |
-
|
34 |
-
$domain = explode( '@', $args['username'] );
|
35 |
-
$check_domain = str_replace( $domain[0], '*', $args['username'] );
|
36 |
-
|
37 |
-
if ( in_array( $args['username'], $emails ) ) {
|
38 |
-
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_email' ) ) ) );
|
39 |
-
}
|
40 |
-
|
41 |
-
if ( in_array( $check_domain, $emails ) ) {
|
42 |
-
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_domain' ) ) ) );
|
43 |
-
}
|
44 |
-
|
45 |
-
}
|
46 |
-
}
|
47 |
-
add_action( 'um_submit_form_errors_hook__blockedemails', 'um_submit_form_errors_hook__blockedemails', 10 );
|
48 |
-
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Error handling: blocked IPs
|
52 |
-
*
|
53 |
-
* @param $args
|
54 |
-
*/
|
55 |
-
function um_submit_form_errors_hook__blockedips( $args ) {
|
56 |
-
$ips = UM()->options()->get( 'blocked_ips' );
|
57 |
-
if ( ! $ips ) {
|
58 |
-
return;
|
59 |
-
}
|
60 |
-
|
61 |
-
$ips = array_map( 'rtrim', explode( "\n", $ips ) );
|
62 |
-
$user_ip = um_user_ip();
|
63 |
-
|
64 |
-
foreach ( $ips as $ip ) {
|
65 |
-
$ip = str_replace( '*', '', $ip );
|
66 |
-
if ( ! empty( $ip ) && strpos( $user_ip, $ip ) === 0 ) {
|
67 |
-
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_ip' ) ) ) );
|
68 |
-
}
|
69 |
-
}
|
70 |
-
}
|
71 |
-
add_action( 'um_submit_form_errors_hook__blockedips', 'um_submit_form_errors_hook__blockedips', 10 );
|
72 |
-
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Error handling: blocked words during sign up
|
76 |
-
*
|
77 |
-
* @param $args
|
78 |
-
*/
|
79 |
-
function um_submit_form_errors_hook__blockedwords( $args ) {
|
80 |
-
$words = UM()->options()->get( 'blocked_words' );
|
81 |
-
if ( empty( $words ) ) {
|
82 |
-
return;
|
83 |
-
}
|
84 |
-
|
85 |
-
$form_id = $args['form_id'];
|
86 |
-
$mode = $args['mode'];
|
87 |
-
$fields = unserialize( $args['custom_fields'] );
|
88 |
-
|
89 |
-
$words = array_map( 'rtrim', explode( "\n", $words ) );
|
90 |
-
if ( ! empty( $fields ) && is_array( $fields ) ) {
|
91 |
-
foreach ( $fields as $key => $array ) {
|
92 |
-
if ( isset( $array['validate'] ) && in_array( $array['validate'], array( 'unique_username', 'unique_email', 'unique_username_or_email' ) ) ) {
|
93 |
-
if ( ! UM()->form()->has_error( $key ) && isset( $args[ $key ] ) && in_array( $args[ $key ], $words ) ) {
|
94 |
-
UM()->form()->add_error( $key, __( 'You are not allowed to use this word as your username.', 'ultimate-member' ) );
|
95 |
-
}
|
96 |
-
}
|
97 |
-
}
|
98 |
-
}
|
99 |
-
}
|
100 |
-
add_action( 'um_submit_form_errors_hook__blockedwords', 'um_submit_form_errors_hook__blockedwords', 10 );
|
101 |
-
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Error handling
|
105 |
-
*
|
106 |
-
* @param $args
|
107 |
-
*/
|
108 |
-
function um_submit_form_errors_hook( $args ) {
|
109 |
-
$mode = $args['mode'];
|
110 |
-
|
111 |
-
/**
|
112 |
-
* UM hook
|
113 |
-
*
|
114 |
-
* @type action
|
115 |
-
* @title um_submit_form_errors_hook__blockedips
|
116 |
-
* @description Submit form validation
|
117 |
-
* @input_vars
|
118 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
119 |
-
* @change_log
|
120 |
-
* ["Since: 2.0"]
|
121 |
-
* @usage add_action( 'um_submit_form_errors_hook__blockedips', 'function_name', 10, 1 );
|
122 |
-
* @example
|
123 |
-
* <?php
|
124 |
-
* add_action( 'um_submit_form_errors_hook__blockedips', 'my_submit_form_errors_hook__blockedips', 10, 1 );
|
125 |
-
* function my_submit_form_errors_hook__blockedips( $args ) {
|
126 |
-
* // your code here
|
127 |
-
* }
|
128 |
-
* ?>
|
129 |
-
*/
|
130 |
-
do_action( 'um_submit_form_errors_hook__blockedips', $args );
|
131 |
-
|
132 |
-
|
133 |
-
/**
|
134 |
-
* UM hook
|
135 |
-
*
|
136 |
-
* @type action
|
137 |
-
* @title um_submit_form_errors_hook__blockedemails
|
138 |
-
* @description Submit form validation
|
139 |
-
* @input_vars
|
140 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
141 |
-
* @change_log
|
142 |
-
* ["Since: 2.0"]
|
143 |
-
* @usage add_action( 'um_submit_form_errors_hook__blockedemails', 'function_name', 10, 1 );
|
144 |
-
* @example
|
145 |
-
* <?php
|
146 |
-
* add_action( 'um_submit_form_errors_hook__blockedemails', 'my_submit_form_errors_hook__blockedemails', 10, 1 );
|
147 |
-
* function my_submit_form_errors_hook__blockedemails( $args ) {
|
148 |
-
* // your code here
|
149 |
-
* }
|
150 |
-
* ?>
|
151 |
-
*/
|
152 |
-
do_action( 'um_submit_form_errors_hook__blockedemails', $args );
|
153 |
-
|
154 |
-
if ( $mode == 'register' ) {
|
155 |
-
|
156 |
-
|
157 |
-
/**
|
158 |
-
* UM hook
|
159 |
-
*
|
160 |
-
* @type action
|
161 |
-
* @title um_submit_form_errors_hook__registration
|
162 |
-
* @description Submit registration form validation
|
163 |
-
* @input_vars
|
164 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
165 |
-
* @change_log
|
166 |
-
* ["Since: 2.0"]
|
167 |
-
* @usage add_action( 'um_submit_form_errors_hook__registration', 'function_name', 10, 1 );
|
168 |
-
* @example
|
169 |
-
* <?php
|
170 |
-
* add_action( 'um_submit_form_errors_hook__registration', 'my_submit_form_errors_registration', 10, 1 );
|
171 |
-
* function my_submit_form_errors_registration( $args ) {
|
172 |
-
* // your code here
|
173 |
-
* }
|
174 |
-
* ?>
|
175 |
-
*/
|
176 |
-
do_action( 'um_submit_form_errors_hook__registration', $args );
|
177 |
-
|
178 |
-
} elseif ( $mode == 'profile' ) {
|
179 |
-
|
180 |
-
|
181 |
-
/**
|
182 |
-
* UM hook
|
183 |
-
*
|
184 |
-
* @type action
|
185 |
-
* @title um_submit_form_errors_hook__registration
|
186 |
-
* @description Submit registration form validation
|
187 |
-
* @input_vars
|
188 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
189 |
-
* @change_log
|
190 |
-
* ["Since: 2.0"]
|
191 |
-
* @usage add_action( 'um_submit_form_errors_hook__registration', 'function_name', 10, 1 );
|
192 |
-
* @example
|
193 |
-
* <?php
|
194 |
-
* add_action( 'um_submit_form_errors_hook__profile', 'my_submit_form_errors_hook__profile', 10, 1 );
|
195 |
-
* function my_submit_form_errors_registration( $args ) {
|
196 |
-
* // your code here
|
197 |
-
* }
|
198 |
-
* ?>
|
199 |
-
*/
|
200 |
-
do_action( 'um_submit_form_errors_hook__profile', $args );
|
201 |
-
|
202 |
-
} elseif ( $mode == 'login' ) {
|
203 |
-
|
204 |
-
|
205 |
-
/**
|
206 |
-
* UM hook
|
207 |
-
*
|
208 |
-
* @type action
|
209 |
-
* @title um_submit_form_errors_hook_login
|
210 |
-
* @description Submit login form validation
|
211 |
-
* @input_vars
|
212 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
213 |
-
* @change_log
|
214 |
-
* ["Since: 2.0"]
|
215 |
-
* @usage add_action( 'um_submit_form_errors_hook_login', 'function_name', 10, 1 );
|
216 |
-
* @example
|
217 |
-
* <?php
|
218 |
-
* add_action( 'um_submit_form_errors_hook_login', 'my_submit_form_errors_hook_login', 10, 1 );
|
219 |
-
* function my_submit_form_errors_hook_login( $args ) {
|
220 |
-
* // your code here
|
221 |
-
* }
|
222 |
-
* ?>
|
223 |
-
*/
|
224 |
-
do_action( 'um_submit_form_errors_hook_login', $args );
|
225 |
-
|
226 |
-
|
227 |
-
/**
|
228 |
-
* UM hook
|
229 |
-
*
|
230 |
-
* @type action
|
231 |
-
* @title um_submit_form_errors_hook_logincheck
|
232 |
-
* @description Submit login form validation
|
233 |
-
* @input_vars
|
234 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
235 |
-
* @change_log
|
236 |
-
* ["Since: 2.0"]
|
237 |
-
* @usage add_action( 'um_submit_form_errors_hook_logincheck', 'function_name', 10, 1 );
|
238 |
-
* @example
|
239 |
-
* <?php
|
240 |
-
* add_action( 'um_submit_form_errors_hook_logincheck', 'my_submit_form_errors_hook_logincheck', 10, 1 );
|
241 |
-
* function my_submit_form_errors_hook_logincheck( $args ) {
|
242 |
-
* // your code here
|
243 |
-
* }
|
244 |
-
* ?>
|
245 |
-
*/
|
246 |
-
do_action( 'um_submit_form_errors_hook_logincheck', $args );
|
247 |
-
|
248 |
-
}
|
249 |
-
|
250 |
-
|
251 |
-
if ( $mode != 'login' ) {
|
252 |
-
|
253 |
-
|
254 |
-
/**
|
255 |
-
* UM hook
|
256 |
-
*
|
257 |
-
* @type action
|
258 |
-
* @title um_submit_form_errors_hook__blockedwords
|
259 |
-
* @description Submit form validation
|
260 |
-
* @input_vars
|
261 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
262 |
-
* @change_log
|
263 |
-
* ["Since: 2.0"]
|
264 |
-
* @usage add_action( 'um_submit_form_errors_hook__blockedwords', 'function_name', 10, 1 );
|
265 |
-
* @example
|
266 |
-
* <?php
|
267 |
-
* add_action( 'um_submit_form_errors_hook__blockedwords', 'my_submit_form_errors_hook__blockedwords', 10, 1 );
|
268 |
-
* function my_submit_form_errors_hook__blockedwords( $args ) {
|
269 |
-
* // your code here
|
270 |
-
* }
|
271 |
-
* ?>
|
272 |
-
*/
|
273 |
-
do_action( 'um_submit_form_errors_hook__blockedwords', $args );
|
274 |
-
|
275 |
-
|
276 |
-
/**
|
277 |
-
* UM hook
|
278 |
-
*
|
279 |
-
* @type action
|
280 |
-
* @title um_submit_form_errors_hook_
|
281 |
-
* @description Submit form validation
|
282 |
-
* @input_vars
|
283 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
284 |
-
* @change_log
|
285 |
-
* ["Since: 2.0"]
|
286 |
-
* @usage add_action( 'um_submit_form_errors_hook_', 'function_name', 10, 1 );
|
287 |
-
* @example
|
288 |
-
* <?php
|
289 |
-
* add_action( 'um_submit_form_errors_hook_', 'my_submit_form_errors_hook', 10, 1 );
|
290 |
-
* function my_submit_form_errors_hook( $args ) {
|
291 |
-
* // your code here
|
292 |
-
* }
|
293 |
-
* ?>
|
294 |
-
*/
|
295 |
-
do_action( 'um_submit_form_errors_hook_', $args );
|
296 |
-
|
297 |
-
}
|
298 |
-
|
299 |
-
}
|
300 |
-
add_action( 'um_submit_form_errors_hook', 'um_submit_form_errors_hook', 10 );
|
301 |
-
|
302 |
-
|
303 |
-
/**
|
304 |
-
* Error processing: Conditions
|
305 |
-
* @staticvar int $counter
|
306 |
-
* @param array $condition
|
307 |
-
* @param array $fields
|
308 |
-
* @param array $args
|
309 |
-
* @param boolean $reset
|
310 |
-
* @return boolean
|
311 |
-
* @throws Exception
|
312 |
-
*/
|
313 |
-
function um_check_conditions_on_submit( $condition, $fields, $args, $reset = false ) {
|
314 |
-
static $counter = 0;
|
315 |
-
if ( $reset ) {
|
316 |
-
$counter = 0;
|
317 |
-
}
|
318 |
-
$continue = false;
|
319 |
-
|
320 |
-
list( $visibility, $parent_key, $op, $parent_value ) = $condition;
|
321 |
-
|
322 |
-
if ( ! isset( $args[ $parent_key ] ) ) {
|
323 |
-
$continue = true;
|
324 |
-
return $continue;
|
325 |
-
}
|
326 |
-
|
327 |
-
if ( ! empty( $fields[ $parent_key ]['conditions'] ) ) {
|
328 |
-
foreach ( $fields[ $parent_key ]['conditions'] as $parent_condition ) {
|
329 |
-
if ( 64 > $counter++ ) {
|
330 |
-
$continue = um_check_conditions_on_submit( $parent_condition, $fields, $args );
|
331 |
-
} else {
|
332 |
-
throw new Exception( 'Endless recursion in the function ' . __FUNCTION__, 512 );
|
333 |
-
}
|
334 |
-
if ( ! empty( $continue ) ) {
|
335 |
-
return $continue;
|
336 |
-
}
|
337 |
-
}
|
338 |
-
}
|
339 |
-
|
340 |
-
$cond_value = ( $fields[ $parent_key ]['type'] == 'radio' ) ? $args[ $parent_key ][0] : $args[ $parent_key ];
|
341 |
-
|
342 |
-
if ( $visibility == 'hide' ) {
|
343 |
-
if ( $op == 'empty' ) {
|
344 |
-
if ( empty( $cond_value ) ) {
|
345 |
-
$continue = true;
|
346 |
-
}
|
347 |
-
} elseif ( $op == 'not empty' ) {
|
348 |
-
if ( ! empty( $cond_value ) ) {
|
349 |
-
$continue = true;
|
350 |
-
}
|
351 |
-
} elseif ( $op == 'equals to' ) {
|
352 |
-
if ( $cond_value == $parent_value ) {
|
353 |
-
$continue = true;
|
354 |
-
}
|
355 |
-
} elseif ( $op == 'not equals' ) {
|
356 |
-
if ( $cond_value != $parent_value ) {
|
357 |
-
$continue = true;
|
358 |
-
}
|
359 |
-
} elseif ( $op == 'greater than' ) {
|
360 |
-
if ( $cond_value > $parent_value ) {
|
361 |
-
$continue = true;
|
362 |
-
}
|
363 |
-
} elseif ( $op == 'less than' ) {
|
364 |
-
if ( $cond_value < $parent_value ) {
|
365 |
-
$continue = true;
|
366 |
-
}
|
367 |
-
} elseif ( $op == 'contains' ) {
|
368 |
-
if ( is_string( $cond_value ) && strstr( $cond_value, $parent_value ) ) {
|
369 |
-
$continue = true;
|
370 |
-
}
|
371 |
-
if( is_array( $cond_value ) && in_array( $parent_value, $cond_value ) ) {
|
372 |
-
$continue = true;
|
373 |
-
}
|
374 |
-
}
|
375 |
-
} elseif ( $visibility == 'show' ) {
|
376 |
-
if ( $op == 'empty' ) {
|
377 |
-
if ( ! empty( $cond_value ) ) {
|
378 |
-
$continue = true;
|
379 |
-
}
|
380 |
-
} elseif ( $op == 'not empty' ) {
|
381 |
-
if ( empty( $cond_value ) ) {
|
382 |
-
$continue = true;
|
383 |
-
}
|
384 |
-
} elseif ( $op == 'equals to' ) {
|
385 |
-
if ( $cond_value != $parent_value ) {
|
386 |
-
$continue = true;
|
387 |
-
}
|
388 |
-
} elseif ( $op == 'not equals' ) {
|
389 |
-
if ( $cond_value == $parent_value ) {
|
390 |
-
$continue = true;
|
391 |
-
}
|
392 |
-
} elseif ( $op == 'greater than' ) {
|
393 |
-
if ( $cond_value <= $parent_value ) {
|
394 |
-
$continue = true;
|
395 |
-
}
|
396 |
-
} elseif ( $op == 'less than' ) {
|
397 |
-
if ( $cond_value >= $parent_value ) {
|
398 |
-
$continue = true;
|
399 |
-
}
|
400 |
-
} elseif ( $op == 'contains' ) {
|
401 |
-
if ( is_string( $cond_value ) && ! strstr( $cond_value, $parent_value ) ) {
|
402 |
-
$continue = true;
|
403 |
-
}
|
404 |
-
if( is_array( $cond_value ) && !in_array( $parent_value, $cond_value ) ) {
|
405 |
-
$continue = true;
|
406 |
-
}
|
407 |
-
}
|
408 |
-
}
|
409 |
-
|
410 |
-
return $continue;
|
411 |
-
}
|
412 |
-
|
413 |
-
|
414 |
-
/**
|
415 |
-
* Error processing hook : standard
|
416 |
-
*
|
417 |
-
* @param $args
|
418 |
-
*/
|
419 |
-
function um_submit_form_errors_hook_( $args ) {
|
420 |
-
$form_id = $args['form_id'];
|
421 |
-
$mode = $args['mode'];
|
422 |
-
$fields = unserialize( $args['custom_fields'] );
|
423 |
-
|
424 |
-
$um_profile_photo = um_profile('profile_photo');
|
425 |
-
if ( get_post_meta( $form_id, '_um_profile_photo_required', true ) && ( empty( $args['profile_photo'] ) && empty( $um_profile_photo ) ) ) {
|
426 |
-
UM()->form()->add_error('profile_photo', __( 'Profile Photo is required.', 'ultimate-member' ) );
|
427 |
-
}
|
428 |
-
|
429 |
-
if ( ! empty( $fields ) ) {
|
430 |
-
|
431 |
-
$can_edit = false;
|
432 |
-
$current_user_roles = [];
|
433 |
-
if ( is_user_logged_in() ) {
|
434 |
-
|
435 |
-
$can_edit = UM()->roles()->um_current_user_can( 'edit', $args['user_id'] );
|
436 |
-
|
437 |
-
um_fetch_user( get_current_user_id() );
|
438 |
-
$current_user_roles = um_user( 'roles' );
|
439 |
-
um_reset_user();
|
440 |
-
}
|
441 |
-
|
442 |
-
foreach ( $fields as $key => $array ) {
|
443 |
-
|
444 |
-
if ( $mode == 'profile' ) {
|
445 |
-
$restricted_fields = UM()->fields()->get_restricted_fields_for_edit();
|
446 |
-
if ( is_array( $restricted_fields ) && in_array( $key, $restricted_fields ) ) {
|
447 |
-
continue;
|
448 |
-
}
|
449 |
-
}
|
450 |
-
|
451 |
-
$can_view = true;
|
452 |
-
if ( isset( $array['public'] ) && $mode != 'register' ) {
|
453 |
-
|
454 |
-
switch ( $array['public'] ) {
|
455 |
-
case '1': // Everyone
|
456 |
-
break;
|
457 |
-
case '2': // Members
|
458 |
-
if ( ! is_user_logged_in() ) {
|
459 |
-
$can_view = false;
|
460 |
-
}
|
461 |
-
break;
|
462 |
-
case '-1': // Only visible to profile owner and admins
|
463 |
-
if ( ! is_user_logged_in() ) {
|
464 |
-
$can_view = false;
|
465 |
-
} elseif ( $args['user_id'] != get_current_user_id() && ! $can_edit ) {
|
466 |
-
$can_view = false;
|
467 |
-
}
|
468 |
-
break;
|
469 |
-
case '-2': // Only specific member roles
|
470 |
-
if ( ! is_user_logged_in() ) {
|
471 |
-
$can_view = false;
|
472 |
-
} elseif ( ! empty( $array['roles'] ) && count( array_intersect( $current_user_roles, $array['roles'] ) ) <= 0 ) {
|
473 |
-
$can_view = false;
|
474 |
-
}
|
475 |
-
break;
|
476 |
-
case '-3': // Only visible to profile owner and specific roles
|
477 |
-
if ( ! is_user_logged_in() ) {
|
478 |
-
$can_view = false;
|
479 |
-
} elseif ( $args['user_id'] != get_current_user_id() && ! empty( $array['roles'] ) && count( array_intersect( $current_user_roles, $array['roles'] ) ) <= 0 ) {
|
480 |
-
$can_view = false;
|
481 |
-
}
|
482 |
-
break;
|
483 |
-
default:
|
484 |
-
$can_view = apply_filters( 'um_can_view_field_custom', $can_view, $array );
|
485 |
-
break;
|
486 |
-
}
|
487 |
-
|
488 |
-
}
|
489 |
-
|
490 |
-
$can_view = apply_filters( 'um_can_view_field', $can_view, $array );
|
491 |
-
|
492 |
-
if ( ! $can_view ) {
|
493 |
-
continue;
|
494 |
-
}
|
495 |
-
|
496 |
-
|
497 |
-
/**
|
498 |
-
* UM hook
|
499 |
-
*
|
500 |
-
* @type filter
|
501 |
-
* @title um_get_custom_field_array
|
502 |
-
* @description Extend custom field data on submit form error
|
503 |
-
* @input_vars
|
504 |
-
* [{"var":"$array","type":"array","desc":"Field data"},
|
505 |
-
* {"var":"$fields","type":"array","desc":"All fields"}]
|
506 |
-
* @change_log
|
507 |
-
* ["Since: 2.0"]
|
508 |
-
* @usage
|
509 |
-
* <?php add_filter( 'um_get_custom_field_array', 'function_name', 10, 2 ); ?>
|
510 |
-
* @example
|
511 |
-
* <?php
|
512 |
-
* add_filter( 'um_get_custom_field_array', 'my_get_custom_field_array', 10, 2 );
|
513 |
-
* function my_get_custom_field_array( $array, $fields ) {
|
514 |
-
* // your code here
|
515 |
-
* return $array;
|
516 |
-
* }
|
517 |
-
* ?>
|
518 |
-
*/
|
519 |
-
$array = apply_filters( 'um_get_custom_field_array', $array, $fields );
|
520 |
-
|
521 |
-
if ( ! empty( $array['conditions'] ) ) {
|
522 |
-
try {
|
523 |
-
foreach ( $array['conditions'] as $condition ) {
|
524 |
-
$continue = um_check_conditions_on_submit( $condition, $fields, $args, true );
|
525 |
-
if ( $continue === true ) {
|
526 |
-
continue 2;
|
527 |
-
}
|
528 |
-
}
|
529 |
-
} catch ( Exception $e ) {
|
530 |
-
UM()->form()->add_error( $key, sprintf( __( '%s - wrong conditions.', 'ultimate-member' ), $array['title'] ) );
|
531 |
-
$notice = '<div class="um-field-error">' . sprintf( __( '%s - wrong conditions.', 'ultimate-member' ), $array['title'] ) . '</div><!-- ' . $e->getMessage() . ' -->';
|
532 |
-
add_action( 'um_after_profile_fields', function() use ( $notice ) {
|
533 |
-
echo $notice;
|
534 |
-
}, 900 );
|
535 |
-
}
|
536 |
-
}
|
537 |
-
|
538 |
-
if ( isset( $array['type'] ) && $array['type'] == 'checkbox' && isset( $array['required'] ) && $array['required'] == 1 && ! isset( $args[ $key ] ) ) {
|
539 |
-
UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member' ), $array['title'] ) );
|
540 |
-
}
|
541 |
-
|
542 |
-
if ( isset( $array['type'] ) && $array['type'] == 'radio' && isset( $array['required'] ) && $array['required'] == 1 && ! isset( $args[ $key ] ) && ! in_array( $key, array( 'role_radio', 'role_select' ) ) ) {
|
543 |
-
UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member'), $array['title'] ) );
|
544 |
-
}
|
545 |
-
|
546 |
-
if ( isset( $array['type'] ) && $array['type'] == 'multiselect' && isset( $array['required'] ) && $array['required'] == 1 && ! isset( $args[ $key ] ) && ! in_array( $key, array( 'role_radio', 'role_select' ) ) ) {
|
547 |
-
UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member' ), $array['title'] ) );
|
548 |
-
}
|
549 |
-
|
550 |
-
/* WordPress uses the default user role if the role wasn't chosen in the registration form. That is why we should use submitted data to validate fields Roles (Radio) and Roles (Dropdown). */
|
551 |
-
if ( in_array( $key, array( 'role_radio', 'role_select' ) ) && isset( $array['required'] ) && $array['required'] == 1 && empty( UM()->form()->post_form['submitted']['role'] ) ) {
|
552 |
-
UM()->form()->add_error( 'role', __( 'Please specify account type.', 'ultimate-member' ) );
|
553 |
-
UM()->form()->post_form[ $key ] = '';
|
554 |
-
}
|
555 |
-
|
556 |
-
/**
|
557 |
-
* UM hook
|
558 |
-
*
|
559 |
-
* @type action
|
560 |
-
* @title um_add_error_on_form_submit_validation
|
561 |
-
* @description Submit form validation
|
562 |
-
* @input_vars
|
563 |
-
* [{"var":"$field","type":"array","desc":"Field Data"},
|
564 |
-
* {"var":"$key","type":"string","desc":"Field Key"},
|
565 |
-
* {"var":"$args","type":"array","desc":"Form Arguments"}]
|
566 |
-
* @change_log
|
567 |
-
* ["Since: 2.0"]
|
568 |
-
* @usage add_action( 'um_add_error_on_form_submit_validation', 'function_name', 10, 3 );
|
569 |
-
* @example
|
570 |
-
* <?php
|
571 |
-
* add_action( 'um_add_error_on_form_submit_validation', 'my_add_error_on_form_submit_validation', 10, 3 );
|
572 |
-
* function my_add_error_on_form_submit_validation( $field, $key, $args ) {
|
573 |
-
* // your code here
|
574 |
-
* }
|
575 |
-
* ?>
|
576 |
-
*/
|
577 |
-
do_action( 'um_add_error_on_form_submit_validation', $array, $key, $args );
|
578 |
-
|
579 |
-
if ( ! empty( $array['required'] ) ) {
|
580 |
-
if ( ! isset( $args[ $key ] ) || $args[ $key ] == '' || $args[ $key ] == 'empty_file' ) {
|
581 |
-
if ( empty( $array['label'] ) ) {
|
582 |
-
UM()->form()->add_error( $key, __( 'This field is required', 'ultimate-member' ) );
|
583 |
-
} else {
|
584 |
-
UM()->form()->add_error( $key, sprintf( __( '%s is required', 'ultimate-member' ), $array['label'] ) );
|
585 |
-
}
|
586 |
-
}
|
587 |
-
}
|
588 |
-
|
589 |
-
if ( isset( $args[ $key ] ) ) {
|
590 |
-
|
591 |
-
if ( isset( $array['max_words'] ) && $array['max_words'] > 0 ) {
|
592 |
-
if ( str_word_count( $args[ $key ], 0, "éèàôù" ) > $array['max_words'] ) {
|
593 |
-
UM()->form()->add_error( $key, sprintf( __( 'You are only allowed to enter a maximum of %s words', 'ultimate-member' ), $array['max_words'] ) );
|
594 |
-
}
|
595 |
-
}
|
596 |
-
|
597 |
-
if ( isset( $array['min_chars'] ) && $array['min_chars'] > 0 ) {
|
598 |
-
if ( $args[ $key ] && mb_strlen( $args[ $key ] ) < $array['min_chars'] ) {
|
599 |
-
if ( empty( $array['label'] ) ) {
|
600 |
-
UM()->form()->add_error( $key, sprintf( __( 'This field must contain at least %s characters', 'ultimate-member' ), $array['min_chars'] ) );
|
601 |
-
} else {
|
602 |
-
UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain at least %s characters', 'ultimate-member' ), $array['label'], $array['min_chars'] ) );
|
603 |
-
}
|
604 |
-
}
|
605 |
-
}
|
606 |
-
|
607 |
-
if ( isset( $array['max_chars'] ) && $array['max_chars'] > 0 ) {
|
608 |
-
if ( $args[ $key ] && mb_strlen( $args[ $key ] ) > $array['max_chars'] ) {
|
609 |
-
if ( empty( $array['label'] ) ) {
|
610 |
-
UM()->form()->add_error( $key, sprintf( __( 'This field must contain less than %s characters', 'ultimate-member' ), $array['max_chars'] ) );
|
611 |
-
} else {
|
612 |
-
UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain less than %s characters', 'ultimate-member' ), $array['label'], $array['max_chars'] ) );
|
613 |
-
}
|
614 |
-
}
|
615 |
-
}
|
616 |
-
|
617 |
-
if ( isset( $array['type'] ) && $array['type'] == 'textarea' && UM()->profile()->get_show_bio_key( $args ) !== $key ) {
|
618 |
-
if ( ! isset( $array['html'] ) || $array['html'] == 0 ) {
|
619 |
-
if ( wp_strip_all_tags( $args[ $key ] ) != trim( $args[ $key ] ) ) {
|
620 |
-
UM()->form()->add_error( $key, __( 'You can not use HTML tags here', 'ultimate-member' ) );
|
621 |
-
}
|
622 |
-
}
|
623 |
-
}
|
624 |
-
|
625 |
-
if ( isset( $array['force_good_pass'] ) && $array['force_good_pass'] == 1 ) {
|
626 |
-
if ( ! UM()->validation()->strong_pass( $args[ $key ] ) ) {
|
627 |
-
UM()->form()->add_error( $key, __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
|
628 |
-
}
|
629 |
-
}
|
630 |
-
|
631 |
-
if ( isset( $array['force_confirm_pass'] ) && $array['force_confirm_pass'] == 1 ) {
|
632 |
-
if ( $args[ 'confirm_' . $key ] == '' && ! UM()->form()->has_error( $key ) ) {
|
633 |
-
UM()->form()->add_error( 'confirm_' . $key , __( 'Please confirm your password', 'ultimate-member' ) );
|
634 |
-
}
|
635 |
-
if ( $args[ 'confirm_' . $key ] != $args[$key] && !UM()->form()->has_error( $key ) ) {
|
636 |
-
UM()->form()->add_error( 'confirm_' . $key , __( 'Your passwords do not match', 'ultimate-member' ) );
|
637 |
-
}
|
638 |
-
}
|
639 |
-
|
640 |
-
if ( isset( $array['min_selections'] ) && $array['min_selections'] > 0 ) {
|
641 |
-
if ( ( ! isset( $args[ $key ] ) ) || ( isset( $args[ $key ] ) && is_array( $args[ $key ] ) && count( $args[ $key ] ) < $array['min_selections'] ) ) {
|
642 |
-
UM()->form()->add_error($key, sprintf( __( 'Please select at least %s choices', 'ultimate-member' ), $array['min_selections'] ) );
|
643 |
-
}
|
644 |
-
}
|
645 |
-
|
646 |
-
if ( isset( $array['max_selections'] ) && $array['max_selections'] > 0 ) {
|
647 |
-
if ( isset( $args[ $key ] ) && is_array( $args[ $key ] ) && count( $args[ $key ] ) > $array['max_selections'] ) {
|
648 |
-
UM()->form()->add_error( $key, sprintf( __( 'You can only select up to %s choices', 'ultimate-member' ), $array['max_selections'] ) );
|
649 |
-
}
|
650 |
-
}
|
651 |
-
|
652 |
-
if ( isset( $array['min'] ) && is_numeric( $args[ $key ] ) ) {
|
653 |
-
if ( isset( $args[ $key ] ) && $args[ $key ] < $array['min'] ) {
|
654 |
-
UM()->form()->add_error( $key, sprintf( __( 'Minimum number limit is %s', 'ultimate-member' ), $array['min'] ) );
|
655 |
-
}
|
656 |
-
}
|
657 |
-
|
658 |
-
if ( isset( $array['max'] ) && is_numeric( $args[ $key ] ) ) {
|
659 |
-
if ( isset( $args[ $key ] ) && $args[ $key ] > $array['max'] ) {
|
660 |
-
UM()->form()->add_error( $key, sprintf( __( 'Maximum number limit is %s', 'ultimate-member' ), $array['max'] ) );
|
661 |
-
}
|
662 |
-
}
|
663 |
-
|
664 |
-
if ( ! empty( $array['validate'] ) ) {
|
665 |
-
|
666 |
-
switch( $array['validate'] ) {
|
667 |
-
|
668 |
-
case 'custom':
|
669 |
-
$custom = $array['custom_validate'];
|
670 |
-
/**
|
671 |
-
* UM hook
|
672 |
-
*
|
673 |
-
* @type action
|
674 |
-
* @title um_custom_field_validation_{$custom}
|
675 |
-
* @description Submit form validation for custom field
|
676 |
-
* @input_vars
|
677 |
-
* [{"var":"$key","type":"string","desc":"Field Key"},
|
678 |
-
* {"var":"$field","type":"array","desc":"Field Data"},
|
679 |
-
* {"var":"$args","type":"array","desc":"Form Arguments"}]
|
680 |
-
* @change_log
|
681 |
-
* ["Since: 2.0"]
|
682 |
-
* @usage add_action( 'um_custom_field_validation_{$custom}', 'function_name', 10, 3 );
|
683 |
-
* @example
|
684 |
-
* <?php
|
685 |
-
* add_action( 'um_custom_field_validation_{$custom}', 'my_custom_field_validation', 10, 3 );
|
686 |
-
* function my_custom_field_validation( $key, $field, $args ) {
|
687 |
-
* // your code here
|
688 |
-
* }
|
689 |
-
* ?>
|
690 |
-
*/
|
691 |
-
do_action( "um_custom_field_validation_{$custom}", $key, $array, $args );
|
692 |
-
break;
|
693 |
-
|
694 |
-
case 'numeric':
|
695 |
-
if ( $args[ $key ] && ! is_numeric( $args[ $key ] ) ) {
|
696 |
-
UM()->form()->add_error( $key, __( 'Please enter numbers only in this field', 'ultimate-member' ) );
|
697 |
-
}
|
698 |
-
break;
|
699 |
-
|
700 |
-
case 'phone_number':
|
701 |
-
if ( ! UM()->validation()->is_phone_number( $args[ $key ] ) ) {
|
702 |
-
UM()->form()->add_error( $key, __( 'Please enter a valid phone number', 'ultimate-member' ) );
|
703 |
-
}
|
704 |
-
break;
|
705 |
-
|
706 |
-
case 'youtube_url':
|
707 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], 'youtube.com' ) ) {
|
708 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
709 |
-
}
|
710 |
-
break;
|
711 |
-
|
712 |
-
case '
|
713 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], '
|
714 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL','ultimate-member'), $array['label'] ) );
|
715 |
-
}
|
716 |
-
break;
|
717 |
-
|
718 |
-
case '
|
719 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], '
|
720 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL',
|
721 |
-
}
|
722 |
-
break;
|
723 |
-
|
724 |
-
case '
|
725 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], '
|
726 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
727 |
-
}
|
728 |
-
break;
|
729 |
-
|
730 |
-
case '
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], '
|
739 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s
|
740 |
-
}
|
741 |
-
break;
|
742 |
-
|
743 |
-
case '
|
744 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], '
|
745 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
746 |
-
}
|
747 |
-
break;
|
748 |
-
|
749 |
-
case '
|
750 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], '
|
751 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
752 |
-
}
|
753 |
-
break;
|
754 |
-
|
755 |
-
case '
|
756 |
-
if ( ! UM()->validation()->is_url( $args[ $key ] ) ) {
|
757 |
-
UM()->form()->add_error( $key, __( 'Please enter a valid URL', 'ultimate-member' ) );
|
758 |
-
}
|
759 |
-
break;
|
760 |
-
|
761 |
-
case '
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
UM()->form()->add_error( $key, __( '
|
779 |
-
} elseif (
|
780 |
-
UM()->form()->add_error( $key, __( '
|
781 |
-
} elseif (
|
782 |
-
UM()->form()->add_error( $key, __( '
|
783 |
-
}
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
}
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
UM()->form()->add_error( $key, __( '
|
817 |
-
} elseif (
|
818 |
-
UM()->form()->add_error( $key, __( '
|
819 |
-
} elseif ( $args[ $key ]
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
}
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
break;
|
875 |
-
|
876 |
-
case '
|
877 |
-
|
878 |
-
if ( $args[ $key ] != '' ) {
|
879 |
-
|
880 |
-
if ( !
|
881 |
-
UM()->form()->add_error( $key
|
882 |
-
}
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
}
|
902 |
-
|
903 |
-
}
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Error handling: blocked emails
|
6 |
+
*
|
7 |
+
* @param $args
|
8 |
+
*/
|
9 |
+
function um_submit_form_errors_hook__blockedemails( $args ) {
|
10 |
+
$emails = UM()->options()->get( 'blocked_emails' );
|
11 |
+
if ( ! $emails ) {
|
12 |
+
return;
|
13 |
+
}
|
14 |
+
|
15 |
+
$emails = array_map( 'rtrim', explode( "\n", $emails ) );
|
16 |
+
|
17 |
+
if ( isset( $args['user_email'] ) && is_email( $args['user_email'] ) ) {
|
18 |
+
|
19 |
+
$domain = explode( '@', $args['user_email'] );
|
20 |
+
$check_domain = str_replace( $domain[0], '*', $args['user_email'] );
|
21 |
+
|
22 |
+
if ( in_array( $args['user_email'], $emails ) ) {
|
23 |
+
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_email' ) ) ) );
|
24 |
+
}
|
25 |
+
|
26 |
+
if ( in_array( $check_domain, $emails ) ) {
|
27 |
+
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_domain' ) ) ) );
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
if ( isset( $args['username'] ) && is_email( $args['username'] ) ) {
|
33 |
+
|
34 |
+
$domain = explode( '@', $args['username'] );
|
35 |
+
$check_domain = str_replace( $domain[0], '*', $args['username'] );
|
36 |
+
|
37 |
+
if ( in_array( $args['username'], $emails ) ) {
|
38 |
+
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_email' ) ) ) );
|
39 |
+
}
|
40 |
+
|
41 |
+
if ( in_array( $check_domain, $emails ) ) {
|
42 |
+
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_domain' ) ) ) );
|
43 |
+
}
|
44 |
+
|
45 |
+
}
|
46 |
+
}
|
47 |
+
add_action( 'um_submit_form_errors_hook__blockedemails', 'um_submit_form_errors_hook__blockedemails', 10 );
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Error handling: blocked IPs
|
52 |
+
*
|
53 |
+
* @param $args
|
54 |
+
*/
|
55 |
+
function um_submit_form_errors_hook__blockedips( $args ) {
|
56 |
+
$ips = UM()->options()->get( 'blocked_ips' );
|
57 |
+
if ( ! $ips ) {
|
58 |
+
return;
|
59 |
+
}
|
60 |
+
|
61 |
+
$ips = array_map( 'rtrim', explode( "\n", $ips ) );
|
62 |
+
$user_ip = um_user_ip();
|
63 |
+
|
64 |
+
foreach ( $ips as $ip ) {
|
65 |
+
$ip = str_replace( '*', '', $ip );
|
66 |
+
if ( ! empty( $ip ) && strpos( $user_ip, $ip ) === 0 ) {
|
67 |
+
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_ip' ) ) ) );
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
add_action( 'um_submit_form_errors_hook__blockedips', 'um_submit_form_errors_hook__blockedips', 10 );
|
72 |
+
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Error handling: blocked words during sign up
|
76 |
+
*
|
77 |
+
* @param $args
|
78 |
+
*/
|
79 |
+
function um_submit_form_errors_hook__blockedwords( $args ) {
|
80 |
+
$words = UM()->options()->get( 'blocked_words' );
|
81 |
+
if ( empty( $words ) ) {
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
|
85 |
+
$form_id = $args['form_id'];
|
86 |
+
$mode = $args['mode'];
|
87 |
+
$fields = unserialize( $args['custom_fields'] );
|
88 |
+
|
89 |
+
$words = array_map( 'rtrim', explode( "\n", $words ) );
|
90 |
+
if ( ! empty( $fields ) && is_array( $fields ) ) {
|
91 |
+
foreach ( $fields as $key => $array ) {
|
92 |
+
if ( isset( $array['validate'] ) && in_array( $array['validate'], array( 'unique_username', 'unique_email', 'unique_username_or_email' ) ) ) {
|
93 |
+
if ( ! UM()->form()->has_error( $key ) && isset( $args[ $key ] ) && in_array( $args[ $key ], $words ) ) {
|
94 |
+
UM()->form()->add_error( $key, __( 'You are not allowed to use this word as your username.', 'ultimate-member' ) );
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
add_action( 'um_submit_form_errors_hook__blockedwords', 'um_submit_form_errors_hook__blockedwords', 10 );
|
101 |
+
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Error handling
|
105 |
+
*
|
106 |
+
* @param $args
|
107 |
+
*/
|
108 |
+
function um_submit_form_errors_hook( $args ) {
|
109 |
+
$mode = $args['mode'];
|
110 |
+
|
111 |
+
/**
|
112 |
+
* UM hook
|
113 |
+
*
|
114 |
+
* @type action
|
115 |
+
* @title um_submit_form_errors_hook__blockedips
|
116 |
+
* @description Submit form validation
|
117 |
+
* @input_vars
|
118 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
119 |
+
* @change_log
|
120 |
+
* ["Since: 2.0"]
|
121 |
+
* @usage add_action( 'um_submit_form_errors_hook__blockedips', 'function_name', 10, 1 );
|
122 |
+
* @example
|
123 |
+
* <?php
|
124 |
+
* add_action( 'um_submit_form_errors_hook__blockedips', 'my_submit_form_errors_hook__blockedips', 10, 1 );
|
125 |
+
* function my_submit_form_errors_hook__blockedips( $args ) {
|
126 |
+
* // your code here
|
127 |
+
* }
|
128 |
+
* ?>
|
129 |
+
*/
|
130 |
+
do_action( 'um_submit_form_errors_hook__blockedips', $args );
|
131 |
+
|
132 |
+
|
133 |
+
/**
|
134 |
+
* UM hook
|
135 |
+
*
|
136 |
+
* @type action
|
137 |
+
* @title um_submit_form_errors_hook__blockedemails
|
138 |
+
* @description Submit form validation
|
139 |
+
* @input_vars
|
140 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
141 |
+
* @change_log
|
142 |
+
* ["Since: 2.0"]
|
143 |
+
* @usage add_action( 'um_submit_form_errors_hook__blockedemails', 'function_name', 10, 1 );
|
144 |
+
* @example
|
145 |
+
* <?php
|
146 |
+
* add_action( 'um_submit_form_errors_hook__blockedemails', 'my_submit_form_errors_hook__blockedemails', 10, 1 );
|
147 |
+
* function my_submit_form_errors_hook__blockedemails( $args ) {
|
148 |
+
* // your code here
|
149 |
+
* }
|
150 |
+
* ?>
|
151 |
+
*/
|
152 |
+
do_action( 'um_submit_form_errors_hook__blockedemails', $args );
|
153 |
+
|
154 |
+
if ( $mode == 'register' ) {
|
155 |
+
|
156 |
+
|
157 |
+
/**
|
158 |
+
* UM hook
|
159 |
+
*
|
160 |
+
* @type action
|
161 |
+
* @title um_submit_form_errors_hook__registration
|
162 |
+
* @description Submit registration form validation
|
163 |
+
* @input_vars
|
164 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
165 |
+
* @change_log
|
166 |
+
* ["Since: 2.0"]
|
167 |
+
* @usage add_action( 'um_submit_form_errors_hook__registration', 'function_name', 10, 1 );
|
168 |
+
* @example
|
169 |
+
* <?php
|
170 |
+
* add_action( 'um_submit_form_errors_hook__registration', 'my_submit_form_errors_registration', 10, 1 );
|
171 |
+
* function my_submit_form_errors_registration( $args ) {
|
172 |
+
* // your code here
|
173 |
+
* }
|
174 |
+
* ?>
|
175 |
+
*/
|
176 |
+
do_action( 'um_submit_form_errors_hook__registration', $args );
|
177 |
+
|
178 |
+
} elseif ( $mode == 'profile' ) {
|
179 |
+
|
180 |
+
|
181 |
+
/**
|
182 |
+
* UM hook
|
183 |
+
*
|
184 |
+
* @type action
|
185 |
+
* @title um_submit_form_errors_hook__registration
|
186 |
+
* @description Submit registration form validation
|
187 |
+
* @input_vars
|
188 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
189 |
+
* @change_log
|
190 |
+
* ["Since: 2.0"]
|
191 |
+
* @usage add_action( 'um_submit_form_errors_hook__registration', 'function_name', 10, 1 );
|
192 |
+
* @example
|
193 |
+
* <?php
|
194 |
+
* add_action( 'um_submit_form_errors_hook__profile', 'my_submit_form_errors_hook__profile', 10, 1 );
|
195 |
+
* function my_submit_form_errors_registration( $args ) {
|
196 |
+
* // your code here
|
197 |
+
* }
|
198 |
+
* ?>
|
199 |
+
*/
|
200 |
+
do_action( 'um_submit_form_errors_hook__profile', $args );
|
201 |
+
|
202 |
+
} elseif ( $mode == 'login' ) {
|
203 |
+
|
204 |
+
|
205 |
+
/**
|
206 |
+
* UM hook
|
207 |
+
*
|
208 |
+
* @type action
|
209 |
+
* @title um_submit_form_errors_hook_login
|
210 |
+
* @description Submit login form validation
|
211 |
+
* @input_vars
|
212 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
213 |
+
* @change_log
|
214 |
+
* ["Since: 2.0"]
|
215 |
+
* @usage add_action( 'um_submit_form_errors_hook_login', 'function_name', 10, 1 );
|
216 |
+
* @example
|
217 |
+
* <?php
|
218 |
+
* add_action( 'um_submit_form_errors_hook_login', 'my_submit_form_errors_hook_login', 10, 1 );
|
219 |
+
* function my_submit_form_errors_hook_login( $args ) {
|
220 |
+
* // your code here
|
221 |
+
* }
|
222 |
+
* ?>
|
223 |
+
*/
|
224 |
+
do_action( 'um_submit_form_errors_hook_login', $args );
|
225 |
+
|
226 |
+
|
227 |
+
/**
|
228 |
+
* UM hook
|
229 |
+
*
|
230 |
+
* @type action
|
231 |
+
* @title um_submit_form_errors_hook_logincheck
|
232 |
+
* @description Submit login form validation
|
233 |
+
* @input_vars
|
234 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
235 |
+
* @change_log
|
236 |
+
* ["Since: 2.0"]
|
237 |
+
* @usage add_action( 'um_submit_form_errors_hook_logincheck', 'function_name', 10, 1 );
|
238 |
+
* @example
|
239 |
+
* <?php
|
240 |
+
* add_action( 'um_submit_form_errors_hook_logincheck', 'my_submit_form_errors_hook_logincheck', 10, 1 );
|
241 |
+
* function my_submit_form_errors_hook_logincheck( $args ) {
|
242 |
+
* // your code here
|
243 |
+
* }
|
244 |
+
* ?>
|
245 |
+
*/
|
246 |
+
do_action( 'um_submit_form_errors_hook_logincheck', $args );
|
247 |
+
|
248 |
+
}
|
249 |
+
|
250 |
+
|
251 |
+
if ( $mode != 'login' ) {
|
252 |
+
|
253 |
+
|
254 |
+
/**
|
255 |
+
* UM hook
|
256 |
+
*
|
257 |
+
* @type action
|
258 |
+
* @title um_submit_form_errors_hook__blockedwords
|
259 |
+
* @description Submit form validation
|
260 |
+
* @input_vars
|
261 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
262 |
+
* @change_log
|
263 |
+
* ["Since: 2.0"]
|
264 |
+
* @usage add_action( 'um_submit_form_errors_hook__blockedwords', 'function_name', 10, 1 );
|
265 |
+
* @example
|
266 |
+
* <?php
|
267 |
+
* add_action( 'um_submit_form_errors_hook__blockedwords', 'my_submit_form_errors_hook__blockedwords', 10, 1 );
|
268 |
+
* function my_submit_form_errors_hook__blockedwords( $args ) {
|
269 |
+
* // your code here
|
270 |
+
* }
|
271 |
+
* ?>
|
272 |
+
*/
|
273 |
+
do_action( 'um_submit_form_errors_hook__blockedwords', $args );
|
274 |
+
|
275 |
+
|
276 |
+
/**
|
277 |
+
* UM hook
|
278 |
+
*
|
279 |
+
* @type action
|
280 |
+
* @title um_submit_form_errors_hook_
|
281 |
+
* @description Submit form validation
|
282 |
+
* @input_vars
|
283 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
284 |
+
* @change_log
|
285 |
+
* ["Since: 2.0"]
|
286 |
+
* @usage add_action( 'um_submit_form_errors_hook_', 'function_name', 10, 1 );
|
287 |
+
* @example
|
288 |
+
* <?php
|
289 |
+
* add_action( 'um_submit_form_errors_hook_', 'my_submit_form_errors_hook', 10, 1 );
|
290 |
+
* function my_submit_form_errors_hook( $args ) {
|
291 |
+
* // your code here
|
292 |
+
* }
|
293 |
+
* ?>
|
294 |
+
*/
|
295 |
+
do_action( 'um_submit_form_errors_hook_', $args );
|
296 |
+
|
297 |
+
}
|
298 |
+
|
299 |
+
}
|
300 |
+
add_action( 'um_submit_form_errors_hook', 'um_submit_form_errors_hook', 10 );
|
301 |
+
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Error processing: Conditions
|
305 |
+
* @staticvar int $counter
|
306 |
+
* @param array $condition
|
307 |
+
* @param array $fields
|
308 |
+
* @param array $args
|
309 |
+
* @param boolean $reset
|
310 |
+
* @return boolean
|
311 |
+
* @throws Exception
|
312 |
+
*/
|
313 |
+
function um_check_conditions_on_submit( $condition, $fields, $args, $reset = false ) {
|
314 |
+
static $counter = 0;
|
315 |
+
if ( $reset ) {
|
316 |
+
$counter = 0;
|
317 |
+
}
|
318 |
+
$continue = false;
|
319 |
+
|
320 |
+
list( $visibility, $parent_key, $op, $parent_value ) = $condition;
|
321 |
+
|
322 |
+
if ( ! isset( $args[ $parent_key ] ) ) {
|
323 |
+
$continue = true;
|
324 |
+
return $continue;
|
325 |
+
}
|
326 |
+
|
327 |
+
if ( ! empty( $fields[ $parent_key ]['conditions'] ) ) {
|
328 |
+
foreach ( $fields[ $parent_key ]['conditions'] as $parent_condition ) {
|
329 |
+
if ( 64 > $counter++ ) {
|
330 |
+
$continue = um_check_conditions_on_submit( $parent_condition, $fields, $args );
|
331 |
+
} else {
|
332 |
+
throw new Exception( 'Endless recursion in the function ' . __FUNCTION__, 512 );
|
333 |
+
}
|
334 |
+
if ( ! empty( $continue ) ) {
|
335 |
+
return $continue;
|
336 |
+
}
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
$cond_value = ( $fields[ $parent_key ]['type'] == 'radio' ) ? $args[ $parent_key ][0] : $args[ $parent_key ];
|
341 |
+
|
342 |
+
if ( $visibility == 'hide' ) {
|
343 |
+
if ( $op == 'empty' ) {
|
344 |
+
if ( empty( $cond_value ) ) {
|
345 |
+
$continue = true;
|
346 |
+
}
|
347 |
+
} elseif ( $op == 'not empty' ) {
|
348 |
+
if ( ! empty( $cond_value ) ) {
|
349 |
+
$continue = true;
|
350 |
+
}
|
351 |
+
} elseif ( $op == 'equals to' ) {
|
352 |
+
if ( $cond_value == $parent_value ) {
|
353 |
+
$continue = true;
|
354 |
+
}
|
355 |
+
} elseif ( $op == 'not equals' ) {
|
356 |
+
if ( $cond_value != $parent_value ) {
|
357 |
+
$continue = true;
|
358 |
+
}
|
359 |
+
} elseif ( $op == 'greater than' ) {
|
360 |
+
if ( $cond_value > $parent_value ) {
|
361 |
+
$continue = true;
|
362 |
+
}
|
363 |
+
} elseif ( $op == 'less than' ) {
|
364 |
+
if ( $cond_value < $parent_value ) {
|
365 |
+
$continue = true;
|
366 |
+
}
|
367 |
+
} elseif ( $op == 'contains' ) {
|
368 |
+
if ( is_string( $cond_value ) && strstr( $cond_value, $parent_value ) ) {
|
369 |
+
$continue = true;
|
370 |
+
}
|
371 |
+
if( is_array( $cond_value ) && in_array( $parent_value, $cond_value ) ) {
|
372 |
+
$continue = true;
|
373 |
+
}
|
374 |
+
}
|
375 |
+
} elseif ( $visibility == 'show' ) {
|
376 |
+
if ( $op == 'empty' ) {
|
377 |
+
if ( ! empty( $cond_value ) ) {
|
378 |
+
$continue = true;
|
379 |
+
}
|
380 |
+
} elseif ( $op == 'not empty' ) {
|
381 |
+
if ( empty( $cond_value ) ) {
|
382 |
+
$continue = true;
|
383 |
+
}
|
384 |
+
} elseif ( $op == 'equals to' ) {
|
385 |
+
if ( $cond_value != $parent_value ) {
|
386 |
+
$continue = true;
|
387 |
+
}
|
388 |
+
} elseif ( $op == 'not equals' ) {
|
389 |
+
if ( $cond_value == $parent_value ) {
|
390 |
+
$continue = true;
|
391 |
+
}
|
392 |
+
} elseif ( $op == 'greater than' ) {
|
393 |
+
if ( $cond_value <= $parent_value ) {
|
394 |
+
$continue = true;
|
395 |
+
}
|
396 |
+
} elseif ( $op == 'less than' ) {
|
397 |
+
if ( $cond_value >= $parent_value ) {
|
398 |
+
$continue = true;
|
399 |
+
}
|
400 |
+
} elseif ( $op == 'contains' ) {
|
401 |
+
if ( is_string( $cond_value ) && ! strstr( $cond_value, $parent_value ) ) {
|
402 |
+
$continue = true;
|
403 |
+
}
|
404 |
+
if( is_array( $cond_value ) && !in_array( $parent_value, $cond_value ) ) {
|
405 |
+
$continue = true;
|
406 |
+
}
|
407 |
+
}
|
408 |
+
}
|
409 |
+
|
410 |
+
return $continue;
|
411 |
+
}
|
412 |
+
|
413 |
+
|
414 |
+
/**
|
415 |
+
* Error processing hook : standard
|
416 |
+
*
|
417 |
+
* @param $args
|
418 |
+
*/
|
419 |
+
function um_submit_form_errors_hook_( $args ) {
|
420 |
+
$form_id = $args['form_id'];
|
421 |
+
$mode = $args['mode'];
|
422 |
+
$fields = unserialize( $args['custom_fields'] );
|
423 |
+
|
424 |
+
$um_profile_photo = um_profile('profile_photo');
|
425 |
+
if ( get_post_meta( $form_id, '_um_profile_photo_required', true ) && ( empty( $args['profile_photo'] ) && empty( $um_profile_photo ) ) ) {
|
426 |
+
UM()->form()->add_error('profile_photo', __( 'Profile Photo is required.', 'ultimate-member' ) );
|
427 |
+
}
|
428 |
+
|
429 |
+
if ( ! empty( $fields ) ) {
|
430 |
+
|
431 |
+
$can_edit = false;
|
432 |
+
$current_user_roles = [];
|
433 |
+
if ( is_user_logged_in() ) {
|
434 |
+
|
435 |
+
$can_edit = UM()->roles()->um_current_user_can( 'edit', $args['user_id'] );
|
436 |
+
|
437 |
+
um_fetch_user( get_current_user_id() );
|
438 |
+
$current_user_roles = um_user( 'roles' );
|
439 |
+
um_reset_user();
|
440 |
+
}
|
441 |
+
|
442 |
+
foreach ( $fields as $key => $array ) {
|
443 |
+
|
444 |
+
if ( $mode == 'profile' ) {
|
445 |
+
$restricted_fields = UM()->fields()->get_restricted_fields_for_edit();
|
446 |
+
if ( is_array( $restricted_fields ) && in_array( $key, $restricted_fields ) ) {
|
447 |
+
continue;
|
448 |
+
}
|
449 |
+
}
|
450 |
+
|
451 |
+
$can_view = true;
|
452 |
+
if ( isset( $array['public'] ) && $mode != 'register' ) {
|
453 |
+
|
454 |
+
switch ( $array['public'] ) {
|
455 |
+
case '1': // Everyone
|
456 |
+
break;
|
457 |
+
case '2': // Members
|
458 |
+
if ( ! is_user_logged_in() ) {
|
459 |
+
$can_view = false;
|
460 |
+
}
|
461 |
+
break;
|
462 |
+
case '-1': // Only visible to profile owner and admins
|
463 |
+
if ( ! is_user_logged_in() ) {
|
464 |
+
$can_view = false;
|
465 |
+
} elseif ( $args['user_id'] != get_current_user_id() && ! $can_edit ) {
|
466 |
+
$can_view = false;
|
467 |
+
}
|
468 |
+
break;
|
469 |
+
case '-2': // Only specific member roles
|
470 |
+
if ( ! is_user_logged_in() ) {
|
471 |
+
$can_view = false;
|
472 |
+
} elseif ( ! empty( $array['roles'] ) && count( array_intersect( $current_user_roles, $array['roles'] ) ) <= 0 ) {
|
473 |
+
$can_view = false;
|
474 |
+
}
|
475 |
+
break;
|
476 |
+
case '-3': // Only visible to profile owner and specific roles
|
477 |
+
if ( ! is_user_logged_in() ) {
|
478 |
+
$can_view = false;
|
479 |
+
} elseif ( $args['user_id'] != get_current_user_id() && ! empty( $array['roles'] ) && count( array_intersect( $current_user_roles, $array['roles'] ) ) <= 0 ) {
|
480 |
+
$can_view = false;
|
481 |
+
}
|
482 |
+
break;
|
483 |
+
default:
|
484 |
+
$can_view = apply_filters( 'um_can_view_field_custom', $can_view, $array );
|
485 |
+
break;
|
486 |
+
}
|
487 |
+
|
488 |
+
}
|
489 |
+
|
490 |
+
$can_view = apply_filters( 'um_can_view_field', $can_view, $array );
|
491 |
+
|
492 |
+
if ( ! $can_view ) {
|
493 |
+
continue;
|
494 |
+
}
|
495 |
+
|
496 |
+
|
497 |
+
/**
|
498 |
+
* UM hook
|
499 |
+
*
|
500 |
+
* @type filter
|
501 |
+
* @title um_get_custom_field_array
|
502 |
+
* @description Extend custom field data on submit form error
|
503 |
+
* @input_vars
|
504 |
+
* [{"var":"$array","type":"array","desc":"Field data"},
|
505 |
+
* {"var":"$fields","type":"array","desc":"All fields"}]
|
506 |
+
* @change_log
|
507 |
+
* ["Since: 2.0"]
|
508 |
+
* @usage
|
509 |
+
* <?php add_filter( 'um_get_custom_field_array', 'function_name', 10, 2 ); ?>
|
510 |
+
* @example
|
511 |
+
* <?php
|
512 |
+
* add_filter( 'um_get_custom_field_array', 'my_get_custom_field_array', 10, 2 );
|
513 |
+
* function my_get_custom_field_array( $array, $fields ) {
|
514 |
+
* // your code here
|
515 |
+
* return $array;
|
516 |
+
* }
|
517 |
+
* ?>
|
518 |
+
*/
|
519 |
+
$array = apply_filters( 'um_get_custom_field_array', $array, $fields );
|
520 |
+
|
521 |
+
if ( ! empty( $array['conditions'] ) ) {
|
522 |
+
try {
|
523 |
+
foreach ( $array['conditions'] as $condition ) {
|
524 |
+
$continue = um_check_conditions_on_submit( $condition, $fields, $args, true );
|
525 |
+
if ( $continue === true ) {
|
526 |
+
continue 2;
|
527 |
+
}
|
528 |
+
}
|
529 |
+
} catch ( Exception $e ) {
|
530 |
+
UM()->form()->add_error( $key, sprintf( __( '%s - wrong conditions.', 'ultimate-member' ), $array['title'] ) );
|
531 |
+
$notice = '<div class="um-field-error">' . sprintf( __( '%s - wrong conditions.', 'ultimate-member' ), $array['title'] ) . '</div><!-- ' . $e->getMessage() . ' -->';
|
532 |
+
add_action( 'um_after_profile_fields', function() use ( $notice ) {
|
533 |
+
echo $notice;
|
534 |
+
}, 900 );
|
535 |
+
}
|
536 |
+
}
|
537 |
+
|
538 |
+
if ( isset( $array['type'] ) && $array['type'] == 'checkbox' && isset( $array['required'] ) && $array['required'] == 1 && ! isset( $args[ $key ] ) ) {
|
539 |
+
UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member' ), $array['title'] ) );
|
540 |
+
}
|
541 |
+
|
542 |
+
if ( isset( $array['type'] ) && $array['type'] == 'radio' && isset( $array['required'] ) && $array['required'] == 1 && ! isset( $args[ $key ] ) && ! in_array( $key, array( 'role_radio', 'role_select' ) ) ) {
|
543 |
+
UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member'), $array['title'] ) );
|
544 |
+
}
|
545 |
+
|
546 |
+
if ( isset( $array['type'] ) && $array['type'] == 'multiselect' && isset( $array['required'] ) && $array['required'] == 1 && ! isset( $args[ $key ] ) && ! in_array( $key, array( 'role_radio', 'role_select' ) ) ) {
|
547 |
+
UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member' ), $array['title'] ) );
|
548 |
+
}
|
549 |
+
|
550 |
+
/* WordPress uses the default user role if the role wasn't chosen in the registration form. That is why we should use submitted data to validate fields Roles (Radio) and Roles (Dropdown). */
|
551 |
+
if ( in_array( $key, array( 'role_radio', 'role_select' ) ) && isset( $array['required'] ) && $array['required'] == 1 && empty( UM()->form()->post_form['submitted']['role'] ) ) {
|
552 |
+
UM()->form()->add_error( 'role', __( 'Please specify account type.', 'ultimate-member' ) );
|
553 |
+
UM()->form()->post_form[ $key ] = '';
|
554 |
+
}
|
555 |
+
|
556 |
+
/**
|
557 |
+
* UM hook
|
558 |
+
*
|
559 |
+
* @type action
|
560 |
+
* @title um_add_error_on_form_submit_validation
|
561 |
+
* @description Submit form validation
|
562 |
+
* @input_vars
|
563 |
+
* [{"var":"$field","type":"array","desc":"Field Data"},
|
564 |
+
* {"var":"$key","type":"string","desc":"Field Key"},
|
565 |
+
* {"var":"$args","type":"array","desc":"Form Arguments"}]
|
566 |
+
* @change_log
|
567 |
+
* ["Since: 2.0"]
|
568 |
+
* @usage add_action( 'um_add_error_on_form_submit_validation', 'function_name', 10, 3 );
|
569 |
+
* @example
|
570 |
+
* <?php
|
571 |
+
* add_action( 'um_add_error_on_form_submit_validation', 'my_add_error_on_form_submit_validation', 10, 3 );
|
572 |
+
* function my_add_error_on_form_submit_validation( $field, $key, $args ) {
|
573 |
+
* // your code here
|
574 |
+
* }
|
575 |
+
* ?>
|
576 |
+
*/
|
577 |
+
do_action( 'um_add_error_on_form_submit_validation', $array, $key, $args );
|
578 |
+
|
579 |
+
if ( ! empty( $array['required'] ) ) {
|
580 |
+
if ( ! isset( $args[ $key ] ) || $args[ $key ] == '' || $args[ $key ] == 'empty_file' ) {
|
581 |
+
if ( empty( $array['label'] ) ) {
|
582 |
+
UM()->form()->add_error( $key, __( 'This field is required', 'ultimate-member' ) );
|
583 |
+
} else {
|
584 |
+
UM()->form()->add_error( $key, sprintf( __( '%s is required', 'ultimate-member' ), $array['label'] ) );
|
585 |
+
}
|
586 |
+
}
|
587 |
+
}
|
588 |
+
|
589 |
+
if ( isset( $args[ $key ] ) ) {
|
590 |
+
|
591 |
+
if ( isset( $array['max_words'] ) && $array['max_words'] > 0 ) {
|
592 |
+
if ( str_word_count( $args[ $key ], 0, "éèàôù" ) > $array['max_words'] ) {
|
593 |
+
UM()->form()->add_error( $key, sprintf( __( 'You are only allowed to enter a maximum of %s words', 'ultimate-member' ), $array['max_words'] ) );
|
594 |
+
}
|
595 |
+
}
|
596 |
+
|
597 |
+
if ( isset( $array['min_chars'] ) && $array['min_chars'] > 0 ) {
|
598 |
+
if ( $args[ $key ] && mb_strlen( $args[ $key ] ) < $array['min_chars'] ) {
|
599 |
+
if ( empty( $array['label'] ) ) {
|
600 |
+
UM()->form()->add_error( $key, sprintf( __( 'This field must contain at least %s characters', 'ultimate-member' ), $array['min_chars'] ) );
|
601 |
+
} else {
|
602 |
+
UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain at least %s characters', 'ultimate-member' ), $array['label'], $array['min_chars'] ) );
|
603 |
+
}
|
604 |
+
}
|
605 |
+
}
|
606 |
+
|
607 |
+
if ( isset( $array['max_chars'] ) && $array['max_chars'] > 0 ) {
|
608 |
+
if ( $args[ $key ] && mb_strlen( $args[ $key ] ) > $array['max_chars'] ) {
|
609 |
+
if ( empty( $array['label'] ) ) {
|
610 |
+
UM()->form()->add_error( $key, sprintf( __( 'This field must contain less than %s characters', 'ultimate-member' ), $array['max_chars'] ) );
|
611 |
+
} else {
|
612 |
+
UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain less than %s characters', 'ultimate-member' ), $array['label'], $array['max_chars'] ) );
|
613 |
+
}
|
614 |
+
}
|
615 |
+
}
|
616 |
+
|
617 |
+
if ( isset( $array['type'] ) && $array['type'] == 'textarea' && UM()->profile()->get_show_bio_key( $args ) !== $key ) {
|
618 |
+
if ( ! isset( $array['html'] ) || $array['html'] == 0 ) {
|
619 |
+
if ( wp_strip_all_tags( $args[ $key ] ) != trim( $args[ $key ] ) ) {
|
620 |
+
UM()->form()->add_error( $key, __( 'You can not use HTML tags here', 'ultimate-member' ) );
|
621 |
+
}
|
622 |
+
}
|
623 |
+
}
|
624 |
+
|
625 |
+
if ( isset( $array['force_good_pass'] ) && $array['force_good_pass'] == 1 ) {
|
626 |
+
if ( ! UM()->validation()->strong_pass( $args[ $key ] ) ) {
|
627 |
+
UM()->form()->add_error( $key, __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
|
628 |
+
}
|
629 |
+
}
|
630 |
+
|
631 |
+
if ( isset( $array['force_confirm_pass'] ) && $array['force_confirm_pass'] == 1 ) {
|
632 |
+
if ( $args[ 'confirm_' . $key ] == '' && ! UM()->form()->has_error( $key ) ) {
|
633 |
+
UM()->form()->add_error( 'confirm_' . $key , __( 'Please confirm your password', 'ultimate-member' ) );
|
634 |
+
}
|
635 |
+
if ( $args[ 'confirm_' . $key ] != $args[$key] && !UM()->form()->has_error( $key ) ) {
|
636 |
+
UM()->form()->add_error( 'confirm_' . $key , __( 'Your passwords do not match', 'ultimate-member' ) );
|
637 |
+
}
|
638 |
+
}
|
639 |
+
|
640 |
+
if ( isset( $array['min_selections'] ) && $array['min_selections'] > 0 ) {
|
641 |
+
if ( ( ! isset( $args[ $key ] ) ) || ( isset( $args[ $key ] ) && is_array( $args[ $key ] ) && count( $args[ $key ] ) < $array['min_selections'] ) ) {
|
642 |
+
UM()->form()->add_error($key, sprintf( __( 'Please select at least %s choices', 'ultimate-member' ), $array['min_selections'] ) );
|
643 |
+
}
|
644 |
+
}
|
645 |
+
|
646 |
+
if ( isset( $array['max_selections'] ) && $array['max_selections'] > 0 ) {
|
647 |
+
if ( isset( $args[ $key ] ) && is_array( $args[ $key ] ) && count( $args[ $key ] ) > $array['max_selections'] ) {
|
648 |
+
UM()->form()->add_error( $key, sprintf( __( 'You can only select up to %s choices', 'ultimate-member' ), $array['max_selections'] ) );
|
649 |
+
}
|
650 |
+
}
|
651 |
+
|
652 |
+
if ( isset( $array['min'] ) && is_numeric( $args[ $key ] ) ) {
|
653 |
+
if ( isset( $args[ $key ] ) && $args[ $key ] < $array['min'] ) {
|
654 |
+
UM()->form()->add_error( $key, sprintf( __( 'Minimum number limit is %s', 'ultimate-member' ), $array['min'] ) );
|
655 |
+
}
|
656 |
+
}
|
657 |
+
|
658 |
+
if ( isset( $array['max'] ) && is_numeric( $args[ $key ] ) ) {
|
659 |
+
if ( isset( $args[ $key ] ) && $args[ $key ] > $array['max'] ) {
|
660 |
+
UM()->form()->add_error( $key, sprintf( __( 'Maximum number limit is %s', 'ultimate-member' ), $array['max'] ) );
|
661 |
+
}
|
662 |
+
}
|
663 |
+
|
664 |
+
if ( ! empty( $array['validate'] ) ) {
|
665 |
+
|
666 |
+
switch( $array['validate'] ) {
|
667 |
+
|
668 |
+
case 'custom':
|
669 |
+
$custom = $array['custom_validate'];
|
670 |
+
/**
|
671 |
+
* UM hook
|
672 |
+
*
|
673 |
+
* @type action
|
674 |
+
* @title um_custom_field_validation_{$custom}
|
675 |
+
* @description Submit form validation for custom field
|
676 |
+
* @input_vars
|
677 |
+
* [{"var":"$key","type":"string","desc":"Field Key"},
|
678 |
+
* {"var":"$field","type":"array","desc":"Field Data"},
|
679 |
+
* {"var":"$args","type":"array","desc":"Form Arguments"}]
|
680 |
+
* @change_log
|
681 |
+
* ["Since: 2.0"]
|
682 |
+
* @usage add_action( 'um_custom_field_validation_{$custom}', 'function_name', 10, 3 );
|
683 |
+
* @example
|
684 |
+
* <?php
|
685 |
+
* add_action( 'um_custom_field_validation_{$custom}', 'my_custom_field_validation', 10, 3 );
|
686 |
+
* function my_custom_field_validation( $key, $field, $args ) {
|
687 |
+
* // your code here
|
688 |
+
* }
|
689 |
+
* ?>
|
690 |
+
*/
|
691 |
+
do_action( "um_custom_field_validation_{$custom}", $key, $array, $args );
|
692 |
+
break;
|
693 |
+
|
694 |
+
case 'numeric':
|
695 |
+
if ( $args[ $key ] && ! is_numeric( $args[ $key ] ) ) {
|
696 |
+
UM()->form()->add_error( $key, __( 'Please enter numbers only in this field', 'ultimate-member' ) );
|
697 |
+
}
|
698 |
+
break;
|
699 |
+
|
700 |
+
case 'phone_number':
|
701 |
+
if ( ! UM()->validation()->is_phone_number( $args[ $key ] ) ) {
|
702 |
+
UM()->form()->add_error( $key, __( 'Please enter a valid phone number', 'ultimate-member' ) );
|
703 |
+
}
|
704 |
+
break;
|
705 |
+
|
706 |
+
case 'youtube_url':
|
707 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'youtube.com' ) ) {
|
708 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
709 |
+
}
|
710 |
+
break;
|
711 |
+
|
712 |
+
case 'telegram_url':
|
713 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 't.me' ) ) {
|
714 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
715 |
+
}
|
716 |
+
break;
|
717 |
+
|
718 |
+
case 'soundcloud_url':
|
719 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'soundcloud.com' ) ) {
|
720 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL','ultimate-member'), $array['label'] ) );
|
721 |
+
}
|
722 |
+
break;
|
723 |
+
|
724 |
+
case 'facebook_url':
|
725 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'facebook.com' ) ) {
|
726 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
727 |
+
}
|
728 |
+
break;
|
729 |
+
|
730 |
+
case 'twitter_url':
|
731 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'twitter.com' ) ) {
|
732 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
733 |
+
}
|
734 |
+
break;
|
735 |
+
|
736 |
+
case 'instagram_url':
|
737 |
+
|
738 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'instagram.com' ) ) {
|
739 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s profile URL', 'ultimate-member' ), $array['label'] ) );
|
740 |
+
}
|
741 |
+
break;
|
742 |
+
|
743 |
+
case 'google_url':
|
744 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'plus.google.com' ) ) {
|
745 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
746 |
+
}
|
747 |
+
break;
|
748 |
+
|
749 |
+
case 'linkedin_url':
|
750 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'linkedin.com' ) ) {
|
751 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
752 |
+
}
|
753 |
+
break;
|
754 |
+
|
755 |
+
case 'vk_url':
|
756 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'vk.com' ) ) {
|
757 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
758 |
+
}
|
759 |
+
break;
|
760 |
+
|
761 |
+
case 'discord':
|
762 |
+
if ( ! UM()->validation()->is_discord_id( $args[ $key ] ) ) {
|
763 |
+
UM()->form()->add_error( $key, __( 'Please enter a valid Discord ID', 'ultimate-member' ) );
|
764 |
+
}
|
765 |
+
break;
|
766 |
+
|
767 |
+
case 'url':
|
768 |
+
if ( ! UM()->validation()->is_url( $args[ $key ] ) ) {
|
769 |
+
UM()->form()->add_error( $key, __( 'Please enter a valid URL', 'ultimate-member' ) );
|
770 |
+
}
|
771 |
+
break;
|
772 |
+
|
773 |
+
case 'unique_username':
|
774 |
+
|
775 |
+
if ( $args[ $key ] == '' ) {
|
776 |
+
UM()->form()->add_error( $key, __( 'You must provide a username', 'ultimate-member' ) );
|
777 |
+
} elseif ( $mode == 'register' && username_exists( sanitize_user( $args[ $key ] ) ) ) {
|
778 |
+
UM()->form()->add_error( $key, __( 'The username you entered is incorrect', 'ultimate-member' ) );
|
779 |
+
} elseif ( is_email( $args[ $key ] ) ) {
|
780 |
+
UM()->form()->add_error( $key, __( 'Username cannot be an email', 'ultimate-member' ) );
|
781 |
+
} elseif ( ! UM()->validation()->safe_username( $args[ $key ] ) ) {
|
782 |
+
UM()->form()->add_error( $key, __( 'Your username contains invalid characters', 'ultimate-member' ) );
|
783 |
+
}
|
784 |
+
|
785 |
+
break;
|
786 |
+
|
787 |
+
case 'unique_username_or_email':
|
788 |
+
|
789 |
+
if ( $args[ $key ] == '' ) {
|
790 |
+
UM()->form()->add_error( $key, __( 'You must provide a username or email', 'ultimate-member' ) );
|
791 |
+
} elseif ( $mode == 'register' && username_exists( sanitize_user( $args[ $key ] ) ) ) {
|
792 |
+
UM()->form()->add_error( $key, __( 'The username you entered is incorrect', 'ultimate-member' ) );
|
793 |
+
} elseif ( $mode == 'register' && email_exists( $args[ $key ] ) ) {
|
794 |
+
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
795 |
+
} elseif ( ! UM()->validation()->safe_username( $args[ $key ] ) ) {
|
796 |
+
UM()->form()->add_error( $key, __( 'Your username contains invalid characters', 'ultimate-member' ) );
|
797 |
+
}
|
798 |
+
|
799 |
+
break;
|
800 |
+
|
801 |
+
case 'unique_email':
|
802 |
+
|
803 |
+
$args[ $key ] = trim( $args[ $key ] );
|
804 |
+
|
805 |
+
if ( in_array( $key, array( 'user_email' ) ) ) {
|
806 |
+
|
807 |
+
if ( ! isset( $args['user_id'] ) ){
|
808 |
+
$args['user_id'] = um_get_requested_user();
|
809 |
+
}
|
810 |
+
|
811 |
+
$email_exists = email_exists( $args[ $key ] );
|
812 |
+
|
813 |
+
if ( $args[ $key ] == '' && in_array( $key, array( 'user_email' ) ) ) {
|
814 |
+
UM()->form()->add_error( $key, __( 'You must provide your email', 'ultimate-member' ) );
|
815 |
+
} elseif ( in_array( $mode, array( 'register' ) ) && $email_exists ) {
|
816 |
+
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
817 |
+
} elseif ( in_array( $mode, array( 'profile' ) ) && $email_exists && $email_exists != $args['user_id'] ) {
|
818 |
+
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
819 |
+
} elseif ( ! is_email( $args[ $key ] ) ) {
|
820 |
+
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member') );
|
821 |
+
} elseif ( ! UM()->validation()->safe_username( $args[ $key ] ) ) {
|
822 |
+
UM()->form()->add_error( $key, __( 'Your email contains invalid characters', 'ultimate-member' ) );
|
823 |
+
}
|
824 |
+
|
825 |
+
} else {
|
826 |
+
|
827 |
+
if ( $args[ $key ] != '' && ! is_email( $args[ $key ] ) ) {
|
828 |
+
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
829 |
+
} elseif ( $args[ $key ] != '' && email_exists( $args[ $key ] ) ) {
|
830 |
+
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
831 |
+
} elseif ( $args[ $key ] != '' ) {
|
832 |
+
|
833 |
+
$users = get_users( 'meta_value=' . $args[ $key ] );
|
834 |
+
|
835 |
+
foreach ( $users as $user ) {
|
836 |
+
if ( $user->ID != $args['user_id'] ) {
|
837 |
+
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
838 |
+
}
|
839 |
+
}
|
840 |
+
|
841 |
+
}
|
842 |
+
|
843 |
+
}
|
844 |
+
|
845 |
+
break;
|
846 |
+
|
847 |
+
case 'is_email':
|
848 |
+
|
849 |
+
$args[ $key ] = trim( $args[ $key ] );
|
850 |
+
|
851 |
+
if ( $args[ $key ] != '' && ! is_email( $args[ $key ] ) ) {
|
852 |
+
UM()->form()->add_error( $key, __( 'This is not a valid email', 'ultimate-member' ) );
|
853 |
+
}
|
854 |
+
|
855 |
+
break;
|
856 |
+
|
857 |
+
case 'unique_value':
|
858 |
+
|
859 |
+
if ( $args[ $key ] != '' ) {
|
860 |
+
|
861 |
+
$args_unique_meta = array(
|
862 |
+
'meta_key' => $key,
|
863 |
+
'meta_value' => $args[ $key ],
|
864 |
+
'compare' => '=',
|
865 |
+
'exclude' => array( $args['user_id'] ),
|
866 |
+
);
|
867 |
+
|
868 |
+
$meta_key_exists = get_users( $args_unique_meta );
|
869 |
+
|
870 |
+
if ( $meta_key_exists ) {
|
871 |
+
UM()->form()->add_error( $key , __( 'You must provide a unique value', 'ultimate-member' ) );
|
872 |
+
}
|
873 |
+
}
|
874 |
+
break;
|
875 |
+
|
876 |
+
case 'alphabetic':
|
877 |
+
|
878 |
+
if ( $args[ $key ] != '' ) {
|
879 |
+
|
880 |
+
if ( ! preg_match( '/^\p{L}+$/u', str_replace( ' ', '', $args[ $key ] ) ) ) {
|
881 |
+
UM()->form()->add_error( $key, __( 'You must provide alphabetic letters', 'ultimate-member' ) );
|
882 |
+
}
|
883 |
+
|
884 |
+
}
|
885 |
+
|
886 |
+
break;
|
887 |
+
|
888 |
+
case 'lowercase':
|
889 |
+
|
890 |
+
if ( $args[ $key ] != '' ) {
|
891 |
+
|
892 |
+
if ( ! ctype_lower( str_replace(' ', '', $args[ $key ] ) ) ) {
|
893 |
+
UM()->form()->add_error( $key , __( 'You must provide lowercase letters.', 'ultimate-member' ) );
|
894 |
+
}
|
895 |
+
}
|
896 |
+
|
897 |
+
break;
|
898 |
+
|
899 |
+
}
|
900 |
+
|
901 |
+
}
|
902 |
+
|
903 |
+
}
|
904 |
+
|
905 |
+
if ( isset( $args['description'] ) ) {
|
906 |
+
$max_chars = UM()->options()->get( 'profile_bio_maxchars' );
|
907 |
+
$profile_show_bio = UM()->options()->get( 'profile_show_bio' );
|
908 |
+
|
909 |
+
if ( $profile_show_bio ) {
|
910 |
+
if ( mb_strlen( str_replace( array( "\r\n", "\n", "\r\t", "\t" ), ' ', $args['description'] ) ) > $max_chars && $max_chars ) {
|
911 |
+
UM()->form()->add_error( 'description', sprintf( __( 'Your user description must contain less than %s characters', 'ultimate-member' ), $max_chars ) );
|
912 |
+
}
|
913 |
+
}
|
914 |
+
|
915 |
+
}
|
916 |
+
|
917 |
+
} // end if ( isset in args array )
|
918 |
+
}
|
919 |
+
}
|
920 |
+
add_action( 'um_submit_form_errors_hook_', 'um_submit_form_errors_hook_', 10 );
|
921 |
+
|
922 |
+
|
923 |
+
/**
|
924 |
+
* @param string $url
|
925 |
+
*
|
926 |
+
* @return string
|
927 |
+
*/
|
928 |
+
function um_invalid_nonce_redirect_url( $url ) {
|
929 |
+
$url = add_query_arg( [
|
930 |
+
'um-hash' => substr( md5( rand() ), 0, 6 ),
|
931 |
+
], remove_query_arg( 'um-hash', $url ) );
|
932 |
+
|
933 |
+
return $url;
|
934 |
+
}
|
935 |
+
add_filter( 'um_login_invalid_nonce_redirect_url', 'um_invalid_nonce_redirect_url', 10, 1 );
|
936 |
+
add_filter( 'um_register_invalid_nonce_redirect_url', 'um_invalid_nonce_redirect_url', 10, 1 );
|
includes/core/um-actions-login.php
CHANGED
@@ -65,12 +65,12 @@ function um_submit_form_errors_hook_login( $args ) {
|
|
65 |
|
66 |
$user = apply_filters( 'authenticate', null, $authenticate, $args['user_password'] );
|
67 |
if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes ) ) {
|
68 |
-
UM()->form()->add_error( $user->get_error_code(), __(
|
69 |
}
|
70 |
|
71 |
$user = apply_filters( 'wp_authenticate_user', $user, $args['user_password'] );
|
72 |
if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes ) ) {
|
73 |
-
UM()->form()->add_error( $user->get_error_code(), __(
|
74 |
}
|
75 |
|
76 |
// if there is an error notify wp
|
65 |
|
66 |
$user = apply_filters( 'authenticate', null, $authenticate, $args['user_password'] );
|
67 |
if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes ) ) {
|
68 |
+
UM()->form()->add_error( $user->get_error_code(), __( 'Password is incorrect. Please try again.', 'ultimate-member' ) );
|
69 |
}
|
70 |
|
71 |
$user = apply_filters( 'wp_authenticate_user', $user, $args['user_password'] );
|
72 |
if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes ) ) {
|
73 |
+
UM()->form()->add_error( $user->get_error_code(), __( 'Password is incorrect. Please try again.', 'ultimate-member' ) );
|
74 |
}
|
75 |
|
76 |
// if there is an error notify wp
|
includes/core/um-actions-profile.php
CHANGED
@@ -1,1754 +1,1760 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
2 |
-
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Um_profile_content_{main_tab}
|
6 |
-
*
|
7 |
-
* @param $args
|
8 |
-
*/
|
9 |
-
function um_profile_content_main( $args ) {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* @var $mode
|
13 |
-
*/
|
14 |
-
extract( $args );
|
15 |
-
|
16 |
-
if ( ! UM()->options()->get( 'profile_tab_main' ) && ! isset( $_REQUEST['um_action'] ) ) {
|
17 |
-
return;
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* UM hook
|
22 |
-
*
|
23 |
-
* @type filter
|
24 |
-
* @title um_profile_can_view_main
|
25 |
-
* @description Check user can view profile
|
26 |
-
* @input_vars
|
27 |
-
* [{"var":"$view","type":"bool","desc":"Can view?"},
|
28 |
-
* {"var":"$user_id","type":"int","desc":"User profile ID"}]
|
29 |
-
* @change_log
|
30 |
-
* ["Since: 2.0"]
|
31 |
-
* @usage
|
32 |
-
* <?php add_filter( 'um_profile_can_view_main', 'function_name', 10, 2 ); ?>
|
33 |
-
* @example
|
34 |
-
* <?php
|
35 |
-
* add_filter( 'um_profile_can_view_main', 'my_profile_can_view_main', 10, 2 );
|
36 |
-
* function my_profile_can_view_main( $view, $user_id ) {
|
37 |
-
* // your code here
|
38 |
-
* return $view;
|
39 |
-
* }
|
40 |
-
* ?>
|
41 |
-
*/
|
42 |
-
$can_view = apply_filters( 'um_profile_can_view_main', -1, um_profile_id() );
|
43 |
-
|
44 |
-
if ( $can_view == -1 ) {
|
45 |
-
/**
|
46 |
-
* UM hook
|
47 |
-
*
|
48 |
-
* @type action
|
49 |
-
* @title um_before_form
|
50 |
-
* @description Some actions before profile form
|
51 |
-
* @input_vars
|
52 |
-
* [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
|
53 |
-
* @change_log
|
54 |
-
* ["Since: 2.0"]
|
55 |
-
* @usage add_action( 'um_before_form', 'function_name', 10, 1 );
|
56 |
-
* @example
|
57 |
-
* <?php
|
58 |
-
* add_action( 'um_before_form', 'my_before_form', 10, 1 );
|
59 |
-
* function my_before_form( $args ) {
|
60 |
-
* // your code here
|
61 |
-
* }
|
62 |
-
* ?>
|
63 |
-
*/
|
64 |
-
do_action( 'um_before_form', $args );
|
65 |
-
|
66 |
-
/**
|
67 |
-
* UM hook
|
68 |
-
*
|
69 |
-
* @type action
|
70 |
-
* @title um_before_{$mode}_fields
|
71 |
-
* @description Some actions before profile form fields
|
72 |
-
* @input_vars
|
73 |
-
* [{"var":"$args","type":"array","desc":"{Profile} form shortcode arguments"}]
|
74 |
-
* @change_log
|
75 |
-
* ["Since: 2.0"]
|
76 |
-
* @usage add_action( 'um_before_{$mode}_fields', 'function_name', 10, 1 );
|
77 |
-
* @example
|
78 |
-
* <?php
|
79 |
-
* add_action( 'um_before_{$mode}_fields', 'my_before_fields', 10, 1 );
|
80 |
-
* function my_before_form( $args ) {
|
81 |
-
* // your code here
|
82 |
-
* }
|
83 |
-
* ?>
|
84 |
-
*/
|
85 |
-
do_action( "um_before_{$mode}_fields", $args );
|
86 |
-
|
87 |
-
/**
|
88 |
-
* UM hook
|
89 |
-
*
|
90 |
-
* @type action
|
91 |
-
* @title um_main_{$mode}_fields
|
92 |
-
* @description Some actions before login form fields
|
93 |
-
* @input_vars
|
94 |
-
* [{"var":"$args","type":"array","desc":"Login form shortcode arguments"}]
|
95 |
-
* @change_log
|
96 |
-
* ["Since: 2.0"]
|
97 |
-
* @usage add_action( 'um_before_{$mode}_fields', 'function_name', 10, 1 );
|
98 |
-
* @example
|
99 |
-
* <?php
|
100 |
-
* add_action( 'um_before_{$mode}_fields', 'my_before_fields', 10, 1 );
|
101 |
-
* function my_before_form( $args ) {
|
102 |
-
* // your code here
|
103 |
-
* }
|
104 |
-
* ?>
|
105 |
-
*/
|
106 |
-
do_action( "um_main_{$mode}_fields", $args );
|
107 |
-
|
108 |
-
/**
|
109 |
-
* UM hook
|
110 |
-
*
|
111 |
-
* @type action
|
112 |
-
* @title um_after_form_fields
|
113 |
-
* @description Some actions after login form fields
|
114 |
-
* @input_vars
|
115 |
-
* [{"var":"$args","type":"array","desc":"Login form shortcode arguments"}]
|
116 |
-
* @change_log
|
117 |
-
* ["Since: 2.0"]
|
118 |
-
* @usage add_action( 'um_after_form_fields', 'function_name', 10, 1 );
|
119 |
-
* @example
|
120 |
-
* <?php
|
121 |
-
* add_action( 'um_after_form_fields', 'my_after_form_fields', 10, 1 );
|
122 |
-
* function my_after_form_fields( $args ) {
|
123 |
-
* // your code here
|
124 |
-
* }
|
125 |
-
* ?>
|
126 |
-
*/
|
127 |
-
do_action( 'um_after_form_fields', $args );
|
128 |
-
|
129 |
-
/**
|
130 |
-
* UM hook
|
131 |
-
*
|
132 |
-
* @type action
|
133 |
-
* @title um_after_{$mode}_fields
|
134 |
-
* @description Some actions after profile form fields
|
135 |
-
* @input_vars
|
136 |
-
* [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
|
137 |
-
* @change_log
|
138 |
-
* ["Since: 2.0"]
|
139 |
-
* @usage add_action( 'um_after_{$mode}_fields', 'function_name', 10, 1 );
|
140 |
-
* @example
|
141 |
-
* <?php
|
142 |
-
* add_action( 'um_after_{$mode}_fields', 'my_after_form_fields', 10, 1 );
|
143 |
-
* function my_after_form_fields( $args ) {
|
144 |
-
* // your code here
|
145 |
-
* }
|
146 |
-
* ?>
|
147 |
-
*/
|
148 |
-
do_action( "um_after_{$mode}_fields", $args );
|
149 |
-
|
150 |
-
/**
|
151 |
-
* UM hook
|
152 |
-
*
|
153 |
-
* @type action
|
154 |
-
* @title um_after_form
|
155 |
-
* @description Some actions after profile form fields
|
156 |
-
* @input_vars
|
157 |
-
* [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
|
158 |
-
* @change_log
|
159 |
-
* ["Since: 2.0"]
|
160 |
-
* @usage add_action( 'um_after_form', 'function_name', 10, 1 );
|
161 |
-
* @example
|
162 |
-
* <?php
|
163 |
-
* add_action( 'um_after_form', 'my_after_form', 10, 1 );
|
164 |
-
* function my_after_form( $args ) {
|
165 |
-
* // your code here
|
166 |
-
* }
|
167 |
-
* ?>
|
168 |
-
*/
|
169 |
-
do_action( 'um_after_form', $args );
|
170 |
-
|
171 |
-
} else {
|
172 |
-
?>
|
173 |
-
<div class="um-profile-note">
|
174 |
-
<span>
|
175 |
-
<i class="um-faicon-lock"></i>
|
176 |
-
<?php echo $can_view; ?>
|
177 |
-
</span>
|
178 |
-
</div>
|
179 |
-
<?php
|
180 |
-
}
|
181 |
-
}
|
182 |
-
add_action( 'um_profile_content_main', 'um_profile_content_main' );
|
183 |
-
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Update user's profile
|
187 |
-
*
|
188 |
-
* @param array $args
|
189 |
-
*/
|
190 |
-
function um_user_edit_profile( $args ) {
|
191 |
-
$to_update = null;
|
192 |
-
$files = array();
|
193 |
-
|
194 |
-
$user_id = null;
|
195 |
-
if ( isset( $args['user_id'] ) ) {
|
196 |
-
$user_id = $args['user_id'];
|
197 |
-
} elseif ( isset( $args['_user_id'] ) ) {
|
198 |
-
$user_id = $args['_user_id'];
|
199 |
-
}
|
200 |
-
|
201 |
-
if ( UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
202 |
-
UM()->user()->set( $user_id );
|
203 |
-
} else {
|
204 |
-
wp_die( __( 'You are not allowed to edit this user.', 'ultimate-member' ) );
|
205 |
-
}
|
206 |
-
|
207 |
-
$userinfo = UM()->user()->profile;
|
208 |
-
|
209 |
-
/**
|
210 |
-
* UM hook
|
211 |
-
*
|
212 |
-
* @type action
|
213 |
-
* @title um_user_before_updating_profile
|
214 |
-
* @description Some actions before profile submit
|
215 |
-
* @input_vars
|
216 |
-
* [{"var":"$userinfo","type":"array","desc":"User Data"}]
|
217 |
-
* @change_log
|
218 |
-
* ["Since: 2.0"]
|
219 |
-
* @usage add_action( 'um_user_before_updating_profile', 'function_name', 10, 1 );
|
220 |
-
* @example
|
221 |
-
* <?php
|
222 |
-
* add_action( 'um_user_before_updating_profile', 'my_user_before_updating_profile', 10, 1 );
|
223 |
-
* function my_user_before_updating_profile( $userinfo ) {
|
224 |
-
* // your code here
|
225 |
-
* }
|
226 |
-
* ?>
|
227 |
-
*/
|
228 |
-
do_action( 'um_user_before_updating_profile', $userinfo );
|
229 |
-
|
230 |
-
if ( ! empty( $args['custom_fields'] ) ) {
|
231 |
-
$fields = apply_filters( 'um_user_edit_profile_fields', unserialize( $args['custom_fields'] ), $args );
|
232 |
-
}
|
233 |
-
|
234 |
-
// loop through fields
|
235 |
-
if ( ! empty( $fields ) ) {
|
236 |
-
|
237 |
-
foreach ( $fields as $key => $array ) {
|
238 |
-
|
239 |
-
if ( ! isset( $array['type'] ) ) {
|
240 |
-
continue;
|
241 |
-
}
|
242 |
-
|
243 |
-
if ( isset( $array['edit_forbidden'] ) ) {
|
244 |
-
continue;
|
245 |
-
}
|
246 |
-
|
247 |
-
// required option? 'required_opt' - it's field attribute predefined in the field data in code
|
248 |
-
if ( isset( $array['required_opt'] ) ) {
|
249 |
-
$opt = $array['required_opt'];
|
250 |
-
if ( UM()->options()->get( $opt[0] ) != $opt[1] ) {
|
251 |
-
continue;
|
252 |
-
}
|
253 |
-
}
|
254 |
-
|
255 |
-
// fields that need to be disabled in edit mode (profile) (email, username, etc.)
|
256 |
-
$arr_restricted_fields = UM()->fields()->get_restricted_fields_for_edit( $user_id );
|
257 |
-
if ( in_array( $key, $arr_restricted_fields ) ) {
|
258 |
-
continue;
|
259 |
-
}
|
260 |
-
|
261 |
-
if ( ! um_can_edit_field( $array ) || ! um_can_view_field( $array ) ) {
|
262 |
-
continue;
|
263 |
-
}
|
264 |
-
|
265 |
-
// skip saving role here
|
266 |
-
if ( in_array( $key, [ 'role', 'role_select', 'role_radio' ] ) ) {
|
267 |
-
continue;
|
268 |
-
}
|
269 |
-
|
270 |
-
//the same code in class-validation.php validate_fields_values for registration form
|
271 |
-
//rating field validation
|
272 |
-
if ( $array['type'] == 'rating' && isset( $args['submitted'][ $key ] ) ) {
|
273 |
-
if ( ! is_numeric( $args['submitted'][ $key ] ) ) {
|
274 |
-
continue;
|
275 |
-
} else {
|
276 |
-
if ( $array['number'] == 5 ) {
|
277 |
-
if ( ! in_array( $args['submitted'][ $key ], range( 1, 5 ) ) ) {
|
278 |
-
continue;
|
279 |
-
}
|
280 |
-
} elseif ( $array['number'] == 10 ) {
|
281 |
-
if ( ! in_array( $args['submitted'][ $key ], range( 1, 10 ) ) ) {
|
282 |
-
continue;
|
283 |
-
}
|
284 |
-
}
|
285 |
-
}
|
286 |
-
}
|
287 |
-
|
288 |
-
|
289 |
-
/**
|
290 |
-
* Returns dropdown/multi-select options keys from a callback function
|
291 |
-
* @since 2019-05-30
|
292 |
-
*/
|
293 |
-
$has_custom_source = apply_filters( "um_has_dropdown_options_source__{$key}", false );
|
294 |
-
if ( isset( $array['options'] ) && in_array( $array['type'], array( 'select', 'multiselect' ) ) ) {
|
295 |
-
|
296 |
-
$options = array();
|
297 |
-
if ( ! empty( $array['custom_dropdown_options_source'] ) && function_exists( $array['custom_dropdown_options_source'] ) && ! $has_custom_source ) {
|
298 |
-
$callback_result = call_user_func( $array['custom_dropdown_options_source'], $array['options'] );
|
299 |
-
if ( is_array( $callback_result ) ) {
|
300 |
-
$options = array_keys( $callback_result );
|
301 |
-
}
|
302 |
-
}
|
303 |
-
|
304 |
-
$array['options'] = apply_filters( "um_custom_dropdown_options__{$key}", $options );
|
305 |
-
|
306 |
-
}
|
307 |
-
|
308 |
-
|
309 |
-
//validation of correct values from options in wp-admin
|
310 |
-
$stripslashes = '';
|
311 |
-
if ( isset( $args['submitted'][ $key ] ) && is_string( $args['submitted'][ $key ] ) ) {
|
312 |
-
$stripslashes = stripslashes( $args['submitted'][ $key ] );
|
313 |
-
}
|
314 |
-
|
315 |
-
if ( in_array( $array['type'], array( 'select' ) ) ) {
|
316 |
-
if ( ! empty( $array['options'] ) && ! empty( $stripslashes ) && ! in_array( $stripslashes, array_map( 'trim', $array['options'] ) ) && ! $has_custom_source ) {
|
317 |
-
continue;
|
318 |
-
}
|
319 |
-
|
320 |
-
//update empty user meta
|
321 |
-
if ( ! isset( $args['submitted'][ $key ] ) || $args['submitted'][ $key ] == '' ) {
|
322 |
-
update_user_meta( $user_id, $key, '' );
|
323 |
-
}
|
324 |
-
}
|
325 |
-
|
326 |
-
//validation of correct values from options in wp-admin
|
327 |
-
//the user cannot set invalid value in the hidden input at the page
|
328 |
-
if ( in_array( $array['type'], array( 'multiselect', 'checkbox', 'radio' ) ) ) {
|
329 |
-
if ( ! empty( $args['submitted'][ $key ] ) && ! empty( $array['options'] ) ) {
|
330 |
-
$args['submitted'][ $key ] = array_map( 'stripslashes', array_map( 'trim', $args['submitted'][ $key ] ) );
|
331 |
-
$args['submitted'][ $key ] = array_intersect( $args['submitted'][ $key ], array_map( 'trim', $array['options'] ) );
|
332 |
-
}
|
333 |
-
|
334 |
-
// update empty user meta
|
335 |
-
if ( ! isset( $args['submitted'][ $key ] ) || $args['submitted'][ $key ] == '' ) {
|
336 |
-
update_user_meta( $user_id, $key, array() );
|
337 |
-
}
|
338 |
-
}
|
339 |
-
|
340 |
-
if ( isset( $args['submitted'][ $key ] ) ) {
|
341 |
-
|
342 |
-
if ( isset( $array['type'] ) && in_array( $array['type'], array( 'image', 'file' ) ) ) {
|
343 |
-
|
344 |
-
if ( um_is_temp_file( $args['submitted'][ $key ] ) || $args['submitted'][ $key ] == 'empty_file' ) {
|
345 |
-
$files[ $key ] = $args['submitted'][ $key ];
|
346 |
-
} elseif( um_is_file_owner( UM()->uploader()->get_upload_base_url() . $user_id . '/' . $args['submitted'][ $key ], $user_id ) ) {
|
347 |
-
|
348 |
-
} else {
|
349 |
-
$files[ $key ] = 'empty_file';
|
350 |
-
}
|
351 |
-
|
352 |
-
} else {
|
353 |
-
if ( $array['type'] == 'password' ) {
|
354 |
-
$to_update[ $key ] = wp_hash_password( $args['submitted'][ $key ] );
|
355 |
-
$args['submitted'][ $key ] = sprintf( __( 'Your choosed %s', 'ultimate-member' ), $array['title'] );
|
356 |
-
} else {
|
357 |
-
if ( isset( $userinfo[ $key ] ) && $args['submitted'][ $key ] != $userinfo[ $key ] ) {
|
358 |
-
$to_update[ $key ] = $args['submitted'][ $key ];
|
359 |
-
} elseif ( $args['submitted'][ $key ] != '' ) {
|
360 |
-
$to_update[ $key ] = $args['submitted'][ $key ];
|
361 |
-
}
|
362 |
-
}
|
363 |
-
|
364 |
-
}
|
365 |
-
|
366 |
-
// use this filter after all validations has been completed and we can extends data based on key
|
367 |
-
$to_update = apply_filters( 'um_change_usermeta_for_update', $to_update, $args, $fields, $key );
|
368 |
-
|
369 |
-
}
|
370 |
-
}
|
371 |
-
}
|
372 |
-
|
373 |
-
$description_key = UM()->profile()->get_show_bio_key( $args );
|
374 |
-
if ( isset( $args['submitted'][ $description_key ] ) ) {
|
375 |
-
$to_update[ $description_key ] = $args['submitted'][ $description_key ];
|
376 |
-
}
|
377 |
-
|
378 |
-
|
379 |
-
// Secure selected role
|
380 |
-
if ( is_admin() ) {
|
381 |
-
|
382 |
-
if ( ! empty( $args['submitted']['role'] ) && current_user_can( 'promote_users' ) ) {
|
383 |
-
global $wp_roles;
|
384 |
-
$role_keys = array_map( function( $item ) {
|
385 |
-
return 'um_' . $item;
|
386 |
-
}, get_option( 'um_roles', array() ) );
|
387 |
-
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
388 |
-
|
389 |
-
if ( ! in_array( $args['submitted']['role'], $exclude_roles ) ) {
|
390 |
-
$to_update['role'] = $args['submitted']['role'];
|
391 |
-
}
|
392 |
-
|
393 |
-
$args['roles_before_upgrade'] = UM()->roles()->get_all_user_roles( $user_id );
|
394 |
-
}
|
395 |
-
|
396 |
-
} else {
|
397 |
-
|
398 |
-
if ( ( isset( $fields['role'] ) && $fields['role']['editable'] != 0 && um_can_view_field( $fields['role'] ) ) ||
|
399 |
-
( isset( $fields['role_select'] ) && $fields['role_select']['editable'] != 0 && um_can_view_field( $fields['role_select'] ) ) ||
|
400 |
-
( isset( $fields['role_radio'] ) ) && $fields['role_radio']['editable'] != 0 && um_can_view_field( $fields['role_radio'] ) ) {
|
401 |
-
|
402 |
-
if ( ! empty( $args['submitted']['role'] ) ) {
|
403 |
-
global $wp_roles;
|
404 |
-
$role_keys = array_map( function( $item ) {
|
405 |
-
return 'um_' . $item;
|
406 |
-
}, get_option( 'um_roles', array() ) );
|
407 |
-
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
408 |
-
|
409 |
-
if ( ! in_array( $args['submitted']['role'], $exclude_roles ) ) {
|
410 |
-
$to_update['role'] = $args['submitted']['role'];
|
411 |
-
}
|
412 |
-
|
413 |
-
$args['roles_before_upgrade'] = UM()->roles()->get_all_user_roles( $user_id );
|
414 |
-
}
|
415 |
-
}
|
416 |
-
|
417 |
-
}
|
418 |
-
|
419 |
-
/**
|
420 |
-
* UM hook
|
421 |
-
*
|
422 |
-
* @type action
|
423 |
-
* @title um_user_pre_updating_profile
|
424 |
-
* @description Some actions before profile submit
|
425 |
-
* @input_vars
|
426 |
-
* [{"var":"$userinfo","type":"array","desc":"Submitted User Data"},
|
427 |
-
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
428 |
-
* @change_log
|
429 |
-
* ["Since: 2.0"]
|
430 |
-
* @usage add_action( 'um_user_pre_updating_profile', 'function_name', 10, 2 );
|
431 |
-
* @example
|
432 |
-
* <?php
|
433 |
-
* add_action( 'um_user_pre_updating_profile', 'my_user_pre_updating_profile', 10, 2 );
|
434 |
-
* function my_user_pre_updating_profile( $userinfo, $user_id ) {
|
435 |
-
* // your code here
|
436 |
-
* }
|
437 |
-
* ?>
|
438 |
-
*/
|
439 |
-
do_action( 'um_user_pre_updating_profile', $to_update, $user_id );
|
440 |
-
|
441 |
-
/**
|
442 |
-
* UM hook
|
443 |
-
*
|
444 |
-
* @type filter
|
445 |
-
* @title um_user_pre_updating_profile_array
|
446 |
-
* @description Change submitted data before update profile
|
447 |
-
* @input_vars
|
448 |
-
* [{"var":"$to_update","type":"array","desc":"Profile data upgrade"},
|
449 |
-
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
450 |
-
* @change_log
|
451 |
-
* ["Since: 2.0"]
|
452 |
-
* @usage
|
453 |
-
* <?php add_filter( 'um_user_pre_updating_profile_array', 'function_name', 10, 2 ); ?>
|
454 |
-
* @example
|
455 |
-
* <?php
|
456 |
-
* add_filter( 'um_user_pre_updating_profile_array', 'my_user_pre_updating_profile', 10, 2 );
|
457 |
-
* function my_user_pre_updating_profile( $to_update, $user_id ) {
|
458 |
-
* // your code here
|
459 |
-
* return $to_update;
|
460 |
-
* }
|
461 |
-
* ?>
|
462 |
-
*/
|
463 |
-
$to_update = apply_filters( 'um_user_pre_updating_profile_array', $to_update, $user_id );
|
464 |
-
|
465 |
-
if ( is_array( $to_update ) ) {
|
466 |
-
|
467 |
-
if ( isset( $to_update['first_name'] ) || isset( $to_update['last_name'] ) || isset( $to_update['nickname'] ) ) {
|
468 |
-
$user = get_userdata( $user_id );
|
469 |
-
if ( ! empty( $user ) && ! is_wp_error( $user ) ) {
|
470 |
-
UM()->user()->previous_data['display_name'] = $user->display_name;
|
471 |
-
|
472 |
-
if ( isset( $to_update['first_name'] ) ) {
|
473 |
-
UM()->user()->previous_data['first_name'] = $user->first_name;
|
474 |
-
}
|
475 |
-
|
476 |
-
if ( isset( $to_update['last_name'] ) ) {
|
477 |
-
UM()->user()->previous_data['last_name'] = $user->last_name;
|
478 |
-
}
|
479 |
-
|
480 |
-
if ( isset( $to_update['nickname'] ) ) {
|
481 |
-
UM()->user()->previous_data['nickname'] = $user->nickname;
|
482 |
-
}
|
483 |
-
}
|
484 |
-
}
|
485 |
-
|
486 |
-
UM()->user()->update_profile( $to_update );
|
487 |
-
/**
|
488 |
-
* UM hook
|
489 |
-
*
|
490 |
-
* @type action
|
491 |
-
* @title um_after_user_updated
|
492 |
-
* @description Some actions after user profile updated
|
493 |
-
* @input_vars
|
494 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
495 |
-
* {"var":"$args","type":"array","desc":"Form Data"},
|
496 |
-
* {"var":"$userinfo","type":"array","desc":"Submitted User Data"}]
|
497 |
-
* @change_log
|
498 |
-
* ["Since: 2.0"]
|
499 |
-
* @usage add_action( 'um_after_user_updated', 'function_name', 10, 33 );
|
500 |
-
* @example
|
501 |
-
* <?php
|
502 |
-
* add_action( 'um_after_user_updated', 'my_after_user_updated', 10, 3 );
|
503 |
-
* function my_after_user_updated( $user_id, $args, $userinfo ) {
|
504 |
-
* // your code here
|
505 |
-
* }
|
506 |
-
* ?>
|
507 |
-
*/
|
508 |
-
do_action( 'um_after_user_updated', $user_id, $args, $to_update );
|
509 |
-
}
|
510 |
-
|
511 |
-
/**
|
512 |
-
* UM hook
|
513 |
-
*
|
514 |
-
* @type filter
|
515 |
-
* @title um_user_pre_updating_files_array
|
516 |
-
* @description Change submitted files before update profile
|
517 |
-
* @input_vars
|
518 |
-
* [{"var":"$files","type":"array","desc":"Profile data files"},
|
519 |
-
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
520 |
-
* @change_log
|
521 |
-
* ["Since: 2.0"]
|
522 |
-
* @usage
|
523 |
-
* <?php add_filter( 'um_user_pre_updating_files_array', 'function_name', 10, 2 ); ?>
|
524 |
-
* @example
|
525 |
-
* <?php
|
526 |
-
* add_filter( 'um_user_pre_updating_files_array', 'my_user_pre_updating_files', 10, 2 );
|
527 |
-
* function my_user_pre_updating_files( $files, $user_id ) {
|
528 |
-
* // your code here
|
529 |
-
* return $files;
|
530 |
-
* }
|
531 |
-
* ?>
|
532 |
-
*/
|
533 |
-
$files = apply_filters( 'um_user_pre_updating_files_array', $files, $user_id );
|
534 |
-
|
535 |
-
if ( ! empty( $files ) && is_array( $files ) ) {
|
536 |
-
UM()->uploader()->replace_upload_dir = true;
|
537 |
-
UM()->uploader()->move_temporary_files( $user_id, $files );
|
538 |
-
UM()->uploader()->replace_upload_dir = false;
|
539 |
-
}
|
540 |
-
|
541 |
-
/**
|
542 |
-
* UM hook
|
543 |
-
*
|
544 |
-
* @type action
|
545 |
-
* @title um_user_after_updating_profile
|
546 |
-
* @description After upgrade user's profile
|
547 |
-
* @input_vars
|
548 |
-
* [{"var":"$submitted","type":"array","desc":"Form data"},
|
549 |
-
* {"var":"$user_id","type":"int","desc":"User Id"}]
|
550 |
-
* @change_log
|
551 |
-
* ["Since: 2.0"]
|
552 |
-
* @usage add_action( 'um_user_after_updating_profile', 'function_name', 10, 1 );
|
553 |
-
* @example
|
554 |
-
* <?php
|
555 |
-
* add_action( 'um_user_after_updating_profile', 'my_user_after_updating_profile'', 10, 2 );
|
556 |
-
* function my_user_after_updating_profile( $submitted, $user_id ) {
|
557 |
-
* // your code here
|
558 |
-
* }
|
559 |
-
* ?>
|
560 |
-
*/
|
561 |
-
do_action( 'um_user_after_updating_profile', $to_update, $user_id, $args );
|
562 |
-
|
563 |
-
/**
|
564 |
-
* UM hook
|
565 |
-
*
|
566 |
-
* @type action
|
567 |
-
* @title um_update_profile_full_name
|
568 |
-
* @description On update user profile change full name
|
569 |
-
* @input_vars
|
570 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
571 |
-
* {"var":"$args","type":"array","desc":"Form data"}]
|
572 |
-
* @change_log
|
573 |
-
* ["Since: 2.0"]
|
574 |
-
* @usage add_action( 'um_update_profile_full_name', 'function_name', 10, 2 );
|
575 |
-
* @example
|
576 |
-
* <?php
|
577 |
-
* add_action( 'um_update_profile_full_name', 'my_update_profile_full_name', 10, 2 );
|
578 |
-
* function my_update_profile_full_name( $user_id, $args ) {
|
579 |
-
* // your code here
|
580 |
-
* }
|
581 |
-
* ?>
|
582 |
-
*/
|
583 |
-
do_action( 'um_update_profile_full_name', $user_id, $to_update );
|
584 |
-
|
585 |
-
if ( ! isset( $args['is_signup'] ) ) {
|
586 |
-
$url = um_user_profile_url( $user_id );
|
587 |
-
$url = apply_filters( 'um_update_profile_redirect_after', $url, $user_id, $args );
|
588 |
-
exit( wp_redirect( um_edit_my_profile_cancel_uri( $url ) ) );
|
589 |
-
}
|
590 |
-
}
|
591 |
-
add_action( 'um_user_edit_profile', 'um_user_edit_profile', 10 );
|
592 |
-
|
593 |
-
|
594 |
-
/**
|
595 |
-
* @param array $post_form
|
596 |
-
*/
|
597 |
-
function um_profile_validate_nonce( $post_form ) {
|
598 |
-
$user_id = isset( $post_form['user_id'] ) ? $post_form['user_id'] : '';
|
599 |
-
$nonce = isset( $post_form['profile_nonce'] ) ? $post_form['profile_nonce'] : '';
|
600 |
-
if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'um-profile-nonce' . $user_id ) ) {
|
601 |
-
wp_die( __( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
602 |
-
}
|
603 |
-
}
|
604 |
-
add_action( 'um_submit_form_errors_hook__profile', 'um_profile_validate_nonce', 10, 1 );
|
605 |
-
|
606 |
-
|
607 |
-
add_filter( 'um_user_pre_updating_files_array', array( UM()->validation(), 'validate_files' ), 10, 1 );
|
608 |
-
add_filter( 'um_before_save_filter_submitted', array( UM()->validation(), 'validate_fields_values' ), 10, 2 );
|
609 |
-
|
610 |
-
/**
|
611 |
-
* Leave roles for User, which are not in the list of update profile (are default WP or 3rd plugins roles)
|
612 |
-
*
|
613 |
-
* @param $user_id
|
614 |
-
* @param $args
|
615 |
-
* @param $to_update
|
616 |
-
*/
|
617 |
-
function um_restore_default_roles( $user_id, $args, $to_update ) {
|
618 |
-
if ( ! empty( $args['submitted']['role'] ) && ! empty( $to_update['role'] ) ) {
|
619 |
-
$wp_user = new WP_User( $user_id );
|
620 |
-
|
621 |
-
$role_keys = array_map( function( $item ) {
|
622 |
-
return 'um_' . $item;
|
623 |
-
}, get_option( 'um_roles', array() ) );
|
624 |
-
|
625 |
-
$leave_roles = array_diff( $args['roles_before_upgrade'], array_merge( $role_keys, array( 'subscriber' ) ) );
|
626 |
-
|
627 |
-
if ( UM()->roles()->is_role_custom( $to_update['role'] ) ) {
|
628 |
-
$wp_user->remove_role( $to_update['role'] );
|
629 |
-
$roles = array_merge( $leave_roles, array( $to_update['role'] ) );
|
630 |
-
} else {
|
631 |
-
$roles = array_merge( array( $to_update['role'] ), $leave_roles );
|
632 |
-
}
|
633 |
-
|
634 |
-
foreach ( $roles as $role_k ) {
|
635 |
-
$wp_user->add_role( $role_k );
|
636 |
-
}
|
637 |
-
}
|
638 |
-
}
|
639 |
-
add_action( 'um_after_user_updated', 'um_restore_default_roles', 10, 3 );
|
640 |
-
|
641 |
-
|
642 |
-
/**
|
643 |
-
* If editing another user
|
644 |
-
*
|
645 |
-
* @param $args
|
646 |
-
*/
|
647 |
-
function um_editing_user_id_input( $args ) {
|
648 |
-
if ( UM()->fields()->editing == 1 && UM()->fields()->set_mode == 'profile' && UM()->user()->target_id ) { ?>
|
649 |
-
|
650 |
-
<input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( UM()->user()->target_id ); ?>" />
|
651 |
-
<input type="hidden" name="profile_nonce" id="profile_nonce" value="<?php echo esc_attr( UM()->form()->nonce ); ?>" />
|
652 |
-
|
653 |
-
<?php }
|
654 |
-
}
|
655 |
-
add_action( 'um_after_form_fields', 'um_editing_user_id_input' );
|
656 |
-
|
657 |
-
|
658 |
-
/**
|
659 |
-
* Remove Yoast from front end for the Profile page
|
660 |
-
*
|
661 |
-
* @see https://gist.github.com/amboutwe/1c847f9c706ff6f8c9eca76abea23fb6
|
662 |
-
* @since 2.1.6
|
663 |
-
*/
|
664 |
-
if ( !function_exists( 'um_profile_remove_wpseo' ) ) {
|
665 |
-
|
666 |
-
function um_profile_remove_wpseo() {
|
667 |
-
if ( um_is_core_page( 'user' ) && um_get_requested_user() ) {
|
668 |
-
|
669 |
-
/* Yoast SEO 12.4 */
|
670 |
-
if ( isset( $GLOBALS['wpseo_front'] ) && is_object( $GLOBALS['wpseo_front'] ) ) {
|
671 |
-
remove_action( 'wp_head', array( $GLOBALS['wpseo_front'], 'head' ), 1 );
|
672 |
-
} elseif ( class_exists( 'WPSEO_Frontend' ) && is_callable( array( 'WPSEO_Frontend', 'get_instance' ) ) ) {
|
673 |
-
remove_action( 'wp_head', array( WPSEO_Frontend::get_instance(), 'head' ), 1 );
|
674 |
-
}
|
675 |
-
|
676 |
-
/* Yoast SEO 14.1 */
|
677 |
-
remove_all_filters( 'wpseo_head' );
|
678 |
-
|
679 |
-
/* Restore title and canonical if broken */
|
680 |
-
if ( ! has_action( 'wp_head', '_wp_render_title_tag' ) ) {
|
681 |
-
add_action( 'wp_head', '_wp_render_title_tag', 18 );
|
682 |
-
}
|
683 |
-
if ( ! has_action( 'wp_head', 'rel_canonical' ) ) {
|
684 |
-
add_action( 'wp_head', 'rel_canonical', 18 );
|
685 |
-
}
|
686 |
-
}
|
687 |
-
}
|
688 |
-
|
689 |
-
}
|
690 |
-
add_action( 'get_header', 'um_profile_remove_wpseo', 8 );
|
691 |
-
|
692 |
-
|
693 |
-
/**
|
694 |
-
* The profile page SEO tags
|
695 |
-
*
|
696 |
-
* @see https://ogp.me/ - The Open Graph protocol
|
697 |
-
* @see https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary - The Twitter Summary card
|
698 |
-
* @see https://schema.org/Person - The schema.org Person schema
|
699 |
-
*/
|
700 |
-
function um_profile_dynamic_meta_desc() {
|
701 |
-
if ( um_is_core_page( 'user' ) && um_get_requested_user() ) {
|
702 |
-
|
703 |
-
$user_id = um_get_requested_user();
|
704 |
-
|
705 |
-
if ( $user_id !== um_user('ID') ) {
|
706 |
-
um_fetch_user( $user_id );
|
707 |
-
}
|
708 |
-
|
709 |
-
/**
|
710 |
-
* Settings by the priority:
|
711 |
-
* "Search engine visibility" in [wp-admin > Settings > Reading]
|
712 |
-
* "Profile Privacy" in [Account > Privacy]
|
713 |
-
* "Avoid indexing my profile by search engines in [Account > Privacy]
|
714 |
-
* "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > User Roles > Edit Role]
|
715 |
-
* "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > Settings > General > Users]
|
716 |
-
*/
|
717 |
-
if ( UM()->user()->is_profile_noindex( $user_id ) ) {
|
718 |
-
echo '<meta name="robots" content="noindex, nofollow" />';
|
719 |
-
return;
|
720 |
-
}
|
721 |
-
|
722 |
-
$locale = get_user_locale( $user_id );
|
723 |
-
$site_name = get_bloginfo( 'name' );
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
$
|
731 |
-
$
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
$
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
"
|
743 |
-
"
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
<
|
755 |
-
|
756 |
-
<meta
|
757 |
-
|
758 |
-
<meta property="og:
|
759 |
-
<meta property="og:
|
760 |
-
<meta property="og:
|
761 |
-
<meta property="og:
|
762 |
-
<meta property="og:
|
763 |
-
<meta property="og:
|
764 |
-
|
765 |
-
<meta
|
766 |
-
<meta
|
767 |
-
<meta
|
768 |
-
|
769 |
-
<meta name="twitter:
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
<
|
774 |
-
|
775 |
-
|
776 |
-
<?php
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
*
|
815 |
-
*
|
816 |
-
*
|
817 |
-
* @
|
818 |
-
* @
|
819 |
-
*
|
820 |
-
*
|
821 |
-
*
|
822 |
-
*
|
823 |
-
*
|
824 |
-
*
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
);
|
838 |
-
|
839 |
-
$items =
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
if (
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
*
|
888 |
-
*
|
889 |
-
*
|
890 |
-
* @
|
891 |
-
*
|
892 |
-
* @
|
893 |
-
*
|
894 |
-
*
|
895 |
-
*
|
896 |
-
*
|
897 |
-
*
|
898 |
-
*
|
899 |
-
*
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
echo
|
911 |
-
|
912 |
-
}
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
$
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
*
|
996 |
-
*
|
997 |
-
*
|
998 |
-
* @
|
999 |
-
* @
|
1000 |
-
*
|
1001 |
-
*
|
1002 |
-
*
|
1003 |
-
*
|
1004 |
-
*
|
1005 |
-
*
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
*
|
1047 |
-
*
|
1048 |
-
*
|
1049 |
-
* @
|
1050 |
-
*
|
1051 |
-
* @
|
1052 |
-
*
|
1053 |
-
*
|
1054 |
-
*
|
1055 |
-
*
|
1056 |
-
*
|
1057 |
-
*
|
1058 |
-
*
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
$items =
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
*
|
1080 |
-
*
|
1081 |
-
*
|
1082 |
-
* @
|
1083 |
-
*
|
1084 |
-
* @
|
1085 |
-
*
|
1086 |
-
*
|
1087 |
-
*
|
1088 |
-
*
|
1089 |
-
*
|
1090 |
-
*
|
1091 |
-
*
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
*
|
1114 |
-
*
|
1115 |
-
*
|
1116 |
-
* @
|
1117 |
-
* @
|
1118 |
-
*
|
1119 |
-
*
|
1120 |
-
*
|
1121 |
-
*
|
1122 |
-
*
|
1123 |
-
*
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
*
|
1144 |
-
*
|
1145 |
-
*
|
1146 |
-
* @
|
1147 |
-
* @
|
1148 |
-
*
|
1149 |
-
*
|
1150 |
-
*
|
1151 |
-
*
|
1152 |
-
*
|
1153 |
-
*
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
*
|
1171 |
-
*
|
1172 |
-
*
|
1173 |
-
* @
|
1174 |
-
* @
|
1175 |
-
*
|
1176 |
-
*
|
1177 |
-
*
|
1178 |
-
*
|
1179 |
-
*
|
1180 |
-
*
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
*
|
1185 |
-
*
|
1186 |
-
*
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
*
|
1191 |
-
*
|
1192 |
-
* @
|
1193 |
-
*
|
1194 |
-
*
|
1195 |
-
*
|
1196 |
-
*
|
1197 |
-
*
|
1198 |
-
*
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
<?php
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
<?php
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
*
|
1258 |
-
*
|
1259 |
-
* @
|
1260 |
-
*
|
1261 |
-
* @
|
1262 |
-
* @
|
1263 |
-
*
|
1264 |
-
*
|
1265 |
-
*
|
1266 |
-
*
|
1267 |
-
*
|
1268 |
-
*
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
*
|
1287 |
-
*
|
1288 |
-
* @
|
1289 |
-
*
|
1290 |
-
* @
|
1291 |
-
* @
|
1292 |
-
*
|
1293 |
-
*
|
1294 |
-
*
|
1295 |
-
*
|
1296 |
-
*
|
1297 |
-
*
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
if ( !
|
1342 |
-
|
1343 |
-
}
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
*
|
1396 |
-
*
|
1397 |
-
* @
|
1398 |
-
*
|
1399 |
-
* @
|
1400 |
-
*
|
1401 |
-
*
|
1402 |
-
*
|
1403 |
-
*
|
1404 |
-
*
|
1405 |
-
*
|
1406 |
-
*
|
1407 |
-
*
|
1408 |
-
*
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
$items
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
*
|
1434 |
-
*
|
1435 |
-
*
|
1436 |
-
* @
|
1437 |
-
*
|
1438 |
-
* @
|
1439 |
-
*
|
1440 |
-
*
|
1441 |
-
*
|
1442 |
-
*
|
1443 |
-
*
|
1444 |
-
*
|
1445 |
-
*
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
echo UM()->fields()->
|
1478 |
-
|
1479 |
-
}
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
*
|
1510 |
-
*
|
1511 |
-
*
|
1512 |
-
* @
|
1513 |
-
* @
|
1514 |
-
*
|
1515 |
-
*
|
1516 |
-
*
|
1517 |
-
*
|
1518 |
-
*
|
1519 |
-
*
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
</div>
|
1567 |
-
|
1568 |
-
<?php } ?>
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
UM()->profile()->active_subnav = null;
|
1607 |
-
}
|
1608 |
-
|
1609 |
-
$has_subnav = false;
|
1610 |
-
if ( count( $tabs ) == 1 ) {
|
1611 |
-
foreach ( $tabs as $tab ) {
|
1612 |
-
if ( isset( $tab['subnav'] ) ) {
|
1613 |
-
$has_subnav = true;
|
1614 |
-
}
|
1615 |
-
}
|
1616 |
-
}
|
1617 |
-
|
1618 |
-
// need enough tabs to continue
|
1619 |
-
if ( count( $tabs ) <= 1 && ! $has_subnav && count( $all_tabs ) === count( $tabs ) ) {
|
1620 |
-
return;
|
1621 |
-
}
|
1622 |
-
|
1623 |
-
if ( count( $tabs ) > 1 || count( $all_tabs ) > count( $tabs ) ) {
|
1624 |
-
// Move default tab priority
|
1625 |
-
$default_tab = UM()->options()->get( 'profile_menu_default_tab' );
|
1626 |
-
$dtab = ( isset( $tabs[ $default_tab ] ) ) ? $tabs[ $default_tab ] : 'main';
|
1627 |
-
if ( isset( $tabs[ $default_tab ] ) ) {
|
1628 |
-
unset( $tabs[ $default_tab ] );
|
1629 |
-
$dtabs[ $default_tab ] = $dtab;
|
1630 |
-
$tabs = $dtabs + $tabs;
|
1631 |
-
}
|
1632 |
-
|
1633 |
-
if ( ! empty( $tabs ) ) { ?>
|
1634 |
-
|
1635 |
-
<div class="um-profile-nav">
|
1636 |
-
|
1637 |
-
<?php foreach ( $tabs as $id => $tab ) {
|
1638 |
-
|
1639 |
-
$nav_link = UM()->permalinks()->get_current_url( get_option( 'permalink_structure' ) );
|
1640 |
-
$nav_link = remove_query_arg( 'um_action', $nav_link );
|
1641 |
-
$nav_link = remove_query_arg( 'subnav', $nav_link );
|
1642 |
-
$nav_link = add_query_arg( 'profiletab', $id, $nav_link );
|
1643 |
-
|
1644 |
-
/**
|
1645 |
-
* UM hook
|
1646 |
-
*
|
1647 |
-
* @type filter
|
1648 |
-
* @title um_profile_menu_link_{$id}
|
1649 |
-
* @description Change profile menu link by tab $id
|
1650 |
-
* @input_vars
|
1651 |
-
* [{"var":"$nav_link","type":"string","desc":"Profile Tab Link"}]
|
1652 |
-
* @change_log
|
1653 |
-
* ["Since: 2.0"]
|
1654 |
-
* @usage
|
1655 |
-
* <?php add_filter( 'um_profile_menu_link_{$id}', 'function_name', 10, 1 ); ?>
|
1656 |
-
* @example
|
1657 |
-
* <?php
|
1658 |
-
* add_filter( 'um_profile_menu_link_{$id}', 'my_profile_menu_link', 10, 1 );
|
1659 |
-
* function my_profile_menu_link( $nav_link ) {
|
1660 |
-
* // your code here
|
1661 |
-
* return $nav_link;
|
1662 |
-
* }
|
1663 |
-
* ?>
|
1664 |
-
*/
|
1665 |
-
$nav_link = apply_filters( "um_profile_menu_link_{$id}", $nav_link );
|
1666 |
-
|
1667 |
-
$profile_nav_class = '';
|
1668 |
-
if ( ! UM()->options()->get( 'profile_menu_icons' ) ) {
|
1669 |
-
$profile_nav_class .= ' without-icon';
|
1670 |
-
}
|
1671 |
-
|
1672 |
-
if ( $id == $active_tab ) {
|
1673 |
-
$profile_nav_class .= ' active';
|
1674 |
-
} ?>
|
1675 |
-
|
1676 |
-
<div class="um-profile-nav-item um-profile-nav-<?php echo esc_attr( $id . ' ' . $profile_nav_class ); ?>">
|
1677 |
-
<?php if ( UM()->options()->get( 'profile_menu_icons' ) ) { ?>
|
1678 |
-
<a href="<?php echo esc_url( $nav_link ); ?>" class="uimob800-show uimob500-show uimob340-show um-tip-n"
|
1679 |
-
title="<?php echo esc_attr( $tab['name'] ); ?>" original-title="<?php echo esc_attr( $tab['name'] ); ?>">
|
1680 |
-
|
1681 |
-
<i class="<?php echo esc_attr( $tab['icon'] ); ?>"></i>
|
1682 |
-
|
1683 |
-
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0 ) { ?>
|
1684 |
-
<span class="um-tab-notifier uimob800-show uimob500-show uimob340-show"><?php echo $tab['notifier']; ?></span>
|
1685 |
-
<?php } ?>
|
1686 |
-
|
1687 |
-
<span class="uimob800-hide uimob500-hide uimob340-hide title"><?php echo esc_html( $tab['name'] ); ?></span>
|
1688 |
-
</a>
|
1689 |
-
<a href="<?php echo esc_url( $nav_link ); ?>" class="uimob800-hide uimob500-hide uimob340-hide"
|
1690 |
-
title="<?php echo esc_attr( $tab['name'] ); ?>">
|
1691 |
-
|
1692 |
-
<i class="<?php echo esc_attr( $tab['icon'] ); ?>"></i>
|
1693 |
-
|
1694 |
-
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0 ) { ?>
|
1695 |
-
<span class="um-tab-notifier"><?php echo $tab['notifier']; ?></span>
|
1696 |
-
<?php } ?>
|
1697 |
-
|
1698 |
-
<span class="title"><?php echo esc_html( $tab['name'] ); ?></span>
|
1699 |
-
</a>
|
1700 |
-
<?php } else { ?>
|
1701 |
-
<a href="<?php echo esc_url( $nav_link ); ?>" class="uimob800-show uimob500-show uimob340-show um-tip-n"
|
1702 |
-
title="<?php echo esc_attr( $tab['name'] ); ?>" original-title="<?php echo esc_attr( $tab['name'] ); ?>">
|
1703 |
-
|
1704 |
-
<i class="<?php echo esc_attr( $tab['icon'] ); ?>"></i>
|
1705 |
-
|
1706 |
-
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0 ) { ?>
|
1707 |
-
<span class="um-tab-notifier uimob800-show uimob500-show uimob340-show"><?php echo $tab['notifier']; ?></span>
|
1708 |
-
<?php } ?>
|
1709 |
-
</a>
|
1710 |
-
<a href="<?php echo esc_url( $nav_link ); ?>" class="uimob800-hide uimob500-hide uimob340-hide"
|
1711 |
-
title="<?php echo esc_attr( $tab['name'] ); ?>">
|
1712 |
-
|
1713 |
-
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0 ) { ?>
|
1714 |
-
<span class="um-tab-notifier"><?php echo $tab['notifier']; ?></span>
|
1715 |
-
<?php } ?>
|
1716 |
-
|
1717 |
-
<span class="title"><?php echo esc_html( $tab['name'] ); ?></span>
|
1718 |
-
</a>
|
1719 |
-
<?php } ?>
|
1720 |
-
</div>
|
1721 |
-
|
1722 |
-
<?php } ?>
|
1723 |
-
|
1724 |
-
<div class="um-clear"></div>
|
1725 |
-
|
1726 |
-
</div>
|
1727 |
-
|
1728 |
-
<?php }
|
1729 |
-
}
|
1730 |
-
|
1731 |
-
foreach ( $tabs as $id => $tab ) {
|
1732 |
-
|
1733 |
-
if ( isset( $tab['subnav'] ) && $active_tab == $id ) {
|
1734 |
-
|
1735 |
-
$active_subnav = ( UM()->profile()->active_subnav() ) ? UM()->profile()->active_subnav() : $tab['subnav_default']; ?>
|
1736 |
-
|
1737 |
-
<div class="um-profile-subnav">
|
1738 |
-
<?php foreach ( $tab['subnav'] as $id_s => $subtab ) {
|
1739 |
-
|
1740 |
-
$subnav_link = add_query_arg( 'subnav', $id_s );
|
1741 |
-
$subnav_link = apply_filters( 'um_user_profile_subnav_link', $subnav_link, $id_s, $subtab ); ?>
|
1742 |
-
|
1743 |
-
<a href="<?php echo esc_url( $subnav_link ); ?>" class="<?php echo $active_subnav == $id_s ? 'active' : ''; ?>">
|
1744 |
-
<?php echo $subtab; ?>
|
1745 |
-
</a>
|
1746 |
-
|
1747 |
-
<?php } ?>
|
1748 |
-
</div>
|
1749 |
-
<?php }
|
1750 |
-
|
1751 |
-
}
|
1752 |
-
|
1753 |
-
}
|
1754 |
-
add_action( 'um_profile_menu', 'um_profile_menu', 9 );
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Um_profile_content_{main_tab}
|
6 |
+
*
|
7 |
+
* @param $args
|
8 |
+
*/
|
9 |
+
function um_profile_content_main( $args ) {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @var $mode
|
13 |
+
*/
|
14 |
+
extract( $args );
|
15 |
+
|
16 |
+
if ( ! UM()->options()->get( 'profile_tab_main' ) && ! isset( $_REQUEST['um_action'] ) ) {
|
17 |
+
return;
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* UM hook
|
22 |
+
*
|
23 |
+
* @type filter
|
24 |
+
* @title um_profile_can_view_main
|
25 |
+
* @description Check user can view profile
|
26 |
+
* @input_vars
|
27 |
+
* [{"var":"$view","type":"bool","desc":"Can view?"},
|
28 |
+
* {"var":"$user_id","type":"int","desc":"User profile ID"}]
|
29 |
+
* @change_log
|
30 |
+
* ["Since: 2.0"]
|
31 |
+
* @usage
|
32 |
+
* <?php add_filter( 'um_profile_can_view_main', 'function_name', 10, 2 ); ?>
|
33 |
+
* @example
|
34 |
+
* <?php
|
35 |
+
* add_filter( 'um_profile_can_view_main', 'my_profile_can_view_main', 10, 2 );
|
36 |
+
* function my_profile_can_view_main( $view, $user_id ) {
|
37 |
+
* // your code here
|
38 |
+
* return $view;
|
39 |
+
* }
|
40 |
+
* ?>
|
41 |
+
*/
|
42 |
+
$can_view = apply_filters( 'um_profile_can_view_main', -1, um_profile_id() );
|
43 |
+
|
44 |
+
if ( $can_view == -1 ) {
|
45 |
+
/**
|
46 |
+
* UM hook
|
47 |
+
*
|
48 |
+
* @type action
|
49 |
+
* @title um_before_form
|
50 |
+
* @description Some actions before profile form
|
51 |
+
* @input_vars
|
52 |
+
* [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
|
53 |
+
* @change_log
|
54 |
+
* ["Since: 2.0"]
|
55 |
+
* @usage add_action( 'um_before_form', 'function_name', 10, 1 );
|
56 |
+
* @example
|
57 |
+
* <?php
|
58 |
+
* add_action( 'um_before_form', 'my_before_form', 10, 1 );
|
59 |
+
* function my_before_form( $args ) {
|
60 |
+
* // your code here
|
61 |
+
* }
|
62 |
+
* ?>
|
63 |
+
*/
|
64 |
+
do_action( 'um_before_form', $args );
|
65 |
+
|
66 |
+
/**
|
67 |
+
* UM hook
|
68 |
+
*
|
69 |
+
* @type action
|
70 |
+
* @title um_before_{$mode}_fields
|
71 |
+
* @description Some actions before profile form fields
|
72 |
+
* @input_vars
|
73 |
+
* [{"var":"$args","type":"array","desc":"{Profile} form shortcode arguments"}]
|
74 |
+
* @change_log
|
75 |
+
* ["Since: 2.0"]
|
76 |
+
* @usage add_action( 'um_before_{$mode}_fields', 'function_name', 10, 1 );
|
77 |
+
* @example
|
78 |
+
* <?php
|
79 |
+
* add_action( 'um_before_{$mode}_fields', 'my_before_fields', 10, 1 );
|
80 |
+
* function my_before_form( $args ) {
|
81 |
+
* // your code here
|
82 |
+
* }
|
83 |
+
* ?>
|
84 |
+
*/
|
85 |
+
do_action( "um_before_{$mode}_fields", $args );
|
86 |
+
|
87 |
+
/**
|
88 |
+
* UM hook
|
89 |
+
*
|
90 |
+
* @type action
|
91 |
+
* @title um_main_{$mode}_fields
|
92 |
+
* @description Some actions before login form fields
|
93 |
+
* @input_vars
|
94 |
+
* [{"var":"$args","type":"array","desc":"Login form shortcode arguments"}]
|
95 |
+
* @change_log
|
96 |
+
* ["Since: 2.0"]
|
97 |
+
* @usage add_action( 'um_before_{$mode}_fields', 'function_name', 10, 1 );
|
98 |
+
* @example
|
99 |
+
* <?php
|
100 |
+
* add_action( 'um_before_{$mode}_fields', 'my_before_fields', 10, 1 );
|
101 |
+
* function my_before_form( $args ) {
|
102 |
+
* // your code here
|
103 |
+
* }
|
104 |
+
* ?>
|
105 |
+
*/
|
106 |
+
do_action( "um_main_{$mode}_fields", $args );
|
107 |
+
|
108 |
+
/**
|
109 |
+
* UM hook
|
110 |
+
*
|
111 |
+
* @type action
|
112 |
+
* @title um_after_form_fields
|
113 |
+
* @description Some actions after login form fields
|
114 |
+
* @input_vars
|
115 |
+
* [{"var":"$args","type":"array","desc":"Login form shortcode arguments"}]
|
116 |
+
* @change_log
|
117 |
+
* ["Since: 2.0"]
|
118 |
+
* @usage add_action( 'um_after_form_fields', 'function_name', 10, 1 );
|
119 |
+
* @example
|
120 |
+
* <?php
|
121 |
+
* add_action( 'um_after_form_fields', 'my_after_form_fields', 10, 1 );
|
122 |
+
* function my_after_form_fields( $args ) {
|
123 |
+
* // your code here
|
124 |
+
* }
|
125 |
+
* ?>
|
126 |
+
*/
|
127 |
+
do_action( 'um_after_form_fields', $args );
|
128 |
+
|
129 |
+
/**
|
130 |
+
* UM hook
|
131 |
+
*
|
132 |
+
* @type action
|
133 |
+
* @title um_after_{$mode}_fields
|
134 |
+
* @description Some actions after profile form fields
|
135 |
+
* @input_vars
|
136 |
+
* [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
|
137 |
+
* @change_log
|
138 |
+
* ["Since: 2.0"]
|
139 |
+
* @usage add_action( 'um_after_{$mode}_fields', 'function_name', 10, 1 );
|
140 |
+
* @example
|
141 |
+
* <?php
|
142 |
+
* add_action( 'um_after_{$mode}_fields', 'my_after_form_fields', 10, 1 );
|
143 |
+
* function my_after_form_fields( $args ) {
|
144 |
+
* // your code here
|
145 |
+
* }
|
146 |
+
* ?>
|
147 |
+
*/
|
148 |
+
do_action( "um_after_{$mode}_fields", $args );
|
149 |
+
|
150 |
+
/**
|
151 |
+
* UM hook
|
152 |
+
*
|
153 |
+
* @type action
|
154 |
+
* @title um_after_form
|
155 |
+
* @description Some actions after profile form fields
|
156 |
+
* @input_vars
|
157 |
+
* [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
|
158 |
+
* @change_log
|
159 |
+
* ["Since: 2.0"]
|
160 |
+
* @usage add_action( 'um_after_form', 'function_name', 10, 1 );
|
161 |
+
* @example
|
162 |
+
* <?php
|
163 |
+
* add_action( 'um_after_form', 'my_after_form', 10, 1 );
|
164 |
+
* function my_after_form( $args ) {
|
165 |
+
* // your code here
|
166 |
+
* }
|
167 |
+
* ?>
|
168 |
+
*/
|
169 |
+
do_action( 'um_after_form', $args );
|
170 |
+
|
171 |
+
} else {
|
172 |
+
?>
|
173 |
+
<div class="um-profile-note">
|
174 |
+
<span>
|
175 |
+
<i class="um-faicon-lock"></i>
|
176 |
+
<?php echo $can_view; ?>
|
177 |
+
</span>
|
178 |
+
</div>
|
179 |
+
<?php
|
180 |
+
}
|
181 |
+
}
|
182 |
+
add_action( 'um_profile_content_main', 'um_profile_content_main' );
|
183 |
+
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Update user's profile
|
187 |
+
*
|
188 |
+
* @param array $args
|
189 |
+
*/
|
190 |
+
function um_user_edit_profile( $args ) {
|
191 |
+
$to_update = null;
|
192 |
+
$files = array();
|
193 |
+
|
194 |
+
$user_id = null;
|
195 |
+
if ( isset( $args['user_id'] ) ) {
|
196 |
+
$user_id = $args['user_id'];
|
197 |
+
} elseif ( isset( $args['_user_id'] ) ) {
|
198 |
+
$user_id = $args['_user_id'];
|
199 |
+
}
|
200 |
+
|
201 |
+
if ( UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
202 |
+
UM()->user()->set( $user_id );
|
203 |
+
} else {
|
204 |
+
wp_die( __( 'You are not allowed to edit this user.', 'ultimate-member' ) );
|
205 |
+
}
|
206 |
+
|
207 |
+
$userinfo = UM()->user()->profile;
|
208 |
+
|
209 |
+
/**
|
210 |
+
* UM hook
|
211 |
+
*
|
212 |
+
* @type action
|
213 |
+
* @title um_user_before_updating_profile
|
214 |
+
* @description Some actions before profile submit
|
215 |
+
* @input_vars
|
216 |
+
* [{"var":"$userinfo","type":"array","desc":"User Data"}]
|
217 |
+
* @change_log
|
218 |
+
* ["Since: 2.0"]
|
219 |
+
* @usage add_action( 'um_user_before_updating_profile', 'function_name', 10, 1 );
|
220 |
+
* @example
|
221 |
+
* <?php
|
222 |
+
* add_action( 'um_user_before_updating_profile', 'my_user_before_updating_profile', 10, 1 );
|
223 |
+
* function my_user_before_updating_profile( $userinfo ) {
|
224 |
+
* // your code here
|
225 |
+
* }
|
226 |
+
* ?>
|
227 |
+
*/
|
228 |
+
do_action( 'um_user_before_updating_profile', $userinfo );
|
229 |
+
|
230 |
+
if ( ! empty( $args['custom_fields'] ) ) {
|
231 |
+
$fields = apply_filters( 'um_user_edit_profile_fields', unserialize( $args['custom_fields'] ), $args );
|
232 |
+
}
|
233 |
+
|
234 |
+
// loop through fields
|
235 |
+
if ( ! empty( $fields ) ) {
|
236 |
+
|
237 |
+
foreach ( $fields as $key => $array ) {
|
238 |
+
|
239 |
+
if ( ! isset( $array['type'] ) ) {
|
240 |
+
continue;
|
241 |
+
}
|
242 |
+
|
243 |
+
if ( isset( $array['edit_forbidden'] ) ) {
|
244 |
+
continue;
|
245 |
+
}
|
246 |
+
|
247 |
+
// required option? 'required_opt' - it's field attribute predefined in the field data in code
|
248 |
+
if ( isset( $array['required_opt'] ) ) {
|
249 |
+
$opt = $array['required_opt'];
|
250 |
+
if ( UM()->options()->get( $opt[0] ) != $opt[1] ) {
|
251 |
+
continue;
|
252 |
+
}
|
253 |
+
}
|
254 |
+
|
255 |
+
// fields that need to be disabled in edit mode (profile) (email, username, etc.)
|
256 |
+
$arr_restricted_fields = UM()->fields()->get_restricted_fields_for_edit( $user_id );
|
257 |
+
if ( in_array( $key, $arr_restricted_fields ) ) {
|
258 |
+
continue;
|
259 |
+
}
|
260 |
+
|
261 |
+
if ( ! um_can_edit_field( $array ) || ! um_can_view_field( $array ) ) {
|
262 |
+
continue;
|
263 |
+
}
|
264 |
+
|
265 |
+
// skip saving role here
|
266 |
+
if ( in_array( $key, [ 'role', 'role_select', 'role_radio' ] ) ) {
|
267 |
+
continue;
|
268 |
+
}
|
269 |
+
|
270 |
+
//the same code in class-validation.php validate_fields_values for registration form
|
271 |
+
//rating field validation
|
272 |
+
if ( $array['type'] == 'rating' && isset( $args['submitted'][ $key ] ) ) {
|
273 |
+
if ( ! is_numeric( $args['submitted'][ $key ] ) ) {
|
274 |
+
continue;
|
275 |
+
} else {
|
276 |
+
if ( $array['number'] == 5 ) {
|
277 |
+
if ( ! in_array( $args['submitted'][ $key ], range( 1, 5 ) ) ) {
|
278 |
+
continue;
|
279 |
+
}
|
280 |
+
} elseif ( $array['number'] == 10 ) {
|
281 |
+
if ( ! in_array( $args['submitted'][ $key ], range( 1, 10 ) ) ) {
|
282 |
+
continue;
|
283 |
+
}
|
284 |
+
}
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Returns dropdown/multi-select options keys from a callback function
|
291 |
+
* @since 2019-05-30
|
292 |
+
*/
|
293 |
+
$has_custom_source = apply_filters( "um_has_dropdown_options_source__{$key}", false );
|
294 |
+
if ( isset( $array['options'] ) && in_array( $array['type'], array( 'select', 'multiselect' ) ) ) {
|
295 |
+
|
296 |
+
$options = array();
|
297 |
+
if ( ! empty( $array['custom_dropdown_options_source'] ) && function_exists( $array['custom_dropdown_options_source'] ) && ! $has_custom_source ) {
|
298 |
+
$callback_result = call_user_func( $array['custom_dropdown_options_source'], $array['options'] );
|
299 |
+
if ( is_array( $callback_result ) ) {
|
300 |
+
$options = array_keys( $callback_result );
|
301 |
+
}
|
302 |
+
}
|
303 |
+
|
304 |
+
$array['options'] = apply_filters( "um_custom_dropdown_options__{$key}", $options );
|
305 |
+
|
306 |
+
}
|
307 |
+
|
308 |
+
|
309 |
+
//validation of correct values from options in wp-admin
|
310 |
+
$stripslashes = '';
|
311 |
+
if ( isset( $args['submitted'][ $key ] ) && is_string( $args['submitted'][ $key ] ) ) {
|
312 |
+
$stripslashes = stripslashes( $args['submitted'][ $key ] );
|
313 |
+
}
|
314 |
+
|
315 |
+
if ( in_array( $array['type'], array( 'select' ) ) ) {
|
316 |
+
if ( ! empty( $array['options'] ) && ! empty( $stripslashes ) && ! in_array( $stripslashes, array_map( 'trim', $array['options'] ) ) && ! $has_custom_source ) {
|
317 |
+
continue;
|
318 |
+
}
|
319 |
+
|
320 |
+
//update empty user meta
|
321 |
+
if ( ! isset( $args['submitted'][ $key ] ) || $args['submitted'][ $key ] == '' ) {
|
322 |
+
update_user_meta( $user_id, $key, '' );
|
323 |
+
}
|
324 |
+
}
|
325 |
+
|
326 |
+
//validation of correct values from options in wp-admin
|
327 |
+
//the user cannot set invalid value in the hidden input at the page
|
328 |
+
if ( in_array( $array['type'], array( 'multiselect', 'checkbox', 'radio' ) ) ) {
|
329 |
+
if ( ! empty( $args['submitted'][ $key ] ) && ! empty( $array['options'] ) ) {
|
330 |
+
$args['submitted'][ $key ] = array_map( 'stripslashes', array_map( 'trim', $args['submitted'][ $key ] ) );
|
331 |
+
$args['submitted'][ $key ] = array_intersect( $args['submitted'][ $key ], array_map( 'trim', $array['options'] ) );
|
332 |
+
}
|
333 |
+
|
334 |
+
// update empty user meta
|
335 |
+
if ( ! isset( $args['submitted'][ $key ] ) || $args['submitted'][ $key ] == '' ) {
|
336 |
+
update_user_meta( $user_id, $key, array() );
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
if ( isset( $args['submitted'][ $key ] ) ) {
|
341 |
+
|
342 |
+
if ( isset( $array['type'] ) && in_array( $array['type'], array( 'image', 'file' ) ) ) {
|
343 |
+
|
344 |
+
if ( um_is_temp_file( $args['submitted'][ $key ] ) || $args['submitted'][ $key ] == 'empty_file' ) {
|
345 |
+
$files[ $key ] = $args['submitted'][ $key ];
|
346 |
+
} elseif( um_is_file_owner( UM()->uploader()->get_upload_base_url() . $user_id . '/' . $args['submitted'][ $key ], $user_id ) ) {
|
347 |
+
|
348 |
+
} else {
|
349 |
+
$files[ $key ] = 'empty_file';
|
350 |
+
}
|
351 |
+
|
352 |
+
} else {
|
353 |
+
if ( $array['type'] == 'password' ) {
|
354 |
+
$to_update[ $key ] = wp_hash_password( $args['submitted'][ $key ] );
|
355 |
+
$args['submitted'][ $key ] = sprintf( __( 'Your choosed %s', 'ultimate-member' ), $array['title'] );
|
356 |
+
} else {
|
357 |
+
if ( isset( $userinfo[ $key ] ) && $args['submitted'][ $key ] != $userinfo[ $key ] ) {
|
358 |
+
$to_update[ $key ] = $args['submitted'][ $key ];
|
359 |
+
} elseif ( $args['submitted'][ $key ] != '' ) {
|
360 |
+
$to_update[ $key ] = $args['submitted'][ $key ];
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
}
|
365 |
+
|
366 |
+
// use this filter after all validations has been completed and we can extends data based on key
|
367 |
+
$to_update = apply_filters( 'um_change_usermeta_for_update', $to_update, $args, $fields, $key );
|
368 |
+
|
369 |
+
}
|
370 |
+
}
|
371 |
+
}
|
372 |
+
|
373 |
+
$description_key = UM()->profile()->get_show_bio_key( $args );
|
374 |
+
if ( isset( $args['submitted'][ $description_key ] ) ) {
|
375 |
+
$to_update[ $description_key ] = $args['submitted'][ $description_key ];
|
376 |
+
}
|
377 |
+
|
378 |
+
|
379 |
+
// Secure selected role
|
380 |
+
if ( is_admin() ) {
|
381 |
+
|
382 |
+
if ( ! empty( $args['submitted']['role'] ) && current_user_can( 'promote_users' ) ) {
|
383 |
+
global $wp_roles;
|
384 |
+
$role_keys = array_map( function( $item ) {
|
385 |
+
return 'um_' . $item;
|
386 |
+
}, get_option( 'um_roles', array() ) );
|
387 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
388 |
+
|
389 |
+
if ( ! in_array( $args['submitted']['role'], $exclude_roles ) ) {
|
390 |
+
$to_update['role'] = $args['submitted']['role'];
|
391 |
+
}
|
392 |
+
|
393 |
+
$args['roles_before_upgrade'] = UM()->roles()->get_all_user_roles( $user_id );
|
394 |
+
}
|
395 |
+
|
396 |
+
} else {
|
397 |
+
|
398 |
+
if ( ( isset( $fields['role'] ) && $fields['role']['editable'] != 0 && um_can_view_field( $fields['role'] ) ) ||
|
399 |
+
( isset( $fields['role_select'] ) && $fields['role_select']['editable'] != 0 && um_can_view_field( $fields['role_select'] ) ) ||
|
400 |
+
( isset( $fields['role_radio'] ) ) && $fields['role_radio']['editable'] != 0 && um_can_view_field( $fields['role_radio'] ) ) {
|
401 |
+
|
402 |
+
if ( ! empty( $args['submitted']['role'] ) ) {
|
403 |
+
global $wp_roles;
|
404 |
+
$role_keys = array_map( function( $item ) {
|
405 |
+
return 'um_' . $item;
|
406 |
+
}, get_option( 'um_roles', array() ) );
|
407 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
408 |
+
|
409 |
+
if ( ! in_array( $args['submitted']['role'], $exclude_roles ) ) {
|
410 |
+
$to_update['role'] = $args['submitted']['role'];
|
411 |
+
}
|
412 |
+
|
413 |
+
$args['roles_before_upgrade'] = UM()->roles()->get_all_user_roles( $user_id );
|
414 |
+
}
|
415 |
+
}
|
416 |
+
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* UM hook
|
421 |
+
*
|
422 |
+
* @type action
|
423 |
+
* @title um_user_pre_updating_profile
|
424 |
+
* @description Some actions before profile submit
|
425 |
+
* @input_vars
|
426 |
+
* [{"var":"$userinfo","type":"array","desc":"Submitted User Data"},
|
427 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
428 |
+
* @change_log
|
429 |
+
* ["Since: 2.0"]
|
430 |
+
* @usage add_action( 'um_user_pre_updating_profile', 'function_name', 10, 2 );
|
431 |
+
* @example
|
432 |
+
* <?php
|
433 |
+
* add_action( 'um_user_pre_updating_profile', 'my_user_pre_updating_profile', 10, 2 );
|
434 |
+
* function my_user_pre_updating_profile( $userinfo, $user_id ) {
|
435 |
+
* // your code here
|
436 |
+
* }
|
437 |
+
* ?>
|
438 |
+
*/
|
439 |
+
do_action( 'um_user_pre_updating_profile', $to_update, $user_id );
|
440 |
+
|
441 |
+
/**
|
442 |
+
* UM hook
|
443 |
+
*
|
444 |
+
* @type filter
|
445 |
+
* @title um_user_pre_updating_profile_array
|
446 |
+
* @description Change submitted data before update profile
|
447 |
+
* @input_vars
|
448 |
+
* [{"var":"$to_update","type":"array","desc":"Profile data upgrade"},
|
449 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
450 |
+
* @change_log
|
451 |
+
* ["Since: 2.0"]
|
452 |
+
* @usage
|
453 |
+
* <?php add_filter( 'um_user_pre_updating_profile_array', 'function_name', 10, 2 ); ?>
|
454 |
+
* @example
|
455 |
+
* <?php
|
456 |
+
* add_filter( 'um_user_pre_updating_profile_array', 'my_user_pre_updating_profile', 10, 2 );
|
457 |
+
* function my_user_pre_updating_profile( $to_update, $user_id ) {
|
458 |
+
* // your code here
|
459 |
+
* return $to_update;
|
460 |
+
* }
|
461 |
+
* ?>
|
462 |
+
*/
|
463 |
+
$to_update = apply_filters( 'um_user_pre_updating_profile_array', $to_update, $user_id );
|
464 |
+
|
465 |
+
if ( is_array( $to_update ) ) {
|
466 |
+
|
467 |
+
if ( isset( $to_update['first_name'] ) || isset( $to_update['last_name'] ) || isset( $to_update['nickname'] ) ) {
|
468 |
+
$user = get_userdata( $user_id );
|
469 |
+
if ( ! empty( $user ) && ! is_wp_error( $user ) ) {
|
470 |
+
UM()->user()->previous_data['display_name'] = $user->display_name;
|
471 |
+
|
472 |
+
if ( isset( $to_update['first_name'] ) ) {
|
473 |
+
UM()->user()->previous_data['first_name'] = $user->first_name;
|
474 |
+
}
|
475 |
+
|
476 |
+
if ( isset( $to_update['last_name'] ) ) {
|
477 |
+
UM()->user()->previous_data['last_name'] = $user->last_name;
|
478 |
+
}
|
479 |
+
|
480 |
+
if ( isset( $to_update['nickname'] ) ) {
|
481 |
+
UM()->user()->previous_data['nickname'] = $user->nickname;
|
482 |
+
}
|
483 |
+
}
|
484 |
+
}
|
485 |
+
|
486 |
+
UM()->user()->update_profile( $to_update );
|
487 |
+
/**
|
488 |
+
* UM hook
|
489 |
+
*
|
490 |
+
* @type action
|
491 |
+
* @title um_after_user_updated
|
492 |
+
* @description Some actions after user profile updated
|
493 |
+
* @input_vars
|
494 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
495 |
+
* {"var":"$args","type":"array","desc":"Form Data"},
|
496 |
+
* {"var":"$userinfo","type":"array","desc":"Submitted User Data"}]
|
497 |
+
* @change_log
|
498 |
+
* ["Since: 2.0"]
|
499 |
+
* @usage add_action( 'um_after_user_updated', 'function_name', 10, 33 );
|
500 |
+
* @example
|
501 |
+
* <?php
|
502 |
+
* add_action( 'um_after_user_updated', 'my_after_user_updated', 10, 3 );
|
503 |
+
* function my_after_user_updated( $user_id, $args, $userinfo ) {
|
504 |
+
* // your code here
|
505 |
+
* }
|
506 |
+
* ?>
|
507 |
+
*/
|
508 |
+
do_action( 'um_after_user_updated', $user_id, $args, $to_update );
|
509 |
+
}
|
510 |
+
|
511 |
+
/**
|
512 |
+
* UM hook
|
513 |
+
*
|
514 |
+
* @type filter
|
515 |
+
* @title um_user_pre_updating_files_array
|
516 |
+
* @description Change submitted files before update profile
|
517 |
+
* @input_vars
|
518 |
+
* [{"var":"$files","type":"array","desc":"Profile data files"},
|
519 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
520 |
+
* @change_log
|
521 |
+
* ["Since: 2.0"]
|
522 |
+
* @usage
|
523 |
+
* <?php add_filter( 'um_user_pre_updating_files_array', 'function_name', 10, 2 ); ?>
|
524 |
+
* @example
|
525 |
+
* <?php
|
526 |
+
* add_filter( 'um_user_pre_updating_files_array', 'my_user_pre_updating_files', 10, 2 );
|
527 |
+
* function my_user_pre_updating_files( $files, $user_id ) {
|
528 |
+
* // your code here
|
529 |
+
* return $files;
|
530 |
+
* }
|
531 |
+
* ?>
|
532 |
+
*/
|
533 |
+
$files = apply_filters( 'um_user_pre_updating_files_array', $files, $user_id );
|
534 |
+
|
535 |
+
if ( ! empty( $files ) && is_array( $files ) ) {
|
536 |
+
UM()->uploader()->replace_upload_dir = true;
|
537 |
+
UM()->uploader()->move_temporary_files( $user_id, $files );
|
538 |
+
UM()->uploader()->replace_upload_dir = false;
|
539 |
+
}
|
540 |
+
|
541 |
+
/**
|
542 |
+
* UM hook
|
543 |
+
*
|
544 |
+
* @type action
|
545 |
+
* @title um_user_after_updating_profile
|
546 |
+
* @description After upgrade user's profile
|
547 |
+
* @input_vars
|
548 |
+
* [{"var":"$submitted","type":"array","desc":"Form data"},
|
549 |
+
* {"var":"$user_id","type":"int","desc":"User Id"}]
|
550 |
+
* @change_log
|
551 |
+
* ["Since: 2.0"]
|
552 |
+
* @usage add_action( 'um_user_after_updating_profile', 'function_name', 10, 1 );
|
553 |
+
* @example
|
554 |
+
* <?php
|
555 |
+
* add_action( 'um_user_after_updating_profile', 'my_user_after_updating_profile'', 10, 2 );
|
556 |
+
* function my_user_after_updating_profile( $submitted, $user_id ) {
|
557 |
+
* // your code here
|
558 |
+
* }
|
559 |
+
* ?>
|
560 |
+
*/
|
561 |
+
do_action( 'um_user_after_updating_profile', $to_update, $user_id, $args );
|
562 |
+
|
563 |
+
/**
|
564 |
+
* UM hook
|
565 |
+
*
|
566 |
+
* @type action
|
567 |
+
* @title um_update_profile_full_name
|
568 |
+
* @description On update user profile change full name
|
569 |
+
* @input_vars
|
570 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
571 |
+
* {"var":"$args","type":"array","desc":"Form data"}]
|
572 |
+
* @change_log
|
573 |
+
* ["Since: 2.0"]
|
574 |
+
* @usage add_action( 'um_update_profile_full_name', 'function_name', 10, 2 );
|
575 |
+
* @example
|
576 |
+
* <?php
|
577 |
+
* add_action( 'um_update_profile_full_name', 'my_update_profile_full_name', 10, 2 );
|
578 |
+
* function my_update_profile_full_name( $user_id, $args ) {
|
579 |
+
* // your code here
|
580 |
+
* }
|
581 |
+
* ?>
|
582 |
+
*/
|
583 |
+
do_action( 'um_update_profile_full_name', $user_id, $to_update );
|
584 |
+
|
585 |
+
if ( ! isset( $args['is_signup'] ) ) {
|
586 |
+
$url = um_user_profile_url( $user_id );
|
587 |
+
$url = apply_filters( 'um_update_profile_redirect_after', $url, $user_id, $args );
|
588 |
+
exit( wp_redirect( um_edit_my_profile_cancel_uri( $url ) ) );
|
589 |
+
}
|
590 |
+
}
|
591 |
+
add_action( 'um_user_edit_profile', 'um_user_edit_profile', 10 );
|
592 |
+
|
593 |
+
|
594 |
+
/**
|
595 |
+
* @param array $post_form
|
596 |
+
*/
|
597 |
+
function um_profile_validate_nonce( $post_form ) {
|
598 |
+
$user_id = isset( $post_form['user_id'] ) ? $post_form['user_id'] : '';
|
599 |
+
$nonce = isset( $post_form['profile_nonce'] ) ? $post_form['profile_nonce'] : '';
|
600 |
+
if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'um-profile-nonce' . $user_id ) ) {
|
601 |
+
wp_die( __( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
602 |
+
}
|
603 |
+
}
|
604 |
+
add_action( 'um_submit_form_errors_hook__profile', 'um_profile_validate_nonce', 10, 1 );
|
605 |
+
|
606 |
+
|
607 |
+
add_filter( 'um_user_pre_updating_files_array', array( UM()->validation(), 'validate_files' ), 10, 1 );
|
608 |
+
add_filter( 'um_before_save_filter_submitted', array( UM()->validation(), 'validate_fields_values' ), 10, 2 );
|
609 |
+
|
610 |
+
/**
|
611 |
+
* Leave roles for User, which are not in the list of update profile (are default WP or 3rd plugins roles)
|
612 |
+
*
|
613 |
+
* @param $user_id
|
614 |
+
* @param $args
|
615 |
+
* @param $to_update
|
616 |
+
*/
|
617 |
+
function um_restore_default_roles( $user_id, $args, $to_update ) {
|
618 |
+
if ( ! empty( $args['submitted']['role'] ) && ! empty( $to_update['role'] ) ) {
|
619 |
+
$wp_user = new WP_User( $user_id );
|
620 |
+
|
621 |
+
$role_keys = array_map( function( $item ) {
|
622 |
+
return 'um_' . $item;
|
623 |
+
}, get_option( 'um_roles', array() ) );
|
624 |
+
|
625 |
+
$leave_roles = array_diff( $args['roles_before_upgrade'], array_merge( $role_keys, array( 'subscriber' ) ) );
|
626 |
+
|
627 |
+
if ( UM()->roles()->is_role_custom( $to_update['role'] ) ) {
|
628 |
+
$wp_user->remove_role( $to_update['role'] );
|
629 |
+
$roles = array_merge( $leave_roles, array( $to_update['role'] ) );
|
630 |
+
} else {
|
631 |
+
$roles = array_merge( array( $to_update['role'] ), $leave_roles );
|
632 |
+
}
|
633 |
+
|
634 |
+
foreach ( $roles as $role_k ) {
|
635 |
+
$wp_user->add_role( $role_k );
|
636 |
+
}
|
637 |
+
}
|
638 |
+
}
|
639 |
+
add_action( 'um_after_user_updated', 'um_restore_default_roles', 10, 3 );
|
640 |
+
|
641 |
+
|
642 |
+
/**
|
643 |
+
* If editing another user
|
644 |
+
*
|
645 |
+
* @param $args
|
646 |
+
*/
|
647 |
+
function um_editing_user_id_input( $args ) {
|
648 |
+
if ( UM()->fields()->editing == 1 && UM()->fields()->set_mode == 'profile' && UM()->user()->target_id ) { ?>
|
649 |
+
|
650 |
+
<input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( UM()->user()->target_id ); ?>" />
|
651 |
+
<input type="hidden" name="profile_nonce" id="profile_nonce" value="<?php echo esc_attr( UM()->form()->nonce ); ?>" />
|
652 |
+
|
653 |
+
<?php }
|
654 |
+
}
|
655 |
+
add_action( 'um_after_form_fields', 'um_editing_user_id_input' );
|
656 |
+
|
657 |
+
|
658 |
+
/**
|
659 |
+
* Remove Yoast from front end for the Profile page
|
660 |
+
*
|
661 |
+
* @see https://gist.github.com/amboutwe/1c847f9c706ff6f8c9eca76abea23fb6
|
662 |
+
* @since 2.1.6
|
663 |
+
*/
|
664 |
+
if ( !function_exists( 'um_profile_remove_wpseo' ) ) {
|
665 |
+
|
666 |
+
function um_profile_remove_wpseo() {
|
667 |
+
if ( um_is_core_page( 'user' ) && um_get_requested_user() ) {
|
668 |
+
|
669 |
+
/* Yoast SEO 12.4 */
|
670 |
+
if ( isset( $GLOBALS['wpseo_front'] ) && is_object( $GLOBALS['wpseo_front'] ) ) {
|
671 |
+
remove_action( 'wp_head', array( $GLOBALS['wpseo_front'], 'head' ), 1 );
|
672 |
+
} elseif ( class_exists( 'WPSEO_Frontend' ) && is_callable( array( 'WPSEO_Frontend', 'get_instance' ) ) ) {
|
673 |
+
remove_action( 'wp_head', array( WPSEO_Frontend::get_instance(), 'head' ), 1 );
|
674 |
+
}
|
675 |
+
|
676 |
+
/* Yoast SEO 14.1 */
|
677 |
+
remove_all_filters( 'wpseo_head' );
|
678 |
+
|
679 |
+
/* Restore title and canonical if broken */
|
680 |
+
if ( ! has_action( 'wp_head', '_wp_render_title_tag' ) ) {
|
681 |
+
add_action( 'wp_head', '_wp_render_title_tag', 18 );
|
682 |
+
}
|
683 |
+
if ( ! has_action( 'wp_head', 'rel_canonical' ) ) {
|
684 |
+
add_action( 'wp_head', 'rel_canonical', 18 );
|
685 |
+
}
|
686 |
+
}
|
687 |
+
}
|
688 |
+
|
689 |
+
}
|
690 |
+
add_action( 'get_header', 'um_profile_remove_wpseo', 8 );
|
691 |
+
|
692 |
+
|
693 |
+
/**
|
694 |
+
* The profile page SEO tags
|
695 |
+
*
|
696 |
+
* @see https://ogp.me/ - The Open Graph protocol
|
697 |
+
* @see https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary - The Twitter Summary card
|
698 |
+
* @see https://schema.org/Person - The schema.org Person schema
|
699 |
+
*/
|
700 |
+
function um_profile_dynamic_meta_desc() {
|
701 |
+
if ( um_is_core_page( 'user' ) && um_get_requested_user() ) {
|
702 |
+
|
703 |
+
$user_id = um_get_requested_user();
|
704 |
+
|
705 |
+
if ( $user_id !== um_user('ID') ) {
|
706 |
+
um_fetch_user( $user_id );
|
707 |
+
}
|
708 |
+
|
709 |
+
/**
|
710 |
+
* Settings by the priority:
|
711 |
+
* "Search engine visibility" in [wp-admin > Settings > Reading]
|
712 |
+
* "Profile Privacy" in [Account > Privacy]
|
713 |
+
* "Avoid indexing my profile by search engines in [Account > Privacy]
|
714 |
+
* "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > User Roles > Edit Role]
|
715 |
+
* "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > Settings > General > Users]
|
716 |
+
*/
|
717 |
+
if ( UM()->user()->is_profile_noindex( $user_id ) ) {
|
718 |
+
echo '<meta name="robots" content="noindex, nofollow" />';
|
719 |
+
return;
|
720 |
+
}
|
721 |
+
|
722 |
+
$locale = get_user_locale( $user_id );
|
723 |
+
$site_name = get_bloginfo( 'name' );
|
724 |
+
|
725 |
+
$twitter = (string) um_user( 'twitter' );
|
726 |
+
if ( ! empty( $twitter ) ) {
|
727 |
+
$twitter = trim( str_replace( 'https://twitter.com/', '', $twitter ), "/ \n\r\t\v\0" );
|
728 |
+
}
|
729 |
+
|
730 |
+
$title = trim( um_user( 'display_name' ) );
|
731 |
+
$description = um_convert_tags( UM()->options()->get( 'profile_desc' ) );
|
732 |
+
$url = um_user_profile_url( $user_id );
|
733 |
+
|
734 |
+
$size = 190;
|
735 |
+
$sizes = UM()->options()->get( 'photo_thumb_sizes' );
|
736 |
+
if ( is_array( $sizes ) ) {
|
737 |
+
$size = um_closest_num( $sizes, $size );
|
738 |
+
}
|
739 |
+
$image = um_get_user_avatar_url( $user_id, $size );
|
740 |
+
|
741 |
+
$person = array(
|
742 |
+
"@context" => "http://schema.org",
|
743 |
+
"@type" => "Person",
|
744 |
+
"name" => esc_attr( $title ),
|
745 |
+
"description" => esc_attr( stripslashes( $description ) ),
|
746 |
+
"image" => esc_url( $image ),
|
747 |
+
"url" => esc_url( $url ),
|
748 |
+
);
|
749 |
+
|
750 |
+
um_reset_user();
|
751 |
+
?>
|
752 |
+
<!-- START - Ultimate Member profile SEO meta tags -->
|
753 |
+
|
754 |
+
<link rel="image_src" href="<?php echo esc_url( $image ); ?>"/>
|
755 |
+
|
756 |
+
<meta name="description" content="<?php echo esc_attr( $description ); ?>"/>
|
757 |
+
|
758 |
+
<meta property="og:type" content="profile"/>
|
759 |
+
<meta property="og:locale" content="<?php echo esc_attr( $locale ); ?>"/>
|
760 |
+
<meta property="og:site_name" content="<?php echo esc_attr( $site_name ); ?>"/>
|
761 |
+
<meta property="og:title" content="<?php echo esc_attr( $title ); ?>"/>
|
762 |
+
<meta property="og:description" content="<?php echo esc_attr( $description ); ?>"/>
|
763 |
+
<meta property="og:image" content="<?php echo esc_url( $image ); ?>"/>
|
764 |
+
<meta property="og:image:alt" content="<?php esc_attr_e( 'Profile photo', 'ultimate-member' ); ?>"/>
|
765 |
+
<meta property="og:image:height" content="<?php echo (int) $size; ?>"/>
|
766 |
+
<meta property="og:image:width" content="<?php echo (int) $size; ?>"/>
|
767 |
+
<meta property="og:url" content="<?php echo esc_url( $url ); ?>"/>
|
768 |
+
|
769 |
+
<meta name="twitter:card" content="summary"/>
|
770 |
+
<?php if ( $twitter ) { ?>
|
771 |
+
<meta name="twitter:site" content="@<?php echo esc_attr( $twitter ); ?>"/>
|
772 |
+
<?php } ?>
|
773 |
+
<meta name="twitter:title" content="<?php echo esc_attr( $title ); ?>"/>
|
774 |
+
<meta name="twitter:description" content="<?php echo esc_attr( $description ); ?>"/>
|
775 |
+
<meta name="twitter:image" content="<?php echo esc_url( $image ); ?>"/>
|
776 |
+
<meta name="twitter:image:alt" content="<?php esc_attr_e( 'Profile photo', 'ultimate-member' ); ?>"/>
|
777 |
+
<meta name="twitter:url" content="<?php echo esc_url( $url ); ?>"/>
|
778 |
+
|
779 |
+
<script type="application/ld+json"><?php echo json_encode( $person ); ?></script>
|
780 |
+
|
781 |
+
<!-- END - Ultimate Member profile SEO meta tags -->
|
782 |
+
<?php
|
783 |
+
}
|
784 |
+
}
|
785 |
+
add_action( 'wp_head', 'um_profile_dynamic_meta_desc', 20 );
|
786 |
+
|
787 |
+
|
788 |
+
/**
|
789 |
+
* Profile header cover
|
790 |
+
*
|
791 |
+
* @param $args
|
792 |
+
*/
|
793 |
+
function um_profile_header_cover_area( $args ) {
|
794 |
+
if ( isset( $args['cover_enabled'] ) && $args['cover_enabled'] == 1 ) {
|
795 |
+
|
796 |
+
$default_cover = UM()->options()->get( 'default_cover' );
|
797 |
+
|
798 |
+
$overlay = '<span class="um-cover-overlay">
|
799 |
+
<span class="um-cover-overlay-s">
|
800 |
+
<ins>
|
801 |
+
<i class="um-faicon-picture-o"></i>
|
802 |
+
<span class="um-cover-overlay-t">' . __( 'Change your cover photo', 'ultimate-member' ) . '</span>
|
803 |
+
</ins>
|
804 |
+
</span>
|
805 |
+
</span>';
|
806 |
+
|
807 |
+
?>
|
808 |
+
|
809 |
+
<div class="um-cover <?php if ( um_user( 'cover_photo' ) || ( $default_cover && $default_cover['url'] ) ) echo 'has-cover'; ?>"
|
810 |
+
data-user_id="<?php echo esc_attr( um_profile_id() ); ?>" data-ratio="<?php echo esc_attr( $args['cover_ratio'] ); ?>">
|
811 |
+
|
812 |
+
<?php
|
813 |
+
/**
|
814 |
+
* UM hook
|
815 |
+
*
|
816 |
+
* @type action
|
817 |
+
* @title um_cover_area_content
|
818 |
+
* @description Cover area content change
|
819 |
+
* @input_vars
|
820 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
821 |
+
* @change_log
|
822 |
+
* ["Since: 2.0"]
|
823 |
+
* @usage add_action( 'um_cover_area_content', 'function_name', 10, 1 );
|
824 |
+
* @example
|
825 |
+
* <?php
|
826 |
+
* add_action( 'um_cover_area_content', 'my_cover_area_content', 10, 1 );
|
827 |
+
* function my_cover_area_content( $user_id ) {
|
828 |
+
* // your code here
|
829 |
+
* }
|
830 |
+
* ?>
|
831 |
+
*/
|
832 |
+
do_action( 'um_cover_area_content', um_profile_id() );
|
833 |
+
if ( UM()->fields()->editing ) {
|
834 |
+
|
835 |
+
$hide_remove = um_user( 'cover_photo' ) ? false : ' style="display:none;"';
|
836 |
+
|
837 |
+
$text = ! um_user( 'cover_photo' ) ? __( 'Upload a cover photo', 'ultimate-member' ) : __( 'Change cover photo', 'ultimate-member' ) ;
|
838 |
+
|
839 |
+
$items = array(
|
840 |
+
'<a href="javascript:void(0);" class="um-manual-trigger" data-parent=".um-cover" data-child=".um-btn-auto-width">' . $text . '</a>',
|
841 |
+
'<a href="javascript:void(0);" class="um-reset-cover-photo" data-user_id="' . um_profile_id() . '" ' . $hide_remove . '>' . __( 'Remove', 'ultimate-member' ) . '</a>',
|
842 |
+
'<a href="javascript:void(0);" class="um-dropdown-hide">' . __( 'Cancel', 'ultimate-member' ) . '</a>',
|
843 |
+
);
|
844 |
+
|
845 |
+
$items = apply_filters( 'um_cover_area_content_dropdown_items', $items, um_profile_id() );
|
846 |
+
|
847 |
+
UM()->profile()->new_ui( 'bc', 'div.um-cover', 'click', $items );
|
848 |
+
} else {
|
849 |
+
|
850 |
+
if ( ! isset( UM()->user()->cannot_edit ) && ! um_user( 'cover_photo' ) ) {
|
851 |
+
|
852 |
+
$items = array(
|
853 |
+
'<a href="javascript:void(0);" class="um-manual-trigger" data-parent=".um-cover" data-child=".um-btn-auto-width">' . __( 'Upload a cover photo', 'ultimate-member' ) . '</a>',
|
854 |
+
'<a href="javascript:void(0);" class="um-dropdown-hide">' . __( 'Cancel', 'ultimate-member' ) . '</a>',
|
855 |
+
);
|
856 |
+
|
857 |
+
$items = apply_filters( 'um_cover_area_content_dropdown_items', $items, um_profile_id() );
|
858 |
+
|
859 |
+
UM()->profile()->new_ui( 'bc', 'div.um-cover', 'click', $items );
|
860 |
+
|
861 |
+
}
|
862 |
+
|
863 |
+
}
|
864 |
+
|
865 |
+
UM()->fields()->add_hidden_field( 'cover_photo' ); ?>
|
866 |
+
|
867 |
+
<div class="um-cover-e" data-ratio="<?php echo esc_attr( $args['cover_ratio'] ); ?>">
|
868 |
+
|
869 |
+
<?php if ( um_user( 'cover_photo' ) ) {
|
870 |
+
|
871 |
+
$get_cover_size = $args['coversize'];
|
872 |
+
|
873 |
+
if ( ! $get_cover_size || $get_cover_size == 'original' ) {
|
874 |
+
$size = null;
|
875 |
+
} else {
|
876 |
+
$size = $get_cover_size;
|
877 |
+
}
|
878 |
+
|
879 |
+
if ( UM()->mobile()->isMobile() ) {
|
880 |
+
|
881 |
+
// set for mobile width = 300 by default but can be changed via filter
|
882 |
+
if ( ! UM()->mobile()->isTablet() ) {
|
883 |
+
$size = 300;
|
884 |
+
}
|
885 |
+
|
886 |
+
/**
|
887 |
+
* UM hook
|
888 |
+
*
|
889 |
+
* @type filter
|
890 |
+
* @title um_mobile_cover_photo
|
891 |
+
* @description Add size for mobile device
|
892 |
+
* @input_vars
|
893 |
+
* [{"var":"$size","type":"int","desc":"Form's agrument - Cover Photo size"}]
|
894 |
+
* @change_log
|
895 |
+
* ["Since: 2.0"]
|
896 |
+
* @usage
|
897 |
+
* <?php add_filter( 'um_mobile_cover_photo', 'change_size', 10, 1 ); ?>
|
898 |
+
* @example
|
899 |
+
* <?php
|
900 |
+
* add_filter( 'um_mobile_cover_photo', 'um_change_cover_mobile_size', 10, 1 );
|
901 |
+
* function um_change_cover_mobile_size( $size ) {
|
902 |
+
* // your code here
|
903 |
+
* return $size;
|
904 |
+
* }
|
905 |
+
* ?>
|
906 |
+
*/
|
907 |
+
$size = apply_filters( 'um_mobile_cover_photo', $size );
|
908 |
+
}
|
909 |
+
|
910 |
+
echo um_user( 'cover_photo', $size );
|
911 |
+
|
912 |
+
} elseif ( $default_cover && $default_cover['url'] ) {
|
913 |
+
|
914 |
+
$default_cover = $default_cover['url'];
|
915 |
+
|
916 |
+
echo '<img src="' . esc_url( $default_cover ) . '" alt="" />';
|
917 |
+
|
918 |
+
} else {
|
919 |
+
|
920 |
+
if ( ! isset( UM()->user()->cannot_edit ) ) { ?>
|
921 |
+
|
922 |
+
<a href="javascript:void(0);" class="um-cover-add"><span class="um-cover-add-i"><i
|
923 |
+
class="um-icon-plus um-tip-n"
|
924 |
+
title="<?php esc_attr_e( 'Upload a cover photo', 'ultimate-member' ); ?>"></i></span></a>
|
925 |
+
|
926 |
+
<?php }
|
927 |
+
|
928 |
+
} ?>
|
929 |
+
|
930 |
+
</div>
|
931 |
+
|
932 |
+
<?php echo $overlay; ?>
|
933 |
+
|
934 |
+
</div>
|
935 |
+
|
936 |
+
<?php
|
937 |
+
|
938 |
+
}
|
939 |
+
|
940 |
+
}
|
941 |
+
add_action( 'um_profile_header_cover_area', 'um_profile_header_cover_area', 9 );
|
942 |
+
|
943 |
+
|
944 |
+
/**
|
945 |
+
* Show social links as icons below profile name
|
946 |
+
*
|
947 |
+
* @param $args
|
948 |
+
*/
|
949 |
+
function um_social_links_icons( $args ) {
|
950 |
+
if ( ! empty( $args['show_social_links'] ) ) {
|
951 |
+
|
952 |
+
echo '<div class="um-profile-connect um-member-connect">';
|
953 |
+
UM()->fields()->show_social_urls();
|
954 |
+
echo '</div>';
|
955 |
+
|
956 |
+
}
|
957 |
+
}
|
958 |
+
add_action( 'um_after_profile_header_name_args', 'um_social_links_icons', 50 );
|
959 |
+
|
960 |
+
|
961 |
+
/**
|
962 |
+
* Profile header
|
963 |
+
*
|
964 |
+
* @param $args
|
965 |
+
*/
|
966 |
+
function um_profile_header( $args ) {
|
967 |
+
$classes = null;
|
968 |
+
|
969 |
+
if ( ! $args['cover_enabled'] ) {
|
970 |
+
$classes .= ' no-cover';
|
971 |
+
}
|
972 |
+
|
973 |
+
$default_size = str_replace( 'px', '', $args['photosize'] );
|
974 |
+
|
975 |
+
// Switch on/off the profile photo uploader
|
976 |
+
$disable_photo_uploader = empty( $args['use_custom_settings'] ) ? UM()->options()->get( 'disable_profile_photo_upload' ) : $args['disable_photo_upload'];
|
977 |
+
|
978 |
+
if ( ! empty( $disable_photo_uploader ) ) {
|
979 |
+
$args['disable_photo_upload'] = 1;
|
980 |
+
$overlay = '';
|
981 |
+
} else {
|
982 |
+
$overlay = '<span class="um-profile-photo-overlay">
|
983 |
+
<span class="um-profile-photo-overlay-s">
|
984 |
+
<ins>
|
985 |
+
<i class="um-faicon-camera"></i>
|
986 |
+
</ins>
|
987 |
+
</span>
|
988 |
+
</span>';
|
989 |
+
} ?>
|
990 |
+
|
991 |
+
<div class="um-header<?php echo esc_attr( $classes ); ?>">
|
992 |
+
|
993 |
+
<?php
|
994 |
+
/**
|
995 |
+
* UM hook
|
996 |
+
*
|
997 |
+
* @type action
|
998 |
+
* @title um_pre_header_editprofile
|
999 |
+
* @description Insert some content before edit profile header
|
1000 |
+
* @input_vars
|
1001 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
1002 |
+
* @change_log
|
1003 |
+
* ["Since: 2.0"]
|
1004 |
+
* @usage add_action( 'um_pre_header_editprofile', 'function_name', 10, 1 );
|
1005 |
+
* @example
|
1006 |
+
* <?php
|
1007 |
+
* add_action( 'um_pre_header_editprofile', 'my_pre_header_editprofile', 10, 1 );
|
1008 |
+
* function my_pre_header_editprofile( $args ) {
|
1009 |
+
* // your code here
|
1010 |
+
* }
|
1011 |
+
* ?>
|
1012 |
+
*/
|
1013 |
+
do_action( 'um_pre_header_editprofile', $args ); ?>
|
1014 |
+
|
1015 |
+
<div class="um-profile-photo" data-user_id="<?php echo esc_attr( um_profile_id() ); ?>">
|
1016 |
+
|
1017 |
+
<a href="<?php echo esc_url( um_user_profile_url() ); ?>" class="um-profile-photo-img" title="<?php echo esc_attr( um_user( 'display_name' ) ); ?>">
|
1018 |
+
<?php if ( ! $default_size || $default_size == 'original' ) {
|
1019 |
+
$profile_photo = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/" . um_profile( 'profile_photo' );
|
1020 |
+
|
1021 |
+
$data = um_get_user_avatar_data( um_user( 'ID' ) );
|
1022 |
+
echo $overlay . sprintf( '<img src="%s" class="%s" alt="%s" data-default="%s" onerror="%s" />',
|
1023 |
+
esc_url( $profile_photo ),
|
1024 |
+
esc_attr( $data['class'] ),
|
1025 |
+
esc_attr( $data['alt'] ),
|
1026 |
+
esc_attr( $data['default'] ),
|
1027 |
+
'if ( ! this.getAttribute(\'data-load-error\') ){ this.setAttribute(\'data-load-error\', \'1\');this.setAttribute(\'src\', this.getAttribute(\'data-default\'));}'
|
1028 |
+
);
|
1029 |
+
} else {
|
1030 |
+
echo $overlay . get_avatar( um_user( 'ID' ), $default_size );
|
1031 |
+
} ?>
|
1032 |
+
</a>
|
1033 |
+
|
1034 |
+
<?php if ( empty( $disable_photo_uploader ) && empty( UM()->user()->cannot_edit ) ) {
|
1035 |
+
|
1036 |
+
UM()->fields()->add_hidden_field( 'profile_photo' );
|
1037 |
+
|
1038 |
+
if ( ! um_profile( 'profile_photo' ) ) { // has profile photo
|
1039 |
+
|
1040 |
+
$items = array(
|
1041 |
+
'<a href="javascript:void(0);" class="um-manual-trigger" data-parent=".um-profile-photo" data-child=".um-btn-auto-width">' . __( 'Upload photo', 'ultimate-member' ) . '</a>',
|
1042 |
+
'<a href="javascript:void(0);" class="um-dropdown-hide">' . __( 'Cancel', 'ultimate-member' ) . '</a>',
|
1043 |
+
);
|
1044 |
+
|
1045 |
+
/**
|
1046 |
+
* UM hook
|
1047 |
+
*
|
1048 |
+
* @type filter
|
1049 |
+
* @title um_user_photo_menu_view
|
1050 |
+
* @description Change user photo on menu view
|
1051 |
+
* @input_vars
|
1052 |
+
* [{"var":"$items","type":"array","desc":"User Photos"}]
|
1053 |
+
* @change_log
|
1054 |
+
* ["Since: 2.0"]
|
1055 |
+
* @usage
|
1056 |
+
* <?php add_filter( 'um_user_photo_menu_view', 'function_name', 10, 1 ); ?>
|
1057 |
+
* @example
|
1058 |
+
* <?php
|
1059 |
+
* add_filter( 'um_user_photo_menu_view', 'my_user_photo_menu_view', 10, 1 );
|
1060 |
+
* function my_user_photo_menu_view( $items ) {
|
1061 |
+
* // your code here
|
1062 |
+
* return $items;
|
1063 |
+
* }
|
1064 |
+
* ?>
|
1065 |
+
*/
|
1066 |
+
$items = apply_filters( 'um_user_photo_menu_view', $items );
|
1067 |
+
|
1068 |
+
UM()->profile()->new_ui( 'bc', 'div.um-profile-photo', 'click', $items );
|
1069 |
+
|
1070 |
+
} elseif ( UM()->fields()->editing == true ) {
|
1071 |
+
|
1072 |
+
$items = array(
|
1073 |
+
'<a href="javascript:void(0);" class="um-manual-trigger" data-parent=".um-profile-photo" data-child=".um-btn-auto-width">' . __( 'Change photo', 'ultimate-member' ) . '</a>',
|
1074 |
+
'<a href="javascript:void(0);" class="um-reset-profile-photo" data-user_id="' . esc_attr( um_profile_id() ) . '" data-default_src="' . esc_url( um_get_default_avatar_uri() ) . '">' . __( 'Remove photo', 'ultimate-member' ) . '</a>',
|
1075 |
+
'<a href="javascript:void(0);" class="um-dropdown-hide">' . __( 'Cancel', 'ultimate-member' ) . '</a>',
|
1076 |
+
);
|
1077 |
+
|
1078 |
+
/**
|
1079 |
+
* UM hook
|
1080 |
+
*
|
1081 |
+
* @type filter
|
1082 |
+
* @title um_user_photo_menu_edit
|
1083 |
+
* @description Change user photo on menu edit
|
1084 |
+
* @input_vars
|
1085 |
+
* [{"var":"$items","type":"array","desc":"User Photos"}]
|
1086 |
+
* @change_log
|
1087 |
+
* ["Since: 2.0"]
|
1088 |
+
* @usage
|
1089 |
+
* <?php add_filter( 'um_user_photo_menu_edit', 'function_name', 10, 1 ); ?>
|
1090 |
+
* @example
|
1091 |
+
* <?php
|
1092 |
+
* add_filter( 'um_user_photo_menu_edit', 'my_user_photo_menu_edit', 10, 1 );
|
1093 |
+
* function my_user_photo_menu_edit( $items ) {
|
1094 |
+
* // your code here
|
1095 |
+
* return $items;
|
1096 |
+
* }
|
1097 |
+
* ?>
|
1098 |
+
*/
|
1099 |
+
$items = apply_filters( 'um_user_photo_menu_edit', $items );
|
1100 |
+
|
1101 |
+
UM()->profile()->new_ui( 'bc', 'div.um-profile-photo', 'click', $items );
|
1102 |
+
|
1103 |
+
}
|
1104 |
+
|
1105 |
+
} ?>
|
1106 |
+
|
1107 |
+
</div>
|
1108 |
+
|
1109 |
+
<div class="um-profile-meta">
|
1110 |
+
|
1111 |
+
<?php
|
1112 |
+
/**
|
1113 |
+
* UM hook
|
1114 |
+
*
|
1115 |
+
* @type action
|
1116 |
+
* @title um_before_profile_main_meta
|
1117 |
+
* @description Insert before profile main meta block
|
1118 |
+
* @input_vars
|
1119 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
1120 |
+
* @change_log
|
1121 |
+
* ["Since: 2.0.1"]
|
1122 |
+
* @usage add_action( 'um_before_profile_main_meta', 'function_name', 10, 1 );
|
1123 |
+
* @example
|
1124 |
+
* <?php
|
1125 |
+
* add_action( 'um_before_profile_main_meta', 'my_before_profile_main_meta', 10, 1 );
|
1126 |
+
* function my_before_profile_main_meta( $args ) {
|
1127 |
+
* // your code here
|
1128 |
+
* }
|
1129 |
+
* ?>
|
1130 |
+
*/
|
1131 |
+
do_action( 'um_before_profile_main_meta', $args ); ?>
|
1132 |
+
|
1133 |
+
<div class="um-main-meta">
|
1134 |
+
|
1135 |
+
<?php if ( $args['show_name'] ) { ?>
|
1136 |
+
<div class="um-name">
|
1137 |
+
|
1138 |
+
<a href="<?php echo esc_url( um_user_profile_url() ); ?>"
|
1139 |
+
title="<?php echo esc_attr( um_user( 'display_name' ) ); ?>"><?php echo um_user( 'display_name', 'html' ); ?></a>
|
1140 |
+
|
1141 |
+
<?php
|
1142 |
+
/**
|
1143 |
+
* UM hook
|
1144 |
+
*
|
1145 |
+
* @type action
|
1146 |
+
* @title um_after_profile_name_inline
|
1147 |
+
* @description Insert after profile name some content
|
1148 |
+
* @input_vars
|
1149 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
1150 |
+
* @change_log
|
1151 |
+
* ["Since: 2.0"]
|
1152 |
+
* @usage add_action( 'um_after_profile_name_inline', 'function_name', 10, 1 );
|
1153 |
+
* @example
|
1154 |
+
* <?php
|
1155 |
+
* add_action( 'um_after_profile_name_inline', 'my_after_profile_name_inline', 10, 1 );
|
1156 |
+
* function my_after_profile_name_inline( $args ) {
|
1157 |
+
* // your code here
|
1158 |
+
* }
|
1159 |
+
* ?>
|
1160 |
+
*/
|
1161 |
+
do_action( 'um_after_profile_name_inline', $args ); ?>
|
1162 |
+
|
1163 |
+
</div>
|
1164 |
+
<?php } ?>
|
1165 |
+
|
1166 |
+
<div class="um-clear"></div>
|
1167 |
+
|
1168 |
+
<?php
|
1169 |
+
/**
|
1170 |
+
* UM hook
|
1171 |
+
*
|
1172 |
+
* @type action
|
1173 |
+
* @title um_after_profile_header_name_args
|
1174 |
+
* @description Insert after profile header name some content
|
1175 |
+
* @input_vars
|
1176 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
1177 |
+
* @change_log
|
1178 |
+
* ["Since: 2.0"]
|
1179 |
+
* @usage add_action( 'um_after_profile_header_name_args', 'function_name', 10, 1 );
|
1180 |
+
* @example
|
1181 |
+
* <?php
|
1182 |
+
* add_action( 'um_after_profile_header_name_args', 'my_after_profile_header_name_args', 10, 1 );
|
1183 |
+
* function my_after_profile_header_name_args( $args ) {
|
1184 |
+
* // your code here
|
1185 |
+
* }
|
1186 |
+
* ?>
|
1187 |
+
*/
|
1188 |
+
do_action( 'um_after_profile_header_name_args', $args );
|
1189 |
+
/**
|
1190 |
+
* UM hook
|
1191 |
+
*
|
1192 |
+
* @type action
|
1193 |
+
* @title um_after_profile_name_inline
|
1194 |
+
* @description Insert after profile name some content
|
1195 |
+
* @change_log
|
1196 |
+
* ["Since: 2.0"]
|
1197 |
+
* @usage add_action( 'um_after_profile_name_inline', 'function_name', 10 );
|
1198 |
+
* @example
|
1199 |
+
* <?php
|
1200 |
+
* add_action( 'um_after_profile_name_inline', 'my_after_profile_name_inline', 10 );
|
1201 |
+
* function my_after_profile_name_inline() {
|
1202 |
+
* // your code here
|
1203 |
+
* }
|
1204 |
+
* ?>
|
1205 |
+
*/
|
1206 |
+
do_action( 'um_after_profile_header_name' ); ?>
|
1207 |
+
|
1208 |
+
</div>
|
1209 |
+
|
1210 |
+
<?php if ( ! empty( $args['metafields'] ) ) { ?>
|
1211 |
+
<div class="um-meta">
|
1212 |
+
|
1213 |
+
<?php echo UM()->profile()->show_meta( $args['metafields'] ); ?>
|
1214 |
+
|
1215 |
+
</div>
|
1216 |
+
<?php }
|
1217 |
+
|
1218 |
+
$description_key = UM()->profile()->get_show_bio_key( $args );
|
1219 |
+
|
1220 |
+
if ( UM()->fields()->viewing == true && um_user( $description_key ) && $args['show_bio'] ) { ?>
|
1221 |
+
|
1222 |
+
<div class="um-meta-text">
|
1223 |
+
<?php $description = get_user_meta( um_user( 'ID' ), $description_key, true );
|
1224 |
+
|
1225 |
+
if ( UM()->options()->get( 'profile_show_html_bio' ) ) {
|
1226 |
+
echo make_clickable( wpautop( wp_kses_post( $description ) ) );
|
1227 |
+
} else {
|
1228 |
+
echo esc_html( $description );
|
1229 |
+
} ?>
|
1230 |
+
</div>
|
1231 |
+
|
1232 |
+
<?php } elseif ( UM()->fields()->editing == true && $args['show_bio'] ) { ?>
|
1233 |
+
|
1234 |
+
<div class="um-meta-text">
|
1235 |
+
<textarea id="um-meta-bio"
|
1236 |
+
data-character-limit="<?php echo esc_attr( UM()->options()->get( 'profile_bio_maxchars' ) ); ?>"
|
1237 |
+
placeholder="<?php esc_attr_e( 'Tell us a bit about yourself...', 'ultimate-member' ); ?>"
|
1238 |
+
name="<?php echo esc_attr( $description_key . '-' . $args['form_id'] ); ?>"
|
1239 |
+
id="<?php echo esc_attr( $description_key . '-' . $args['form_id'] ); ?>"><?php echo UM()->fields()->field_value( $description_key ) ?></textarea>
|
1240 |
+
<span class="um-meta-bio-character um-right"><span
|
1241 |
+
class="um-bio-limit"><?php echo UM()->options()->get( 'profile_bio_maxchars' ); ?></span></span>
|
1242 |
+
|
1243 |
+
<?php if ( UM()->fields()->is_error( $description_key ) ) {
|
1244 |
+
echo UM()->fields()->field_error( UM()->fields()->show_error( $description_key ), true );
|
1245 |
+
} ?>
|
1246 |
+
|
1247 |
+
</div>
|
1248 |
+
|
1249 |
+
<?php } ?>
|
1250 |
+
|
1251 |
+
<div class="um-profile-status <?php echo esc_attr( um_user( 'account_status' ) ); ?>">
|
1252 |
+
<span><?php printf( __( 'This user account status is %s', 'ultimate-member' ), um_user( 'account_status_name' ) ); ?></span>
|
1253 |
+
</div>
|
1254 |
+
|
1255 |
+
<?php
|
1256 |
+
/**
|
1257 |
+
* UM hook
|
1258 |
+
*
|
1259 |
+
* @type action
|
1260 |
+
* @title um_after_header_meta
|
1261 |
+
* @description Insert after header meta some content
|
1262 |
+
* @input_vars
|
1263 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
1264 |
+
* {"var":"$args","type":"array","desc":"Form Arguments"}]
|
1265 |
+
* @change_log
|
1266 |
+
* ["Since: 2.0"]
|
1267 |
+
* @usage add_action( 'um_after_header_meta', 'function_name', 10, 2 );
|
1268 |
+
* @example
|
1269 |
+
* <?php
|
1270 |
+
* add_action( 'um_after_header_meta', 'my_after_header_meta', 10, 2 );
|
1271 |
+
* function my_after_header_meta( $user_id, $args ) {
|
1272 |
+
* // your code here
|
1273 |
+
* }
|
1274 |
+
* ?>
|
1275 |
+
*/
|
1276 |
+
do_action( 'um_after_header_meta', um_user( 'ID' ), $args ); ?>
|
1277 |
+
|
1278 |
+
</div>
|
1279 |
+
<div class="um-clear"></div>
|
1280 |
+
|
1281 |
+
<?php if ( UM()->fields()->is_error( 'profile_photo' ) ) {
|
1282 |
+
echo UM()->fields()->field_error( UM()->fields()->show_error( 'profile_photo' ), 'force_show' );
|
1283 |
+
}
|
1284 |
+
|
1285 |
+
/**
|
1286 |
+
* UM hook
|
1287 |
+
*
|
1288 |
+
* @type action
|
1289 |
+
* @title um_after_header_info
|
1290 |
+
* @description Insert after header info some content
|
1291 |
+
* @input_vars
|
1292 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
1293 |
+
* {"var":"$args","type":"array","desc":"Form Arguments"}]
|
1294 |
+
* @change_log
|
1295 |
+
* ["Since: 2.0"]
|
1296 |
+
* @usage add_action( 'um_after_header_info', 'function_name', 10, 2 );
|
1297 |
+
* @example
|
1298 |
+
* <?php
|
1299 |
+
* add_action( 'um_after_header_info', 'my_after_header_info', 10, 2 );
|
1300 |
+
* function my_after_header_info( $user_id, $args ) {
|
1301 |
+
* // your code here
|
1302 |
+
* }
|
1303 |
+
* ?>
|
1304 |
+
*/
|
1305 |
+
do_action( 'um_after_header_info', um_user( 'ID' ), $args ); ?>
|
1306 |
+
|
1307 |
+
</div>
|
1308 |
+
|
1309 |
+
<?php
|
1310 |
+
}
|
1311 |
+
add_action( 'um_profile_header', 'um_profile_header', 9 );
|
1312 |
+
|
1313 |
+
|
1314 |
+
/**
|
1315 |
+
* Adds profile permissions to view/edit
|
1316 |
+
*
|
1317 |
+
* @param $args
|
1318 |
+
*/
|
1319 |
+
function um_pre_profile_shortcode( $args ) {
|
1320 |
+
/**
|
1321 |
+
* @var $mode
|
1322 |
+
*/
|
1323 |
+
extract( $args );
|
1324 |
+
|
1325 |
+
if ( $mode == 'profile' ) {
|
1326 |
+
if ( UM()->fields()->editing ) {
|
1327 |
+
if ( um_get_requested_user() ) {
|
1328 |
+
if ( ! UM()->roles()->um_current_user_can( 'edit', um_get_requested_user() ) ) {
|
1329 |
+
um_redirect_home( um_get_requested_user(), um_is_myprofile() );
|
1330 |
+
}
|
1331 |
+
um_fetch_user( um_get_requested_user() );
|
1332 |
+
}
|
1333 |
+
} else {
|
1334 |
+
UM()->fields()->viewing = 1;
|
1335 |
+
|
1336 |
+
if ( um_get_requested_user() ) {
|
1337 |
+
if ( ! um_can_view_profile( um_get_requested_user() ) && ! um_is_myprofile() ) {
|
1338 |
+
um_redirect_home( um_get_requested_user(), um_is_myprofile() );
|
1339 |
+
}
|
1340 |
+
|
1341 |
+
if ( ! UM()->roles()->um_current_user_can( 'edit', um_get_requested_user() ) ) {
|
1342 |
+
UM()->user()->cannot_edit = 1;
|
1343 |
+
}
|
1344 |
+
|
1345 |
+
um_fetch_user( um_get_requested_user() );
|
1346 |
+
} else {
|
1347 |
+
if ( ! is_user_logged_in() ) {
|
1348 |
+
um_redirect_home( um_get_requested_user(), um_is_myprofile() );
|
1349 |
+
}
|
1350 |
+
|
1351 |
+
if ( ! um_user( 'can_edit_profile' ) ) {
|
1352 |
+
UM()->user()->cannot_edit = 1;
|
1353 |
+
}
|
1354 |
+
}
|
1355 |
+
}
|
1356 |
+
}
|
1357 |
+
}
|
1358 |
+
add_action( 'um_pre_profile_shortcode', 'um_pre_profile_shortcode' );
|
1359 |
+
|
1360 |
+
|
1361 |
+
/**
|
1362 |
+
* Display the edit profile icon
|
1363 |
+
*
|
1364 |
+
* @param $args
|
1365 |
+
*/
|
1366 |
+
function um_add_edit_icon( $args ) {
|
1367 |
+
if ( ! is_user_logged_in() ) {
|
1368 |
+
// not allowed for guests
|
1369 |
+
return;
|
1370 |
+
}
|
1371 |
+
|
1372 |
+
// do not proceed if user cannot edit
|
1373 |
+
|
1374 |
+
if ( UM()->fields()->editing == true ) { ?>
|
1375 |
+
|
1376 |
+
<div class="um-profile-edit um-profile-headericon">
|
1377 |
+
<a href="javascript:void(0);" class="um-profile-edit-a um-profile-save"><i class="um-faicon-check"></i></a>
|
1378 |
+
</div>
|
1379 |
+
|
1380 |
+
<?php return;
|
1381 |
+
}
|
1382 |
+
|
1383 |
+
if ( ! um_is_myprofile() ) {
|
1384 |
+
|
1385 |
+
if ( ! UM()->roles()->um_current_user_can( 'edit', um_profile_id() ) && ! UM()->roles()->um_current_user_can( 'delete', um_profile_id() ) ) {
|
1386 |
+
return;
|
1387 |
+
}
|
1388 |
+
|
1389 |
+
$items = UM()->user()->get_admin_actions();
|
1390 |
+
if ( UM()->roles()->um_current_user_can( 'edit', um_profile_id() ) ) {
|
1391 |
+
$items['editprofile'] = '<a href="' . esc_url( um_edit_profile_url() ) . '" class="real_url">' . __( 'Edit Profile', 'ultimate-member' ) . '</a>';
|
1392 |
+
}
|
1393 |
+
|
1394 |
+
/**
|
1395 |
+
* UM hook
|
1396 |
+
*
|
1397 |
+
* @type filter
|
1398 |
+
* @title um_profile_edit_menu_items
|
1399 |
+
* @description Edit menu items on profile page
|
1400 |
+
* @input_vars
|
1401 |
+
* [{"var":"$items","type":"array","desc":"User Menu"},
|
1402 |
+
* {"var":"$user_id","type":"int","desc":"Profile ID"}]
|
1403 |
+
* @change_log
|
1404 |
+
* ["Since: 2.0"]
|
1405 |
+
* @usage
|
1406 |
+
* <?php add_filter( 'um_profile_edit_menu_items', 'function_name', 10, 2 ); ?>
|
1407 |
+
* @example
|
1408 |
+
* <?php
|
1409 |
+
* add_filter( 'um_profile_edit_menu_items', 'my_profile_edit_menu_items', 10, 2 );
|
1410 |
+
* function my_profile_edit_menu_items( $items, $user_id ) {
|
1411 |
+
* // your code here
|
1412 |
+
* return $items;
|
1413 |
+
* }
|
1414 |
+
* ?>
|
1415 |
+
*/
|
1416 |
+
$items = apply_filters( 'um_profile_edit_menu_items', $items, um_profile_id() );
|
1417 |
+
|
1418 |
+
$items['cancel'] = '<a href="javascript:void(0);" class="um-dropdown-hide">' . __( 'Cancel', 'ultimate-member' ) . '</a>';
|
1419 |
+
|
1420 |
+
} else {
|
1421 |
+
$items = array(
|
1422 |
+
'editprofile' => '<a href="' . esc_url( um_edit_profile_url() ) . '" class="real_url">' . __( 'Edit Profile', 'ultimate-member' ) . '</a>',
|
1423 |
+
'myaccount' => '<a href="' . esc_url( um_get_core_page( 'account' ) ) . '" class="real_url">' . __( 'My Account', 'ultimate-member' ) . '</a>',
|
1424 |
+
'logout' => '<a href="' . esc_url( um_get_core_page( 'logout' ) ) . '" class="real_url">' . __( 'Logout', 'ultimate-member' ) . '</a>',
|
1425 |
+
'cancel' => '<a href="javascript:void(0);" class="um-dropdown-hide">' . __( 'Cancel', 'ultimate-member' ) . '</a>',
|
1426 |
+
);
|
1427 |
+
|
1428 |
+
if ( ! empty( UM()->user()->cannot_edit ) ) {
|
1429 |
+
unset( $items['editprofile'] );
|
1430 |
+
}
|
1431 |
+
|
1432 |
+
/**
|
1433 |
+
* UM hook
|
1434 |
+
*
|
1435 |
+
* @type filter
|
1436 |
+
* @title um_myprofile_edit_menu_items
|
1437 |
+
* @description Edit menu items on my profile page
|
1438 |
+
* @input_vars
|
1439 |
+
* [{"var":"$items","type":"array","desc":"User Menu"}]
|
1440 |
+
* @change_log
|
1441 |
+
* ["Since: 2.0"]
|
1442 |
+
* @usage
|
1443 |
+
* <?php add_filter( 'um_myprofile_edit_menu_items', 'function_name', 10, 1 ); ?>
|
1444 |
+
* @example
|
1445 |
+
* <?php
|
1446 |
+
* add_filter( 'um_myprofile_edit_menu_items', 'my_myprofile_edit_menu_items', 10, 1 );
|
1447 |
+
* function my_myprofile_edit_menu_items( $items ) {
|
1448 |
+
* // your code here
|
1449 |
+
* return $items;
|
1450 |
+
* }
|
1451 |
+
* ?>
|
1452 |
+
*/
|
1453 |
+
$items = apply_filters( 'um_myprofile_edit_menu_items', $items );
|
1454 |
+
} ?>
|
1455 |
+
|
1456 |
+
<div class="um-profile-edit um-profile-headericon">
|
1457 |
+
|
1458 |
+
<a href="javascript:void(0);" class="um-profile-edit-a"><i class="um-faicon-cog"></i></a>
|
1459 |
+
|
1460 |
+
<?php UM()->profile()->new_ui( $args['header_menu'], 'div.um-profile-edit', 'click', $items ); ?>
|
1461 |
+
|
1462 |
+
</div>
|
1463 |
+
|
1464 |
+
<?php
|
1465 |
+
}
|
1466 |
+
add_action( 'um_pre_header_editprofile', 'um_add_edit_icon' );
|
1467 |
+
|
1468 |
+
|
1469 |
+
/**
|
1470 |
+
* Show Fields
|
1471 |
+
*
|
1472 |
+
* @param $args
|
1473 |
+
*/
|
1474 |
+
function um_add_profile_fields( $args ) {
|
1475 |
+
if ( UM()->fields()->editing == true ) {
|
1476 |
+
|
1477 |
+
echo UM()->fields()->display( 'profile', $args );
|
1478 |
+
|
1479 |
+
} else {
|
1480 |
+
|
1481 |
+
UM()->fields()->viewing = true;
|
1482 |
+
|
1483 |
+
echo UM()->fields()->display_view( 'profile', $args );
|
1484 |
+
|
1485 |
+
}
|
1486 |
+
|
1487 |
+
}
|
1488 |
+
add_action( 'um_main_profile_fields', 'um_add_profile_fields', 100 );
|
1489 |
+
|
1490 |
+
|
1491 |
+
/**
|
1492 |
+
* Form processing
|
1493 |
+
*
|
1494 |
+
* @param $args
|
1495 |
+
*/
|
1496 |
+
function um_submit_form_profile( $args ) {
|
1497 |
+
if ( isset( UM()->form()->errors ) ) {
|
1498 |
+
return;
|
1499 |
+
}
|
1500 |
+
|
1501 |
+
UM()->fields()->set_mode = 'profile';
|
1502 |
+
UM()->fields()->editing = true;
|
1503 |
+
|
1504 |
+
if ( ! empty( $args['submitted'] ) ) {
|
1505 |
+
$args['submitted'] = array_diff_key( $args['submitted'], array_flip( UM()->user()->banned_keys ) );
|
1506 |
+
}
|
1507 |
+
|
1508 |
+
/**
|
1509 |
+
* UM hook
|
1510 |
+
*
|
1511 |
+
* @type action
|
1512 |
+
* @title um_user_edit_profile
|
1513 |
+
* @description Run on successful submit profile form
|
1514 |
+
* @input_vars
|
1515 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
1516 |
+
* @change_log
|
1517 |
+
* ["Since: 2.0"]
|
1518 |
+
* @usage add_action( 'um_user_edit_profile', 'function_name', 10, 1 );
|
1519 |
+
* @example
|
1520 |
+
* <?php
|
1521 |
+
* add_action( 'um_user_edit_profile', 'my_user_edit_profile', 10, 1 );
|
1522 |
+
* function my_user_edit_profile( $args ) {
|
1523 |
+
* // your code here
|
1524 |
+
* }
|
1525 |
+
* ?>
|
1526 |
+
*/
|
1527 |
+
do_action( 'um_user_edit_profile', $args );
|
1528 |
+
}
|
1529 |
+
add_action( 'um_submit_form_profile', 'um_submit_form_profile', 10 );
|
1530 |
+
|
1531 |
+
|
1532 |
+
/**
|
1533 |
+
* Show the submit button (highest priority)
|
1534 |
+
*
|
1535 |
+
* @param $args
|
1536 |
+
*/
|
1537 |
+
function um_add_submit_button_to_profile( $args ) {
|
1538 |
+
// DO NOT add when reviewing user's details
|
1539 |
+
if ( UM()->user()->preview == true && is_admin() ) {
|
1540 |
+
return;
|
1541 |
+
}
|
1542 |
+
|
1543 |
+
// only when editing
|
1544 |
+
if ( UM()->fields()->editing == false ) {
|
1545 |
+
return;
|
1546 |
+
}
|
1547 |
+
|
1548 |
+
if ( ! isset( $args['primary_btn_word'] ) || $args['primary_btn_word'] == '' ){
|
1549 |
+
$args['primary_btn_word'] = UM()->options()->get( 'profile_primary_btn_word' );
|
1550 |
+
}
|
1551 |
+
if ( ! isset( $args['secondary_btn_word'] ) || $args['secondary_btn_word'] == '' ){
|
1552 |
+
$args['secondary_btn_word'] = UM()->options()->get( 'profile_secondary_btn_word' );
|
1553 |
+
} ?>
|
1554 |
+
|
1555 |
+
<div class="um-col-alt">
|
1556 |
+
|
1557 |
+
<?php if ( ! empty( $args['secondary_btn'] ) ) { ?>
|
1558 |
+
|
1559 |
+
<div class="um-left um-half">
|
1560 |
+
<input type="submit" value="<?php esc_attr_e( wp_unslash( $args['primary_btn_word'] ), 'ultimate-member' ); ?>" class="um-button" />
|
1561 |
+
</div>
|
1562 |
+
<div class="um-right um-half">
|
1563 |
+
<a href="<?php echo esc_url( um_edit_my_profile_cancel_uri() ); ?>" class="um-button um-alt">
|
1564 |
+
<?php _e( wp_unslash( $args['secondary_btn_word'] ), 'ultimate-member' ); ?>
|
1565 |
+
</a>
|
1566 |
+
</div>
|
1567 |
+
|
1568 |
+
<?php } else { ?>
|
1569 |
+
|
1570 |
+
<div class="um-center">
|
1571 |
+
<input type="submit" value="<?php esc_attr_e( wp_unslash( $args['primary_btn_word'] ), 'ultimate-member' ); ?>" class="um-button" />
|
1572 |
+
</div>
|
1573 |
+
|
1574 |
+
<?php } ?>
|
1575 |
+
|
1576 |
+
<div class="um-clear"></div>
|
1577 |
+
|
1578 |
+
</div>
|
1579 |
+
|
1580 |
+
<?php
|
1581 |
+
}
|
1582 |
+
add_action( 'um_after_profile_fields', 'um_add_submit_button_to_profile', 1000 );
|
1583 |
+
|
1584 |
+
|
1585 |
+
/**
|
1586 |
+
* Display the available profile tabs
|
1587 |
+
*
|
1588 |
+
* @param array $args
|
1589 |
+
*/
|
1590 |
+
function um_profile_menu( $args ) {
|
1591 |
+
if ( ! UM()->options()->get( 'profile_menu' ) ) {
|
1592 |
+
return;
|
1593 |
+
}
|
1594 |
+
|
1595 |
+
// get active tabs
|
1596 |
+
$tabs = UM()->profile()->tabs_active();
|
1597 |
+
|
1598 |
+
$all_tabs = $tabs;
|
1599 |
+
|
1600 |
+
$tabs = array_filter( $tabs, function( $item ) {
|
1601 |
+
if ( ! empty( $item['hidden'] ) ) {
|
1602 |
+
return false;
|
1603 |
+
}
|
1604 |
+
return true;
|
1605 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|