Ultimate Member – User Profile & Membership Plugin - Version 2.2.3

Version Description

Download this release

Release Info

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

Code changes from version 2.2.2 to 2.2.3

assets/js/um-members.js CHANGED
@@ -303,12 +303,14 @@ function um_ajax_get_members( directory, args ) {
303
  var filter_name = filter.find('select').attr('name');
304
  var value = um_get_data_for_directory( directory, 'filter_' + filter_name );
305
  if ( typeof value != 'undefined' ) {
 
306
  request[ filter_name ] = value.split( '||' );
307
  }
308
  } else if ( filter.hasClass( 'um-text-filter-type' ) && filter.find('input[type="text"]').length ) {
309
  var filter_name = filter.find('input[type="text"]').attr('name');
310
  var value = um_get_data_for_directory( directory, 'filter_' + filter_name );
311
  if ( typeof value != 'undefined' ) {
 
312
  request[ filter_name ] = value;
313
  }
314
  } else {
@@ -491,9 +493,11 @@ function um_get_filters_data( directory ) {
491
  filter_title = filter.find('select').data('placeholder');
492
 
493
  var filter_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
 
494
  if ( typeof filter_value == 'undefined' ) {
495
  filter_value = [];
496
  } else {
 
497
  filter_value = filter_value.split( '||' );
498
  }
499
 
@@ -956,7 +960,8 @@ jQuery(document.body).ready( function() {
956
 
957
  //filtration process
958
  jQuery( document.body ).on( 'change', '.um-directory .um-search-filter select', function() {
959
- var selected_val = um_sanitize_value( jQuery(this).val() );
 
960
 
961
  if ( selected_val === '' ) {
962
  return;
@@ -991,7 +996,7 @@ jQuery(document.body).ready( function() {
991
  }
992
 
993
  //disable options and disable select if all options are disabled
994
- jQuery(this).find('option[value="' + selected_val + '"]').prop('disabled', true).hide();
995
  if ( jQuery(this).find('option:not(:disabled)').length === 1 ) {
996
  jQuery(this).prop('disabled', true);
997
  }
@@ -1115,6 +1120,7 @@ jQuery(document.body).ready( function() {
1115
  if ( typeof current_value == 'undefined' ) {
1116
  current_value = [];
1117
  } else {
 
1118
  current_value = current_value.split( '||' );
1119
  }
1120
 
303
  var filter_name = filter.find('select').attr('name');
304
  var value = um_get_data_for_directory( directory, 'filter_' + filter_name );
305
  if ( typeof value != 'undefined' ) {
306
+ value = um_unsanitize_value( value );
307
  request[ filter_name ] = value.split( '||' );
308
  }
309
  } else if ( filter.hasClass( 'um-text-filter-type' ) && filter.find('input[type="text"]').length ) {
310
  var filter_name = filter.find('input[type="text"]').attr('name');
311
  var value = um_get_data_for_directory( directory, 'filter_' + filter_name );
312
  if ( typeof value != 'undefined' ) {
313
+ value = um_unsanitize_value( value );
314
  request[ filter_name ] = value;
315
  }
316
  } else {
493
  filter_title = filter.find('select').data('placeholder');
494
 
495
  var filter_value = um_get_data_for_directory( directory, 'filter_' + filter_name );
496
+
497
  if ( typeof filter_value == 'undefined' ) {
498
  filter_value = [];
499
  } else {
500
+ filter_value = um_unsanitize_value( filter_value );
501
  filter_value = filter_value.split( '||' );
502
  }
503
 
960
 
961
  //filtration process
962
  jQuery( document.body ).on( 'change', '.um-directory .um-search-filter select', function() {
963
+ var selected_val_raw = jQuery(this).val();
964
+ var selected_val = um_sanitize_value( selected_val_raw );
965
 
966
  if ( selected_val === '' ) {
967
  return;
996
  }
997
 
998
  //disable options and disable select if all options are disabled
999
+ jQuery(this).find('option[value="' + selected_val_raw + '"]').prop('disabled', true).hide();
1000
  if ( jQuery(this).find('option:not(:disabled)').length === 1 ) {
1001
  jQuery(this).prop('disabled', true);
1002
  }
1120
  if ( typeof current_value == 'undefined' ) {
1121
  current_value = [];
1122
  } else {
1123
+ current_value = um_unsanitize_value( current_value );
1124
  current_value = current_value.split( '||' );
1125
  }
1126
 
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=e.siblings(".um-slider-range").data("placeholder-s"),i=e.siblings(".um-slider-range").data("placeholder-p");t=r?r.values[0]===r.values[1]?a.replace("{value}",r.values[0]).replace("{field_label}",e.siblings(".um-slider-range").data("label")):i.replace("{min_range}",r.values[0]).replace("{max_range}",r.values[1]).replace("{field_label}",e.siblings(".um-slider-range").data("label")):e.slider("values",0)===e.slider("values",1)?a.replace("{value}",e.slider("values",0)).replace("{field_label}",e.siblings(".um-slider-range").data("label")):i.replace("{min_range}",e.slider("values",0)).replace("{max_range}",e.slider("values",1)).replace("{field_label}",e.siblings(".um-slider-range").data("label")),e.siblings(".um-slider-range").html(t),e.siblings(".um_range_min").val(e.slider("values",0)),e.siblings(".um_range_max").val(e.slider("values",1))}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))&&(_[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))&&(_[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.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=um_sanitize_value(jQuery(this).val());if(""!==e){var r=jQuery(this).parents(".um-directory");if(!um_is_directory_busy(r)){um_members_show_preloader(r);var t=jQuery(this).prop("name"),a=um_get_data_for_directory(r,"filter_"+t);a=void 0===a?[]:a.split("||"),-1===jQuery.inArray(e,a)&&(a.push(e),um_set_url_from_data(r,"filter_"+t,a=a.join("||")),r.data("page",1),um_set_url_from_data(r,"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 i=jQuery(this);i.select2("destroy").select2({dropdownParent:i.parent()}),i.val("").trigger("change"),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("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.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=e.siblings(".um-slider-range").data("placeholder-s"),i=e.siblings(".um-slider-range").data("placeholder-p");t=r?r.values[0]===r.values[1]?a.replace("{value}",r.values[0]).replace("{field_label}",e.siblings(".um-slider-range").data("label")):i.replace("{min_range}",r.values[0]).replace("{max_range}",r.values[1]).replace("{field_label}",e.siblings(".um-slider-range").data("label")):e.slider("values",0)===e.slider("values",1)?a.replace("{value}",e.slider("values",0)).replace("{field_label}",e.siblings(".um-slider-range").data("label")):i.replace("{min_range}",e.slider("values",0)).replace("{max_range}",e.slider("values",1)).replace("{field_label}",e.siblings(".um-slider-range").data("label")),e.siblings(".um-slider-range").html(t),e.siblings(".um_range_min").val(e.slider("values",0)),e.siblings(".um_range_max").val(e.slider("values",1))}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))})})});
assets/js/um-modal.js CHANGED
@@ -102,6 +102,7 @@ jQuery(document).ready(function() {
102
  user_id = jQuery(this).parents('#um_upload_single').data('user_id');
103
  }
104
 
 
105
  var form_id = 0;
106
  var mode = '';
107
  if ( jQuery('div.um-field-image[data-key="' + key + '"]').length === 1 ) {
102
  user_id = jQuery(this).parents('#um_upload_single').data('user_id');
103
  }
104
 
105
+ var d;
106
  var form_id = 0;
107
  var mode = '';
108
  if ( jQuery('div.um-field-image[data-key="' + key + '"]').length === 1 ) {
assets/js/um-modal.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(){jQuery(document).on("click",".um-popup-overlay",function(){remove_Modal()}),jQuery(document).on("click",'.um-modal-overlay, a[data-action="um_remove_modal"]',function(){um_remove_modal()}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"], .um-modal:not(:has(.um-form)) a',function(e){return e.preventDefault(),!1}),jQuery(document).on("click",".um-modal .um-single-file-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-fileinfo a").attr("href"),i=a.find(".um-single-file-upload").data("set_mode");return jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:t,mode:i,nonce:um_scripts.nonce},success:function(){a.find(".um-single-file-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive()}}),!1}),jQuery(document).on("click",".um-modal .um-single-image-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview img").attr("src"),i=a.find(".um-single-image-upload").data("set_mode");return jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:t,mode:i,nonce:um_scripts.nonce},success:function(){jQuery("img.cropper-hidden").cropper("destroy"),a.find(".um-single-image-preview img").attr("src",""),a.find(".um-single-image-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive()}}),!1}),jQuery(document).on("click",".um-finish-upload.file:not(.disabled)",function(){var e=jQuery(this).attr("data-key"),a=jQuery(this).parents(".um-modal-body").find(".um-single-file-preview").html();um_remove_modal(),jQuery(".um-single-file-preview[data-key="+e+"]").fadeIn().html(a);var t=jQuery(".um-field[data-key="+e+"]").find(".um-single-fileinfo a").data("file");jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find(".um-btn-auto-width").html(jQuery(this).attr("data-change")),jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find('input[type="hidden"]').val(t)}),jQuery(document).on("click",".um-finish-upload.image:not(.disabled)",function(){var a=jQuery(this),t=jQuery(this).attr("data-key"),e=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview"),i=e.find("img").attr("src"),r=e.attr("data-coord"),u=e.find("img").data("file"),m=0;jQuery(this).parents("#um_upload_single").data("user_id")&&(m=jQuery(this).parents("#um_upload_single").data("user_id"));var n=0,o="";if(1===jQuery('div.um-field-image[data-key="'+t+'"]').length){var s=jQuery('div.um-field-image[data-key="'+t+'"]').closest(".um-form");n=s.find('input[name="form_id"]').val(),o=s.attr("data-mode")}r?(jQuery(this).html(jQuery(this).attr("data-processing")).addClass("disabled"),jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_resize_image",src:i,coord:r,user_id:m,key:t,set_id:n,set_mode:o,nonce:um_scripts.nonce},success:function(e){e.success&&(d=new Date,"profile_photo"===t?jQuery(".um-profile-photo-img img").attr("src",e.data.image.source_url+"?"+d.getTime()):"cover_photo"===t&&(jQuery(".um-cover-e").empty().html('<img src="'+e.data.image.source_url+"?"+d.getTime()+'" alt="" />'),jQuery(".um").hasClass("um-editing")&&jQuery(".um-cover-overlay").show()),jQuery(".um-single-image-preview[data-key="+t+"]").fadeIn().find("img").attr("src",e.data.image.source_url+"?"+d.getTime()),um_remove_modal(),jQuery("img.cropper-invisible").remove(),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find(".um-btn-auto-width").html(a.attr("data-change")),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find('input[type="hidden"]').val(e.data.image.filename))}})):(d=new Date,jQuery(".um-single-image-preview[data-key="+t+"]").fadeIn().find("img").attr("src",i+"?"+d.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find(".um-btn-auto-width").html(a.attr("data-change")),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find("input[type=hidden]").val(u))}),jQuery(document.body).on("click",'a[data-modal^="um_"], span[data-modal^="um_"]',function(e){var a=jQuery(this).attr("data-modal"),t="normal";jQuery(this).data("modal-size")&&(t=jQuery(this).data("modal-size")),jQuery(this).data("modal-copy")&&(jQuery("#"+a).html(jQuery(this).parents(".um-field").find(".um-modal-hidden-content").html()),jQuery(this).parents(".um-profile-photo").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-profile-photo").attr("data-user_id")),jQuery(this).parents(".um-cover").attr("data-ratio")&&jQuery("#"+a).attr("data-ratio",jQuery(this).parents(".um-cover").attr("data-ratio")),jQuery(this).parents(".um-cover").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-cover").attr("data-user_id")),0<jQuery('input[type="hidden"][name="user_id"]').length&&jQuery("#"+a).attr("data-user_id",jQuery('input[type="hidden"][name="user_id"]').val())),um_new_modal(a,t)})});
1
+ jQuery(document).ready(function(){jQuery(document).on("click",".um-popup-overlay",function(){remove_Modal()}),jQuery(document).on("click",'.um-modal-overlay, a[data-action="um_remove_modal"]',function(){um_remove_modal()}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"], .um-modal:not(:has(.um-form)) a',function(e){return e.preventDefault(),!1}),jQuery(document).on("click",".um-modal .um-single-file-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-fileinfo a").attr("href"),i=a.find(".um-single-file-upload").data("set_mode");return jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:t,mode:i,nonce:um_scripts.nonce},success:function(){a.find(".um-single-file-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive()}}),!1}),jQuery(document).on("click",".um-modal .um-single-image-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview img").attr("src"),i=a.find(".um-single-image-upload").data("set_mode");return jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:t,mode:i,nonce:um_scripts.nonce},success:function(){jQuery("img.cropper-hidden").cropper("destroy"),a.find(".um-single-image-preview img").attr("src",""),a.find(".um-single-image-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive()}}),!1}),jQuery(document).on("click",".um-finish-upload.file:not(.disabled)",function(){var e=jQuery(this).attr("data-key"),a=jQuery(this).parents(".um-modal-body").find(".um-single-file-preview").html();um_remove_modal(),jQuery(".um-single-file-preview[data-key="+e+"]").fadeIn().html(a);var t=jQuery(".um-field[data-key="+e+"]").find(".um-single-fileinfo a").data("file");jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find(".um-btn-auto-width").html(jQuery(this).attr("data-change")),jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find('input[type="hidden"]').val(t)}),jQuery(document).on("click",".um-finish-upload.image:not(.disabled)",function(){var a,t=jQuery(this),i=jQuery(this).attr("data-key"),e=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview"),r=e.find("img").attr("src"),u=e.attr("data-coord"),d=e.find("img").data("file"),m=0;jQuery(this).parents("#um_upload_single").data("user_id")&&(m=jQuery(this).parents("#um_upload_single").data("user_id"));var n=0,o="";if(1===jQuery('div.um-field-image[data-key="'+i+'"]').length){var s=jQuery('div.um-field-image[data-key="'+i+'"]').closest(".um-form");n=s.find('input[name="form_id"]').val(),o=s.attr("data-mode")}u?(jQuery(this).html(jQuery(this).attr("data-processing")).addClass("disabled"),jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_resize_image",src:r,coord:u,user_id:m,key:i,set_id:n,set_mode:o,nonce:um_scripts.nonce},success:function(e){e.success&&(a=new Date,"profile_photo"===i?jQuery(".um-profile-photo-img img").attr("src",e.data.image.source_url+"?"+a.getTime()):"cover_photo"===i&&(jQuery(".um-cover-e").empty().html('<img src="'+e.data.image.source_url+"?"+a.getTime()+'" alt="" />'),jQuery(".um").hasClass("um-editing")&&jQuery(".um-cover-overlay").show()),jQuery(".um-single-image-preview[data-key="+i+"]").fadeIn().find("img").attr("src",e.data.image.source_url+"?"+a.getTime()),um_remove_modal(),jQuery("img.cropper-invisible").remove(),jQuery(".um-single-image-preview[data-key="+i+"]").parents(".um-field").find(".um-btn-auto-width").html(t.attr("data-change")),jQuery(".um-single-image-preview[data-key="+i+"]").parents(".um-field").find('input[type="hidden"]').val(e.data.image.filename))}})):(a=new Date,jQuery(".um-single-image-preview[data-key="+i+"]").fadeIn().find("img").attr("src",r+"?"+a.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+i+"]").parents(".um-field").find(".um-btn-auto-width").html(t.attr("data-change")),jQuery(".um-single-image-preview[data-key="+i+"]").parents(".um-field").find("input[type=hidden]").val(d))}),jQuery(document.body).on("click",'a[data-modal^="um_"], span[data-modal^="um_"]',function(e){var a=jQuery(this).attr("data-modal"),t="normal";jQuery(this).data("modal-size")&&(t=jQuery(this).data("modal-size")),jQuery(this).data("modal-copy")&&(jQuery("#"+a).html(jQuery(this).parents(".um-field").find(".um-modal-hidden-content").html()),jQuery(this).parents(".um-profile-photo").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-profile-photo").attr("data-user_id")),jQuery(this).parents(".um-cover").attr("data-ratio")&&jQuery("#"+a).attr("data-ratio",jQuery(this).parents(".um-cover").attr("data-ratio")),jQuery(this).parents(".um-cover").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-cover").attr("data-user_id")),0<jQuery('input[type="hidden"][name="user_id"]').length&&jQuery("#"+a).attr("data-user_id",jQuery('input[type="hidden"][name="user_id"]').val())),um_new_modal(a,t)})});
assets/js/um-scripts.js CHANGED
@@ -9,6 +9,13 @@ function um_sanitize_value( value, el ) {
9
  return sanitized_value;
10
  }
11
 
 
 
 
 
 
 
 
12
 
13
  function um_init_datetimepicker() {
14
  jQuery('.um-datepicker:not(.picker__input)').each(function(){
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(){
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_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 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")})});
includes/admin/core/class-admin-dragdrop.php CHANGED
@@ -1,249 +1,249 @@
1
- <?php
2
- namespace um\admin\core;
3
-
4
-
5
- if ( ! defined( 'ABSPATH' ) ) exit;
6
-
7
-
8
- if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
9
-
10
-
11
- /**
12
- * Class Admin_DragDrop
13
- * @package um\admin\core
14
- */
15
- class Admin_DragDrop {
16
-
17
-
18
- /**
19
- * Admin_DragDrop constructor.
20
- */
21
- function __construct() {
22
- add_action( 'admin_footer', array( &$this, 'load_field_order' ), 9 );
23
- }
24
-
25
-
26
- /**
27
- * Update order of fields
28
- */
29
- public function update_order() {
30
- UM()->admin()->check_ajax_nonce();
31
-
32
- if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
33
- wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
34
- }
35
-
36
- /**
37
- * @var $form_id
38
- */
39
- extract( $_POST );
40
-
41
- if ( isset( $form_id ) ) {
42
- $form_id = absint( $form_id );
43
- }
44
-
45
- $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
46
-
47
- $this->row_data = get_option( 'um_form_rowdata_' . $form_id, array() );
48
- $this->exist_rows = array();
49
-
50
- if ( ! empty( $fields ) ) {
51
- foreach ( $fields as $key => $array ) {
52
- if ( 'row' === $array['type'] ) {
53
- $this->row_data[ $key ] = $array;
54
- unset( $fields[ $key ] );
55
- }
56
- }
57
- } else {
58
- $fields = array();
59
- }
60
-
61
- foreach ( $_POST as $key => $value ) {
62
-
63
- $key = sanitize_key( $key );
64
-
65
- // adding rows
66
- if ( 0 === strpos( $key, '_um_row_' ) ) {
67
-
68
- $update_args = null;
69
-
70
- $row_id = str_replace( '_um_row_', '', $key );
71
-
72
- if ( strstr( $_POST[ '_um_rowcols_' . $row_id . '_cols' ], ':' ) ) {
73
- $cols = sanitize_text_field( $_POST[ '_um_rowcols_' . $row_id . '_cols' ] );
74
- } else {
75
- $cols = absint( $_POST[ '_um_rowcols_' . $row_id . '_cols' ] );
76
- }
77
-
78
- $row_array = array(
79
- 'type' => 'row',
80
- 'id' => sanitize_key( $value ),
81
- 'sub_rows' => absint( $_POST[ '_um_rowsub_' . $row_id . '_rows' ] ),
82
- 'cols' => $cols,
83
- 'origin' => sanitize_key( $_POST[ '_um_roworigin_' . $row_id . '_val' ] ),
84
- );
85
-
86
- $row_args = $row_array;
87
-
88
- if ( isset( $this->row_data[ $row_array['origin'] ] ) ) {
89
- foreach ( $this->row_data[ $row_array['origin'] ] as $k => $v ) {
90
- if ( 'position' !== $k && 'metakey' !== $k ) {
91
- $update_args[ $k ] = $v;
92
- }
93
- }
94
- if ( isset( $update_args ) ) {
95
- $row_args = array_merge( $update_args, $row_array );
96
- }
97
- $this->exist_rows[] = $key;
98
- }
99
-
100
- $fields[ $key ] = $row_args;
101
-
102
- }
103
-
104
- // change field position
105
- if ( 0 === strpos( $key, 'um_position_' ) ) {
106
- $field_key = str_replace( 'um_position_', '', $key );
107
- if ( isset( $fields[ $field_key ] ) ) {
108
- $fields[ $field_key ]['position'] = absint( $value );
109
- }
110
- }
111
-
112
- // change field master row
113
- if ( 0 === strpos( $key, 'um_row_' ) ) {
114
- $field_key = str_replace( 'um_row_', '', $key );
115
- if ( isset( $fields[ $field_key ] ) ) {
116
- $fields[ $field_key ]['in_row'] = sanitize_key( $value );
117
- }
118
- }
119
-
120
- // change field sub row
121
- if ( 0 === strpos( $key, 'um_subrow_' ) ) {
122
- $field_key = str_replace( 'um_subrow_', '', $key );
123
- if ( isset( $fields[ $field_key ] ) ) {
124
- $fields[ $field_key ]['in_sub_row'] = sanitize_key( $value );
125
- }
126
- }
127
-
128
- // change field column
129
- if ( 0 === strpos( $key, 'um_col_' ) ) {
130
- $field_key = str_replace( 'um_col_', '', $key );
131
- if ( isset( $fields[ $field_key ] ) ) {
132
- $fields[ $field_key ]['in_column'] = absint( $value );
133
- }
134
- }
135
-
136
- // add field to group
137
- if ( 0 === strpos( $key, 'um_group_' ) ) {
138
- $field_key = str_replace( 'um_group_', '', $key );
139
- if ( isset( $fields[ $field_key ] ) ) {
140
- $fields[ $field_key ]['in_group'] = ! empty( $value ) ? absint( $value ) : '';
141
- }
142
- }
143
- }
144
-
145
- foreach ( $this->row_data as $k => $v ) {
146
- if ( ! in_array( $k, $this->exist_rows, true ) ) {
147
- unset( $this->row_data[ $k ] );
148
- }
149
- }
150
-
151
- update_option( 'um_existing_rows_' . $form_id, $this->exist_rows );
152
-
153
- update_option( 'um_form_rowdata_' . $form_id, $this->row_data );
154
-
155
- UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
156
-
157
- }
158
-
159
-
160
- /**
161
- * Load form to maintain form order
162
- */
163
- public function load_field_order() {
164
-
165
- $screen = get_current_screen();
166
-
167
- if ( ! isset( $screen->id ) || 'um_form' !== $screen->id ) {
168
- return;
169
- } ?>
170
-
171
- <div class="um-col-demon-settings" data-in_row="" data-in_sub_row="" data-in_column="" data-in_group=""></div>
172
-
173
- <div class="um-col-demon-row" style="display:none;">
174
-
175
- <div class="um-admin-drag-row-icons">
176
- <a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
177
- <a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member' ); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( get_the_ID() ); ?>"><i class="um-faicon-pencil"></i></a>
178
- <span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
179
- <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-row"><i class="um-faicon-trash-o"></i></a>
180
- </div>
181
- <div class="um-admin-clear"></div>
182
-
183
- <div class="um-admin-drag-rowsubs">
184
- <div class="um-admin-drag-rowsub">
185
-
186
- <div class="um-admin-drag-ctrls columns">
187
- <a href="javascript:void(0);" class="active" data-cols="1"></a>
188
- <a href="javascript:void(0);" data-cols="2"></a>
189
- <a href="javascript:void(0);" data-cols="3"></a>
190
- </div>
191
-
192
- <div class="um-admin-drag-rowsub-icons">
193
- <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
194
- <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a>
195
- </div><div class="um-admin-clear"></div>
196
-
197
- <div class="um-admin-drag-col">
198
- </div>
199
-
200
- <div class="um-admin-drag-col-dynamic"></div>
201
-
202
- <div class="um-admin-clear"></div>
203
-
204
- </div>
205
- </div>
206
-
207
- </div>
208
-
209
- <div class="um-col-demon-subrow" style="display:none;">
210
-
211
- <div class="um-admin-drag-ctrls columns">
212
- <a href="javascript:void(0);" class="active" data-cols="1"></a>
213
- <a href="javascript:void(0);" data-cols="2"></a>
214
- <a href="javascript:void(0);" data-cols="3"></a>
215
- </div>
216
-
217
- <div class="um-admin-drag-rowsub-icons">
218
- <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
219
- <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a>
220
- </div><div class="um-admin-clear"></div>
221
-
222
- <div class="um-admin-drag-col">
223
- </div>
224
-
225
- <div class="um-admin-drag-col-dynamic"></div>
226
-
227
- <div class="um-admin-clear"></div>
228
-
229
- </div>
230
-
231
-
232
- <form action="" method="post" class="um_update_order">
233
-
234
- <input type="hidden" name="form_id" id="form_id" value="<?php echo esc_attr( get_the_ID() ); ?>" />
235
- <input type="hidden" name="action" value="um_update_order" />
236
- <input type="hidden" name="nonce" value="<?php echo esc_attr( wp_create_nonce( 'um-admin-nonce' ) ) ?>" />
237
-
238
- <div class="um_update_order_fields">
239
-
240
- </div>
241
-
242
- </form>
243
-
244
- <?php
245
-
246
- }
247
-
248
- }
249
- }
1
+ <?php
2
+ namespace um\admin\core;
3
+
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) exit;
6
+
7
+
8
+ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
9
+
10
+
11
+ /**
12
+ * Class Admin_DragDrop
13
+ * @package um\admin\core
14
+ */
15
+ class Admin_DragDrop {
16
+
17
+
18
+ /**
19
+ * Admin_DragDrop constructor.
20
+ */
21
+ function __construct() {
22
+ add_action( 'admin_footer', array( &$this, 'load_field_order' ), 9 );
23
+ }
24
+
25
+
26
+ /**
27
+ * Update order of fields
28
+ */
29
+ public function update_order() {
30
+ UM()->admin()->check_ajax_nonce();
31
+
32
+ if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
33
+ wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
34
+ }
35
+
36
+ /**
37
+ * @var $form_id
38
+ */
39
+ extract( $_POST );
40
+
41
+ if ( isset( $form_id ) ) {
42
+ $form_id = absint( $form_id );
43
+ }
44
+
45
+ $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
46
+
47
+ $this->row_data = get_option( 'um_form_rowdata_' . $form_id, array() );
48
+ $this->exist_rows = array();
49
+
50
+ if ( ! empty( $fields ) ) {
51
+ foreach ( $fields as $key => $array ) {
52
+ if ( 'row' === $array['type'] ) {
53
+ $this->row_data[ $key ] = $array;
54
+ unset( $fields[ $key ] );
55
+ }
56
+ }
57
+ } else {
58
+ $fields = array();
59
+ }
60
+
61
+ foreach ( $_POST as $key => $value ) {
62
+ // don't use sanitize_key here because of a key can be in Uppercase
63
+ $key = sanitize_text_field( $key );
64
+
65
+ // adding rows
66
+ if ( 0 === strpos( $key, '_um_row_' ) ) {
67
+
68
+ $update_args = null;
69
+
70
+ $row_id = str_replace( '_um_row_', '', $key );
71
+
72
+ if ( strstr( $_POST[ '_um_rowcols_' . $row_id . '_cols' ], ':' ) ) {
73
+ $cols = sanitize_text_field( $_POST[ '_um_rowcols_' . $row_id . '_cols' ] );
74
+ } else {
75
+ $cols = absint( $_POST[ '_um_rowcols_' . $row_id . '_cols' ] );
76
+ }
77
+
78
+ $row_array = array(
79
+ 'type' => 'row',
80
+ 'id' => sanitize_key( $value ),
81
+ 'sub_rows' => absint( $_POST[ '_um_rowsub_' . $row_id . '_rows' ] ),
82
+ 'cols' => $cols,
83
+ 'origin' => sanitize_key( $_POST[ '_um_roworigin_' . $row_id . '_val' ] ),
84
+ );
85
+
86
+ $row_args = $row_array;
87
+
88
+ if ( isset( $this->row_data[ $row_array['origin'] ] ) ) {
89
+ foreach ( $this->row_data[ $row_array['origin'] ] as $k => $v ) {
90
+ if ( 'position' !== $k && 'metakey' !== $k ) {
91
+ $update_args[ $k ] = $v;
92
+ }
93
+ }
94
+ if ( isset( $update_args ) ) {
95
+ $row_args = array_merge( $update_args, $row_array );
96
+ }
97
+ $this->exist_rows[] = $key;
98
+ }
99
+
100
+ $fields[ $key ] = $row_args;
101
+
102
+ }
103
+
104
+ // change field position
105
+ if ( 0 === strpos( $key, 'um_position_' ) ) {
106
+ $field_key = str_replace( 'um_position_', '', $key );
107
+ if ( isset( $fields[ $field_key ] ) ) {
108
+ $fields[ $field_key ]['position'] = absint( $value );
109
+ }
110
+ }
111
+
112
+ // change field master row
113
+ if ( 0 === strpos( $key, 'um_row_' ) ) {
114
+ $field_key = str_replace( 'um_row_', '', $key );
115
+ if ( isset( $fields[ $field_key ] ) ) {
116
+ $fields[ $field_key ]['in_row'] = sanitize_key( $value );
117
+ }
118
+ }
119
+
120
+ // change field sub row
121
+ if ( 0 === strpos( $key, 'um_subrow_' ) ) {
122
+ $field_key = str_replace( 'um_subrow_', '', $key );
123
+ if ( isset( $fields[ $field_key ] ) ) {
124
+ $fields[ $field_key ]['in_sub_row'] = sanitize_key( $value );
125
+ }
126
+ }
127
+
128
+ // change field column
129
+ if ( 0 === strpos( $key, 'um_col_' ) ) {
130
+ $field_key = str_replace( 'um_col_', '', $key );
131
+ if ( isset( $fields[ $field_key ] ) ) {
132
+ $fields[ $field_key ]['in_column'] = absint( $value );
133
+ }
134
+ }
135
+
136
+ // add field to group
137
+ if ( 0 === strpos( $key, 'um_group_' ) ) {
138
+ $field_key = str_replace( 'um_group_', '', $key );
139
+ if ( isset( $fields[ $field_key ] ) ) {
140
+ $fields[ $field_key ]['in_group'] = ! empty( $value ) ? absint( $value ) : '';
141
+ }
142
+ }
143
+ }
144
+
145
+ foreach ( $this->row_data as $k => $v ) {
146
+ if ( ! in_array( $k, $this->exist_rows, true ) ) {
147
+ unset( $this->row_data[ $k ] );
148
+ }
149
+ }
150
+
151
+ update_option( 'um_existing_rows_' . $form_id, $this->exist_rows );
152
+
153
+ update_option( 'um_form_rowdata_' . $form_id, $this->row_data );
154
+
155
+ UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
156
+
157
+ }
158
+
159
+
160
+ /**
161
+ * Load form to maintain form order
162
+ */
163
+ public function load_field_order() {
164
+
165
+ $screen = get_current_screen();
166
+
167
+ if ( ! isset( $screen->id ) || 'um_form' !== $screen->id ) {
168
+ return;
169
+ } ?>
170
+
171
+ <div class="um-col-demon-settings" data-in_row="" data-in_sub_row="" data-in_column="" data-in_group=""></div>
172
+
173
+ <div class="um-col-demon-row" style="display:none;">
174
+
175
+ <div class="um-admin-drag-row-icons">
176
+ <a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
177
+ <a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member' ); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( get_the_ID() ); ?>"><i class="um-faicon-pencil"></i></a>
178
+ <span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
179
+ <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-row"><i class="um-faicon-trash-o"></i></a>
180
+ </div>
181
+ <div class="um-admin-clear"></div>
182
+
183
+ <div class="um-admin-drag-rowsubs">
184
+ <div class="um-admin-drag-rowsub">
185
+
186
+ <div class="um-admin-drag-ctrls columns">
187
+ <a href="javascript:void(0);" class="active" data-cols="1"></a>
188
+ <a href="javascript:void(0);" data-cols="2"></a>
189
+ <a href="javascript:void(0);" data-cols="3"></a>
190
+ </div>
191
+
192
+ <div class="um-admin-drag-rowsub-icons">
193
+ <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
194
+ <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a>
195
+ </div><div class="um-admin-clear"></div>
196
+
197
+ <div class="um-admin-drag-col">
198
+ </div>
199
+
200
+ <div class="um-admin-drag-col-dynamic"></div>
201
+
202
+ <div class="um-admin-clear"></div>
203
+
204
+ </div>
205
+ </div>
206
+
207
+ </div>
208
+
209
+ <div class="um-col-demon-subrow" style="display:none;">
210
+
211
+ <div class="um-admin-drag-ctrls columns">
212
+ <a href="javascript:void(0);" class="active" data-cols="1"></a>
213
+ <a href="javascript:void(0);" data-cols="2"></a>
214
+ <a href="javascript:void(0);" data-cols="3"></a>
215
+ </div>
216
+
217
+ <div class="um-admin-drag-rowsub-icons">
218
+ <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
219
+ <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a>
220
+ </div><div class="um-admin-clear"></div>
221
+
222
+ <div class="um-admin-drag-col">
223
+ </div>
224
+
225
+ <div class="um-admin-drag-col-dynamic"></div>
226
+
227
+ <div class="um-admin-clear"></div>
228
+
229
+ </div>
230
+
231
+
232
+ <form action="" method="post" class="um_update_order">
233
+
234
+ <input type="hidden" name="form_id" id="form_id" value="<?php echo esc_attr( get_the_ID() ); ?>" />
235
+ <input type="hidden" name="action" value="um_update_order" />
236
+ <input type="hidden" name="nonce" value="<?php echo esc_attr( wp_create_nonce( 'um-admin-nonce' ) ) ?>" />
237
+
238
+ <div class="um_update_order_fields">
239
+
240
+ </div>
241
+
242
+ </form>
243
+
244
+ <?php
245
+
246
+ }
247
+
248
+ }
249
+ }
includes/admin/core/class-admin-metabox.php CHANGED
@@ -1,2427 +1,2427 @@
1
- <?php
2
- namespace um\admin\core;
3
-
4
-
5
- if ( ! defined( 'ABSPATH' ) ) exit;
6
-
7
-
8
- if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
9
-
10
-
11
- /**
12
- * Class Admin_Metabox
13
- *
14
- * @package um\admin\core
15
- */
16
- class Admin_Metabox {
17
-
18
-
19
- /**
20
- * @var bool
21
- */
22
- private $form_nonce_added = false;
23
-
24
-
25
- /**
26
- * @var bool
27
- */
28
- private $directory_nonce_added = false;
29
-
30
-
31
- /**
32
- * @var bool
33
- */
34
- private $custom_nonce_added = false;
35
-
36
-
37
- var $init_icon = false;
38
-
39
-
40
- /**
41
- * Admin_Metabox constructor.
42
- */
43
- function __construct() {
44
- $this->in_edit = false;
45
- $this->edit_mode_value = null;
46
- $this->edit_array = [];
47
-
48
- add_action( 'admin_head', array( &$this, 'admin_head' ), 9);
49
- add_action( 'admin_footer', array( &$this, 'load_modal_content' ), 9 );
50
-
51
- add_action( 'load-post.php', array( &$this, 'add_metabox' ), 9 );
52
- add_action( 'load-post-new.php', array( &$this, 'add_metabox' ), 9 );
53
-
54
- add_action( 'admin_init', array( &$this, 'add_taxonomy_metabox' ), 9 );
55
-
56
- //roles metaboxes
57
- add_action( 'um_roles_add_meta_boxes', array( &$this, 'add_metabox_role' ) );
58
-
59
- add_filter( 'um_builtin_validation_types_continue_loop', array( &$this, 'validation_types_continue_loop' ), 1, 4 );
60
- add_filter( 'um_restrict_content_hide_metabox', array( &$this, 'hide_metabox_restrict_content_shop' ), 10, 1 );
61
-
62
- add_filter( 'um_member_directory_meta_value_before_save', array( UM()->member_directory(), 'before_save_data' ), 10, 3 );
63
- }
64
-
65
-
66
- /**
67
- * Hide Woocommerce Shop page restrict content metabox
68
- * @param $hide
69
- *
70
- * @return bool
71
- */
72
- function hide_metabox_restrict_content_shop( $hide ) {
73
- if ( function_exists( 'wc_get_page_id' ) && ! empty( $_GET['post'] ) &&
74
- absint( $_GET['post'] ) == wc_get_page_id( 'shop' ) ) {
75
- return true;
76
- }
77
-
78
- return $hide;
79
- }
80
-
81
-
82
- /**
83
- * Filter validation types on loop
84
- *
85
- * @param $break
86
- * @param $key
87
- * @param $form_id
88
- * @param $field_array
89
- *
90
- * @return bool
91
- */
92
- function validation_types_continue_loop( $break, $key, $form_id, $field_array ) {
93
-
94
- // show unique username validation only for user_login field
95
- if ( isset( $field_array['metakey'] ) && $field_array['metakey'] == 'user_login' && $key !== 'unique_username' ) {
96
- return false;
97
- }
98
-
99
- return $break;
100
- }
101
-
102
-
103
- /**
104
- * Gets the role meta
105
- *
106
- * @param $id
107
- *
108
- * @return mixed
109
- */
110
- function get_custom_post_meta( $id ) {
111
- $all_meta = get_post_custom( $id );
112
- foreach ( $all_meta as $k => $v ) {
113
- if ( strstr( $k, '_um_' ) ) {
114
- $um_meta[ $k ] = $v;
115
- }
116
- }
117
- if ( isset( $um_meta ) ) {
118
- return $um_meta;
119
- }
120
-
121
- return false;
122
- }
123
-
124
-
125
- /**
126
- * Runs on admin head
127
- */
128
- function admin_head(){
129
- global $post;
130
- if ( UM()->admin()->is_plugin_post_type() && isset($post->ID) ){
131
- $this->postmeta = $this->get_custom_post_meta($post->ID);
132
- }
133
- }
134
-
135
-
136
- /**
137
- * Init the metaboxes
138
- */
139
- function add_metabox() {
140
- global $current_screen;
141
-
142
- if ( $current_screen->id == 'um_form' ) {
143
- add_action( 'add_meta_boxes', array(&$this, 'add_metabox_form'), 1 );
144
- add_action( 'save_post', array(&$this, 'save_metabox_form'), 10, 2 );
145
- }
146
-
147
- if ( $current_screen->id == 'um_directory' ) {
148
- add_action( 'add_meta_boxes', array(&$this, 'add_metabox_directory'), 1 );
149
- add_action( 'save_post', array(&$this, 'save_metabox_directory'), 10, 2 );
150
- }
151
-
152
- //restrict content metabox
153
- $post_types = UM()->options()->get( 'restricted_access_post_metabox' );
154
- if ( ! empty( $post_types[ $current_screen->id ] ) ) {
155
-
156
- /**
157
- * UM hook
158
- *
159
- * @type filter
160
- * @title um_restrict_content_hide_metabox
161
- * @description Show/Hide Restrict content metabox
162
- * @input_vars
163
- * [{"var":"$show","type":"bool","desc":"Show Metabox"}]
164
- * @change_log
165
- * ["Since: 2.0"]
166
- * @usage add_filter( 'um_restrict_content_hide_metabox', 'function_name', 10, 1 );
167
- * @example
168
- * <?php
169
- * add_filter( 'um_restrict_content_hide_metabox', 'my_restrict_content_hide_metabox', 10, 1 );
170
- * function my_restrict_content_hide_metabox( $show ) {
171
- * // your code here
172
- * return $show;
173
- * }
174
- * ?>
175
- */
176
- $hide_metabox = apply_filters( 'um_restrict_content_hide_metabox', false );
177
-
178
- if ( ! $hide_metabox ) {
179
- add_action( 'add_meta_boxes', array(&$this, 'add_metabox_restrict_content'), 1 );
180
- add_action( 'save_post', array( &$this, 'save_metabox_restrict_content' ), 10, 2 );
181
- }
182
-
183
- if ( $current_screen->id == 'attachment' ) {
184
- add_action( 'add_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
185
- add_action( 'edit_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
186
- }
187
- }
188
-
189
-
190
- add_action( 'save_post', array( &$this, 'save_metabox_custom' ), 10, 2 );
191
- }
192
-
193
-
194
- /**
195
- * @param $post_id
196
- * @param $post
197
- */
198
- public function save_metabox_custom( $post_id, $post ) {
199
- // validate nonce
200
- if ( ! isset( $_POST['um_admin_save_metabox_custom_nonce'] ) ||
201
- ! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) {
202
- return;
203
- }
204
-
205
- /**
206
- * UM hook
207
- *
208
- * @type action
209
- * @title um_admin_custom_restrict_content_metaboxes
210
- * @description Save metabox custom with restrict content
211
- * @input_vars
212
- * [{"var":"$post_id","type":"int","desc":"Post ID"},
213
- * {"var":"$post","type":"array","desc":"Post data"}]
214
- * @change_log
215
- * ["Since: 2.0"]
216
- * @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10, 2 );
217
- * @example
218
- * <?php
219
- * add_action( 'um_admin_custom_restrict_content_metaboxes', 'my_admin_custom_restrict_content', 10, 2 );
220
- * function my_admin_custom_restrict_content( $post_id, $post ) {
221
- * // your code here
222
- * }
223
- * ?>
224
- */
225
- do_action( 'um_admin_custom_restrict_content_metaboxes', $post_id, $post );
226
- }
227
-
228
-
229
- /**
230
- *
231
- */
232
- function add_metabox_restrict_content() {
233
- global $current_screen;
234
-
235
- add_meta_box(
236
- 'um-admin-restrict-content',
237
- __( 'Ultimate Member: Content Restriction', 'ultimate-member' ),
238
- array( &$this, 'restrict_content_cb' ),
239
- $current_screen->id,
240
- 'normal',
241
- 'default'
242
- );
243
-
244
- /**
245
- * UM hook
246
- *
247
- * @type action
248
- * @title um_admin_custom_restrict_content_metaboxes
249
- * @description Add restrict content custom metabox
250
- * @change_log
251
- * ["Since: 2.0"]
252
- * @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10 );
253
- * @example
254
- * <?php
255
- * add_action( 'um_admin_custom_restrict_content_metaboxes', 'my_admin_custom_restrict_content', 10 );
256
- * function my_admin_custom_restrict_content() {
257
- * // your code here
258
- * }
259
- * ?>
260
- */
261
- do_action( 'um_admin_custom_restrict_content_metaboxes' );
262
- }
263
-
264
-
265
- /**
266
- * Content restriction metabox
267
- *
268
- * @param $object
269
- * @param $box
270
- */
271
- function restrict_content_cb( $object, $box ) {
272
- include_once UM()->admin()->templates_path . 'access/restrict_content.php';
273
- wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_restrict_content_nonce' );
274
- }
275
-
276
-
277
- /**
278
- * Init the metaboxes
279
- */
280
- function add_taxonomy_metabox() {
281
- //restrict content metabox
282
- $all_taxonomies = get_taxonomies( array( 'public' => true ) );
283
- $tax_types = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
284
- $exclude_taxonomies = UM()->excluded_taxonomies();
285
-
286
- foreach ( $all_taxonomies as $key => $taxonomy ) {
287
- if ( in_array( $key, $exclude_taxonomies ) || empty( $tax_types[$key] ) )
288
- continue;
289
-
290
- add_action( $taxonomy . '_add_form_fields', array( &$this, 'um_category_access_fields_create' ) );
291
- add_action( $taxonomy . '_edit_form_fields', array( &$this, 'um_category_access_fields_edit' ) );
292
- add_action( 'create_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) );
293
- add_action( 'edited_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) );
294
- }
295
- }
296
-
297
-
298
- /**
299
- * @param $post_id
300
- * @param $post
301
- */
302
- function save_metabox_restrict_content( $post_id, $post ) {
303
- // validate nonce
304
- if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] ) ||
305
- ! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) {
306
- return;
307
- }
308
-
309
- // validate user
310
- $post_type = get_post_type_object( $post->post_type );
311
- if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
312
- return;
313
- }
314
-
315
- if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
316
- $restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
317
-
318
- update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
319
- } else {
320
- delete_post_meta( $post_id, 'um_content_restriction' );
321
- }
322
- }
323
-
324
-
325
- /**
326
- * @param $post_id
327
- *
328
- */
329
- function save_attachment_metabox_restrict_content( $post_id ) {
330
- // validate nonce
331
- if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] )
332
- || ! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) {
333
- return;
334
- }
335
-
336
- $post = get_post( $post_id );
337
-
338
- // validate user
339
- $post_type = get_post_type_object( $post->post_type );
340
- if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
341
- return;
342
- }
343
-
344
- if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
345
- $restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
346
-
347
- update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
348
- } else {
349
- delete_post_meta( $post_id, 'um_content_restriction' );
350
- }
351
- }
352
-
353
-
354
- /**
355
- *
356
- */
357
- function um_category_access_fields_create() {
358
- /**
359
- * UM hook
360
- *
361
- * @type filter
362
- * @title um_admin_category_access_settings_fields
363
- * @description Settings fields for terms
364
- * @input_vars
365
- * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"},
366
- * {"var":"$data","type":"array","desc":"Settings Data"},
367
- * {"var":"$screen","type":"string","desc":"Category Screen"}]
368
- * @change_log
369
- * ["Since: 2.0"]
370
- * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 );
371
- * @example
372
- * <?php
373
- * add_filter( 'um_admin_category_access_settings_fields', 'my_admin_category_access_settings_fields', 10, 3 );
374
- * function my_admin_category_access_settings_fields( $access_settings_fields, $data, $screen ) {
375
- * // your code here
376
- * $access_settings_fields[] = array(
377
- * 'id' => 'my-field-key',
378
- * 'type' => 'my-field-type',
379
- * 'label' => __( 'My field Label', 'ultimate-member' ),
380
- * 'description' => __( 'My Field Description', 'ultimate-member' ),
381
- * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
382
- * );
383
- * return $access_settings_fields;
384
- * }
385
- * ?>
386
- */
387
- $fields = apply_filters( 'um_admin_category_access_settings_fields', array(
388
- array(
389
- 'id' => '_um_custom_access_settings',
390
- 'type' => 'checkbox',
391
- 'label' => __( 'Restrict access to this term and its posts?', 'ultimate-member' ),
392
- 'description' => __( 'Activate content restriction for this term and its posts. Affects only posts that do not have individual Restriction Content settings', 'ultimate-member' ),
393
- 'value' => 0,
394
- ),
395
- array(
396
- 'id' => '_um_accessible',
397
- 'type' => 'select',
398
- 'label' => __( 'Who can access this term and its posts?', 'ultimate-member' ),
399
- 'value' => '0',
400
- 'options' => array(
401
- '0' => __( 'Everyone', 'ultimate-member' ),
402
- '1' => __( 'Logged out users', 'ultimate-member' ),
403
- '2' => __( 'Logged in users', 'ultimate-member' ),
404
- ),
405
- 'conditional' => array( '_um_custom_access_settings', '=', '1' ),
406
- ),
407
- array(
408
- 'id' => '_um_access_roles',
409
- 'type' => 'multi_checkbox',
410
- 'label' => __( 'Select which roles can access this term and its posts', 'ultimate-member' ),
411
- 'description' => __( 'Leave empty if you want to display a term for all logged in users', 'ultimate-member' ),
412
- 'options' => UM()->roles()->get_roles( false ),
413
- 'columns' => 3,
414
- 'conditional' => array( '_um_accessible', '=', '2' ),
415
- ),
416
- array(
417
- 'id' => '_um_access_hide_from_queries',
418
- 'type' => 'checkbox',
419
- 'label' => __( 'Would you like to display 404 error on the term\'s archive page and terms\' posts single pages when users haven\'t access?', 'ultimate-member' ),
420
- 'description' => __( 'Recommended to be enabled. Restricted term\'s archive page and all terms\' posts will be hidden by exclusion from WP Query. The safest and most effective method that hides post and its comments from all requests, RSS feeds, etc. on your site', 'ultimate-member' ),
421
- 'value' => 1,
422
- 'conditional' => array( '_um_accessible', '!=', '0' ),
423
- ),
424
- array(
425
- 'id' => '_um_noaccess_action',
426
- 'type' => 'select',
427
- 'label' => __( 'What happens when users without access try to view the term\'s post?', 'ultimate-member' ),
428
- 'description' => __( 'Action when users without access tries to view the term\'s post', 'ultimate-member' ),
429
- 'value' => '0',
430
- 'options' => array(
431
- '0' => __( 'Show access restricted message', 'ultimate-member' ),
432
- '1' => __( 'Redirect user', 'ultimate-member' ),
433
- ),
434
- 'conditional' => array( '_um_access_hide_from_queries', '=', '0' ),
435
- ),
436
- array(
437
- 'id' => '_um_restrict_by_custom_message',
438
- 'type' => 'select',
439
- 'label' => __( 'Restricted access message type', 'ultimate-member' ),
440
- 'description' => __( 'Would you like to use the global default message or apply a custom message to this term\'s post?', 'ultimate-member' ),
441
- 'value' => '0',
442
- 'options' => array(
443
- '0' => __( 'Global default message', 'ultimate-member' ),
444
- '1' => __( 'Custom message', 'ultimate-member' ),
445
- ),
446
- 'conditional' => array( '_um_noaccess_action', '=', '0' ),
447
- ),
448
- array(
449
- 'id' => '_um_restrict_custom_message',
450
- 'type' => 'wp_editor',
451
- 'label' => __( 'Custom restricted access message', 'ultimate-member' ),
452
- 'description' => __( 'You may replace global restricted access message here', 'ultimate-member' ),
453
- 'value' => '',
454
- 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ),
455
- ),
456
- array(
457
- 'id' => '_um_access_redirect',
458
- 'type' => 'select',
459
- 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
460
- 'description' => __( 'Select redirect to page when user hasn\'t access to the term\'s post', 'ultimate-member' ),
461
- 'value' => '0',
462
- 'conditional' => array( '_um_noaccess_action', '=', '1' ),
463
- 'options' => array(
464
- '0' => __( 'Login page', 'ultimate-member' ),
465
- '1' => __( 'Custom URL', 'ultimate-member' ),
466
- ),
467
- ),
468
- array(
469
- 'id' => '_um_access_redirect_url',
470
- 'type' => 'text',
471
- 'label' => __( 'Redirect URL', 'ultimate-member' ),
472
- 'description' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ),
473
- 'value' => '',
474
- 'conditional' => array( '_um_access_redirect', '=', '1' ),
475
- ),
476
- ), array(), 'create' );
477
-
478
- UM()->admin_forms(
479
- array(
480
- 'class' => 'um-restrict-content um-third-column',
481
- 'prefix_id' => 'um_content_restriction',
482
- 'without_wrapper' => true,
483
- 'div_line' => true,
484
- 'fields' => $fields,
485
- )
486
- )->render_form();
487
-
488
- wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' );
489
- }
490
-
491
-
492
- /**
493
- * @param $term
494
- */
495
- function um_category_access_fields_edit( $term ) {
496
- $termID = $term->term_id;
497
-
498
- $data = get_term_meta( $termID, 'um_content_restriction', true );
499
-
500
- $_um_access_roles_value = array();
501
- if ( ! empty( $data['_um_access_roles'] ) ) {
502
- foreach ( $data['_um_access_roles'] as $key => $value ) {
503
- if ( $value ) {
504
- $_um_access_roles_value[] = $key;
505
- }
506
- }
507
- }
508
-
509
- /**
510
- * UM hook
511
- *
512
- * @type filter
513
- * @title um_admin_category_access_settings_fields
514
- * @description Settings fields for terms
515
- * @input_vars
516
- * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"},
517
- * {"var":"$data","type":"array","desc":"Settings Data"},
518
- * {"var":"$screen","type":"string","desc":"Category Screen"}]
519
- * @change_log
520
- * ["Since: 2.0"]
521
- * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 );
522
- * @example
523
- * <?php
524
- * add_filter( 'um_admin_category_access_settings_fields', 'my_admin_category_access_settings_fields', 10, 3 );
525
- * function my_admin_category_access_settings_fields( $access_settings_fields, $data, $screen ) {
526
- * // your code here
527
- * $access_settings_fields[] = array(
528
- * 'id' => 'my-field-key',
529
- * 'type' => 'my-field-type',
530
- * 'label' => __( 'My field Label', 'ultimate-member' ),
531
- * 'description' => __( 'My Field Description', 'ultimate-member' ),
532
- * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
533
- * );
534
- * return $access_settings_fields;
535
- * }
536
- * ?>
537
- */
538
- $fields = apply_filters( 'um_admin_category_access_settings_fields', array(
539
- array(
540
- 'id' => '_um_custom_access_settings',
541
- 'type' => 'checkbox',
542
- 'label' => __( 'Restrict access to this term and its posts?', 'ultimate-member' ),
543
- 'description' => __( 'Activate content restriction for this term and its posts. Affects only posts that do not have individual Restriction Content settings', 'ultimate-member' ),
544
- 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
545
- ),
546
- array(
547
- 'id' => '_um_accessible',
548
- 'type' => 'select',
549
- 'label' => __( 'Who can access this term and its posts?', 'ultimate-member' ),
550
- 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : '0',
551
- 'options' => array(
552
- '0' => __( 'Everyone', 'ultimate-member' ),
553
- '1' => __( 'Logged out users', 'ultimate-member' ),
554
- '2' => __( 'Logged in users', 'ultimate-member' ),
555
- ),
556
- 'conditional' => array( '_um_custom_access_settings', '=', '1' ),
557
- ),
558
- array(
559
- 'id' => '_um_access_roles',
560
- 'type' => 'multi_checkbox',
561
- 'label' => __( 'Select which roles can access this term and its posts', 'ultimate-member' ),
562
- 'description' => __( 'Leave empty if you want to display a term for all logged in users', 'ultimate-member' ),
563
- 'value' => $_um_access_roles_value,
564
- 'options' => UM()->roles()->get_roles( false ),
565
- 'columns' => 3,
566
- 'conditional' => array( '_um_accessible', '=', '2' ),
567
- ),
568
- array(
569
- 'id' => '_um_access_hide_from_queries',
570
- 'type' => 'checkbox',
571
- 'label' => __( 'Would you like to display 404 error on the term\'s archive page and terms\' posts single pages when users haven\'t access?', 'ultimate-member' ),
572
- 'description' => __( 'Recommended to be enabled. Restricted term\'s archive page and all terms\' posts will be hidden by exclusion from WP Query. The safest and most effective method that hides post and its comments from all requests, RSS feeds, etc. on your site', 'ultimate-member' ),
573
- 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
574
- 'conditional' => array( '_um_accessible', '!=', '0' ),
575
- ),
576
- array(
577
- 'id' => '_um_noaccess_action',
578
- 'type' => 'select',
579
- 'label' => __( 'What happens when users without access try to view the term\'s post?', 'ultimate-member' ),
580
- 'description' => __( 'Action when users without access tries to view the term\'s post', 'ultimate-member' ),
581
- 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : '0',
582
- 'options' => array(
583
- '0' => __( 'Show access restricted message', 'ultimate-member' ),
584
- '1' => __( 'Redirect user', 'ultimate-member' ),
585
- ),
586
- 'conditional' => array( '_um_access_hide_from_queries', '=', '0' ),
587
- ),
588
- array(
589
- 'id' => '_um_restrict_by_custom_message',
590
- 'type' => 'select',
591
- 'label' => __( 'Restricted access message type', 'ultimate-member' ),
592
- 'description' => __( 'Would you like to use the global default message or apply a custom message to this term\'s post?', 'ultimate-member' ),
593
- 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
594
- 'options' => array(
595
- '0' => __( 'Global default message', 'ultimate-member' ),
596
- '1' => __( 'Custom message', 'ultimate-member' ),
597
- ),
598
- 'conditional' => array( '_um_noaccess_action', '=', '0' ),
599
- ),
600
- array(
601
- 'id' => '_um_restrict_custom_message',
602
- 'type' => 'wp_editor',
603
- 'label' => __( 'Custom restricted access message', 'ultimate-member' ),
604
- 'description' => __( 'You may replace global restricted access message here', 'ultimate-member' ),
605
- 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
606
- 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ),
607
- ),
608
- array(
609
- 'id' => '_um_access_redirect',
610
- 'type' => 'select',
611
- 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
612
- 'description' => __( 'Select redirect to page when user hasn\'t access to the term\'s post', 'ultimate-member' ),
613
- 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
614
- 'options' => array(
615
- '0' => __( 'Login page', 'ultimate-member' ),
616
- '1' => __( 'Custom URL', 'ultimate-member' ),
617
- ),
618
- 'conditional' => array( '_um_noaccess_action', '=', '1' ),
619
- ),
620
- array(
621
- 'id' => '_um_access_redirect_url',
622
- 'type' => 'text',
623
- 'label' => __( 'Redirect URL', 'ultimate-member' ),
624
- 'description' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ),
625
- 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
626
- 'conditional' => array( '_um_access_redirect', '=', '1' ),
627
- ),
628
- ), $data, 'edit' );
629
-
630
- UM()->admin_forms(
631
- array(
632
- 'class' => 'um-restrict-content um-third-column',
633
- 'prefix_id' => 'um_content_restriction',
634
- 'without_wrapper' => true,
635
- 'fields' => $fields,
636
- )
637
- )->render_form();
638
-
639
- wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' );
640
- }
641
-
642
-
643
- /**
644
- * @param $termID
645
- *
646
- * @return mixed
647
- */
648
- function um_category_access_fields_save( $termID ) {
649
-
650
- // validate nonce
651
- if ( ! isset( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'] ) || ! wp_verify_nonce( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'], basename( __FILE__ ) ) ) {
652
- return $termID;
653
- }
654
-
655
- // validate user
656
- $term = get_term( $termID );
657
- $taxonomy = get_taxonomy( $term->taxonomy );
658
-
659
- if ( ! current_user_can( $taxonomy->cap->edit_terms, $termID ) ) {
660
- return $termID;
661
- }
662
-
663
- if ( ! empty( $_REQUEST['um_content_restriction'] ) && is_array( $_REQUEST['um_content_restriction'] ) ) {
664
- $restriction_meta = UM()->admin()->sanitize_term_restriction_meta( $_REQUEST['um_content_restriction'] );
665
-
666
- update_term_meta( $termID, 'um_content_restriction', $restriction_meta );
667
- } else {
668
- delete_term_meta( $termID, 'um_content_restriction' );
669
- }
670
-
671
- return $termID;
672
- }
673
-
674
-
675
- /**
676
- * Load a directory metabox
677
- *
678
- * @param $object
679
- * @param $box
680
- */
681
- function load_metabox_directory( $object, $box ) {
682
- $box['id'] = str_replace( 'um-admin-form-', '', $box['id'] );
683
-
684
- preg_match('#\{.*?\}#s', $box['id'], $matches );
685
-
686
- if ( isset( $matches[0] ) ) {
687
- $path = $matches[0];
688
- $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
689
- } else {
690
- $path = um_path;
691
- }
692
-
693
- $path = str_replace('{','', $path );
694
- $path = str_replace('}','', $path );
695
-
696
-
697
- include_once $path . 'includes/admin/templates/directory/'. $box['id'] . '.php';
698
- if ( ! $this->directory_nonce_added ) {
699
- $this->directory_nonce_added = true;
700
- wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_directory_nonce' );
701
- }
702
- }
703
-
704
-
705
- /**
706
- * Load a role metabox
707
- *
708
- * @param $object
709
- * @param $box
710
- */
711
- function load_metabox_role( $object, $box ) {
712
- global $post;
713
-
714
- $box['id'] = str_replace( 'um-admin-form-', '', $box['id'] );
715
-
716
- if ( $box['id'] == 'builder' ) {
717
- UM()->builder()->form_id = get_the_ID();
718
- }
719
-
720
- preg_match('#\{.*?\}#s', $box['id'], $matches);
721
-
722
- if ( isset($matches[0]) ){
723
- $path = $matches[0];
724
- $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
725
- } else {
726
- $path = um_path;
727
- }
728
-
729
- $path = str_replace('{','', $path );
730
- $path = str_replace('}','', $path );
731
-
732
- include_once $path . 'includes/admin/templates/role/'. $box['id'] . '.php';
733
- //wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_role_nonce' );
734
- }
735
-
736
-
737
- /**
738
- * Load a form metabox
739
- *
740
- * @param $object
741
- * @param $box
742
- */
743
- function load_metabox_form( $object, $box ) {
744
- global $post;
745
-
746
- $box['id'] = str_replace( 'um-admin-form-','', $box['id'] );
747
-
748
- if ( $box['id'] == 'builder' ) {
749
- UM()->builder()->form_id = get_the_ID();
750
- }
751
-
752
- preg_match('#\{.*?\}#s', $box['id'], $matches);
753
-
754
- if ( isset( $matches[0] ) ) {
755
- $path = $matches[0];
756
- $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
757
- } else {
758
- $path = um_path;
759
- }
760
-
761
- $path = str_replace('{','', $path );
762
- $path = str_replace('}','', $path );
763
-
764
- include_once $path . 'includes/admin/templates/form/'. $box['id'] . '.php';
765
-
766
- if ( ! $this->form_nonce_added ) {
767
- $this->form_nonce_added = true;
768
- wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_form_nonce' );
769
- }
770
- }
771
-
772
-
773
- /**
774
- * Load admin custom metabox
775
- *
776
- * @param $object
777
- * @param $box
778
- */
779
- function load_metabox_custom( $object, $box ) {
780
- global $post;
781
-
782
- $box['id'] = str_replace('um-admin-custom-','', $box['id']);
783
-
784
- preg_match('#\{.*?\}#s', $box['id'], $matches);
785
-
786
- if ( isset($matches[0]) ){
787
- $path = $matches[0];
788
- $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
789
- } else {
790
- $path = um_path;
791
- }
792
-
793
- $path = str_replace('{','', $path );
794
- $path = str_replace('}','', $path );
795
-
796
- include_once $path . 'includes/admin/templates/'. $box['id'] . '.php';
797
- if ( ! $this->custom_nonce_added ) {
798
- $this->custom_nonce_added = true;
799
- wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_custom_nonce' );
800
- }
801
- }
802
-
803
-
804
- /**
805
- * Add directory metabox
806
- */
807
- function add_metabox_directory() {
808
- add_meta_box( 'um-admin-form-general', __( 'General Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
809
- add_meta_box( 'um-admin-form-sorting', __( 'Sorting', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
810
- add_meta_box( 'um-admin-form-profile', __( 'Profile Card', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
811
- add_meta_box( 'um-admin-form-search', __( 'Search Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
812
- add_meta_box( 'um-admin-form-pagination', __( 'Results &amp; Pagination', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
813
- add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'side', 'default' );
814
- add_meta_box( 'um-admin-form-appearance', __( 'Styling: General', 'ultimate-member' ), array( &$this, 'load_metabox_directory'), 'um_directory', 'side', 'default' );
815
- }
816
-
817
-
818
- /**
819
- * Add role metabox
820
- */
821
- function add_metabox_role() {
822
- $callback = array( &$this, 'load_metabox_role' );
823
-
824
- $roles_metaboxes = array(
825
- array(
826
- 'id' => 'um-admin-form-admin-permissions',
827
- 'title' => __( 'Administrative Permissions', 'ultimate-member' ),
828
- 'callback' => $callback,
829
- 'screen' => 'um_role_meta',
830
- 'context' => 'normal',
831
- 'priority' => 'default'
832
- ),
833
- array(
834
- 'id' => 'um-admin-form-general',
835
- 'title' => __( 'General Permissions', 'ultimate-member' ),
836
- 'callback' => $callback,
837
- 'screen' => 'um_role_meta',
838
- 'context' => 'normal',
839
- 'priority' => 'default'
840
- ),
841
- array(
842
- 'id' => 'um-admin-form-profile',
843
- 'title' => __( 'Profile Access', 'ultimate-member' ),
844
- 'callback' => $callback,
845
- 'screen' => 'um_role_meta',
846
- 'context' => 'normal',
847
- 'priority' => 'default'
848
- )
849
- );
850
-
851
- if ( ! isset( $_GET['id'] ) || 'administrator' !== sanitize_key( $_GET['id'] ) ) {
852
- $roles_metaboxes[] = array(
853
- 'id' => 'um-admin-form-home',
854
- 'title' => __( 'Homepage Options', 'ultimate-member' ),
855
- 'callback' => $callback,
856
- 'screen' => 'um_role_meta',
857
- 'context' => 'normal',
858
- 'priority' => 'default'
859
- );
860
- }
861
-
862
- $roles_metaboxes = array_merge( $roles_metaboxes, array(
863
- array(
864
- 'id' => 'um-admin-form-register',
865
- 'title' => __( 'Registration Options', 'ultimate-member' ),
866
- 'callback' => $callback,
867
- 'screen' => 'um_role_meta',
868
- 'context' => 'normal',
869
- 'priority' => 'default'
870
- ),
871
- array(
872
- 'id' => 'um-admin-form-login',
873
- 'title' => __( 'Login Options', 'ultimate-member' ),
874
- 'callback' => $callback,
875
- 'screen' => 'um_role_meta',
876
- 'context' => 'normal',
877
- 'priority' => 'default'
878
- ),
879
- array(
880
- 'id' => 'um-admin-form-logout',
881
- 'title' => __( 'Logout Options', 'ultimate-member' ),
882
- 'callback' => $callback,
883
- 'screen' => 'um_role_meta',
884
- 'context' => 'normal',
885
- 'priority' => 'default'
886
- ),
887
- array(
888
- 'id' => 'um-admin-form-delete',
889
- 'title' => __( 'Delete Options', 'ultimate-member' ),
890
- 'callback' => $callback,
891
- 'screen' => 'um_role_meta',
892
- 'context' => 'normal',
893
- 'priority' => 'default'
894
- ),
895
- array(
896
- 'id' => 'um-admin-form-publish',
897
- 'title' => __( 'Publish', 'ultimate-member' ),
898
- 'callback' => $callback,
899
- 'screen' => 'um_role_meta',
900
- 'context' => 'side',
901
- 'priority' => 'default'
902
- )
903
- ) );
904
-
905
- /**
906
- * UM hook
907
- *
908
- * @type filter
909
- * @title um_admin_role_metaboxes
910
- * @description Extend metaboxes at Add/Edit User Role
911
- * @input_vars
912
- * [{"var":"$roles_metaboxes","type":"array","desc":"Metaboxes at Add/Edit UM Role"}]
913
- * @change_log
914
- * ["Since: 2.0"]
915
- * @usage add_filter( 'um_admin_role_metaboxes', 'function_name', 10, 1 );
916
- * @example
917
- * <?php
918
- * add_filter( 'um_admin_role_metaboxes', 'my_admin_role_metaboxes', 10, 1 );
919
- * function my_admin_role_metaboxes( $roles_metaboxes ) {
920
- * // your code here
921
- * $roles_metaboxes[] = array(
922
- * 'id' => 'um-admin-form-your-custom',
923
- * 'title' => __( 'My Roles Metabox', 'ultimate-member' ),
924
- * 'callback' => 'my-metabox-callback',
925
- * 'screen' => 'um_role_meta',
926
- * 'context' => 'side',
927
- * 'priority' => 'default'
928
- * );
929
- *
930
- * return $roles_metaboxes;
931
- * }
932
- * ?>
933
- */
934
- $roles_metaboxes = apply_filters( 'um_admin_role_metaboxes', $roles_metaboxes );
935
-
936
- $wp_caps_metabox = false;
937
- if ( ! empty( $_GET['id'] ) ) {
938
- $data = get_option( 'um_role_' . sanitize_key( $_GET['id'] ) . '_meta' );
939
- if ( ! empty( $data['_um_is_custom'] ) ) {
940
- $wp_caps_metabox = true;
941
- }
942
- }
943
- if ( 'add' == sanitize_key( $_GET['tab'] ) || $wp_caps_metabox ) {
944
- $roles_metaboxes[] = array(
945
- 'id' => 'um-admin-form-wp-capabilities',
946
- 'title' => __( 'WP Capabilities', 'ultimate-member' ),
947
- 'callback' => $callback,
948
- 'screen' => 'um_role_meta',
949
- 'context' => 'normal',
950
- 'priority' => 'default'
951
- );
952
- }
953
-
954
-
955
- foreach ( $roles_metaboxes as $metabox ) {
956
- add_meta_box(
957
- $metabox['id'],
958
- $metabox['title'],
959
- $metabox['callback'],
960
- $metabox['screen'],
961
- $metabox['context'],
962
- $metabox['priority']
963
- );
964
- }
965
- }
966
-
967
-
968
- /**
969
- * Add form metabox
970
- */
971
- function add_metabox_form() {
972
-
973
- add_meta_box( 'um-admin-form-mode', __( 'Select Form Type', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' );
974
- add_meta_box( 'um-admin-form-builder', __( 'Form Builder', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' );
975
- add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
976
-
977
- add_meta_box( 'um-admin-form-register_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
978
-
979
- /**
980
- * UM hook
981
- *
982
- * @type action
983
- * @title um_admin_custom_register_metaboxes
984
- * @description Add custom metaboxes for register form
985
- * @change_log
986
- * ["Since: 2.0"]
987
- * @usage add_action( 'um_admin_custom_register_metaboxes', 'function_name', 10 );
988
- * @example
989
- * <?php
990
- * add_action( 'um_admin_custom_register_metaboxes', 'my_admin_custom_register_metaboxes', 10 );
991
- * function my_admin_custom_register_metaboxes() {
992
- * // your code here
993
- * }
994
- * ?>
995
- */
996
- do_action( 'um_admin_custom_register_metaboxes' );
997
-
998
- add_meta_box( 'um-admin-form-profile_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
999
- add_meta_box( 'um-admin-form-profile_settings', __( 'User Meta', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
1000
-
1001
- /**
1002
- * UM hook
1003
- *
1004
- * @type action
1005
- * @title um_admin_custom_profile_metaboxes
1006
- * @description Add custom metaboxes for profile form
1007
- * @change_log
1008
- * ["Since: 2.0"]
1009
- * @usage add_action( 'um_admin_custom_profile_metaboxes', 'function_name', 10 );
1010
- * @example
1011
- * <?php
1012
- * add_action( 'um_admin_custom_profile_metaboxes', 'my_admin_custom_profile_metaboxes', 10 );
1013
- * function my_admin_custom_profile_metaboxes() {
1014
- * // your code here
1015
- * }
1016
- * ?>
1017
- */
1018
- do_action( 'um_admin_custom_profile_metaboxes' );
1019
-
1020
- add_meta_box( 'um-admin-form-login_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
1021
- add_meta_box( 'um-admin-form-login_settings', __( 'Options', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
1022
-
1023
- /**
1024
- * UM hook
1025
- *
1026
- * @type action
1027
- * @title um_admin_custom_login_metaboxes
1028
- * @description Add custom metaboxes for login form
1029
- * @change_log
1030
- * ["Since: 2.0"]
1031
- * @usage add_action( 'um_admin_custom_login_metaboxes', 'function_name', 10 );
1032
- * @example
1033
- * <?php
1034
- * add_action( 'um_admin_custom_login_metaboxes', 'my_admin_custom_login_metaboxes', 10 );
1035
- * function my_admin_custom_login_metaboxes() {
1036
- * // your code here
1037
- * }
1038
- * ?>
1039
- */
1040
- do_action( 'um_admin_custom_login_metaboxes' );
1041
- }
1042
-
1043
-
1044
- /**
1045
- * Save directory metabox
1046
- *
1047
- * @param $post_id
1048
- * @param $post
1049
- */
1050
- function save_metabox_directory( $post_id, $post ) {
1051
- global $wpdb;
1052
-
1053
- // validate nonce
1054
- if ( ! isset( $_POST['um_admin_save_metabox_directory_nonce'] ) ||
1055
- ! wp_verify_nonce( $_POST['um_admin_save_metabox_directory_nonce'], basename( __FILE__ ) ) ) {
1056
- return;
1057
- }
1058
-
1059
- // validate post type
1060
- if ( $post->post_type != 'um_directory' ) {
1061
- return;
1062
- }
1063
-
1064
- // validate user
1065
- $post_type = get_post_type_object( $post->post_type );
1066
- if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
1067
- return;
1068
- }
1069
-
1070
- $where = array( 'ID' => $post_id );
1071
-
1072
- if ( empty( $_POST['post_title'] ) ) {
1073
- $_POST['post_title'] = sprintf( __( 'Directory #%s', 'ultimate-member' ), $post_id );
1074
- }
1075
-
1076
- $wpdb->update( $wpdb->posts, array( 'post_title' => sanitize_text_field( $_POST['post_title'] ) ), $where );
1077
-
1078
- do_action( 'um_before_member_directory_save', $post_id );
1079
-
1080
- // save
1081
- delete_post_meta( $post_id, '_um_roles' );
1082
- delete_post_meta( $post_id, '_um_tagline_fields' );
1083
- delete_post_meta( $post_id, '_um_reveal_fields' );
1084
- delete_post_meta( $post_id, '_um_search_fields' );
1085
- delete_post_meta( $post_id, '_um_roles_can_search' );
1086
- delete_post_meta( $post_id, '_um_roles_can_filter' );
1087
- delete_post_meta( $post_id, '_um_show_these_users' );
1088
- delete_post_meta( $post_id, '_um_exclude_these_users' );
1089
-
1090
- delete_post_meta( $post_id, '_um_search_filters' );
1091
- delete_post_meta( $post_id, '_um_search_filters_gmt' );
1092
-
1093
- delete_post_meta( $post_id, '_um_sorting_fields' );
1094
-
1095
- //save metadata
1096
- $metadata = UM()->admin()->sanitize_member_directory_meta( $_POST['um_metadata'] );
1097
- foreach ( $metadata as $k => $v ) {
1098
-
1099
- if ( $k == '_um_show_these_users' && trim( $v ) ) {
1100
- $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1101
- }
1102
-
1103
- if ( $k == '_um_exclude_these_users' && trim( $v ) ) {
1104
- $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1105
- }
1106
-
1107
- if ( strstr( $k, '_um_' ) ) {
1108
-
1109
- if ( $k === '_um_is_default' ) {
1110
-
1111
- $mode = UM()->query()->get_attr( 'mode', $post_id );
1112
-
1113
- if ( ! empty( $mode ) ) {
1114
-
1115
- $posts = $wpdb->get_col(
1116
- "SELECT post_id
1117
- FROM {$wpdb->postmeta}
1118
- WHERE meta_key = '_um_mode' AND
1119
- meta_value = 'directory'"
1120
- );
1121
-
1122
- foreach ( $posts as $p_id ) {
1123
- delete_post_meta( $p_id, '_um_is_default' );
1124
- }
1125
-
1126
- }
1127
-
1128
- }
1129
-
1130
- $v = apply_filters( 'um_member_directory_meta_value_before_save', $v, $k, $post_id );
1131
-
1132
- update_post_meta( $post_id, $k, $v );
1133
-
1134
- }
1135
- }
1136
-
1137
- update_post_meta( $post_id, '_um_search_filters_gmt', (int) $_POST['um-gmt-offset'] );
1138
- }
1139
-
1140
-
1141
- /**
1142
- * Save form metabox
1143
- *
1144
- * @param $post_id
1145
- * @param $post
1146
- */
1147
- function save_metabox_form( $post_id, $post ) {
1148
- global $wpdb;
1149
-
1150
- // validate nonce
1151
- if ( ! isset( $_POST['um_admin_save_metabox_form_nonce'] ) ||
1152
- ! wp_verify_nonce( $_POST['um_admin_save_metabox_form_nonce'], basename( __FILE__ ) ) ) {
1153
- return;
1154
- }
1155
-
1156
- // validate post type
1157
- if ( $post->post_type != 'um_form' ) {
1158
- return;
1159
- }
1160
-
1161
- // validate user
1162
- $post_type = get_post_type_object( $post->post_type );
1163
- if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
1164
- return;
1165
- }
1166
-
1167
- $where = array( 'ID' => $post_id );
1168
- if ( empty( $_POST['post_title'] ) ) {
1169
- $_POST['post_title'] = sprintf( __( 'Form #%s', 'ultimate-member' ), $post_id );
1170
- }
1171
- $wpdb->update( $wpdb->posts, array( 'post_title' => sanitize_text_field( $_POST['post_title'] ) ), $where );
1172
-
1173
- // save
1174
- delete_post_meta( $post_id, '_um_profile_metafields' );
1175
-
1176
- $form_meta = UM()->admin()->sanitize_form_meta( $_POST['form'] );
1177
-
1178
- foreach ( $form_meta as $k => $v ) {
1179
- if ( strstr( $k, '_um_' ) ) {
1180
- if ( $k === '_um_is_default' ) {
1181
- $mode = UM()->query()->get_attr( 'mode', $post_id );
1182
- if ( ! empty( $mode ) ) {
1183
- $posts = $wpdb->get_col( $wpdb->prepare(
1184
- "SELECT post_id
1185
- FROM {$wpdb->postmeta}
1186
- WHERE meta_key = '_um_mode' AND
1187
- meta_value = %s",
1188
- $mode
1189
- ) );
1190
- foreach ( $posts as $p_id ) {
1191
- delete_post_meta( $p_id, '_um_is_default' );
1192
- }
1193
- }
1194
- }
1195
-
1196
- update_post_meta( $post_id, $k, $v );
1197
- }
1198
- }
1199
-
1200
- }
1201
-
1202
-
1203
- /**
1204
- * Load modal content
1205
- */
1206
- function load_modal_content() {
1207
- $screen = get_current_screen();
1208
-
1209
- if ( isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) {
1210
- foreach ( glob( um_path . 'includes/admin/templates/modal/forms/*.php' ) as $modal_content ) {
1211
- include_once $modal_content;
1212
- }
1213
- }
1214
-
1215
- if ( $this->init_icon ) {
1216
- include_once um_path . 'includes/admin/templates/modal/forms/fonticons.php';
1217
- }
1218
-
1219
- if ( $screen->id == 'users' ) {
1220
- include_once um_path . 'includes/admin/templates/modal/dynamic_registration_preview.php';
1221
- }
1222
-
1223
- // needed on forms only
1224
- if ( ! isset( $this->is_loaded ) && isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) {
1225
- $settings['textarea_rows'] = 8;
1226
-
1227
- echo '<div class="um-hidden-editor-edit" style="display:none;">';
1228
- wp_editor( '', 'um_editor_edit', $settings );
1229
- echo '</div>';
1230
-
1231
- echo '<div class="um-hidden-editor-new" style="display:none;">';
1232
- wp_editor( '', 'um_editor_new', $settings );
1233
- echo '</div>';
1234
-
1235
- $this->is_loaded = true;
1236
- }
1237
- }
1238
-
1239
-
1240
- /**
1241
- * Show field input for edit at modal field
1242
- *
1243
- * @param $attribute
1244
- * @param null $form_id
1245
- * @param array $field_args
1246
- */
1247
- function field_input( $attribute, $form_id = null, $field_args = array() ) {
1248
-
1249
- if ( $this->in_edit == true ) { // we're editing a field
1250
- $real_attr = substr( $attribute, 1 );
1251
- $this->edit_mode_value = isset( $this->edit_array[ $real_attr ] ) ? $this->edit_array[ $real_attr ] : null;
1252
- }
1253
-
1254
- switch ( $attribute ) {
1255
-
1256
- default:
1257
-
1258
- /**
1259
- * UM hook
1260
- *
1261
- * @type action
1262
- * @title um_admin_field_edit_hook{$attribute}
1263
- * @description Integration for 3-d party fields at wp-admin
1264
- * @input_vars
1265
- * [{"var":"$edit_mode_value","type":"string","desc":"Post ID"}]
1266
- * @change_log
1267
- * ["Since: 2.0"]
1268
- * @usage add_action( 'um_admin_field_edit_hook{$attribute}', 'function_name', 10, 1 );
1269
- * @example
1270
- * <?php
1271
- * add_action( 'um_admin_field_edit_hook{$attribute}', 'my_admin_field_edit', 10, 1 );
1272
- * function my_admin_field_edit( $edit_mode_value ) {
1273
- * // your code here
1274
- * }
1275
- * ?>
1276
- */
1277
- do_action( "um_admin_field_edit_hook{$attribute}", $this->edit_mode_value, $form_id, $this->edit_array );
1278
-
1279
- break;
1280
-
1281
- case '_visibility':
1282
- ?>
1283
-
1284
- <p><label for="_visibility"><?php _e( 'Visibility', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select where this field should appear. This option should only be changed on the profile form and allows you to show a field in one mode only (edit or view) or in both modes.','ultimate-member' ) ); ?></label>
1285
- <select name="_visibility" id="_visibility" style="width: 100%">
1286
- <option value="all" <?php selected( 'all', $this->edit_mode_value ); ?>><?php _e( 'View everywhere', 'ultimate-member' ) ?></option>
1287
- <option value="edit" <?php selected( 'edit', $this->edit_mode_value ); ?>><?php _e( 'Edit mode only', 'ultimate-member' ) ?></option>
1288
- <option value="view" <?php selected( 'view', $this->edit_mode_value ); ?>><?php _e( 'View mode only', 'ultimate-member' ) ?></option>
1289
- </select>
1290
- </p>
1291
-
1292
- <?php
1293
- break;
1294
-
1295
- case '_conditional_action':
1296
- case '_conditional_action1':
1297
- case '_conditional_action2':
1298
- case '_conditional_action3':
1299
- case '_conditional_action4':
1300
- ?>
1301
-
1302
- <p>
1303
- <select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 90px">
1304
-
1305
- <option></option>
1306
-
1307
- <?php $actions = array( 'show', 'hide' );
1308
- foreach ( $actions as $action ) { ?>
1309
-
1310
- <option value="<?php echo esc_attr( $action ); ?>" <?php selected( $action, $this->edit_mode_value ); ?>><?php echo $action; ?></option>
1311
-
1312
- <?php } ?>
1313
-
1314
- </select>
1315
-
1316
- &nbsp;&nbsp;<?php _e( 'If' ); ?>
1317
- </p>
1318
-
1319
- <?php
1320
- break;
1321
-
1322
- case '_conditional_field':
1323
- case '_conditional_field1':
1324
- case '_conditional_field2':
1325
- case '_conditional_field3':
1326
- case '_conditional_field4':
1327
- ?>
1328
-
1329
- <p>
1330
- <select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 150px">
1331
-
1332
- <option></option>
1333
-
1334
- <?php $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
1335
-
1336
- foreach ( $fields as $key => $array ) {
1337
- if ( isset( $array['title'] ) &&
1338
- ( ! isset( $this->edit_array['metakey'] ) || $key != $this->edit_array['metakey'] ) ) { ?>
1339
-
1340
- <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $key, $this->edit_mode_value ) ?>><?php echo $array['title'] ?></option>
1341
-
1342
- <?php }
1343
- } ?>
1344
-
1345
- </select>
1346
- </p>
1347
-
1348
- <?php
1349
- break;
1350
-
1351
- case '_conditional_operator':
1352
- case '_conditional_operator1':
1353
- case '_conditional_operator2':
1354
- case '_conditional_operator3':
1355
- case '_conditional_operator4':
1356
- ?>
1357
-
1358
- <p>
1359
- <select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 150px">
1360
-
1361
- <option></option>
1362
-
1363
- <?php $operators = array(
1364
- 'empty',
1365
- 'not empty',
1366
- 'equals to',
1367
- 'not equals',
1368
- 'greater than',
1369
- 'less than',
1370
- 'contains'
1371
- );
1372
-
1373
- foreach ( $operators as $operator ) { ?>
1374
-
1375
- <option value="<?php echo esc_attr( $operator ); ?>" <?php selected( $operator, $this->edit_mode_value ); ?>><?php echo $operator; ?></option>
1376
-
1377
- <?php } ?>
1378
-
1379
- </select>
1380
- </p>
1381
-
1382
- <?php
1383
- break;
1384
-
1385
- case '_conditional_value':
1386
- case '_conditional_value1':
1387
- case '_conditional_value2':
1388
- case '_conditional_value3':
1389
- case '_conditional_value4':
1390
- ?>
1391
-
1392
- <p>
1393
- <input type="text" name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" value="<?php echo isset( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" placeholder="<?php esc_attr_e( 'Value', 'ultimate-member' ); ?>" style="width: 150px!important;position: relative;top: -1px;" />
1394
- </p>
1395
-
1396
- <?php
1397
- break;
1398
-
1399
- case '_validate':
1400
- ?>
1401
-
1402
- <p><label for="_validate"><?php _e( 'Validate', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Does this field require a special validation', 'ultimate-member' ) ); ?></label>
1403
- <select name="_validate" id="_validate" data-placeholder="<?php esc_attr_e( 'Select a validation type...', 'ultimate-member' ) ?>" class="um-adm-conditional" data-cond1="custom" data-cond1-show="_custom_validate" style="width: 100%">
1404
-
1405
- <option value="" <?php selected( '', $this->edit_mode_value ); ?>></option>
1406
-
1407
- <?php foreach( UM()->builtin()->validation_types() as $key => $name ) { ?>
1408
- <?php
1409
- /**
1410
- * UM hook
1411
- *
1412
- * @type filter
1413
- * @title um_builtin_validation_types_continue_loop
1414
- * @description Builtin Validation Types
1415
- * @input_vars
1416
- * [{"var":"$continue","type":"bool","desc":"Validate?"},
1417
- * {"var":"$key","type":"string","desc":"Field Key"},
1418
- * {"var":"$form_id","type":"int","desc":"Form ID"},
1419
- * {"var":"$field_args","type":"array","desc":"Field Settings"}]
1420
- * @change_log
1421
- * ["Since: 2.0"]
1422
- * @usage add_filter( 'um_builtin_validation_types_continue_loop', 'function_name', 10, 4 );
1423
- * @example
1424
- * <?php
1425
- * add_filter( 'um_builtin_validation_types_continue_loop', 'my_builtin_validation_types', 10, 4 );
1426
- * function my_builtin_validation_types( $continue, $key, $form_id, $field_args ) {
1427
- * // your code here
1428
- * return $continue;
1429
- * }
1430
- * ?>
1431
- */
1432
- $continue = apply_filters( "um_builtin_validation_types_continue_loop", true, $key, $form_id, $field_args );
1433
- if ( $continue ) { ?>
1434
- <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $this->edit_mode_value ); ?>><?php echo $name; ?></option>
1435
- <?php } ?>
1436
- <?php } ?>
1437
-
1438
- </select>
1439
- </p>
1440
-
1441
- <?php
1442
- break;
1443
-
1444
- case '_custom_validate':
1445
- ?>
1446
-
1447
- <p class="_custom_validate"><label for="_custom_validate"><?php _e( 'Custom Action', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to apply your custom validation, you can use action hooks to add custom validation. Please refer to documentation for further details.', 'ultimate-member' ) ); ?></label>
1448
- <input type="text" name="_custom_validate" id="_custom_validate" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1449
- </p>
1450
-
1451
- <?php
1452
- break;
1453
-
1454
- case '_icon':
1455
-
1456
- if ( $this->set_field_type == 'row' ) {
1457
- $back = 'UM_edit_row';
1458
-
1459
- ?>
1460
-
1461
- <p class="_heading_text"><label for="_icon"><?php _e( 'Icon', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
1462
-
1463
- <a href="javascript:void(0);" class="button" data-modal="UM_fonticons" data-modal-size="normal" data-dynamic-content="um_admin_fonticon_selector" data-arg1="" data-arg2="" data-back="<?php echo esc_attr( $back ); ?>"><?php _e( 'Choose Icon', 'ultimate-member' ) ?></a>
1464
-
1465
- <span class="um-admin-icon-value"><?php if ( $this->edit_mode_value ) { ?><i class="<?php echo $this->edit_mode_value; ?>"></i><?php } else { ?><?php _e( 'No Icon', 'ultimate-member' ) ?><?php } ?></span>
1466
-
1467
- <input type="hidden" name="_icon" id="_icon" value="<?php echo (isset( $this->edit_mode_value ) ) ? $this->edit_mode_value : ''; ?>" />
1468
-
1469
- <?php if ( $this->edit_mode_value ) { ?>
1470
- <span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>
1471
- <?php } else { ?>
1472
- <span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>
1473
- <?php } ?>
1474
-
1475
- </p>
1476
-
1477
- <?php } else {
1478
-
1479
- if ( $this->in_edit ) {
1480
- $back = 'UM_edit_field';
1481
- } else {
1482
- $back = 'UM_add_field';
1483
- }
1484
-
1485
- ?>
1486
-
1487
- <div class="um-admin-tri">
1488
-
1489
- <p><label for="_icon"><?php _e( 'Icon', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
1490
-
1491
- <a href="javascript:void(0);" class="button" data-modal="UM_fonticons" data-modal-size="normal" data-dynamic-content="um_admin_fonticon_selector" data-arg1="" data-arg2="" data-back="<?php echo esc_attr( $back ); ?>"><?php _e( 'Choose Icon', 'ultimate-member' ) ?></a>
1492
-
1493
- <span class="um-admin-icon-value"><?php if ( $this->edit_mode_value ) { ?><i class="<?php echo $this->edit_mode_value; ?>"></i><?php } else { ?><?php _e( 'No Icon', 'ultimate-member' ) ?><?php } ?></span>
1494
-
1495
- <input type="hidden" name="_icon" id="_icon" value="<?php echo (isset( $this->edit_mode_value ) ) ? $this->edit_mode_value : ''; ?>" />
1496
-
1497
- <?php if ( $this->edit_mode_value ) { ?>
1498
- <span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>
1499
- <?php } else { ?>
1500
- <span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>
1501
- <?php } ?>
1502
-
1503
- </p>
1504
-
1505
- </div>
1506
-
1507
- <?php
1508
-
1509
- }
1510
-
1511
- break;
1512
-
1513
- case '_css_class':
1514
- ?>
1515
-
1516
- <p><label for="_css_class"><?php _e( 'CSS Class', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Specify a custom CSS class to be applied to this element', 'ultimate-member' ) ); ?></label>
1517
- <input type="text" name="_css_class" id="_css_class" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1518
- </p>
1519
-
1520
- <?php
1521
- break;
1522
-
1523
- case '_width':
1524
- ?>
1525
-
1526
- <p><label for="_width"><?php _e( 'Thickness (in pixels)', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the width in pixels, e.g. 4 or 2, etc', 'ultimate-member' ) ); ?></label>
1527
- <input type="text" name="_width" id="_width" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 4; ?>" />
1528
- </p>
1529
-
1530
- <?php
1531
- break;
1532
-
1533
- case '_divider_text':
1534
- ?>
1535
-
1536
- <p><label for="_divider_text"><?php _e( 'Optional Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Optional text to include with the divider', 'ultimate-member' ) ); ?></label>
1537
- <input type="text" name="_divider_text" id="_divider_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1538
- </p>
1539
-
1540
- <?php
1541
- break;
1542
-
1543
- case '_padding':
1544
- ?>
1545
-
1546
- <p><label for="_padding"><?php _e( 'Padding', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set padding for this section', 'ultimate-member' ) ); ?></label>
1547
- <input type="text" name="_padding" id="_padding" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 0px 0px'; ?>" />
1548
- </p>
1549
-
1550
- <?php
1551
- break;
1552
-
1553
- case '_margin':
1554
- ?>
1555
-
1556
- <p><label for="_margin"><?php _e( 'Margin', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set margin for this section', 'ultimate-member' ) ); ?></label>
1557
- <input type="text" name="_margin" id="_margin" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 30px 0px'; ?>" />
1558
- </p>
1559
-
1560
- <?php
1561
- break;
1562
-
1563
- case '_border':
1564
- ?>
1565
-
1566
- <p><label for="_border"><?php _e( 'Border', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set border for this section', 'ultimate-member' ) ); ?></label>
1567
- <input type="text" name="_border" id="_border" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 0px 0px'; ?>" />
1568
- </p>
1569
-
1570
- <?php
1571
- break;
1572
-
1573
- case '_borderstyle':
1574
- ?>
1575
-
1576
- <p><label for="_borderstyle"><?php _e( 'Style', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the border style', 'ultimate-member' ) ); ?></label>
1577
- <select name="_borderstyle" id="_borderstyle" style="width: 100%">
1578
- <option value="solid" <?php selected( 'solid', $this->edit_mode_value ); ?>><?php _e( 'Solid', 'ultimate-member' ) ?></option>
1579
- <option value="dotted" <?php selected( 'dotted', $this->edit_mode_value ); ?>><?php _e( 'Dotted', 'ultimate-member' ) ?></option>
1580
- <option value="dashed" <?php selected( 'dashed', $this->edit_mode_value ); ?>><?php _e( 'Dashed', 'ultimate-member' ) ?></option>
1581
- <option value="double" <?php selected( 'double', $this->edit_mode_value ); ?>><?php _e( 'Double', 'ultimate-member' ) ?></option>
1582
- </select>
1583
- </p>
1584
-
1585
- <?php
1586
- break;
1587
-
1588
- case '_borderradius':
1589
- ?>
1590
-
1591
- <p><label for="_borderradius"><?php _e( 'Border Radius', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Rounded corners can be applied by setting a pixels value here. e.g. 5px', 'ultimate-member' ) ); ?></label>
1592
- <input type="text" name="_borderradius" id="_borderradius" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px'; ?>" />
1593
- </p>
1594
-
1595
- <?php
1596
- break;
1597
-
1598
- case '_bordercolor':
1599
- ?>
1600
-
1601
- <p><label for="_bordercolor"><?php _e( 'Border Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Give a color to this border', 'ultimate-member' ) ); ?></label>
1602
- <input type="text" name="_bordercolor" id="_bordercolor" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1603
- </p>
1604
-
1605
- <?php
1606
- break;
1607
-
1608
- case '_heading':
1609
- ?>
1610
-
1611
- <p><label for="_heading"><?php _e( 'Enable Row Heading', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to enable a heading for this row', 'ultimate-member' ) ); ?></label>
1612
- <input type="checkbox" name="_heading" id="_heading" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_heading_text" data-cond1-hide="xxx" />
1613
- </p>
1614
-
1615
- <?php
1616
- break;
1617
-
1618
- case '_heading_text':
1619
- ?>
1620
-
1621
- <p class="_heading_text"><label for="_heading_text"><?php _e( 'Heading Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter the row heading text here', 'ultimate-member' ) ); ?></label>
1622
- <input type="text" name="_heading_text" id="_heading_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1623
- </p>
1624
-
1625
- <?php
1626
- break;
1627
-
1628
- case '_background':
1629
- ?>
1630
-
1631
- <p><label for="_background"><?php _e( 'Background Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the background of entire section', 'ultimate-member' ) ); ?></label>
1632
- <input type="text" name="_background" id="_background" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1633
- </p>
1634
-
1635
- <?php
1636
- break;
1637
-
1638
- case '_heading_background_color':
1639
- ?>
1640
-
1641
- <p class="_heading_text"><label for="_heading_background_color"><?php _e( 'Heading Background Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the background of the heading section', 'ultimate-member' ) ); ?></label>
1642
- <input type="text" name="_heading_background_color" id="_heading_background_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1643
- </p>
1644
-
1645
- <?php
1646
- break;
1647
-
1648
- case '_heading_text_color':
1649
- ?>
1650
-
1651
- <p class="_heading_text"><label for="_heading_text_color"><?php _e( 'Heading Text Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the text color of heading part only', 'ultimate-member' ) ); ?></label>
1652
- <input type="text" name="_heading_text_color" id="_heading_text_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1653
- </p>
1654
-
1655
- <?php
1656
- break;
1657
-
1658
- case '_text_color':
1659
- ?>
1660
-
1661
- <p><label for="_text_color"><?php _e( 'Text Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the text color of entire section', 'ultimate-member' ) ); ?></label>
1662
- <input type="text" name="_text_color" id="_text_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1663
- </p>
1664
-
1665
- <?php
1666
- break;
1667
-
1668
- case '_icon_color':
1669
- ?>
1670
-
1671
- <p class="_heading_text"><label for="_icon_color"><?php _e( 'Icon Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the color of selected icon. By default It will be the same color as heading text color', 'ultimate-member' ) ); ?></label>
1672
- <input type="text" name="_icon_color" id="_icon_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1673
- </p>
1674
-
1675
- <?php
1676
- break;
1677
-
1678
- case '_color':
1679
- ?>
1680
-
1681
- <p><label for="_color"><?php _e( 'Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select a color for this divider', 'ultimate-member' ) ); ?></label>
1682
- <input type="text" name="_color" id="_color" class="um-admin-colorpicker" data-default-color="#eeeeee" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '#eeeeee'; ?>" />
1683
- </p>
1684
-
1685
- <?php
1686
- break;
1687
-
1688
- case '_url_text':
1689
- ?>
1690
-
1691
- <p><label for="_url_text"><?php _e( 'URL Alt Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Entering custom text here will replace the url with a text link', 'ultimate-member' ) ); ?></label>
1692
- <input type="text" name="_url_text" id="_url_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1693
- </p>
1694
-
1695
- <?php
1696
- break;
1697
-
1698
- case '_url_target':
1699
- ?>
1700
-
1701
- <p><label for="_url_target"><?php _e( 'Link Target', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose whether to open this link in same window or in a new window', 'ultimate-member' ) ); ?></label>
1702
- <select name="_url_target" id="_url_target" style="width: 100%">
1703
- <option value="_blank" <?php selected( '_blank', $this->edit_mode_value ); ?>><?php _e( 'Open in new window', 'ultimate-member' ) ?></option>
1704
- <option value="_self" <?php selected( '_self', $this->edit_mode_value ); ?>><?php _e( 'Same window', 'ultimate-member' ) ?></option>
1705
- </select>
1706
- </p>
1707
-
1708
- <?php
1709
- break;
1710
-
1711
- case '_url_rel':
1712
- ?>
1713
-
1714
- <p><label for="_url_rel"><?php _e( 'SEO Follow', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to follow or nofollow this link by search engines', 'ultimate-member' ) ); ?></label>
1715
- <select name="_url_rel" id="_url_rel" style="width: 100%">
1716
- <option value="follow" <?php selected( 'follow', $this->edit_mode_value ); ?>><?php _e( 'Follow', 'ultimate-member' ) ?></option>
1717
- <option value="nofollow" <?php selected( 'nofollow', $this->edit_mode_value ); ?>><?php _e( 'No-Follow', 'ultimate-member' ) ?></option>
1718
- </select>
1719
- </p>
1720
-
1721
- <?php
1722
- break;
1723
-
1724
- case '_force_good_pass':
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 : 0 ) ?> />
1729
- </p>
1730
-
1731
- <?php
1732
- break;
1733
-
1734
- case '_force_confirm_pass':
1735
- ?>
1736
-
1737
- <p><label for="_force_confirm_pass"><?php _e( 'Automatically add a confirm password field?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on to add a confirm password field. If turned on the confirm password field will only show on register forms and not on login forms.', 'ultimate-member' ) ); ?></label>
1738
- <input type="checkbox" name="_force_confirm_pass" id="_force_confirm_pass" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_label_confirm_pass" data-cond1-hide="xxx" />
1739
- </p>
1740
-
1741
- <?php
1742
- break;
1743
-
1744
- case '_style':
1745
- ?>
1746
-
1747
- <p><label for="_style"><?php _e( 'Style', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the line-style of divider', 'ultimate-member' ) ); ?></label>
1748
- <select name="_style" id="_style" style="width: 100%">
1749
- <option value="solid" <?php selected( 'solid', $this->edit_mode_value ); ?>><?php _e( 'Solid', 'ultimate-member' ) ?></option>
1750
- <option value="dotted" <?php selected( 'dotted', $this->edit_mode_value ); ?>><?php _e( 'Dotted', 'ultimate-member' ) ?></option>
1751
- <option value="dashed" <?php selected( 'dashed', $this->edit_mode_value ); ?>><?php _e( 'Dashed', 'ultimate-member' ) ?></option>
1752
- <option value="double" <?php selected( 'double', $this->edit_mode_value ); ?>><?php _e( 'Double', 'ultimate-member' ) ?></option>
1753
- </select>
1754
- </p>
1755
-
1756
- <?php
1757
- break;
1758
-
1759
- case '_intervals':
1760
-
1761
- ?>
1762
-
1763
- <p><label for="_intervals"><?php _e( 'Time Intervals (in minutes)', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the minutes interval between each time in the time picker.', 'ultimate-member' ) ); ?></label>
1764
- <input type="text" name="_intervals" id="_intervals" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 60; ?>" placeholder="<?php esc_attr_e( 'e.g. 30, 60, 120', 'ultimate-member' ) ?>" />
1765
- </p>
1766
-
1767
- <?php
1768
- break;
1769
-
1770
-
1771
- case '_format':
1772
-
1773
- if ( $this->set_field_type == 'date' ) {
1774
- ?>
1775
-
1776
- <p><label for="_format"><?php _e( 'Date User-Friendly Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The display format of the date which is visible to user.', 'ultimate-member' ) ); ?></label>
1777
- <select name="_format" id="_format" style="width: 100%">
1778
- <option value="j M Y" <?php selected( 'j M Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('j M Y'); ?></option>
1779
- <option value="M j Y" <?php selected( 'M j Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('M j Y'); ?></option>
1780
- <option value="j F Y" <?php selected( 'j F Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('j F Y'); ?></option>
1781
- <option value="F j Y" <?php selected( 'F j Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('F j Y'); ?></option>
1782
- </select>
1783
- </p>
1784
-
1785
- <?php } else { ?>
1786
-
1787
- <p><label for="_format"><?php _e( 'Time Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the displayed time-format for this field', 'ultimate-member' ) ); ?></label>
1788
- <select name="_format" id="_format" style="width: 100%">
1789
- <option value="g:i a" <?php selected( 'g:i a', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('g:i a'); ?><?php _e( '( 12-hr format )', 'ultimate-member' ) ?></option>
1790
- <option value="g:i A" <?php selected( 'g:i A', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('g:i A'); ?><?php _e( '( 12-hr format )', 'ultimate-member' ) ?></option>
1791
- <option value="H:i" <?php selected( 'H:i', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('H:i'); ?><?php _e( '( 24-hr format )', 'ultimate-member' ) ?></option>
1792
- </select>
1793
- </p>
1794
-
1795
- <?php
1796
- }
1797
- break;
1798
-
1799
- case '_format_custom':
1800
- ?>
1801
-
1802
- <p><label for="_format_custom"><?php _e( 'Use custom Date format', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'This option overrides "Date User-Friendly Format" option. See https://www.php.net/manual/en/function.date.php', 'ultimate-member' ) ); ?></label>
1803
- <input type="text" name="_format_custom" id="_format_custom" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" placeholder="j M Y" />
1804
- </p>
1805
-
1806
- <?php
1807
- break;
1808
-
1809
- case '_pretty_format':
1810
- ?>
1811
-
1812
- <p><label for="_pretty_format"><?php _e( 'Displayed Date Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether you wish to show the date in full or only show the years e.g. 25 Years', 'ultimate-member' ) ); ?></label>
1813
- <select name="_pretty_format" id="_pretty_format" style="width: 100%">
1814
- <option value="0" <?php selected( 0, $this->edit_mode_value ); ?>><?php _e( 'Show full date', 'ultimate-member' ) ?></option>
1815
- <option value="1" <?php selected( 1, $this->edit_mode_value ); ?>><?php _e( 'Show years only', 'ultimate-member' ) ?></option>
1816
- </select>
1817
- </p>
1818
-
1819
- <?php
1820
- break;
1821
-
1822
- case '_disabled_weekdays':
1823
-
1824
- if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
1825
- $values = $this->edit_mode_value;
1826
- } else {
1827
- $values = array('');
1828
- }
1829
- ?>
1830
-
1831
- <p><label for="_disabled_weekdays"><?php _e( 'Disable specific weekdays', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Disable specific week days from being available for selection in this date picker', 'ultimate-member' ) ); ?></label>
1832
- <select name="_disabled_weekdays[]" id="_disabled_weekdays" multiple="multiple" style="width: 100%">
1833
- <option value="1" <?php if ( in_array( 1, $values ) ) { echo 'selected'; } ?>><?php _e( 'Sunday', 'ultimate-member' ) ?></option>
1834
- <option value="2" <?php if ( in_array( 2, $values ) ) { echo 'selected'; } ?>><?php _e( 'Monday', 'ultimate-member' ) ?></option>
1835
- <option value="3" <?php if ( in_array( 3, $values ) ) { echo 'selected'; } ?>><?php _e( 'Tuesday', 'ultimate-member' ) ?></option>
1836
- <option value="4" <?php if ( in_array( 4, $values ) ) { echo 'selected'; } ?>><?php _e( 'Wednesday', 'ultimate-member' ) ?></option>
1837
- <option value="5" <?php if ( in_array( 5, $values ) ) { echo 'selected'; } ?>><?php _e( 'Thursday', 'ultimate-member' ) ?></option>
1838
- <option value="6" <?php if ( in_array( 6, $values ) ) { echo 'selected'; } ?>><?php _e( 'Friday', 'ultimate-member' ) ?></option>
1839
- <option value="7" <?php if ( in_array( 7, $values ) ) { echo 'selected'; } ?>><?php _e( 'Saturday', 'ultimate-member' ) ?></option>
1840
- </select>
1841
- </p>
1842
-
1843
- <?php
1844
- break;
1845
-
1846
- case '_years':
1847
- ?>
1848
-
1849
- <p class="_years"><label for="_years"><?php _e( 'Number of Years to pick from', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Number of years available for the date selection. Default to last 50 years', 'ultimate-member' ) ); ?></label>
1850
- <input type="text" name="_years" id="_years" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 50; ?>" />
1851
- </p>
1852
-
1853
- <?php
1854
- break;
1855
-
1856
- case '_years_x':
1857
- ?>
1858
-
1859
- <p class="_years"><label for="_years_x"><?php _e( 'Years Selection', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This decides which years should be shown relative to today date', 'ultimate-member' ) ); ?></label>
1860
- <select name="_years_x" id="_years_x" style="width: 100%">
1861
- <option value="equal" <?php selected( 'equal', $this->edit_mode_value ); ?>><?php _e( 'Equal years before / after today', 'ultimate-member' ) ?></option>
1862
- <option value="past" <?php selected( 'past', $this->edit_mode_value ); ?>><?php _e( 'Past years only', 'ultimate-member' ) ?></option>
1863
- <option value="future" <?php selected( 'future', $this->edit_mode_value ); ?>><?php _e( 'Future years only', 'ultimate-member' ) ?></option>
1864
- </select>
1865
- </p>
1866
-
1867
- <?php
1868
- break;
1869
-
1870
- case '_range_start':
1871
- ?>
1872
-
1873
- <p class="_date_range"><label for="_range_start"><?php _e( 'Date Range Start', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set the minimum date/day in range in the format YYYY/MM/DD', 'ultimate-member' ) ); ?></label>
1874
- <input type="text" name="_range_start" id="_range_start" value="<?php echo $this->edit_mode_value; ?>" placeholder="<?php esc_attr_e( 'YYYY/MM/DD', 'ultimate-member' ) ?>" />
1875
- </p>
1876
-
1877
- <?php
1878
- break;
1879
-
1880
- case '_range_end':
1881
- ?>
1882
-
1883
- <p class="_date_range"><label for="_range_end"><?php _e( 'Date Range End', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set the maximum date/day in range in the format YYYY/MM/DD', 'ultimate-member' ) ); ?></label>
1884
- <input type="text" name="_range_end" id="_range_end" value="<?php echo $this->edit_mode_value; ?>" placeholder="<?php esc_attr_e( 'YYYY/MM/DD', 'ultimate-member' ) ?>" />
1885
- </p>
1886
-
1887
- <?php
1888
- break;
1889
-
1890
- case '_range':
1891
- ?>
1892
-
1893
- <p><label for="_range"><?php _e( 'Set Date Range', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to show a specific number of years or specify a date range to be available for the date picker.', 'ultimate-member' ) ); ?></label>
1894
- <select name="_range" id="_range" class="um-adm-conditional" data-cond1='years' data-cond1-show='_years' data-cond2="date_range" data-cond2-show="_date_range" style="width: 100%">
1895
- <option value="years" <?php selected( 'years', $this->edit_mode_value ); ?>><?php _e( 'Fixed Number of Years', 'ultimate-member' ) ?></option>
1896
- <option value="date_range" <?php selected( 'date_range', $this->edit_mode_value ); ?>><?php _e( 'Specific Date Range', 'ultimate-member' ) ?></option>
1897
- </select>
1898
- </p>
1899
-
1900
- <?php
1901
- break;
1902
-
1903
- case '_content':
1904
-
1905
- if ( $this->set_field_type == 'shortcode' ) {
1906
-
1907
- ?>
1908
-
1909
- <p><label for="_content"><?php _e( 'Enter Shortcode', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter the shortcode in the following textarea and it will be displayed on the fields', 'ultimate-member' ) ); ?></label>
1910
- <textarea name="_content" id="_content" placeholder="<?php esc_attr_e( 'e.g. [my_custom_shortcode]', 'ultimate-member' ) ?>"><?php echo $this->edit_mode_value; ?></textarea>
1911
- </p>
1912
-
1913
- <?php
1914
-
1915
- } else {
1916
-
1917
- ?>
1918
-
1919
- <div class="um-admin-editor-h"><label><?php _e( 'Content Editor', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Edit the content of this field here', 'ultimate-member' ) ); ?></label></div>
1920
-
1921
- <div class="um-admin-editor"><!-- editor dynamically loaded here --></div>
1922
-
1923
- <?php
1924
-
1925
- }
1926
-
1927
- break;
1928
-
1929
- case '_crop':
1930
- ?>
1931
-
1932
- <p><label for="_crop"><?php _e( 'Crop Feature', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enable/disable crop feature for this image upload and define ratio', 'ultimate-member' ) ); ?></label>
1933
- <select name="_crop" id="_crop" style="width: 100%">
1934
- <option value="0" <?php selected( '0', $this->edit_mode_value ); ?>><?php _e( 'Turn Off (Default)', 'ultimate-member' ) ?></option>
1935
- <option value="1" <?php selected( '1', $this->edit_mode_value ); ?>><?php _e( 'Crop and force 1:1 ratio', 'ultimate-member' ) ?></option>
1936
- <option value="3" <?php selected( '3', $this->edit_mode_value ); ?>><?php _e( 'Crop and force user-defined ratio', 'ultimate-member' ) ?></option>
1937
- </select>
1938
- </p>
1939
-
1940
- <?php
1941
- break;
1942
-
1943
- case '_allowed_types':
1944
-
1945
- if ( $this->set_field_type == 'image' ) {
1946
-
1947
- if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
1948
- $values = $this->edit_mode_value;
1949
- } else {
1950
- $values = array( 'png','jpeg','jpg','gif' );
1951
- } ?>
1952
-
1953
- <p><label for="_allowed_types"><?php _e( 'Allowed Image Types', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the image types that you want to allow to be uploaded via this field.', 'ultimate-member' ) ); ?></label>
1954
- <select name="_allowed_types[]" id="_allowed_types" multiple="multiple" style="width: 100%">
1955
- <?php foreach( UM()->files()->allowed_image_types() as $e => $n ) { ?>
1956
- <option value="<?php echo $e; ?>" <?php if ( in_array( $e, $values ) ) { echo 'selected'; } ?>><?php echo $n; ?></option>
1957
- <?php } ?>
1958
- </select>
1959
- </p>
1960
-
1961
- <?php
1962
-
1963
- } else {
1964
-
1965
- if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
1966
- $values = $this->edit_mode_value;
1967
- } else {
1968
- $values = array( 'pdf', 'txt' );
1969
- } ?>
1970
-
1971
- <p><label for="_allowed_types"><?php _e( 'Allowed File Types', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the image types that you want to allow to be uploaded via this field.', 'ultimate-member' ) ); ?></label>
1972
- <select name="_allowed_types[]" id="_allowed_types" multiple="multiple" style="width: 100%">
1973
- <?php foreach( UM()->files()->allowed_file_types() as $e => $n ) { ?>
1974
- <option value="<?php echo $e; ?>" <?php if ( in_array( $e, $values ) ) { echo 'selected'; } ?>><?php echo $n; ?></option>
1975
- <?php } ?>
1976
- </select>
1977
- </p>
1978
-
1979
- <?php
1980
-
1981
- }
1982
-
1983
- break;
1984
-
1985
- case '_upload_text':
1986
-
1987
- if ( $this->set_field_type == 'image' ) {
1988
- $value = __( 'Drag &amp; Drop Photo', 'ultimate-member' );
1989
- }
1990
- if ( $this->set_field_type == 'file' ) {
1991
- $value = __( 'Drag &amp; Drop File', 'ultimate-member' );
1992
- }
1993
-
1994
- ?>
1995
-
1996
- <p><label for="_upload_text"><?php _e( 'Upload Box Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the headline that appears in the upload box for this field', 'ultimate-member' ) ); ?></label>
1997
- <input type="text" name="_upload_text" id="_upload_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : $value; ?>" />
1998
- </p>
1999
-
2000
- <?php
2001
- break;
2002
-
2003
- case '_upload_help_text':
2004
- ?>
2005
-
2006
- <p><label for="_upload_help_text"><?php _e( 'Additional Instructions Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you need to add information or secondary line below the headline of upload box, enter it here', 'ultimate-member' ) ); ?></label>
2007
- <input type="text" name="_upload_help_text" id="_upload_help_text" value="<?php echo $this->edit_mode_value; ?>" />
2008
- </p>
2009
-
2010
- <?php
2011
- break;
2012
-
2013
- case '_button_text':
2014
- ?>
2015
-
2016
- <p><label for="_button_text"><?php _e( 'Upload Box Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The text that appears on the button. e.g. Upload', 'ultimate-member' ) ); ?></label>
2017
- <input type="text" name="_button_text" id="_button_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : __( 'Upload', 'ultimate-member' ); ?>" />
2018
- </p>
2019
-
2020
- <?php
2021
- break;
2022
-
2023
- case '_max_size':
2024
- ?>
2025
-
2026
- <p><label for="_max_size"><?php _e( 'Maximum Size in bytes', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The maximum size for image that can be uploaded through this field. Leave empty for unlimited size.', 'ultimate-member' ) ); ?></label>
2027
- <input type="text" name="_max_size" id="_max_size" value="<?php echo $this->edit_mode_value; ?>" />
2028
- </p>
2029
-
2030
- <?php
2031
- break;
2032
-
2033
- case '_height':
2034
- ?>
2035
-
2036
- <p><label for="_height"><?php _e( 'Textarea Height', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The height of textarea in pixels. Default is 100 pixels', 'ultimate-member' ) ); ?></label>
2037
- <input type="text" name="_height" id="_height" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '100px'; ?>" />
2038
- </p>
2039
-
2040
- <?php
2041
- break;
2042
-
2043
- case '_spacing':
2044
- ?>
2045
-
2046
- <p><label for="_spacing"><?php _e( 'Spacing', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the required spacing in pixels. e.g. 20px', 'ultimate-member' ) ); ?></label>
2047
- <input type="text" name="_spacing" id="_spacing" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '20px'; ?>" />
2048
- </p>
2049
-
2050
- <?php
2051
- break;
2052
-
2053
- case '_is_multi':
2054
- ?>
2055
-
2056
- <p><label for="_is_multi"><?php _e( 'Allow multiple selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enable/disable multiple selections for this field', 'ultimate-member' ) ); ?></label>
2057
- <input type="checkbox" name="_is_multi" id="_is_multi" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_max_selections" data-cond1-hide="xxx" />
2058
- </p>
2059
-
2060
- <?php
2061
- break;
2062
-
2063
- case '_max_selections':
2064
- ?>
2065
-
2066
- <p class="_max_selections"><label for="_max_selections"><?php _e( 'Maximum number of selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter a number here to force a maximum number of selections by user for this field', 'ultimate-member' ) ); ?></label>
2067
- <input type="text" name="_max_selections" id="_max_selections" value="<?php echo $this->edit_mode_value; ?>" />
2068
- </p>
2069
-
2070
- <?php
2071
- break;
2072
-
2073
- case '_min_selections':
2074
- ?>
2075
-
2076
- <p class="_min_selections"><label for="_min_selections"><?php _e( 'Minimum number of selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter a number here to force a minimum number of selections by user for this field', 'ultimate-member' ) ); ?></label>
2077
- <input type="text" name="_min_selections" id="_min_selections" value="<?php echo $this->edit_mode_value; ?>" />
2078
- </p>
2079
-
2080
- <?php
2081
- break;
2082
-
2083
- case '_max_entries':
2084
- ?>
2085
-
2086
- <p class="_max_entries"><label for="_max_selections"><?php _e( 'Maximum number of entries', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the max number of entries the user can add via field group.', 'ultimate-member' ) ); ?></label>
2087
- <input type="text" name="_max_entries" id="_max_entries" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 10; ?>" />
2088
- </p>
2089
-
2090
- <?php
2091
- break;
2092
-
2093
- case '_max_words':
2094
- ?>
2095
-
2096
- <p><label for="_max_words"><?php _e( 'Maximum allowed words', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a maximum number of words to be input in this textarea. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
2097
- <input type="text" name="_max_words" id="_max_words" value="<?php echo $this->edit_mode_value; ?>" />
2098
- </p>
2099
-
2100
- <?php
2101
- break;
2102
-
2103
- case '_min':
2104
- ?>
2105
-
2106
- <p><label for="_min"><?php _e( 'Minimum Number', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Minimum number that can be entered in this field', 'ultimate-member' ) ); ?></label>
2107
- <input type="text" name="_min" id="_min" value="<?php echo $this->edit_mode_value; ?>" />
2108
- </p>
2109
-
2110
- <?php
2111
- break;
2112
-
2113
- case '_max':
2114
- ?>
2115
-
2116
- <p><label for="_max"><?php _e( 'Maximum Number', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Maximum number that can be entered in this field', 'ultimate-member' ) ); ?></label>
2117
- <input type="text" name="_max" id="_max" value="<?php echo $this->edit_mode_value; ?>" />
2118
- </p>
2119
-
2120
- <?php
2121
- break;
2122
-
2123
- case '_min_chars':
2124
- ?>
2125
-
2126
- <p><label for="_min_chars"><?php _e( 'Minimum length', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a minimum number of characters to be input in this field. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
2127
- <input type="text" name="_min_chars" id="_min_chars" value="<?php echo $this->edit_mode_value; ?>" />
2128
- </p>
2129
-
2130
- <?php
2131
- break;
2132
-
2133
- case '_max_chars':
2134
- ?>
2135
-
2136
- <p><label for="_max_chars"><?php _e( 'Maximum length', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a maximum number of characters to be input in this field. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
2137
- <input type="text" name="_max_chars" id="_max_chars" value="<?php echo $this->edit_mode_value; ?>" />
2138
- </p>
2139
-
2140
- <?php
2141
- break;
2142
-
2143
- case '_html':
2144
- ?>
2145
-
2146
- <p><label for="_html"><?php _e( 'Does this textarea accept HTML?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on/off HTML tags for this textarea', 'ultimate-member' ) ); ?></label>
2147
- <input type="checkbox" name="_html" id="_html" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> />
2148
- </p>
2149
-
2150
- <?php
2151
- break;
2152
-
2153
- case '_options':
2154
-
2155
- if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
2156
- $values = implode("\n", $this->edit_mode_value);
2157
- } else if ( $this->edit_mode_value ) {
2158
- $values = $this->edit_mode_value;
2159
- } else {
2160
- $values = '';
2161
- } ?>
2162
-
2163
- <p><label for="_options"><?php _e( 'Edit Choices', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter one choice per line. This will represent the available choices or selections available for user.', 'ultimate-member' ) ); ?></label>
2164
- <textarea name="_options" id="_options"><?php echo $values; ?></textarea>
2165
- </p>
2166
-
2167
- <?php
2168
- break;
2169
-
2170
- case '_title':
2171
- ?>
2172
-
2173
- <p><label for="_title"><?php _e( 'Title', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the title of the field for your reference in the backend. The title will not appear on the front-end of your website.', 'ultimate-member' ) ); ?></label>
2174
- <input type="text" name="_title" id="_title" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2175
- </p>
2176
-
2177
- <?php
2178
- break;
2179
-
2180
- case '_id':
2181
-
2182
- ?>
2183
-
2184
- <p style="display:none"><label for="_id"><?php _e( 'Unique ID', 'ultimate-member' ) ?></label>
2185
- <input type="text" name="_id" id="_id" value="<?php echo $this->edit_mode_value; ?>" />
2186
- </p>
2187
-
2188
- <?php
2189
-
2190
- break;
2191
-
2192
- case '_metakey':
2193
-
2194
- if ( $this->in_edit ) {
2195
-
2196
- ?>
2197
-
2198
- <p><label for="_metakey"><?php _e( 'Meta Key', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The meta key cannot be changed for duplicated fields or when editing an existing field. If you require a different meta key please create a new field.', 'ultimate-member' ) ); ?></label>
2199
- <input type="text" name="_metakey_locked" id="_metakey_locked" value="<?php echo $this->edit_mode_value; ?>" disabled />
2200
- </p>
2201
-
2202
- <?php } else { ?>
2203
-
2204
- <p><label for="_metakey"><?php _e( 'Meta Key', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'A meta key is required to store the entered info in this field in the database. The meta key should be unique to this field and be written in lowercase with an underscore ( _ ) separating words e.g country_list or job_title', 'ultimate-member' ) ); ?></label>
2205
- <input type="text" name="_metakey" id="_metakey" value="" />
2206
- </p>
2207
-
2208
- <?php
2209
-
2210
- }
2211
-
2212
- break;
2213
-
2214
- case '_help':
2215
- ?>
2216
-
2217
- <p><label for="_help"><?php _e( 'Help Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __('This is the text that appears in a tooltip when a user hovers over the info icon. Help text is useful for providing users with more information about what they should enter in the field. Leave blank if no help text is needed for field.', 'ultimate-member' ) ); ?></label>
2218
- <input type="text" name="_help" id="_help" value="<?php echo $this->edit_mode_value; ?>" />
2219
- </p>
2220
-
2221
- <?php
2222
- break;
2223
-
2224
- case '_default':
2225
- ?>
2226
-
2227
- <?php if ( $this->set_field_type == 'textarea' ) { ?>
2228
-
2229
- <p><label for="_default"><?php _e( 'Default Text', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'Text to display by default in this field', 'ultimate-member' ) ); ?></label>
2230
- <textarea name="_default" id="_default"><?php echo $this->edit_mode_value; ?></textarea>
2231
- </p>
2232
-
2233
- <?php } elseif ( $this->set_field_type == 'date' ) { ?>
2234
-
2235
- <p class="um"><label for="_default"><?php _e( 'Default Date', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'You may use all PHP compatible date formats such as: 2020-02-02, 02/02/2020, yesterday, today, tomorrow, next monday, first day of next month, +3 day', 'ultimate-member' ) ); ?></label>
2236
- <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" class="um-datepicker" data-format="yyyy/mm/dd" />
2237
- </p>
2238
-
2239
- <?php } elseif ( $this->set_field_type == 'time' ) { ?>
2240
-
2241
- <p class="um"><label for="_default"><?php _e( 'Default Time', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'You may use all PHP compatible date formats such as: 2020-02-02, 02/02/2020, yesterday, today, tomorrow, next monday, first day of next month, +3 day', 'ultimate-member' ) ); ?></label>
2242
- <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" class="um-timepicker" data-format="HH:i" />
2243
- </p>
2244
-
2245
- <?php } elseif ( $this->set_field_type == 'rating' ) { ?>
2246
-
2247
- <p><label for="_default"><?php _e( 'Default Rating', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'If you wish the rating field to be prefilled with a number of stars, enter it here.', 'ultimate-member' ) ); ?></label>
2248
- <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" />
2249
- </p>
2250
-
2251
- <?php } else { ?>
2252
-
2253
- <p><label for="_default"><?php _e( 'Default Value', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'This option allows you to pre-fill the field with a default value prior to the user entering a value in the field. Leave blank to have no default value', 'ultimate-member' ) ); ?></label>
2254
- <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" />
2255
- </p>
2256
-
2257
- <?php } ?>
2258
-
2259
- <?php
2260
- break;
2261
-
2262
- case '_label':
2263
- ?>
2264
-
2265
- <p><label for="_label"><?php _e( 'Label', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The field label is the text that appears above the field on your front-end form. Leave blank to not show a label above field.', 'ultimate-member' ) ); ?></label>
2266
- <input type="text" name="_label" id="_label" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2267
- </p>
2268
-
2269
- <?php
2270
- break;
2271
-
2272
- case '_label_confirm_pass':
2273
- ?>
2274
-
2275
- <p><label for="_label_confirm_pass"><?php _e( 'Confirm password field label', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This label is the text that appears above the confirm password field. Leave blank to show default label.', 'ultimate-member' ) ); ?></label>
2276
- <input type="text" name="_label_confirm_pass" id="_label_confirm_pass" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2277
- </p>
2278
-
2279
- <?php
2280
- break;
2281
-
2282
- case '_placeholder':
2283
- ?>
2284
-
2285
- <p><label for="_placeholder"><?php _e( 'Placeholder', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the text that appears within the field e.g please enter your email address. Leave blank to not show any placeholder text.', 'ultimate-member' ) ); ?></label>
2286
- <input type="text" name="_placeholder" id="_placeholder" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2287
- </p>
2288
-
2289
- <?php
2290
- break;
2291
-
2292
- case '_public':
2293
- $privacy_options = array(
2294
- '1' => __( 'Everyone', 'ultimate-member' ),
2295
- '2' => __( 'Members', 'ultimate-member' ),
2296
- '-1' => __( 'Only visible to profile owner and users who can edit other member accounts', 'ultimate-member' ),
2297
- '-3' => __( 'Only visible to profile owner and specific roles', 'ultimate-member' ),
2298
- '-2' => __( 'Only specific member roles', 'ultimate-member' ),
2299
- );
2300
-
2301
- $privacy_options = apply_filters( 'um_field_privacy_options', $privacy_options ); ?>
2302
-
2303
- <p>
2304
- <label for="_public"><?php _e( 'Privacy', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Field privacy allows you to select who can view this field on the front-end. The site admin can view all fields regardless of the option set here.', 'ultimate-member' ) ); ?></label>
2305
- <select name="_public" id="_public" class="um-adm-conditional" data-cond1="-2" data-cond1-show="_roles" data-cond2="-3" data-cond2-show="_roles" style="width: 100%">
2306
- <?php foreach ( $privacy_options as $value => $title ) { ?>
2307
- <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $value, $this->edit_mode_value ); ?>>
2308
- <?php echo $title ?>
2309
- </option>
2310
- <?php } ?>
2311
- </select>
2312
- </p>
2313
-
2314
- <?php
2315
- break;
2316
-
2317
- case '_roles':
2318
-
2319
- if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
2320
- $values = $this->edit_mode_value;
2321
- } else {
2322
- $values = array('');
2323
- }
2324
-
2325
- ?>
2326
-
2327
- <p class="_roles"><label for="_roles"><?php _e( 'Select member roles', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the member roles that can view this field on the front-end.', 'ultimate-member' ) ); ?></label>
2328
- <select name="_roles[]" id="_roles" style="width: 100%" multiple="multiple">
2329
-
2330
- <?php foreach ( UM()->roles()->get_roles() as $key => $value) { ?>
2331
-
2332
- <option value="<?php echo $key; ?>" <?php if ( in_array( $key, $values ) ) { echo 'selected'; } ?>><?php echo $value; ?></option>
2333
-
2334
- <?php } ?>
2335
-
2336
- </select>
2337
- </p>
2338
-
2339
- <?php
2340
- break;
2341
-
2342
- case '_required':
2343
-
2344
- if ( $this->set_field_type == 'password' )
2345
- $def_required = 1;
2346
- else
2347
- $def_required = 0;
2348
-
2349
- ?>
2350
-
2351
- <div class="um-admin-tri">
2352
-
2353
- <p><label for="_required"><?php _e( 'Is this field required?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This option allows you to set whether the field must be filled in before the form can be processed.', 'ultimate-member' ) ); ?></label>
2354
- <input type="checkbox" name="_required" id="_required" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : $def_required ) ?> />
2355
- </p>
2356
-
2357
- </div>
2358
-
2359
- <?php
2360
- break;
2361
-
2362
- case '_editable':
2363
- ?>
2364
-
2365
- <div class="um-admin-tri">
2366
-
2367
- <p><label for="_editable"><?php _e( 'Can user edit this field?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This option allows you to set whether or not the user can edit the information in this field.', 'ultimate-member' ) ); ?></label>
2368
- <input type="hidden" name="_editable" id="_editable_hidden" value="0" />
2369
- <input type="checkbox" name="_editable" id="_editable" value="1" <?php checked( null === $this->edit_mode_value || $this->edit_mode_value ) ?> />
2370
- </p>
2371
-
2372
- </div>
2373
-
2374
- <?php
2375
- break;
2376
-
2377
- case '_number':
2378
- ?>
2379
-
2380
- <p><label for="_number"><?php _e( 'Rating System', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose whether you want a 5-stars or 10-stars ratings based here.', 'ultimate-member' ) ); ?></label>
2381
- <select name="_number" id="_number" style="width: 100%">
2382
- <option value="5" <?php selected( 5, $this->edit_mode_value ); ?>><?php _e( '5 stars rating system', 'ultimate-member' ) ?></option>
2383
- <option value="10" <?php selected( 10, $this->edit_mode_value ); ?>><?php _e( '10 stars rating system', 'ultimate-member' ) ?></option>
2384
- </select>
2385
- </p>
2386
-
2387
- <?php
2388
- break;
2389
-
2390
- case '_custom_dropdown_options_source':
2391
- ?>
2392
-
2393
- <p><label for="_custom_dropdown_options_source"><?php _e( 'Choices Callback', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Add a callback source to retrieve choices.', 'ultimate-member' ) ); ?></label>
2394
- <input type="text" name="_custom_dropdown_options_source" id="_custom_dropdown_options_source" value="<?php echo htmlspecialchars($this->edit_mode_value, ENT_QUOTES); ?>" />
2395
- </p>
2396
-
2397
- <?php
2398
- break;
2399
-
2400
-
2401
- case '_parent_dropdown_relationship':
2402
- ?>
2403
-
2404
- <p><label for="_parent_dropdown_relationship"><?php _e( 'Parent Option', 'ultimate-member' ) ?><?php UM()->tooltip( __( 'Dynamically populates the option based from selected parent option.', 'ultimate-member' ) ); ?></label>
2405
- <select name="_parent_dropdown_relationship" id="_parent_dropdown_relationship" style="width: 100%">
2406
- <option value=""><?php _e( 'No Selected', 'ultimate-member' ) ?></option>
2407
-
2408
- <?php if ( UM()->builtin()->custom_fields ) {
2409
- foreach ( UM()->builtin()->custom_fields as $field_key => $array ) {
2410
- if ( in_array( $array['type'], array( 'select' ) ) && ( ! isset( $field_args['metakey'] ) || $field_args['metakey'] != $array['metakey'] ) && isset( $array['title'] ) ) { ?>
2411
- <option value="<?php echo esc_attr( $array['metakey'] ) ?>" <?php selected( $array['metakey'], $this->edit_mode_value ) ?>><?php echo $array['title'] ?></option>
2412
- <?php }
2413
- }
2414
- } ?>
2415
- </select>
2416
- </p>
2417
-
2418
- <?php
2419
- break;
2420
-
2421
-
2422
- }
2423
-
2424
- }
2425
-
2426
- }
2427
- }
1
+ <?php
2
+ namespace um\admin\core;
3
+
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) exit;
6
+
7
+
8
+ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
9
+
10
+
11
+ /**
12
+ * Class Admin_Metabox
13
+ *
14
+ * @package um\admin\core
15
+ */
16
+ class Admin_Metabox {
17
+
18
+
19
+ /**
20
+ * @var bool
21
+ */
22
+ private $form_nonce_added = false;
23
+
24
+
25
+ /**
26
+ * @var bool
27
+ */
28
+ private $directory_nonce_added = false;
29
+
30
+
31
+ /**
32
+ * @var bool
33
+ */
34
+ private $custom_nonce_added = false;
35
+
36
+
37
+ var $init_icon = false;
38
+
39
+
40
+ /**
41
+ * Admin_Metabox constructor.
42
+ */
43
+ function __construct() {
44
+ $this->in_edit = false;
45
+ $this->edit_mode_value = null;
46
+ $this->edit_array = [];
47
+
48
+ add_action( 'admin_head', array( &$this, 'admin_head' ), 9);
49
+ add_action( 'admin_footer', array( &$this, 'load_modal_content' ), 9 );
50
+
51
+ add_action( 'load-post.php', array( &$this, 'add_metabox' ), 9 );
52
+ add_action( 'load-post-new.php', array( &$this, 'add_metabox' ), 9 );
53
+
54
+ add_action( 'admin_init', array( &$this, 'add_taxonomy_metabox' ), 9 );
55
+
56
+ //roles metaboxes
57
+ add_action( 'um_roles_add_meta_boxes', array( &$this, 'add_metabox_role' ) );
58
+
59
+ add_filter( 'um_builtin_validation_types_continue_loop', array( &$this, 'validation_types_continue_loop' ), 1, 4 );
60
+ add_filter( 'um_restrict_content_hide_metabox', array( &$this, 'hide_metabox_restrict_content_shop' ), 10, 1 );
61
+
62
+ add_filter( 'um_member_directory_meta_value_before_save', array( UM()->member_directory(), 'before_save_data' ), 10, 3 );
63
+ }
64
+
65
+
66
+ /**
67
+ * Hide Woocommerce Shop page restrict content metabox
68
+ * @param $hide
69
+ *
70
+ * @return bool
71
+ */
72
+ function hide_metabox_restrict_content_shop( $hide ) {
73
+ if ( function_exists( 'wc_get_page_id' ) && ! empty( $_GET['post'] ) &&
74
+ absint( $_GET['post'] ) == wc_get_page_id( 'shop' ) ) {
75
+ return true;
76
+ }
77
+
78
+ return $hide;
79
+ }
80
+
81
+
82
+ /**
83
+ * Filter validation types on loop
84
+ *
85
+ * @param $break
86
+ * @param $key
87
+ * @param $form_id
88
+ * @param $field_array
89
+ *
90
+ * @return bool
91
+ */
92
+ function validation_types_continue_loop( $break, $key, $form_id, $field_array ) {
93
+
94
+ // show unique username validation only for user_login field
95
+ if ( isset( $field_array['metakey'] ) && $field_array['metakey'] == 'user_login' && $key !== 'unique_username' ) {
96
+ return false;
97
+ }
98
+
99
+ return $break;
100
+ }
101
+
102
+
103
+ /**
104
+ * Gets the role meta
105
+ *
106
+ * @param $id
107
+ *
108
+ * @return mixed
109
+ */
110
+ function get_custom_post_meta( $id ) {
111
+ $all_meta = get_post_custom( $id );
112
+ foreach ( $all_meta as $k => $v ) {
113
+ if ( strstr( $k, '_um_' ) ) {
114
+ $um_meta[ $k ] = $v;
115
+ }
116
+ }
117
+ if ( isset( $um_meta ) ) {
118
+ return $um_meta;
119
+ }
120
+
121
+ return false;
122
+ }
123
+
124
+
125
+ /**
126
+ * Runs on admin head
127
+ */
128
+ function admin_head(){
129
+ global $post;
130
+ if ( UM()->admin()->is_plugin_post_type() && isset($post->ID) ){
131
+ $this->postmeta = $this->get_custom_post_meta($post->ID);
132
+ }
133
+ }
134
+
135
+
136
+ /**
137
+ * Init the metaboxes
138
+ */
139
+ function add_metabox() {
140
+ global $current_screen;
141
+
142
+ if ( $current_screen->id == 'um_form' ) {
143
+ add_action( 'add_meta_boxes', array(&$this, 'add_metabox_form'), 1 );
144
+ add_action( 'save_post', array(&$this, 'save_metabox_form'), 10, 2 );
145
+ }
146
+
147
+ if ( $current_screen->id == 'um_directory' ) {
148
+ add_action( 'add_meta_boxes', array(&$this, 'add_metabox_directory'), 1 );
149
+ add_action( 'save_post', array(&$this, 'save_metabox_directory'), 10, 2 );
150
+ }
151
+
152
+ //restrict content metabox
153
+ $post_types = UM()->options()->get( 'restricted_access_post_metabox' );
154
+ if ( ! empty( $post_types[ $current_screen->id ] ) ) {
155
+
156
+ /**
157
+ * UM hook
158
+ *
159
+ * @type filter
160
+ * @title um_restrict_content_hide_metabox
161
+ * @description Show/Hide Restrict content metabox
162
+ * @input_vars
163
+ * [{"var":"$show","type":"bool","desc":"Show Metabox"}]
164
+ * @change_log
165
+ * ["Since: 2.0"]
166
+ * @usage add_filter( 'um_restrict_content_hide_metabox', 'function_name', 10, 1 );
167
+ * @example
168
+ * <?php
169
+ * add_filter( 'um_restrict_content_hide_metabox', 'my_restrict_content_hide_metabox', 10, 1 );
170
+ * function my_restrict_content_hide_metabox( $show ) {
171
+ * // your code here
172
+ * return $show;
173
+ * }
174
+ * ?>
175
+ */
176
+ $hide_metabox = apply_filters( 'um_restrict_content_hide_metabox', false );
177
+
178
+ if ( ! $hide_metabox ) {
179
+ add_action( 'add_meta_boxes', array(&$this, 'add_metabox_restrict_content'), 1 );
180
+ add_action( 'save_post', array( &$this, 'save_metabox_restrict_content' ), 10, 2 );
181
+ }
182
+
183
+ if ( $current_screen->id == 'attachment' ) {
184
+ add_action( 'add_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
185
+ add_action( 'edit_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
186
+ }
187
+ }
188
+
189
+
190
+ add_action( 'save_post', array( &$this, 'save_metabox_custom' ), 10, 2 );
191
+ }
192
+
193
+
194
+ /**
195
+ * @param $post_id
196
+ * @param $post
197
+ */
198
+ public function save_metabox_custom( $post_id, $post ) {
199
+ // validate nonce
200
+ if ( ! isset( $_POST['um_admin_save_metabox_custom_nonce'] ) ||
201
+ ! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) {
202
+ return;
203
+ }
204
+
205
+ /**
206
+ * UM hook
207
+ *
208
+ * @type action
209
+ * @title um_admin_custom_restrict_content_metaboxes
210
+ * @description Save metabox custom with restrict content
211
+ * @input_vars
212
+ * [{"var":"$post_id","type":"int","desc":"Post ID"},
213
+ * {"var":"$post","type":"array","desc":"Post data"}]
214
+ * @change_log
215
+ * ["Since: 2.0"]
216
+ * @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10, 2 );
217
+ * @example
218
+ * <?php
219
+ * add_action( 'um_admin_custom_restrict_content_metaboxes', 'my_admin_custom_restrict_content', 10, 2 );
220
+ * function my_admin_custom_restrict_content( $post_id, $post ) {
221
+ * // your code here
222
+ * }
223
+ * ?>
224
+ */
225
+ do_action( 'um_admin_custom_restrict_content_metaboxes', $post_id, $post );
226
+ }
227
+
228
+
229
+ /**
230
+ *
231
+ */
232
+ function add_metabox_restrict_content() {
233
+ global $current_screen;
234
+
235
+ add_meta_box(
236
+ 'um-admin-restrict-content',
237
+ __( 'Ultimate Member: Content Restriction', 'ultimate-member' ),
238
+ array( &$this, 'restrict_content_cb' ),
239
+ $current_screen->id,
240
+ 'normal',
241
+ 'default'
242
+ );
243
+
244
+ /**
245
+ * UM hook
246
+ *
247
+ * @type action
248
+ * @title um_admin_custom_restrict_content_metaboxes
249
+ * @description Add restrict content custom metabox
250
+ * @change_log
251
+ * ["Since: 2.0"]
252
+ * @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10 );
253
+ * @example
254
+ * <?php
255
+ * add_action( 'um_admin_custom_restrict_content_metaboxes', 'my_admin_custom_restrict_content', 10 );
256
+ * function my_admin_custom_restrict_content() {
257
+ * // your code here
258
+ * }
259
+ * ?>
260
+ */
261
+ do_action( 'um_admin_custom_restrict_content_metaboxes' );
262
+ }
263
+
264
+
265
+ /**
266
+ * Content restriction metabox
267
+ *
268
+ * @param $object
269
+ * @param $box
270
+ */
271
+ function restrict_content_cb( $object, $box ) {
272
+ include_once UM()->admin()->templates_path . 'access/restrict_content.php';
273
+ wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_restrict_content_nonce' );
274
+ }
275
+
276
+
277
+ /**
278
+ * Init the metaboxes
279
+ */
280
+ function add_taxonomy_metabox() {
281
+ //restrict content metabox
282
+ $all_taxonomies = get_taxonomies( array( 'public' => true ) );
283
+ $tax_types = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
284
+ $exclude_taxonomies = UM()->excluded_taxonomies();
285
+
286
+ foreach ( $all_taxonomies as $key => $taxonomy ) {
287
+ if ( in_array( $key, $exclude_taxonomies ) || empty( $tax_types[$key] ) )
288
+ continue;
289
+
290
+ add_action( $taxonomy . '_add_form_fields', array( &$this, 'um_category_access_fields_create' ) );
291
+ add_action( $taxonomy . '_edit_form_fields', array( &$this, 'um_category_access_fields_edit' ) );
292
+ add_action( 'create_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) );
293
+ add_action( 'edited_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) );
294
+ }
295
+ }
296
+
297
+
298
+ /**
299
+ * @param $post_id
300
+ * @param $post
301
+ */
302
+ function save_metabox_restrict_content( $post_id, $post ) {
303
+ // validate nonce
304
+ if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] ) ||
305
+ ! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) {
306
+ return;
307
+ }
308
+
309
+ // validate user
310
+ $post_type = get_post_type_object( $post->post_type );
311
+ if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
312
+ return;
313
+ }
314
+
315
+ if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
316
+ $restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
317
+
318
+ update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
319
+ } else {
320
+ delete_post_meta( $post_id, 'um_content_restriction' );
321
+ }
322
+ }
323
+
324
+
325
+ /**
326
+ * @param $post_id
327
+ *
328
+ */
329
+ function save_attachment_metabox_restrict_content( $post_id ) {
330
+ // validate nonce
331
+ if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] )
332
+ || ! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) {
333
+ return;
334
+ }
335
+
336
+ $post = get_post( $post_id );
337
+
338
+ // validate user
339
+ $post_type = get_post_type_object( $post->post_type );
340
+ if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
341
+ return;
342
+ }
343
+
344
+ if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
345
+ $restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
346
+
347
+ update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
348
+ } else {
349
+ delete_post_meta( $post_id, 'um_content_restriction' );
350
+ }
351
+ }
352
+
353
+
354
+ /**
355
+ *
356
+ */
357
+ function um_category_access_fields_create() {
358
+ /**
359
+ * UM hook
360
+ *
361
+ * @type filter
362
+ * @title um_admin_category_access_settings_fields
363
+ * @description Settings fields for terms
364
+ * @input_vars
365
+ * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"},
366
+ * {"var":"$data","type":"array","desc":"Settings Data"},
367
+ * {"var":"$screen","type":"string","desc":"Category Screen"}]
368
+ * @change_log
369
+ * ["Since: 2.0"]
370
+ * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 );
371
+ * @example
372
+ * <?php
373
+ * add_filter( 'um_admin_category_access_settings_fields', 'my_admin_category_access_settings_fields', 10, 3 );
374
+ * function my_admin_category_access_settings_fields( $access_settings_fields, $data, $screen ) {
375
+ * // your code here
376
+ * $access_settings_fields[] = array(
377
+ * 'id' => 'my-field-key',
378
+ * 'type' => 'my-field-type',
379
+ * 'label' => __( 'My field Label', 'ultimate-member' ),
380
+ * 'description' => __( 'My Field Description', 'ultimate-member' ),
381
+ * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
382
+ * );
383
+ * return $access_settings_fields;
384
+ * }
385
+ * ?>
386
+ */
387
+ $fields = apply_filters( 'um_admin_category_access_settings_fields', array(
388
+ array(
389
+ 'id' => '_um_custom_access_settings',
390
+ 'type' => 'checkbox',
391
+ 'label' => __( 'Restrict access to this term and its posts?', 'ultimate-member' ),
392
+ 'description' => __( 'Activate content restriction for this term and its posts. Affects only posts that do not have individual Restriction Content settings', 'ultimate-member' ),
393
+ 'value' => 0,
394
+ ),
395
+ array(
396
+ 'id' => '_um_accessible',
397
+ 'type' => 'select',
398
+ 'label' => __( 'Who can access this term and its posts?', 'ultimate-member' ),
399
+ 'value' => '0',
400
+ 'options' => array(
401
+ '0' => __( 'Everyone', 'ultimate-member' ),
402
+ '1' => __( 'Logged out users', 'ultimate-member' ),
403
+ '2' => __( 'Logged in users', 'ultimate-member' ),
404
+ ),
405
+ 'conditional' => array( '_um_custom_access_settings', '=', '1' ),
406
+ ),
407
+ array(
408
+ 'id' => '_um_access_roles',
409
+ 'type' => 'multi_checkbox',
410
+ 'label' => __( 'Select which roles can access this term and its posts', 'ultimate-member' ),
411
+ 'description' => __( 'Leave empty if you want to display a term for all logged in users', 'ultimate-member' ),
412
+ 'options' => UM()->roles()->get_roles( false ),
413
+ 'columns' => 3,
414
+ 'conditional' => array( '_um_accessible', '=', '2' ),
415
+ ),
416
+ array(
417
+ 'id' => '_um_access_hide_from_queries',
418
+ 'type' => 'checkbox',
419
+ 'label' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Hide from queries', 'ultimate-member' ) : __( 'Would you like to display 404 error on the term\'s archive page and terms\' posts single pages when users haven\'t access?', 'ultimate-member' ),
420
+ 'description' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Exclude only from WP queries results', 'ultimate-member' ) : __( 'Recommended to be enabled. Restricted term\'s archive page and all terms\' posts will be hidden by exclusion from WP Query. The safest and most effective method that hides post and its comments from all requests, RSS feeds, etc. on your site', 'ultimate-member' ),
421
+ 'value' => 1,
422
+ 'conditional' => array( '_um_accessible', '!=', '0' ),
423
+ ),
424
+ array(
425
+ 'id' => '_um_noaccess_action',
426
+ 'type' => 'select',
427
+ 'label' => __( 'What happens when users without access try to view the term\'s post?', 'ultimate-member' ),
428
+ 'description' => __( 'Action when users without access tries to view the term\'s post', 'ultimate-member' ),
429
+ 'value' => '0',
430
+ 'options' => array(
431
+ '0' => __( 'Show access restricted message', 'ultimate-member' ),
432
+ '1' => __( 'Redirect user', 'ultimate-member' ),
433
+ ),
434
+ 'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? '' : array( '_um_access_hide_from_queries', '=', '0' ),
435
+ ),
436
+ array(
437
+ 'id' => '_um_restrict_by_custom_message',
438
+ 'type' => 'select',
439
+ 'label' => __( 'Restricted access message type', 'ultimate-member' ),
440
+ 'description' => __( 'Would you like to use the global default message or apply a custom message to this term\'s post?', 'ultimate-member' ),
441
+ 'value' => '0',
442
+ 'options' => array(
443
+ '0' => __( 'Global default message', 'ultimate-member' ),
444
+ '1' => __( 'Custom message', 'ultimate-member' ),
445
+ ),
446
+ 'conditional' => array( '_um_noaccess_action', '=', '0' ),
447
+ ),
448
+ array(
449
+ 'id' => '_um_restrict_custom_message',
450
+ 'type' => 'wp_editor',
451
+ 'label' => __( 'Custom restricted access message', 'ultimate-member' ),
452
+ 'description' => __( 'You may replace global restricted access message here', 'ultimate-member' ),
453
+ 'value' => '',
454
+ 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ),
455
+ ),
456
+ array(
457
+ 'id' => '_um_access_redirect',
458
+ 'type' => 'select',
459
+ 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
460
+ 'description' => __( 'Select redirect to page when user hasn\'t access to the term\'s post', 'ultimate-member' ),
461
+ 'value' => '0',
462
+ 'conditional' => array( '_um_noaccess_action', '=', '1' ),
463
+ 'options' => array(
464
+ '0' => __( 'Login page', 'ultimate-member' ),
465
+ '1' => __( 'Custom URL', 'ultimate-member' ),
466
+ ),
467
+ ),
468
+ array(
469
+ 'id' => '_um_access_redirect_url',
470
+ 'type' => 'text',
471
+ 'label' => __( 'Redirect URL', 'ultimate-member' ),
472
+ 'description' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ),
473
+ 'value' => '',
474
+ 'conditional' => array( '_um_access_redirect', '=', '1' ),
475
+ ),
476
+ ), array(), 'create' );
477
+
478
+ UM()->admin_forms(
479
+ array(
480
+ 'class' => 'um-restrict-content um-third-column',
481
+ 'prefix_id' => 'um_content_restriction',
482
+ 'without_wrapper' => true,
483
+ 'div_line' => true,
484
+ 'fields' => $fields,
485
+ )
486
+ )->render_form();
487
+
488
+ wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' );
489
+ }
490
+
491
+
492
+ /**
493
+ * @param $term
494
+ */
495
+ function um_category_access_fields_edit( $term ) {
496
+ $termID = $term->term_id;
497
+
498
+ $data = get_term_meta( $termID, 'um_content_restriction', true );
499
+
500
+ $_um_access_roles_value = array();
501
+ if ( ! empty( $data['_um_access_roles'] ) ) {
502
+ foreach ( $data['_um_access_roles'] as $key => $value ) {
503
+ if ( $value ) {
504
+ $_um_access_roles_value[] = $key;
505
+ }
506
+ }
507
+ }
508
+
509
+ /**
510
+ * UM hook
511
+ *
512
+ * @type filter
513
+ * @title um_admin_category_access_settings_fields
514
+ * @description Settings fields for terms
515
+ * @input_vars
516
+ * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"},
517
+ * {"var":"$data","type":"array","desc":"Settings Data"},
518
+ * {"var":"$screen","type":"string","desc":"Category Screen"}]
519
+ * @change_log
520
+ * ["Since: 2.0"]
521
+ * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 );
522
+ * @example
523
+ * <?php
524
+ * add_filter( 'um_admin_category_access_settings_fields', 'my_admin_category_access_settings_fields', 10, 3 );
525
+ * function my_admin_category_access_settings_fields( $access_settings_fields, $data, $screen ) {
526
+ * // your code here
527
+ * $access_settings_fields[] = array(
528
+ * 'id' => 'my-field-key',
529
+ * 'type' => 'my-field-type',
530
+ * 'label' => __( 'My field Label', 'ultimate-member' ),
531
+ * 'description' => __( 'My Field Description', 'ultimate-member' ),
532
+ * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
533
+ * );
534
+ * return $access_settings_fields;
535
+ * }
536
+ * ?>
537
+ */
538
+ $fields = apply_filters( 'um_admin_category_access_settings_fields', array(
539
+ array(
540
+ 'id' => '_um_custom_access_settings',
541
+ 'type' => 'checkbox',
542
+ 'label' => __( 'Restrict access to this term and its posts?', 'ultimate-member' ),
543
+ 'description' => __( 'Activate content restriction for this term and its posts. Affects only posts that do not have individual Restriction Content settings', 'ultimate-member' ),
544
+ 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
545
+ ),
546
+ array(
547
+ 'id' => '_um_accessible',
548
+ 'type' => 'select',
549
+ 'label' => __( 'Who can access this term and its posts?', 'ultimate-member' ),
550
+ 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : '0',
551
+ 'options' => array(
552
+ '0' => __( 'Everyone', 'ultimate-member' ),
553
+ '1' => __( 'Logged out users', 'ultimate-member' ),
554
+ '2' => __( 'Logged in users', 'ultimate-member' ),
555
+ ),
556
+ 'conditional' => array( '_um_custom_access_settings', '=', '1' ),
557
+ ),
558
+ array(
559
+ 'id' => '_um_access_roles',
560
+ 'type' => 'multi_checkbox',
561
+ 'label' => __( 'Select which roles can access this term and its posts', 'ultimate-member' ),
562
+ 'description' => __( 'Leave empty if you want to display a term for all logged in users', 'ultimate-member' ),
563
+ 'value' => $_um_access_roles_value,
564
+ 'options' => UM()->roles()->get_roles( false ),
565
+ 'columns' => 3,
566
+ 'conditional' => array( '_um_accessible', '=', '2' ),
567
+ ),
568
+ array(
569
+ 'id' => '_um_access_hide_from_queries',
570
+ 'type' => 'checkbox',
571
+ 'label' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Hide from queries', 'ultimate-member' ) : __( 'Would you like to display 404 error on the term\'s archive page and terms\' posts single pages when users haven\'t access?', 'ultimate-member' ),
572
+ 'description' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Exclude only from WP queries results', 'ultimate-member' ) : __( 'Recommended to be enabled. Restricted term\'s archive page and all terms\' posts will be hidden by exclusion from WP Query. The safest and most effective method that hides post and its comments from all requests, RSS feeds, etc. on your site', 'ultimate-member' ),
573
+ 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
574
+ 'conditional' => array( '_um_accessible', '!=', '0' ),
575
+ ),
576
+ array(
577
+ 'id' => '_um_noaccess_action',
578
+ 'type' => 'select',
579
+ 'label' => __( 'What happens when users without access try to view the term\'s post?', 'ultimate-member' ),
580
+ 'description' => __( 'Action when users without access tries to view the term\'s post', 'ultimate-member' ),
581
+ 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : '0',
582
+ 'options' => array(
583
+ '0' => __( 'Show access restricted message', 'ultimate-member' ),
584
+ '1' => __( 'Redirect user', 'ultimate-member' ),
585
+ ),
586
+ 'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? '' : array( '_um_access_hide_from_queries', '=', '0' ),
587
+ ),
588
+ array(
589
+ 'id' => '_um_restrict_by_custom_message',
590
+ 'type' => 'select',
591
+ 'label' => __( 'Restricted access message type', 'ultimate-member' ),
592
+ 'description' => __( 'Would you like to use the global default message or apply a custom message to this term\'s post?', 'ultimate-member' ),
593
+ 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
594
+ 'options' => array(
595
+ '0' => __( 'Global default message', 'ultimate-member' ),
596
+ '1' => __( 'Custom message', 'ultimate-member' ),
597
+ ),
598
+ 'conditional' => array( '_um_noaccess_action', '=', '0' ),
599
+ ),
600
+ array(
601
+ 'id' => '_um_restrict_custom_message',
602
+ 'type' => 'wp_editor',
603
+ 'label' => __( 'Custom restricted access message', 'ultimate-member' ),
604
+ 'description' => __( 'You may replace global restricted access message here', 'ultimate-member' ),
605
+ 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
606
+ 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ),
607
+ ),
608
+ array(
609
+ 'id' => '_um_access_redirect',
610
+ 'type' => 'select',
611
+ 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
612
+ 'description' => __( 'Select redirect to page when user hasn\'t access to the term\'s post', 'ultimate-member' ),
613
+ 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
614
+ 'options' => array(
615
+ '0' => __( 'Login page', 'ultimate-member' ),
616
+ '1' => __( 'Custom URL', 'ultimate-member' ),
617
+ ),
618
+ 'conditional' => array( '_um_noaccess_action', '=', '1' ),
619
+ ),
620
+ array(
621
+ 'id' => '_um_access_redirect_url',
622
+ 'type' => 'text',
623
+ 'label' => __( 'Redirect URL', 'ultimate-member' ),
624
+ 'description' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ),
625
+ 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
626
+ 'conditional' => array( '_um_access_redirect', '=', '1' ),
627
+ ),
628
+ ), $data, 'edit' );
629
+
630
+ UM()->admin_forms(
631
+ array(
632
+ 'class' => 'um-restrict-content um-third-column',
633
+ 'prefix_id' => 'um_content_restriction',
634
+ 'without_wrapper' => true,
635
+ 'fields' => $fields,
636
+ )
637
+ )->render_form();
638
+
639
+ wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' );
640
+ }
641
+
642
+
643
+ /**
644
+ * @param $termID
645
+ *
646
+ * @return mixed
647
+ */
648
+ function um_category_access_fields_save( $termID ) {
649
+
650
+ // validate nonce
651
+ if ( ! isset( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'] ) || ! wp_verify_nonce( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'], basename( __FILE__ ) ) ) {
652
+ return $termID;
653
+ }
654
+
655
+ // validate user
656
+ $term = get_term( $termID );
657
+ $taxonomy = get_taxonomy( $term->taxonomy );
658
+
659
+ if ( ! current_user_can( $taxonomy->cap->edit_terms, $termID ) ) {
660
+ return $termID;
661
+ }
662
+
663
+ if ( ! empty( $_REQUEST['um_content_restriction'] ) && is_array( $_REQUEST['um_content_restriction'] ) ) {
664
+ $restriction_meta = UM()->admin()->sanitize_term_restriction_meta( $_REQUEST['um_content_restriction'] );
665
+
666
+ update_term_meta( $termID, 'um_content_restriction', $restriction_meta );
667
+ } else {
668
+ delete_term_meta( $termID, 'um_content_restriction' );
669
+ }
670
+
671
+ return $termID;
672
+ }
673
+
674
+
675
+ /**
676
+ * Load a directory metabox
677
+ *
678
+ * @param $object
679
+ * @param $box
680
+ */
681
+ function load_metabox_directory( $object, $box ) {
682
+ $box['id'] = str_replace( 'um-admin-form-', '', $box['id'] );
683
+
684
+ preg_match('#\{.*?\}#s', $box['id'], $matches );
685
+
686
+ if ( isset( $matches[0] ) ) {
687
+ $path = $matches[0];
688
+ $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
689
+ } else {
690
+ $path = um_path;
691
+ }
692
+
693
+ $path = str_replace('{','', $path );
694
+ $path = str_replace('}','', $path );
695
+
696
+
697
+ include_once $path . 'includes/admin/templates/directory/'. $box['id'] . '.php';
698
+ if ( ! $this->directory_nonce_added ) {
699
+ $this->directory_nonce_added = true;
700
+ wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_directory_nonce' );
701
+ }
702
+ }
703
+
704
+
705
+ /**
706
+ * Load a role metabox
707
+ *
708
+ * @param $object
709
+ * @param $box
710
+ */
711
+ function load_metabox_role( $object, $box ) {
712
+ global $post;
713
+
714
+ $box['id'] = str_replace( 'um-admin-form-', '', $box['id'] );
715
+
716
+ if ( $box['id'] == 'builder' ) {
717
+ UM()->builder()->form_id = get_the_ID();
718
+ }
719
+
720
+ preg_match('#\{.*?\}#s', $box['id'], $matches);
721
+
722
+ if ( isset($matches[0]) ){
723
+ $path = $matches[0];
724
+ $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
725
+ } else {
726
+ $path = um_path;
727
+ }
728
+
729
+ $path = str_replace('{','', $path );
730
+ $path = str_replace('}','', $path );
731
+
732
+ include_once $path . 'includes/admin/templates/role/'. $box['id'] . '.php';
733
+ //wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_role_nonce' );
734
+ }
735
+
736
+
737
+ /**
738
+ * Load a form metabox
739
+ *
740
+ * @param $object
741
+ * @param $box
742
+ */
743
+ function load_metabox_form( $object, $box ) {
744
+ global $post;
745
+
746
+ $box['id'] = str_replace( 'um-admin-form-','', $box['id'] );
747
+
748
+ if ( $box['id'] == 'builder' ) {
749
+ UM()->builder()->form_id = get_the_ID();
750
+ }
751
+
752
+ preg_match('#\{.*?\}#s', $box['id'], $matches);
753
+
754
+ if ( isset( $matches[0] ) ) {
755
+ $path = $matches[0];
756
+ $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
757
+ } else {
758
+ $path = um_path;
759
+ }
760
+
761
+ $path = str_replace('{','', $path );
762
+ $path = str_replace('}','', $path );
763
+
764
+ include_once $path . 'includes/admin/templates/form/'. $box['id'] . '.php';
765
+
766
+ if ( ! $this->form_nonce_added ) {
767
+ $this->form_nonce_added = true;
768
+ wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_form_nonce' );
769
+ }
770
+ }
771
+
772
+
773
+ /**
774
+ * Load admin custom metabox
775
+ *
776
+ * @param $object
777
+ * @param $box
778
+ */
779
+ function load_metabox_custom( $object, $box ) {
780
+ global $post;
781
+
782
+ $box['id'] = str_replace('um-admin-custom-','', $box['id']);
783
+
784
+ preg_match('#\{.*?\}#s', $box['id'], $matches);
785
+
786
+ if ( isset($matches[0]) ){
787
+ $path = $matches[0];
788
+ $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
789
+ } else {
790
+ $path = um_path;
791
+ }
792
+
793
+ $path = str_replace('{','', $path );
794
+ $path = str_replace('}','', $path );
795
+
796
+ include_once $path . 'includes/admin/templates/'. $box['id'] . '.php';
797
+ if ( ! $this->custom_nonce_added ) {
798
+ $this->custom_nonce_added = true;
799
+ wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_custom_nonce' );
800
+ }
801
+ }
802
+
803
+
804
+ /**
805
+ * Add directory metabox
806
+ */
807
+ function add_metabox_directory() {
808
+ add_meta_box( 'um-admin-form-general', __( 'General Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
809
+ add_meta_box( 'um-admin-form-sorting', __( 'Sorting', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
810
+ add_meta_box( 'um-admin-form-profile', __( 'Profile Card', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
811
+ add_meta_box( 'um-admin-form-search', __( 'Search Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
812
+ add_meta_box( 'um-admin-form-pagination', __( 'Results &amp; Pagination', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
813
+ add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'side', 'default' );
814
+ add_meta_box( 'um-admin-form-appearance', __( 'Styling: General', 'ultimate-member' ), array( &$this, 'load_metabox_directory'), 'um_directory', 'side', 'default' );
815
+ }
816
+
817
+
818
+ /**
819
+ * Add role metabox
820
+ */
821
+ function add_metabox_role() {
822
+ $callback = array( &$this, 'load_metabox_role' );
823
+
824
+ $roles_metaboxes = array(
825
+ array(
826
+ 'id' => 'um-admin-form-admin-permissions',
827
+ 'title' => __( 'Administrative Permissions', 'ultimate-member' ),
828
+ 'callback' => $callback,
829
+ 'screen' => 'um_role_meta',
830
+ 'context' => 'normal',
831
+ 'priority' => 'default'
832
+ ),
833
+ array(
834
+ 'id' => 'um-admin-form-general',
835
+ 'title' => __( 'General Permissions', 'ultimate-member' ),
836
+ 'callback' => $callback,
837
+ 'screen' => 'um_role_meta',
838
+ 'context' => 'normal',
839
+ 'priority' => 'default'
840
+ ),
841
+ array(
842
+ 'id' => 'um-admin-form-profile',
843
+ 'title' => __( 'Profile Access', 'ultimate-member' ),
844
+ 'callback' => $callback,
845
+ 'screen' => 'um_role_meta',
846
+ 'context' => 'normal',
847
+ 'priority' => 'default'
848
+ )
849
+ );
850
+
851
+ if ( ! isset( $_GET['id'] ) || 'administrator' !== sanitize_key( $_GET['id'] ) ) {
852
+ $roles_metaboxes[] = array(
853
+ 'id' => 'um-admin-form-home',
854
+ 'title' => __( 'Homepage Options', 'ultimate-member' ),
855
+ 'callback' => $callback,
856
+ 'screen' => 'um_role_meta',
857
+ 'context' => 'normal',
858
+ 'priority' => 'default'
859
+ );
860
+ }
861
+
862
+ $roles_metaboxes = array_merge( $roles_metaboxes, array(
863
+ array(
864
+ 'id' => 'um-admin-form-register',
865
+ 'title' => __( 'Registration Options', 'ultimate-member' ),
866
+ 'callback' => $callback,
867
+ 'screen' => 'um_role_meta',
868
+ 'context' => 'normal',
869
+ 'priority' => 'default'
870
+ ),
871
+ array(
872
+ 'id' => 'um-admin-form-login',
873
+ 'title' => __( 'Login Options', 'ultimate-member' ),
874
+ 'callback' => $callback,
875
+ 'screen' => 'um_role_meta',
876
+ 'context' => 'normal',
877
+ 'priority' => 'default'
878
+ ),
879
+ array(
880
+ 'id' => 'um-admin-form-logout',
881
+ 'title' => __( 'Logout Options', 'ultimate-member' ),
882
+ 'callback' => $callback,
883
+ 'screen' => 'um_role_meta',
884
+ 'context' => 'normal',
885
+ 'priority' => 'default'
886
+ ),
887
+ array(
888
+ 'id' => 'um-admin-form-delete',
889
+ 'title' => __( 'Delete Options', 'ultimate-member' ),
890
+ 'callback' => $callback,
891
+ 'screen' => 'um_role_meta',
892
+ 'context' => 'normal',
893
+ 'priority' => 'default'
894
+ ),
895
+ array(
896
+ 'id' => 'um-admin-form-publish',
897
+ 'title' => __( 'Publish', 'ultimate-member' ),
898
+ 'callback' => $callback,
899
+ 'screen' => 'um_role_meta',
900
+ 'context' => 'side',
901
+ 'priority' => 'default'
902
+ )
903
+ ) );
904
+
905
+ /**
906
+ * UM hook
907
+ *
908
+ * @type filter
909
+ * @title um_admin_role_metaboxes
910
+ * @description Extend metaboxes at Add/Edit User Role
911
+ * @input_vars
912
+ * [{"var":"$roles_metaboxes","type":"array","desc":"Metaboxes at Add/Edit UM Role"}]
913
+ * @change_log
914
+ * ["Since: 2.0"]
915
+ * @usage add_filter( 'um_admin_role_metaboxes', 'function_name', 10, 1 );
916
+ * @example
917
+ * <?php
918
+ * add_filter( 'um_admin_role_metaboxes', 'my_admin_role_metaboxes', 10, 1 );
919
+ * function my_admin_role_metaboxes( $roles_metaboxes ) {
920
+ * // your code here
921
+ * $roles_metaboxes[] = array(
922
+ * 'id' => 'um-admin-form-your-custom',
923
+ * 'title' => __( 'My Roles Metabox', 'ultimate-member' ),
924
+ * 'callback' => 'my-metabox-callback',
925
+ * 'screen' => 'um_role_meta',
926
+ * 'context' => 'side',
927
+ * 'priority' => 'default'
928
+ * );
929
+ *
930
+ * return $roles_metaboxes;
931
+ * }
932
+ * ?>
933
+ */
934
+ $roles_metaboxes = apply_filters( 'um_admin_role_metaboxes', $roles_metaboxes );
935
+
936
+ $wp_caps_metabox = false;
937
+ if ( ! empty( $_GET['id'] ) ) {
938
+ $data = get_option( 'um_role_' . sanitize_key( $_GET['id'] ) . '_meta' );
939
+ if ( ! empty( $data['_um_is_custom'] ) ) {
940
+ $wp_caps_metabox = true;
941
+ }
942
+ }
943
+ if ( 'add' == sanitize_key( $_GET['tab'] ) || $wp_caps_metabox ) {
944
+ $roles_metaboxes[] = array(
945
+ 'id' => 'um-admin-form-wp-capabilities',
946
+ 'title' => __( 'WP Capabilities', 'ultimate-member' ),
947
+ 'callback' => $callback,
948
+ 'screen' => 'um_role_meta',
949
+ 'context' => 'normal',
950
+ 'priority' => 'default'
951
+ );
952
+ }
953
+
954
+
955
+ foreach ( $roles_metaboxes as $metabox ) {
956
+ add_meta_box(
957
+ $metabox['id'],
958
+ $metabox['title'],
959
+ $metabox['callback'],
960
+ $metabox['screen'],
961
+ $metabox['context'],
962
+ $metabox['priority']
963
+ );
964
+ }
965
+ }
966
+
967
+
968
+ /**
969
+ * Add form metabox
970
+ */
971
+ function add_metabox_form() {
972
+
973
+ add_meta_box( 'um-admin-form-mode', __( 'Select Form Type', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' );
974
+ add_meta_box( 'um-admin-form-builder', __( 'Form Builder', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' );
975
+ add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
976
+
977
+ add_meta_box( 'um-admin-form-register_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
978
+
979
+ /**
980
+ * UM hook
981
+ *
982
+ * @type action
983
+ * @title um_admin_custom_register_metaboxes
984
+ * @description Add custom metaboxes for register form
985
+ * @change_log
986
+ * ["Since: 2.0"]
987
+ * @usage add_action( 'um_admin_custom_register_metaboxes', 'function_name', 10 );
988
+ * @example
989
+ * <?php
990
+ * add_action( 'um_admin_custom_register_metaboxes', 'my_admin_custom_register_metaboxes', 10 );
991
+ * function my_admin_custom_register_metaboxes() {
992
+ * // your code here
993
+ * }
994
+ * ?>
995
+ */
996
+ do_action( 'um_admin_custom_register_metaboxes' );
997
+
998
+ add_meta_box( 'um-admin-form-profile_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
999
+ add_meta_box( 'um-admin-form-profile_settings', __( 'User Meta', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
1000
+
1001
+ /**
1002
+ * UM hook
1003
+ *
1004
+ * @type action
1005
+ * @title um_admin_custom_profile_metaboxes
1006
+ * @description Add custom metaboxes for profile form
1007
+ * @change_log
1008
+ * ["Since: 2.0"]
1009
+ * @usage add_action( 'um_admin_custom_profile_metaboxes', 'function_name', 10 );
1010
+ * @example
1011
+ * <?php
1012
+ * add_action( 'um_admin_custom_profile_metaboxes', 'my_admin_custom_profile_metaboxes', 10 );
1013
+ * function my_admin_custom_profile_metaboxes() {
1014
+ * // your code here
1015
+ * }
1016
+ * ?>
1017
+ */
1018
+ do_action( 'um_admin_custom_profile_metaboxes' );
1019
+
1020
+ add_meta_box( 'um-admin-form-login_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
1021
+ add_meta_box( 'um-admin-form-login_settings', __( 'Options', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
1022
+
1023
+ /**
1024
+ * UM hook
1025
+ *
1026
+ * @type action
1027
+ * @title um_admin_custom_login_metaboxes
1028
+ * @description Add custom metaboxes for login form
1029
+ * @change_log
1030
+ * ["Since: 2.0"]
1031
+ * @usage add_action( 'um_admin_custom_login_metaboxes', 'function_name', 10 );
1032
+ * @example
1033
+ * <?php
1034
+ * add_action( 'um_admin_custom_login_metaboxes', 'my_admin_custom_login_metaboxes', 10 );
1035
+ * function my_admin_custom_login_metaboxes() {
1036
+ * // your code here
1037
+ * }
1038
+ * ?>
1039
+ */
1040
+ do_action( 'um_admin_custom_login_metaboxes' );
1041
+ }
1042
+
1043
+
1044
+ /**
1045
+ * Save directory metabox
1046
+ *
1047
+ * @param $post_id
1048
+ * @param $post
1049
+ */
1050
+ function save_metabox_directory( $post_id, $post ) {
1051
+ global $wpdb;
1052
+
1053
+ // validate nonce
1054
+ if ( ! isset( $_POST['um_admin_save_metabox_directory_nonce'] ) ||
1055
+ ! wp_verify_nonce( $_POST['um_admin_save_metabox_directory_nonce'], basename( __FILE__ ) ) ) {
1056
+ return;
1057
+ }
1058
+
1059
+ // validate post type
1060
+ if ( $post->post_type != 'um_directory' ) {
1061
+ return;
1062
+ }
1063
+
1064
+ // validate user
1065
+ $post_type = get_post_type_object( $post->post_type );
1066
+ if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
1067
+ return;
1068
+ }
1069
+
1070
+ $where = array( 'ID' => $post_id );
1071
+
1072
+ if ( empty( $_POST['post_title'] ) ) {
1073
+ $_POST['post_title'] = sprintf( __( 'Directory #%s', 'ultimate-member' ), $post_id );
1074
+ }
1075
+
1076
+ $wpdb->update( $wpdb->posts, array( 'post_title' => sanitize_text_field( $_POST['post_title'] ) ), $where );
1077
+
1078
+ do_action( 'um_before_member_directory_save', $post_id );
1079
+
1080
+ // save
1081
+ delete_post_meta( $post_id, '_um_roles' );
1082
+ delete_post_meta( $post_id, '_um_tagline_fields' );
1083
+ delete_post_meta( $post_id, '_um_reveal_fields' );
1084
+ delete_post_meta( $post_id, '_um_search_fields' );
1085
+ delete_post_meta( $post_id, '_um_roles_can_search' );
1086
+ delete_post_meta( $post_id, '_um_roles_can_filter' );
1087
+ delete_post_meta( $post_id, '_um_show_these_users' );
1088
+ delete_post_meta( $post_id, '_um_exclude_these_users' );
1089
+
1090
+ delete_post_meta( $post_id, '_um_search_filters' );
1091
+ delete_post_meta( $post_id, '_um_search_filters_gmt' );
1092
+
1093
+ delete_post_meta( $post_id, '_um_sorting_fields' );
1094
+
1095
+ //save metadata
1096
+ $metadata = UM()->admin()->sanitize_member_directory_meta( $_POST['um_metadata'] );
1097
+ foreach ( $metadata as $k => $v ) {
1098
+
1099
+ if ( $k == '_um_show_these_users' && trim( $v ) ) {
1100
+ $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1101
+ }
1102
+
1103
+ if ( $k == '_um_exclude_these_users' && trim( $v ) ) {
1104
+ $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1105
+ }
1106
+
1107
+ if ( strstr( $k, '_um_' ) ) {
1108
+
1109
+ if ( $k === '_um_is_default' ) {
1110
+
1111
+ $mode = UM()->query()->get_attr( 'mode', $post_id );
1112
+
1113
+ if ( ! empty( $mode ) ) {
1114
+
1115
+ $posts = $wpdb->get_col(
1116
+ "SELECT post_id
1117
+ FROM {$wpdb->postmeta}
1118
+ WHERE meta_key = '_um_mode' AND
1119
+ meta_value = 'directory'"
1120
+ );
1121
+
1122
+ foreach ( $posts as $p_id ) {
1123
+ delete_post_meta( $p_id, '_um_is_default' );
1124
+ }
1125
+
1126
+ }
1127
+
1128
+ }
1129
+
1130
+ $v = apply_filters( 'um_member_directory_meta_value_before_save', $v, $k, $post_id );
1131
+
1132
+ update_post_meta( $post_id, $k, $v );
1133
+
1134
+ }
1135
+ }
1136
+
1137
+ update_post_meta( $post_id, '_um_search_filters_gmt', (int) $_POST['um-gmt-offset'] );
1138
+ }
1139
+
1140
+
1141
+ /**
1142
+ * Save form metabox
1143
+ *
1144
+ * @param $post_id
1145
+ * @param $post
1146
+ */
1147
+ function save_metabox_form( $post_id, $post ) {
1148
+ global $wpdb;
1149
+
1150
+ // validate nonce
1151
+ if ( ! isset( $_POST['um_admin_save_metabox_form_nonce'] ) ||
1152
+ ! wp_verify_nonce( $_POST['um_admin_save_metabox_form_nonce'], basename( __FILE__ ) ) ) {
1153
+ return;
1154
+ }
1155
+
1156
+ // validate post type
1157
+ if ( $post->post_type != 'um_form' ) {
1158
+ return;
1159
+ }
1160
+
1161
+ // validate user
1162
+ $post_type = get_post_type_object( $post->post_type );
1163
+ if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
1164
+ return;
1165
+ }
1166
+
1167
+ $where = array( 'ID' => $post_id );
1168
+ if ( empty( $_POST['post_title'] ) ) {
1169
+ $_POST['post_title'] = sprintf( __( 'Form #%s', 'ultimate-member' ), $post_id );
1170
+ }
1171
+ $wpdb->update( $wpdb->posts, array( 'post_title' => sanitize_text_field( $_POST['post_title'] ) ), $where );
1172
+
1173
+ // save
1174
+ delete_post_meta( $post_id, '_um_profile_metafields' );
1175
+
1176
+ $form_meta = UM()->admin()->sanitize_form_meta( $_POST['form'] );
1177
+
1178
+ foreach ( $form_meta as $k => $v ) {
1179
+ if ( strstr( $k, '_um_' ) ) {
1180
+ if ( $k === '_um_is_default' ) {
1181
+ $mode = UM()->query()->get_attr( 'mode', $post_id );
1182
+ if ( ! empty( $mode ) ) {
1183
+ $posts = $wpdb->get_col( $wpdb->prepare(
1184
+ "SELECT post_id
1185
+ FROM {$wpdb->postmeta}
1186
+ WHERE meta_key = '_um_mode' AND
1187
+ meta_value = %s",
1188
+ $mode
1189
+ ) );
1190
+ foreach ( $posts as $p_id ) {
1191
+ delete_post_meta( $p_id, '_um_is_default' );
1192
+ }
1193
+ }
1194
+ }
1195
+
1196
+ update_post_meta( $post_id, $k, $v );
1197
+ }
1198
+ }
1199
+
1200
+ }
1201
+
1202
+
1203
+ /**
1204
+ * Load modal content
1205
+ */
1206
+ function load_modal_content() {
1207
+ $screen = get_current_screen();
1208
+
1209
+ if ( isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) {
1210
+ foreach ( glob( um_path . 'includes/admin/templates/modal/forms/*.php' ) as $modal_content ) {
1211
+ include_once $modal_content;
1212
+ }
1213
+ }
1214
+
1215
+ if ( $this->init_icon ) {
1216
+ include_once um_path . 'includes/admin/templates/modal/forms/fonticons.php';
1217
+ }
1218
+
1219
+ if ( $screen->id == 'users' ) {
1220
+ include_once um_path . 'includes/admin/templates/modal/dynamic_registration_preview.php';
1221
+ }
1222
+
1223
+ // needed on forms only
1224
+ if ( ! isset( $this->is_loaded ) && isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) {
1225
+ $settings['textarea_rows'] = 8;
1226
+
1227
+ echo '<div class="um-hidden-editor-edit" style="display:none;">';
1228
+ wp_editor( '', 'um_editor_edit', $settings );
1229
+ echo '</div>';
1230
+
1231
+ echo '<div class="um-hidden-editor-new" style="display:none;">';
1232
+ wp_editor( '', 'um_editor_new', $settings );
1233
+ echo '</div>';
1234
+
1235
+ $this->is_loaded = true;
1236
+ }
1237
+ }
1238
+
1239
+
1240
+ /**
1241
+ * Show field input for edit at modal field
1242
+ *
1243
+ * @param $attribute
1244
+ * @param null $form_id
1245
+ * @param array $field_args
1246
+ */
1247
+ function field_input( $attribute, $form_id = null, $field_args = array() ) {
1248
+
1249
+ if ( $this->in_edit == true ) { // we're editing a field
1250
+ $real_attr = substr( $attribute, 1 );
1251
+ $this->edit_mode_value = isset( $this->edit_array[ $real_attr ] ) ? $this->edit_array[ $real_attr ] : null;
1252
+ }
1253
+
1254
+ switch ( $attribute ) {
1255
+
1256
+ default:
1257
+
1258
+ /**
1259
+ * UM hook
1260
+ *
1261
+ * @type action
1262
+ * @title um_admin_field_edit_hook{$attribute}
1263
+ * @description Integration for 3-d party fields at wp-admin
1264
+ * @input_vars
1265
+ * [{"var":"$edit_mode_value","type":"string","desc":"Post ID"}]
1266
+ * @change_log
1267
+ * ["Since: 2.0"]
1268
+ * @usage add_action( 'um_admin_field_edit_hook{$attribute}', 'function_name', 10, 1 );
1269
+ * @example
1270
+ * <?php
1271
+ * add_action( 'um_admin_field_edit_hook{$attribute}', 'my_admin_field_edit', 10, 1 );
1272
+ * function my_admin_field_edit( $edit_mode_value ) {
1273
+ * // your code here
1274
+ * }
1275
+ * ?>
1276
+ */
1277
+ do_action( "um_admin_field_edit_hook{$attribute}", $this->edit_mode_value, $form_id, $this->edit_array );
1278
+
1279
+ break;
1280
+
1281
+ case '_visibility':
1282
+ ?>
1283
+
1284
+ <p><label for="_visibility"><?php _e( 'Visibility', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select where this field should appear. This option should only be changed on the profile form and allows you to show a field in one mode only (edit or view) or in both modes.','ultimate-member' ) ); ?></label>
1285
+ <select name="_visibility" id="_visibility" style="width: 100%">
1286
+ <option value="all" <?php selected( 'all', $this->edit_mode_value ); ?>><?php _e( 'View everywhere', 'ultimate-member' ) ?></option>
1287
+ <option value="edit" <?php selected( 'edit', $this->edit_mode_value ); ?>><?php _e( 'Edit mode only', 'ultimate-member' ) ?></option>
1288
+ <option value="view" <?php selected( 'view', $this->edit_mode_value ); ?>><?php _e( 'View mode only', 'ultimate-member' ) ?></option>
1289
+ </select>
1290
+ </p>
1291
+
1292
+ <?php
1293
+ break;
1294
+
1295
+ case '_conditional_action':
1296
+ case '_conditional_action1':
1297
+ case '_conditional_action2':
1298
+ case '_conditional_action3':
1299
+ case '_conditional_action4':
1300
+ ?>
1301
+
1302
+ <p>
1303
+ <select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 90px">
1304
+
1305
+ <option></option>
1306
+
1307
+ <?php $actions = array( 'show', 'hide' );
1308
+ foreach ( $actions as $action ) { ?>
1309
+
1310
+ <option value="<?php echo esc_attr( $action ); ?>" <?php selected( $action, $this->edit_mode_value ); ?>><?php echo $action; ?></option>
1311
+
1312
+ <?php } ?>
1313
+
1314
+ </select>
1315
+
1316
+ &nbsp;&nbsp;<?php _e( 'If' ); ?>
1317
+ </p>
1318
+
1319
+ <?php
1320
+ break;
1321
+
1322
+ case '_conditional_field':
1323
+ case '_conditional_field1':
1324
+ case '_conditional_field2':
1325
+ case '_conditional_field3':
1326
+ case '_conditional_field4':
1327
+ ?>
1328
+
1329
+ <p>
1330
+ <select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 150px">
1331
+
1332
+ <option></option>
1333
+
1334
+ <?php $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
1335
+
1336
+ foreach ( $fields as $key => $array ) {
1337
+ if ( isset( $array['title'] ) &&
1338
+ ( ! isset( $this->edit_array['metakey'] ) || $key != $this->edit_array['metakey'] ) ) { ?>
1339
+
1340
+ <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $key, $this->edit_mode_value ) ?>><?php echo $array['title'] ?></option>
1341
+
1342
+ <?php }
1343
+ } ?>
1344
+
1345
+ </select>
1346
+ </p>
1347
+
1348
+ <?php
1349
+ break;
1350
+
1351
+ case '_conditional_operator':
1352
+ case '_conditional_operator1':
1353
+ case '_conditional_operator2':
1354
+ case '_conditional_operator3':
1355
+ case '_conditional_operator4':
1356
+ ?>
1357
+
1358
+ <p>
1359
+ <select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 150px">
1360
+
1361
+ <option></option>
1362
+
1363
+ <?php $operators = array(
1364
+ 'empty',
1365
+ 'not empty',
1366
+ 'equals to',
1367
+ 'not equals',
1368
+ 'greater than',
1369
+ 'less than',
1370
+ 'contains'
1371
+ );
1372
+
1373
+ foreach ( $operators as $operator ) { ?>
1374
+
1375
+ <option value="<?php echo esc_attr( $operator ); ?>" <?php selected( $operator, $this->edit_mode_value ); ?>><?php echo $operator; ?></option>
1376
+
1377
+ <?php } ?>
1378
+
1379
+ </select>
1380
+ </p>
1381
+
1382
+ <?php
1383
+ break;
1384
+
1385
+ case '_conditional_value':
1386
+ case '_conditional_value1':
1387
+ case '_conditional_value2':
1388
+ case '_conditional_value3':
1389
+ case '_conditional_value4':
1390
+ ?>
1391
+
1392
+ <p>
1393
+ <input type="text" name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" value="<?php echo isset( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" placeholder="<?php esc_attr_e( 'Value', 'ultimate-member' ); ?>" style="width: 150px!important;position: relative;top: -1px;" />
1394
+ </p>
1395
+
1396
+ <?php
1397
+ break;
1398
+
1399
+ case '_validate':
1400
+ ?>
1401
+
1402
+ <p><label for="_validate"><?php _e( 'Validate', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Does this field require a special validation', 'ultimate-member' ) ); ?></label>
1403
+ <select name="_validate" id="_validate" data-placeholder="<?php esc_attr_e( 'Select a validation type...', 'ultimate-member' ) ?>" class="um-adm-conditional" data-cond1="custom" data-cond1-show="_custom_validate" style="width: 100%">
1404
+
1405
+ <option value="" <?php selected( '', $this->edit_mode_value ); ?>></option>
1406
+
1407
+ <?php foreach( UM()->builtin()->validation_types() as $key => $name ) { ?>
1408
+ <?php
1409
+ /**
1410
+ * UM hook
1411
+ *
1412
+ * @type filter
1413
+ * @title um_builtin_validation_types_continue_loop
1414
+ * @description Builtin Validation Types
1415
+ * @input_vars
1416
+ * [{"var":"$continue","type":"bool","desc":"Validate?"},
1417
+ * {"var":"$key","type":"string","desc":"Field Key"},
1418
+ * {"var":"$form_id","type":"int","desc":"Form ID"},
1419
+ * {"var":"$field_args","type":"array","desc":"Field Settings"}]
1420
+ * @change_log
1421
+ * ["Since: 2.0"]
1422
+ * @usage add_filter( 'um_builtin_validation_types_continue_loop', 'function_name', 10, 4 );
1423
+ * @example
1424
+ * <?php
1425
+ * add_filter( 'um_builtin_validation_types_continue_loop', 'my_builtin_validation_types', 10, 4 );
1426
+ * function my_builtin_validation_types( $continue, $key, $form_id, $field_args ) {
1427
+ * // your code here
1428
+ * return $continue;
1429
+ * }
1430
+ * ?>
1431
+ */
1432
+ $continue = apply_filters( "um_builtin_validation_types_continue_loop", true, $key, $form_id, $field_args );
1433
+ if ( $continue ) { ?>
1434
+ <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $this->edit_mode_value ); ?>><?php echo $name; ?></option>
1435
+ <?php } ?>
1436
+ <?php } ?>
1437
+
1438
+ </select>
1439
+ </p>
1440
+
1441
+ <?php
1442
+ break;
1443
+
1444
+ case '_custom_validate':
1445
+ ?>
1446
+
1447
+ <p class="_custom_validate"><label for="_custom_validate"><?php _e( 'Custom Action', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to apply your custom validation, you can use action hooks to add custom validation. Please refer to documentation for further details.', 'ultimate-member' ) ); ?></label>
1448
+ <input type="text" name="_custom_validate" id="_custom_validate" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1449
+ </p>
1450
+
1451
+ <?php
1452
+ break;
1453
+
1454
+ case '_icon':
1455
+
1456
+ if ( $this->set_field_type == 'row' ) {
1457
+ $back = 'UM_edit_row';
1458
+
1459
+ ?>
1460
+
1461
+ <p class="_heading_text"><label for="_icon"><?php _e( 'Icon', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
1462
+
1463
+ <a href="javascript:void(0);" class="button" data-modal="UM_fonticons" data-modal-size="normal" data-dynamic-content="um_admin_fonticon_selector" data-arg1="" data-arg2="" data-back="<?php echo esc_attr( $back ); ?>"><?php _e( 'Choose Icon', 'ultimate-member' ) ?></a>
1464
+
1465
+ <span class="um-admin-icon-value"><?php if ( $this->edit_mode_value ) { ?><i class="<?php echo $this->edit_mode_value; ?>"></i><?php } else { ?><?php _e( 'No Icon', 'ultimate-member' ) ?><?php } ?></span>
1466
+
1467
+ <input type="hidden" name="_icon" id="_icon" value="<?php echo (isset( $this->edit_mode_value ) ) ? $this->edit_mode_value : ''; ?>" />
1468
+
1469
+ <?php if ( $this->edit_mode_value ) { ?>
1470
+ <span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>
1471
+ <?php } else { ?>
1472
+ <span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>
1473
+ <?php } ?>
1474
+
1475
+ </p>
1476
+
1477
+ <?php } else {
1478
+
1479
+ if ( $this->in_edit ) {
1480
+ $back = 'UM_edit_field';
1481
+ } else {
1482
+ $back = 'UM_add_field';
1483
+ }
1484
+
1485
+ ?>
1486
+
1487
+ <div class="um-admin-tri">
1488
+
1489
+ <p><label for="_icon"><?php _e( 'Icon', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
1490
+
1491
+ <a href="javascript:void(0);" class="button" data-modal="UM_fonticons" data-modal-size="normal" data-dynamic-content="um_admin_fonticon_selector" data-arg1="" data-arg2="" data-back="<?php echo esc_attr( $back ); ?>"><?php _e( 'Choose Icon', 'ultimate-member' ) ?></a>
1492
+
1493
+ <span class="um-admin-icon-value"><?php if ( $this->edit_mode_value ) { ?><i class="<?php echo $this->edit_mode_value; ?>"></i><?php } else { ?><?php _e( 'No Icon', 'ultimate-member' ) ?><?php } ?></span>
1494
+
1495
+ <input type="hidden" name="_icon" id="_icon" value="<?php echo (isset( $this->edit_mode_value ) ) ? $this->edit_mode_value : ''; ?>" />
1496
+
1497
+ <?php if ( $this->edit_mode_value ) { ?>
1498
+ <span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>
1499
+ <?php } else { ?>
1500
+ <span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>
1501
+ <?php } ?>
1502
+
1503
+ </p>
1504
+
1505
+ </div>
1506
+
1507
+ <?php
1508
+
1509
+ }
1510
+
1511
+ break;
1512
+
1513
+ case '_css_class':
1514
+ ?>
1515
+
1516
+ <p><label for="_css_class"><?php _e( 'CSS Class', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Specify a custom CSS class to be applied to this element', 'ultimate-member' ) ); ?></label>
1517
+ <input type="text" name="_css_class" id="_css_class" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1518
+ </p>
1519
+
1520
+ <?php
1521
+ break;
1522
+
1523
+ case '_width':
1524
+ ?>
1525
+
1526
+ <p><label for="_width"><?php _e( 'Thickness (in pixels)', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the width in pixels, e.g. 4 or 2, etc', 'ultimate-member' ) ); ?></label>
1527
+ <input type="text" name="_width" id="_width" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 4; ?>" />
1528
+ </p>
1529
+
1530
+ <?php
1531
+ break;
1532
+
1533
+ case '_divider_text':
1534
+ ?>
1535
+
1536
+ <p><label for="_divider_text"><?php _e( 'Optional Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Optional text to include with the divider', 'ultimate-member' ) ); ?></label>
1537
+ <input type="text" name="_divider_text" id="_divider_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1538
+ </p>
1539
+
1540
+ <?php
1541
+ break;
1542
+
1543
+ case '_padding':
1544
+ ?>
1545
+
1546
+ <p><label for="_padding"><?php _e( 'Padding', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set padding for this section', 'ultimate-member' ) ); ?></label>
1547
+ <input type="text" name="_padding" id="_padding" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 0px 0px'; ?>" />
1548
+ </p>
1549
+
1550
+ <?php
1551
+ break;
1552
+
1553
+ case '_margin':
1554
+ ?>
1555
+
1556
+ <p><label for="_margin"><?php _e( 'Margin', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set margin for this section', 'ultimate-member' ) ); ?></label>
1557
+ <input type="text" name="_margin" id="_margin" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 30px 0px'; ?>" />
1558
+ </p>
1559
+
1560
+ <?php
1561
+ break;
1562
+
1563
+ case '_border':
1564
+ ?>
1565
+
1566
+ <p><label for="_border"><?php _e( 'Border', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set border for this section', 'ultimate-member' ) ); ?></label>
1567
+ <input type="text" name="_border" id="_border" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 0px 0px'; ?>" />
1568
+ </p>
1569
+
1570
+ <?php
1571
+ break;
1572
+
1573
+ case '_borderstyle':
1574
+ ?>
1575
+
1576
+ <p><label for="_borderstyle"><?php _e( 'Style', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the border style', 'ultimate-member' ) ); ?></label>
1577
+ <select name="_borderstyle" id="_borderstyle" style="width: 100%">
1578
+ <option value="solid" <?php selected( 'solid', $this->edit_mode_value ); ?>><?php _e( 'Solid', 'ultimate-member' ) ?></option>
1579
+ <option value="dotted" <?php selected( 'dotted', $this->edit_mode_value ); ?>><?php _e( 'Dotted', 'ultimate-member' ) ?></option>
1580
+ <option value="dashed" <?php selected( 'dashed', $this->edit_mode_value ); ?>><?php _e( 'Dashed', 'ultimate-member' ) ?></option>
1581
+ <option value="double" <?php selected( 'double', $this->edit_mode_value ); ?>><?php _e( 'Double', 'ultimate-member' ) ?></option>
1582
+ </select>
1583
+ </p>
1584
+
1585
+ <?php
1586
+ break;
1587
+
1588
+ case '_borderradius':
1589
+ ?>
1590
+
1591
+ <p><label for="_borderradius"><?php _e( 'Border Radius', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Rounded corners can be applied by setting a pixels value here. e.g. 5px', 'ultimate-member' ) ); ?></label>
1592
+ <input type="text" name="_borderradius" id="_borderradius" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px'; ?>" />
1593
+ </p>
1594
+
1595
+ <?php
1596
+ break;
1597
+
1598
+ case '_bordercolor':
1599
+ ?>
1600
+
1601
+ <p><label for="_bordercolor"><?php _e( 'Border Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Give a color to this border', 'ultimate-member' ) ); ?></label>
1602
+ <input type="text" name="_bordercolor" id="_bordercolor" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1603
+ </p>
1604
+
1605
+ <?php
1606
+ break;
1607
+
1608
+ case '_heading':
1609
+ ?>
1610
+
1611
+ <p><label for="_heading"><?php _e( 'Enable Row Heading', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to enable a heading for this row', 'ultimate-member' ) ); ?></label>
1612
+ <input type="checkbox" name="_heading" id="_heading" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_heading_text" data-cond1-hide="xxx" />
1613
+ </p>
1614
+
1615
+ <?php
1616
+ break;
1617
+
1618
+ case '_heading_text':
1619
+ ?>
1620
+
1621
+ <p class="_heading_text"><label for="_heading_text"><?php _e( 'Heading Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter the row heading text here', 'ultimate-member' ) ); ?></label>
1622
+ <input type="text" name="_heading_text" id="_heading_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1623
+ </p>
1624
+
1625
+ <?php
1626
+ break;
1627
+
1628
+ case '_background':
1629
+ ?>
1630
+
1631
+ <p><label for="_background"><?php _e( 'Background Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the background of entire section', 'ultimate-member' ) ); ?></label>
1632
+ <input type="text" name="_background" id="_background" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1633
+ </p>
1634
+
1635
+ <?php
1636
+ break;
1637
+
1638
+ case '_heading_background_color':
1639
+ ?>
1640
+
1641
+ <p class="_heading_text"><label for="_heading_background_color"><?php _e( 'Heading Background Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the background of the heading section', 'ultimate-member' ) ); ?></label>
1642
+ <input type="text" name="_heading_background_color" id="_heading_background_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1643
+ </p>
1644
+
1645
+ <?php
1646
+ break;
1647
+
1648
+ case '_heading_text_color':
1649
+ ?>
1650
+
1651
+ <p class="_heading_text"><label for="_heading_text_color"><?php _e( 'Heading Text Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the text color of heading part only', 'ultimate-member' ) ); ?></label>
1652
+ <input type="text" name="_heading_text_color" id="_heading_text_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1653
+ </p>
1654
+
1655
+ <?php
1656
+ break;
1657
+
1658
+ case '_text_color':
1659
+ ?>
1660
+
1661
+ <p><label for="_text_color"><?php _e( 'Text Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the text color of entire section', 'ultimate-member' ) ); ?></label>
1662
+ <input type="text" name="_text_color" id="_text_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1663
+ </p>
1664
+
1665
+ <?php
1666
+ break;
1667
+
1668
+ case '_icon_color':
1669
+ ?>
1670
+
1671
+ <p class="_heading_text"><label for="_icon_color"><?php _e( 'Icon Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the color of selected icon. By default It will be the same color as heading text color', 'ultimate-member' ) ); ?></label>
1672
+ <input type="text" name="_icon_color" id="_icon_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1673
+ </p>
1674
+
1675
+ <?php
1676
+ break;
1677
+
1678
+ case '_color':
1679
+ ?>
1680
+
1681
+ <p><label for="_color"><?php _e( 'Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select a color for this divider', 'ultimate-member' ) ); ?></label>
1682
+ <input type="text" name="_color" id="_color" class="um-admin-colorpicker" data-default-color="#eeeeee" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '#eeeeee'; ?>" />
1683
+ </p>
1684
+
1685
+ <?php
1686
+ break;
1687
+
1688
+ case '_url_text':
1689
+ ?>
1690
+
1691
+ <p><label for="_url_text"><?php _e( 'URL Alt Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Entering custom text here will replace the url with a text link', 'ultimate-member' ) ); ?></label>
1692
+ <input type="text" name="_url_text" id="_url_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
1693
+ </p>
1694
+
1695
+ <?php
1696
+ break;
1697
+
1698
+ case '_url_target':
1699
+ ?>
1700
+
1701
+ <p><label for="_url_target"><?php _e( 'Link Target', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose whether to open this link in same window or in a new window', 'ultimate-member' ) ); ?></label>
1702
+ <select name="_url_target" id="_url_target" style="width: 100%">
1703
+ <option value="_blank" <?php selected( '_blank', $this->edit_mode_value ); ?>><?php _e( 'Open in new window', 'ultimate-member' ) ?></option>
1704
+ <option value="_self" <?php selected( '_self', $this->edit_mode_value ); ?>><?php _e( 'Same window', 'ultimate-member' ) ?></option>
1705
+ </select>
1706
+ </p>
1707
+
1708
+ <?php
1709
+ break;
1710
+
1711
+ case '_url_rel':
1712
+ ?>
1713
+
1714
+ <p><label for="_url_rel"><?php _e( 'SEO Follow', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to follow or nofollow this link by search engines', 'ultimate-member' ) ); ?></label>
1715
+ <select name="_url_rel" id="_url_rel" style="width: 100%">
1716
+ <option value="follow" <?php selected( 'follow', $this->edit_mode_value ); ?>><?php _e( 'Follow', 'ultimate-member' ) ?></option>
1717
+ <option value="nofollow" <?php selected( 'nofollow', $this->edit_mode_value ); ?>><?php _e( 'No-Follow', 'ultimate-member' ) ?></option>
1718
+ </select>
1719
+ </p>
1720
+
1721
+ <?php
1722
+ break;
1723
+
1724
+ case '_force_good_pass':
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 : 0 ) ?> />
1729
+ </p>
1730
+
1731
+ <?php
1732
+ break;
1733
+
1734
+ case '_force_confirm_pass':
1735
+ ?>
1736
+
1737
+ <p><label for="_force_confirm_pass"><?php _e( 'Automatically add a confirm password field?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on to add a confirm password field. If turned on the confirm password field will only show on register forms and not on login forms.', 'ultimate-member' ) ); ?></label>
1738
+ <input type="checkbox" name="_force_confirm_pass" id="_force_confirm_pass" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_label_confirm_pass" data-cond1-hide="xxx" />
1739
+ </p>
1740
+
1741
+ <?php
1742
+ break;
1743
+
1744
+ case '_style':
1745
+ ?>
1746
+
1747
+ <p><label for="_style"><?php _e( 'Style', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the line-style of divider', 'ultimate-member' ) ); ?></label>
1748
+ <select name="_style" id="_style" style="width: 100%">
1749
+ <option value="solid" <?php selected( 'solid', $this->edit_mode_value ); ?>><?php _e( 'Solid', 'ultimate-member' ) ?></option>
1750
+ <option value="dotted" <?php selected( 'dotted', $this->edit_mode_value ); ?>><?php _e( 'Dotted', 'ultimate-member' ) ?></option>
1751
+ <option value="dashed" <?php selected( 'dashed', $this->edit_mode_value ); ?>><?php _e( 'Dashed', 'ultimate-member' ) ?></option>
1752
+ <option value="double" <?php selected( 'double', $this->edit_mode_value ); ?>><?php _e( 'Double', 'ultimate-member' ) ?></option>
1753
+ </select>
1754
+ </p>
1755
+
1756
+ <?php
1757
+ break;
1758
+
1759
+ case '_intervals':
1760
+
1761
+ ?>
1762
+
1763
+ <p><label for="_intervals"><?php _e( 'Time Intervals (in minutes)', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the minutes interval between each time in the time picker.', 'ultimate-member' ) ); ?></label>
1764
+ <input type="text" name="_intervals" id="_intervals" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 60; ?>" placeholder="<?php esc_attr_e( 'e.g. 30, 60, 120', 'ultimate-member' ) ?>" />
1765
+ </p>
1766
+
1767
+ <?php
1768
+ break;
1769
+
1770
+
1771
+ case '_format':
1772
+
1773
+ if ( $this->set_field_type == 'date' ) {
1774
+ ?>
1775
+
1776
+ <p><label for="_format"><?php _e( 'Date User-Friendly Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The display format of the date which is visible to user.', 'ultimate-member' ) ); ?></label>
1777
+ <select name="_format" id="_format" style="width: 100%">
1778
+ <option value="j M Y" <?php selected( 'j M Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('j M Y'); ?></option>
1779
+ <option value="M j Y" <?php selected( 'M j Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('M j Y'); ?></option>
1780
+ <option value="j F Y" <?php selected( 'j F Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('j F Y'); ?></option>
1781
+ <option value="F j Y" <?php selected( 'F j Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('F j Y'); ?></option>
1782
+ </select>
1783
+ </p>
1784
+
1785
+ <?php } else { ?>
1786
+
1787
+ <p><label for="_format"><?php _e( 'Time Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the displayed time-format for this field', 'ultimate-member' ) ); ?></label>
1788
+ <select name="_format" id="_format" style="width: 100%">
1789
+ <option value="g:i a" <?php selected( 'g:i a', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('g:i a'); ?><?php _e( '( 12-hr format )', 'ultimate-member' ) ?></option>
1790
+ <option value="g:i A" <?php selected( 'g:i A', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('g:i A'); ?><?php _e( '( 12-hr format )', 'ultimate-member' ) ?></option>
1791
+ <option value="H:i" <?php selected( 'H:i', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('H:i'); ?><?php _e( '( 24-hr format )', 'ultimate-member' ) ?></option>
1792
+ </select>
1793
+ </p>
1794
+
1795
+ <?php
1796
+ }
1797
+ break;
1798
+
1799
+ case '_format_custom':
1800
+ ?>
1801
+
1802
+ <p><label for="_format_custom"><?php _e( 'Use custom Date format', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'This option overrides "Date User-Friendly Format" option. See https://www.php.net/manual/en/function.date.php', 'ultimate-member' ) ); ?></label>
1803
+ <input type="text" name="_format_custom" id="_format_custom" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" placeholder="j M Y" />
1804
+ </p>
1805
+
1806
+ <?php
1807
+ break;
1808
+
1809
+ case '_pretty_format':
1810
+ ?>
1811
+
1812
+ <p><label for="_pretty_format"><?php _e( 'Displayed Date Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether you wish to show the date in full or only show the years e.g. 25 Years', 'ultimate-member' ) ); ?></label>
1813
+ <select name="_pretty_format" id="_pretty_format" style="width: 100%">
1814
+ <option value="0" <?php selected( 0, $this->edit_mode_value ); ?>><?php _e( 'Show full date', 'ultimate-member' ) ?></option>
1815
+ <option value="1" <?php selected( 1, $this->edit_mode_value ); ?>><?php _e( 'Show years only', 'ultimate-member' ) ?></option>
1816
+ </select>
1817
+ </p>
1818
+
1819
+ <?php
1820
+ break;
1821
+
1822
+ case '_disabled_weekdays':
1823
+
1824
+ if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
1825
+ $values = $this->edit_mode_value;
1826
+ } else {
1827
+ $values = array('');
1828
+ }
1829
+ ?>
1830
+
1831
+ <p><label for="_disabled_weekdays"><?php _e( 'Disable specific weekdays', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Disable specific week days from being available for selection in this date picker', 'ultimate-member' ) ); ?></label>
1832
+ <select name="_disabled_weekdays[]" id="_disabled_weekdays" multiple="multiple" style="width: 100%">
1833
+ <option value="1" <?php if ( in_array( 1, $values ) ) { echo 'selected'; } ?>><?php _e( 'Sunday', 'ultimate-member' ) ?></option>
1834
+ <option value="2" <?php if ( in_array( 2, $values ) ) { echo 'selected'; } ?>><?php _e( 'Monday', 'ultimate-member' ) ?></option>
1835
+ <option value="3" <?php if ( in_array( 3, $values ) ) { echo 'selected'; } ?>><?php _e( 'Tuesday', 'ultimate-member' ) ?></option>
1836
+ <option value="4" <?php if ( in_array( 4, $values ) ) { echo 'selected'; } ?>><?php _e( 'Wednesday', 'ultimate-member' ) ?></option>
1837
+ <option value="5" <?php if ( in_array( 5, $values ) ) { echo 'selected'; } ?>><?php _e( 'Thursday', 'ultimate-member' ) ?></option>
1838
+ <option value="6" <?php if ( in_array( 6, $values ) ) { echo 'selected'; } ?>><?php _e( 'Friday', 'ultimate-member' ) ?></option>
1839
+ <option value="7" <?php if ( in_array( 7, $values ) ) { echo 'selected'; } ?>><?php _e( 'Saturday', 'ultimate-member' ) ?></option>
1840
+ </select>
1841
+ </p>
1842
+
1843
+ <?php
1844
+ break;
1845
+
1846
+ case '_years':
1847
+ ?>
1848
+
1849
+ <p class="_years"><label for="_years"><?php _e( 'Number of Years to pick from', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Number of years available for the date selection. Default to last 50 years', 'ultimate-member' ) ); ?></label>
1850
+ <input type="text" name="_years" id="_years" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 50; ?>" />
1851
+ </p>
1852
+
1853
+ <?php
1854
+ break;
1855
+
1856
+ case '_years_x':
1857
+ ?>
1858
+
1859
+ <p class="_years"><label for="_years_x"><?php _e( 'Years Selection', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This decides which years should be shown relative to today date', 'ultimate-member' ) ); ?></label>
1860
+ <select name="_years_x" id="_years_x" style="width: 100%">
1861
+ <option value="equal" <?php selected( 'equal', $this->edit_mode_value ); ?>><?php _e( 'Equal years before / after today', 'ultimate-member' ) ?></option>
1862
+ <option value="past" <?php selected( 'past', $this->edit_mode_value ); ?>><?php _e( 'Past years only', 'ultimate-member' ) ?></option>
1863
+ <option value="future" <?php selected( 'future', $this->edit_mode_value ); ?>><?php _e( 'Future years only', 'ultimate-member' ) ?></option>
1864
+ </select>
1865
+ </p>
1866
+
1867
+ <?php
1868
+ break;
1869
+
1870
+ case '_range_start':
1871
+ ?>
1872
+
1873
+ <p class="_date_range"><label for="_range_start"><?php _e( 'Date Range Start', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set the minimum date/day in range in the format YYYY/MM/DD', 'ultimate-member' ) ); ?></label>
1874
+ <input type="text" name="_range_start" id="_range_start" value="<?php echo $this->edit_mode_value; ?>" placeholder="<?php esc_attr_e( 'YYYY/MM/DD', 'ultimate-member' ) ?>" />
1875
+ </p>
1876
+
1877
+ <?php
1878
+ break;
1879
+
1880
+ case '_range_end':
1881
+ ?>
1882
+
1883
+ <p class="_date_range"><label for="_range_end"><?php _e( 'Date Range End', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set the maximum date/day in range in the format YYYY/MM/DD', 'ultimate-member' ) ); ?></label>
1884
+ <input type="text" name="_range_end" id="_range_end" value="<?php echo $this->edit_mode_value; ?>" placeholder="<?php esc_attr_e( 'YYYY/MM/DD', 'ultimate-member' ) ?>" />
1885
+ </p>
1886
+
1887
+ <?php
1888
+ break;
1889
+
1890
+ case '_range':
1891
+ ?>
1892
+
1893
+ <p><label for="_range"><?php _e( 'Set Date Range', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to show a specific number of years or specify a date range to be available for the date picker.', 'ultimate-member' ) ); ?></label>
1894
+ <select name="_range" id="_range" class="um-adm-conditional" data-cond1='years' data-cond1-show='_years' data-cond2="date_range" data-cond2-show="_date_range" style="width: 100%">
1895
+ <option value="years" <?php selected( 'years', $this->edit_mode_value ); ?>><?php _e( 'Fixed Number of Years', 'ultimate-member' ) ?></option>
1896
+ <option value="date_range" <?php selected( 'date_range', $this->edit_mode_value ); ?>><?php _e( 'Specific Date Range', 'ultimate-member' ) ?></option>
1897
+ </select>
1898
+ </p>
1899
+
1900
+ <?php
1901
+ break;
1902
+
1903
+ case '_content':
1904
+
1905
+ if ( $this->set_field_type == 'shortcode' ) {
1906
+
1907
+ ?>
1908
+
1909
+ <p><label for="_content"><?php _e( 'Enter Shortcode', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter the shortcode in the following textarea and it will be displayed on the fields', 'ultimate-member' ) ); ?></label>
1910
+ <textarea name="_content" id="_content" placeholder="<?php esc_attr_e( 'e.g. [my_custom_shortcode]', 'ultimate-member' ) ?>"><?php echo $this->edit_mode_value; ?></textarea>
1911
+ </p>
1912
+
1913
+ <?php
1914
+
1915
+ } else {
1916
+
1917
+ ?>
1918
+
1919
+ <div class="um-admin-editor-h"><label><?php _e( 'Content Editor', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Edit the content of this field here', 'ultimate-member' ) ); ?></label></div>
1920
+
1921
+ <div class="um-admin-editor"><!-- editor dynamically loaded here --></div>
1922
+
1923
+ <?php
1924
+
1925
+ }
1926
+
1927
+ break;
1928
+
1929
+ case '_crop':
1930
+ ?>
1931
+
1932
+ <p><label for="_crop"><?php _e( 'Crop Feature', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enable/disable crop feature for this image upload and define ratio', 'ultimate-member' ) ); ?></label>
1933
+ <select name="_crop" id="_crop" style="width: 100%">
1934
+ <option value="0" <?php selected( '0', $this->edit_mode_value ); ?>><?php _e( 'Turn Off (Default)', 'ultimate-member' ) ?></option>
1935
+ <option value="1" <?php selected( '1', $this->edit_mode_value ); ?>><?php _e( 'Crop and force 1:1 ratio', 'ultimate-member' ) ?></option>
1936
+ <option value="3" <?php selected( '3', $this->edit_mode_value ); ?>><?php _e( 'Crop and force user-defined ratio', 'ultimate-member' ) ?></option>
1937
+ </select>
1938
+ </p>
1939
+
1940
+ <?php
1941
+ break;
1942
+
1943
+ case '_allowed_types':
1944
+
1945
+ if ( $this->set_field_type == 'image' ) {
1946
+
1947
+ if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
1948
+ $values = $this->edit_mode_value;
1949
+ } else {
1950
+ $values = array( 'png','jpeg','jpg','gif' );
1951
+ } ?>
1952
+
1953
+ <p><label for="_allowed_types"><?php _e( 'Allowed Image Types', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the image types that you want to allow to be uploaded via this field.', 'ultimate-member' ) ); ?></label>
1954
+ <select name="_allowed_types[]" id="_allowed_types" multiple="multiple" style="width: 100%">
1955
+ <?php foreach( UM()->files()->allowed_image_types() as $e => $n ) { ?>
1956
+ <option value="<?php echo $e; ?>" <?php if ( in_array( $e, $values ) ) { echo 'selected'; } ?>><?php echo $n; ?></option>
1957
+ <?php } ?>
1958
+ </select>
1959
+ </p>
1960
+
1961
+ <?php
1962
+
1963
+ } else {
1964
+
1965
+ if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
1966
+ $values = $this->edit_mode_value;
1967
+ } else {
1968
+ $values = array( 'pdf', 'txt' );
1969
+ } ?>
1970
+
1971
+ <p><label for="_allowed_types"><?php _e( 'Allowed File Types', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the image types that you want to allow to be uploaded via this field.', 'ultimate-member' ) ); ?></label>
1972
+ <select name="_allowed_types[]" id="_allowed_types" multiple="multiple" style="width: 100%">
1973
+ <?php foreach( UM()->files()->allowed_file_types() as $e => $n ) { ?>
1974
+ <option value="<?php echo $e; ?>" <?php if ( in_array( $e, $values ) ) { echo 'selected'; } ?>><?php echo $n; ?></option>
1975
+ <?php } ?>
1976
+ </select>
1977
+ </p>
1978
+
1979
+ <?php
1980
+
1981
+ }
1982
+
1983
+ break;
1984
+
1985
+ case '_upload_text':
1986
+
1987
+ if ( $this->set_field_type == 'image' ) {
1988
+ $value = __( 'Drag &amp; Drop Photo', 'ultimate-member' );
1989
+ }
1990
+ if ( $this->set_field_type == 'file' ) {
1991
+ $value = __( 'Drag &amp; Drop File', 'ultimate-member' );
1992
+ }
1993
+
1994
+ ?>
1995
+
1996
+ <p><label for="_upload_text"><?php _e( 'Upload Box Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the headline that appears in the upload box for this field', 'ultimate-member' ) ); ?></label>
1997
+ <input type="text" name="_upload_text" id="_upload_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : $value; ?>" />
1998
+ </p>
1999
+
2000
+ <?php
2001
+ break;
2002
+
2003
+ case '_upload_help_text':
2004
+ ?>
2005
+
2006
+ <p><label for="_upload_help_text"><?php _e( 'Additional Instructions Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you need to add information or secondary line below the headline of upload box, enter it here', 'ultimate-member' ) ); ?></label>
2007
+ <input type="text" name="_upload_help_text" id="_upload_help_text" value="<?php echo $this->edit_mode_value; ?>" />
2008
+ </p>
2009
+
2010
+ <?php
2011
+ break;
2012
+
2013
+ case '_button_text':
2014
+ ?>
2015
+
2016
+ <p><label for="_button_text"><?php _e( 'Upload Box Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The text that appears on the button. e.g. Upload', 'ultimate-member' ) ); ?></label>
2017
+ <input type="text" name="_button_text" id="_button_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : __( 'Upload', 'ultimate-member' ); ?>" />
2018
+ </p>
2019
+
2020
+ <?php
2021
+ break;
2022
+
2023
+ case '_max_size':
2024
+ ?>
2025
+
2026
+ <p><label for="_max_size"><?php _e( 'Maximum Size in bytes', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The maximum size for image that can be uploaded through this field. Leave empty for unlimited size.', 'ultimate-member' ) ); ?></label>
2027
+ <input type="text" name="_max_size" id="_max_size" value="<?php echo $this->edit_mode_value; ?>" />
2028
+ </p>
2029
+
2030
+ <?php
2031
+ break;
2032
+
2033
+ case '_height':
2034
+ ?>
2035
+
2036
+ <p><label for="_height"><?php _e( 'Textarea Height', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The height of textarea in pixels. Default is 100 pixels', 'ultimate-member' ) ); ?></label>
2037
+ <input type="text" name="_height" id="_height" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '100px'; ?>" />
2038
+ </p>
2039
+
2040
+ <?php
2041
+ break;
2042
+
2043
+ case '_spacing':
2044
+ ?>
2045
+
2046
+ <p><label for="_spacing"><?php _e( 'Spacing', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the required spacing in pixels. e.g. 20px', 'ultimate-member' ) ); ?></label>
2047
+ <input type="text" name="_spacing" id="_spacing" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '20px'; ?>" />
2048
+ </p>
2049
+
2050
+ <?php
2051
+ break;
2052
+
2053
+ case '_is_multi':
2054
+ ?>
2055
+
2056
+ <p><label for="_is_multi"><?php _e( 'Allow multiple selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enable/disable multiple selections for this field', 'ultimate-member' ) ); ?></label>
2057
+ <input type="checkbox" name="_is_multi" id="_is_multi" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_max_selections" data-cond1-hide="xxx" />
2058
+ </p>
2059
+
2060
+ <?php
2061
+ break;
2062
+
2063
+ case '_max_selections':
2064
+ ?>
2065
+
2066
+ <p class="_max_selections"><label for="_max_selections"><?php _e( 'Maximum number of selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter a number here to force a maximum number of selections by user for this field', 'ultimate-member' ) ); ?></label>
2067
+ <input type="text" name="_max_selections" id="_max_selections" value="<?php echo $this->edit_mode_value; ?>" />
2068
+ </p>
2069
+
2070
+ <?php
2071
+ break;
2072
+
2073
+ case '_min_selections':
2074
+ ?>
2075
+
2076
+ <p class="_min_selections"><label for="_min_selections"><?php _e( 'Minimum number of selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter a number here to force a minimum number of selections by user for this field', 'ultimate-member' ) ); ?></label>
2077
+ <input type="text" name="_min_selections" id="_min_selections" value="<?php echo $this->edit_mode_value; ?>" />
2078
+ </p>
2079
+
2080
+ <?php
2081
+ break;
2082
+
2083
+ case '_max_entries':
2084
+ ?>
2085
+
2086
+ <p class="_max_entries"><label for="_max_selections"><?php _e( 'Maximum number of entries', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the max number of entries the user can add via field group.', 'ultimate-member' ) ); ?></label>
2087
+ <input type="text" name="_max_entries" id="_max_entries" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 10; ?>" />
2088
+ </p>
2089
+
2090
+ <?php
2091
+ break;
2092
+
2093
+ case '_max_words':
2094
+ ?>
2095
+
2096
+ <p><label for="_max_words"><?php _e( 'Maximum allowed words', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a maximum number of words to be input in this textarea. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
2097
+ <input type="text" name="_max_words" id="_max_words" value="<?php echo $this->edit_mode_value; ?>" />
2098
+ </p>
2099
+
2100
+ <?php
2101
+ break;
2102
+
2103
+ case '_min':
2104
+ ?>
2105
+
2106
+ <p><label for="_min"><?php _e( 'Minimum Number', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Minimum number that can be entered in this field', 'ultimate-member' ) ); ?></label>
2107
+ <input type="text" name="_min" id="_min" value="<?php echo $this->edit_mode_value; ?>" />
2108
+ </p>
2109
+
2110
+ <?php
2111
+ break;
2112
+
2113
+ case '_max':
2114
+ ?>
2115
+
2116
+ <p><label for="_max"><?php _e( 'Maximum Number', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Maximum number that can be entered in this field', 'ultimate-member' ) ); ?></label>
2117
+ <input type="text" name="_max" id="_max" value="<?php echo $this->edit_mode_value; ?>" />
2118
+ </p>
2119
+
2120
+ <?php
2121
+ break;
2122
+
2123
+ case '_min_chars':
2124
+ ?>
2125
+
2126
+ <p><label for="_min_chars"><?php _e( 'Minimum length', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a minimum number of characters to be input in this field. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
2127
+ <input type="text" name="_min_chars" id="_min_chars" value="<?php echo $this->edit_mode_value; ?>" />
2128
+ </p>
2129
+
2130
+ <?php
2131
+ break;
2132
+
2133
+ case '_max_chars':
2134
+ ?>
2135
+
2136
+ <p><label for="_max_chars"><?php _e( 'Maximum length', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a maximum number of characters to be input in this field. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
2137
+ <input type="text" name="_max_chars" id="_max_chars" value="<?php echo $this->edit_mode_value; ?>" />
2138
+ </p>
2139
+
2140
+ <?php
2141
+ break;
2142
+
2143
+ case '_html':
2144
+ ?>
2145
+
2146
+ <p><label for="_html"><?php _e( 'Does this textarea accept HTML?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on/off HTML tags for this textarea', 'ultimate-member' ) ); ?></label>
2147
+ <input type="checkbox" name="_html" id="_html" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> />
2148
+ </p>
2149
+
2150
+ <?php
2151
+ break;
2152
+
2153
+ case '_options':
2154
+
2155
+ if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
2156
+ $values = implode("\n", $this->edit_mode_value);
2157
+ } else if ( $this->edit_mode_value ) {
2158
+ $values = $this->edit_mode_value;
2159
+ } else {
2160
+ $values = '';
2161
+ } ?>
2162
+
2163
+ <p><label for="_options"><?php _e( 'Edit Choices', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter one choice per line. This will represent the available choices or selections available for user.', 'ultimate-member' ) ); ?></label>
2164
+ <textarea name="_options" id="_options"><?php echo $values; ?></textarea>
2165
+ </p>
2166
+
2167
+ <?php
2168
+ break;
2169
+
2170
+ case '_title':
2171
+ ?>
2172
+
2173
+ <p><label for="_title"><?php _e( 'Title', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the title of the field for your reference in the backend. The title will not appear on the front-end of your website.', 'ultimate-member' ) ); ?></label>
2174
+ <input type="text" name="_title" id="_title" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2175
+ </p>
2176
+
2177
+ <?php
2178
+ break;
2179
+
2180
+ case '_id':
2181
+
2182
+ ?>
2183
+
2184
+ <p style="display:none"><label for="_id"><?php _e( 'Unique ID', 'ultimate-member' ) ?></label>
2185
+ <input type="text" name="_id" id="_id" value="<?php echo $this->edit_mode_value; ?>" />
2186
+ </p>
2187
+
2188
+ <?php
2189
+
2190
+ break;
2191
+
2192
+ case '_metakey':
2193
+
2194
+ if ( $this->in_edit ) {
2195
+
2196
+ ?>
2197
+
2198
+ <p><label for="_metakey"><?php _e( 'Meta Key', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The meta key cannot be changed for duplicated fields or when editing an existing field. If you require a different meta key please create a new field.', 'ultimate-member' ) ); ?></label>
2199
+ <input type="text" name="_metakey_locked" id="_metakey_locked" value="<?php echo $this->edit_mode_value; ?>" disabled />
2200
+ </p>
2201
+
2202
+ <?php } else { ?>
2203
+
2204
+ <p><label for="_metakey"><?php _e( 'Meta Key', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'A meta key is required to store the entered info in this field in the database. The meta key should be unique to this field and be written in lowercase with an underscore ( _ ) separating words e.g country_list or job_title', 'ultimate-member' ) ); ?></label>
2205
+ <input type="text" name="_metakey" id="_metakey" value="" />
2206
+ </p>
2207
+
2208
+ <?php
2209
+
2210
+ }
2211
+
2212
+ break;
2213
+
2214
+ case '_help':
2215
+ ?>
2216
+
2217
+ <p><label for="_help"><?php _e( 'Help Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __('This is the text that appears in a tooltip when a user hovers over the info icon. Help text is useful for providing users with more information about what they should enter in the field. Leave blank if no help text is needed for field.', 'ultimate-member' ) ); ?></label>
2218
+ <input type="text" name="_help" id="_help" value="<?php echo $this->edit_mode_value; ?>" />
2219
+ </p>
2220
+
2221
+ <?php
2222
+ break;
2223
+
2224
+ case '_default':
2225
+ ?>
2226
+
2227
+ <?php if ( $this->set_field_type == 'textarea' ) { ?>
2228
+
2229
+ <p><label for="_default"><?php _e( 'Default Text', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'Text to display by default in this field', 'ultimate-member' ) ); ?></label>
2230
+ <textarea name="_default" id="_default"><?php echo $this->edit_mode_value; ?></textarea>
2231
+ </p>
2232
+
2233
+ <?php } elseif ( $this->set_field_type == 'date' ) { ?>
2234
+
2235
+ <p class="um"><label for="_default"><?php _e( 'Default Date', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'You may use all PHP compatible date formats such as: 2020-02-02, 02/02/2020, yesterday, today, tomorrow, next monday, first day of next month, +3 day', 'ultimate-member' ) ); ?></label>
2236
+ <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" class="um-datepicker" data-format="yyyy/mm/dd" />
2237
+ </p>
2238
+
2239
+ <?php } elseif ( $this->set_field_type == 'time' ) { ?>
2240
+
2241
+ <p class="um"><label for="_default"><?php _e( 'Default Time', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'You may use all PHP compatible date formats such as: 2020-02-02, 02/02/2020, yesterday, today, tomorrow, next monday, first day of next month, +3 day', 'ultimate-member' ) ); ?></label>
2242
+ <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" class="um-timepicker" data-format="HH:i" />
2243
+ </p>
2244
+
2245
+ <?php } elseif ( $this->set_field_type == 'rating' ) { ?>
2246
+
2247
+ <p><label for="_default"><?php _e( 'Default Rating', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'If you wish the rating field to be prefilled with a number of stars, enter it here.', 'ultimate-member' ) ); ?></label>
2248
+ <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" />
2249
+ </p>
2250
+
2251
+ <?php } else { ?>
2252
+
2253
+ <p><label for="_default"><?php _e( 'Default Value', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'This option allows you to pre-fill the field with a default value prior to the user entering a value in the field. Leave blank to have no default value', 'ultimate-member' ) ); ?></label>
2254
+ <input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" />
2255
+ </p>
2256
+
2257
+ <?php } ?>
2258
+
2259
+ <?php
2260
+ break;
2261
+
2262
+ case '_label':
2263
+ ?>
2264
+
2265
+ <p><label for="_label"><?php _e( 'Label', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The field label is the text that appears above the field on your front-end form. Leave blank to not show a label above field.', 'ultimate-member' ) ); ?></label>
2266
+ <input type="text" name="_label" id="_label" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2267
+ </p>
2268
+
2269
+ <?php
2270
+ break;
2271
+
2272
+ case '_label_confirm_pass':
2273
+ ?>
2274
+
2275
+ <p><label for="_label_confirm_pass"><?php _e( 'Confirm password field label', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This label is the text that appears above the confirm password field. Leave blank to show default label.', 'ultimate-member' ) ); ?></label>
2276
+ <input type="text" name="_label_confirm_pass" id="_label_confirm_pass" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2277
+ </p>
2278
+
2279
+ <?php
2280
+ break;
2281
+
2282
+ case '_placeholder':
2283
+ ?>
2284
+
2285
+ <p><label for="_placeholder"><?php _e( 'Placeholder', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the text that appears within the field e.g please enter your email address. Leave blank to not show any placeholder text.', 'ultimate-member' ) ); ?></label>
2286
+ <input type="text" name="_placeholder" id="_placeholder" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2287
+ </p>
2288
+
2289
+ <?php
2290
+ break;
2291
+
2292
+ case '_public':
2293
+ $privacy_options = array(
2294
+ '1' => __( 'Everyone', 'ultimate-member' ),
2295
+ '2' => __( 'Members', 'ultimate-member' ),
2296
+ '-1' => __( 'Only visible to profile owner and users who can edit other member accounts', 'ultimate-member' ),
2297
+ '-3' => __( 'Only visible to profile owner and specific roles', 'ultimate-member' ),
2298
+ '-2' => __( 'Only specific member roles', 'ultimate-member' ),
2299
+ );
2300
+
2301
+ $privacy_options = apply_filters( 'um_field_privacy_options', $privacy_options ); ?>
2302
+
2303
+ <p>
2304
+ <label for="_public"><?php _e( 'Privacy', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Field privacy allows you to select who can view this field on the front-end. The site admin can view all fields regardless of the option set here.', 'ultimate-member' ) ); ?></label>
2305
+ <select name="_public" id="_public" class="um-adm-conditional" data-cond1="-2" data-cond1-show="_roles" data-cond2="-3" data-cond2-show="_roles" style="width: 100%">
2306
+ <?php foreach ( $privacy_options as $value => $title ) { ?>
2307
+ <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $value, $this->edit_mode_value ); ?>>
2308
+ <?php echo $title ?>
2309
+ </option>
2310
+ <?php } ?>
2311
+ </select>
2312
+ </p>
2313
+
2314
+ <?php
2315
+ break;
2316
+
2317
+ case '_roles':
2318
+
2319
+ if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
2320
+ $values = $this->edit_mode_value;
2321
+ } else {
2322
+ $values = array('');
2323
+ }
2324
+
2325
+ ?>
2326
+
2327
+ <p class="_roles"><label for="_roles"><?php _e( 'Select member roles', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the member roles that can view this field on the front-end.', 'ultimate-member' ) ); ?></label>
2328
+ <select name="_roles[]" id="_roles" style="width: 100%" multiple="multiple">
2329
+
2330
+ <?php foreach ( UM()->roles()->get_roles() as $key => $value) { ?>
2331
+
2332
+ <option value="<?php echo $key; ?>" <?php if ( in_array( $key, $values ) ) { echo 'selected'; } ?>><?php echo $value; ?></option>
2333
+
2334
+ <?php } ?>
2335
+
2336
+ </select>
2337
+ </p>
2338
+
2339
+ <?php
2340
+ break;
2341
+
2342
+ case '_required':
2343
+
2344
+ if ( $this->set_field_type == 'password' )
2345
+ $def_required = 1;
2346
+ else
2347
+ $def_required = 0;
2348
+
2349
+ ?>
2350
+
2351
+ <div class="um-admin-tri">
2352
+
2353
+ <p><label for="_required"><?php _e( 'Is this field required?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This option allows you to set whether the field must be filled in before the form can be processed.', 'ultimate-member' ) ); ?></label>
2354
+ <input type="checkbox" name="_required" id="_required" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : $def_required ) ?> />
2355
+ </p>
2356
+
2357
+ </div>
2358
+
2359
+ <?php
2360
+ break;
2361
+
2362
+ case '_editable':
2363
+ ?>
2364
+
2365
+ <div class="um-admin-tri">
2366
+
2367
+ <p><label for="_editable"><?php _e( 'Can user edit this field?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This option allows you to set whether or not the user can edit the information in this field.', 'ultimate-member' ) ); ?></label>
2368
+ <input type="hidden" name="_editable" id="_editable_hidden" value="0" />
2369
+ <input type="checkbox" name="_editable" id="_editable" value="1" <?php checked( null === $this->edit_mode_value || $this->edit_mode_value ) ?> />
2370
+ </p>
2371
+
2372
+ </div>
2373
+
2374
+ <?php
2375
+ break;
2376
+
2377
+ case '_number':
2378
+ ?>
2379
+
2380
+ <p><label for="_number"><?php _e( 'Rating System', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose whether you want a 5-stars or 10-stars ratings based here.', 'ultimate-member' ) ); ?></label>
2381
+ <select name="_number" id="_number" style="width: 100%">
2382
+ <option value="5" <?php selected( 5, $this->edit_mode_value ); ?>><?php _e( '5 stars rating system', 'ultimate-member' ) ?></option>
2383
+ <option value="10" <?php selected( 10, $this->edit_mode_value ); ?>><?php _e( '10 stars rating system', 'ultimate-member' ) ?></option>
2384
+ </select>
2385
+ </p>
2386
+
2387
+ <?php
2388
+ break;
2389
+
2390
+ case '_custom_dropdown_options_source':
2391
+ ?>
2392
+
2393
+ <p><label for="_custom_dropdown_options_source"><?php _e( 'Choices Callback', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Add a callback source to retrieve choices.', 'ultimate-member' ) ); ?></label>
2394
+ <input type="text" name="_custom_dropdown_options_source" id="_custom_dropdown_options_source" value="<?php echo htmlspecialchars($this->edit_mode_value, ENT_QUOTES); ?>" />
2395
+ </p>
2396
+
2397
+ <?php
2398
+ break;
2399
+
2400
+
2401
+ case '_parent_dropdown_relationship':
2402
+ ?>
2403
+
2404
+ <p><label for="_parent_dropdown_relationship"><?php _e( 'Parent Option', 'ultimate-member' ) ?><?php UM()->tooltip( __( 'Dynamically populates the option based from selected parent option.', 'ultimate-member' ) ); ?></label>
2405
+ <select name="_parent_dropdown_relationship" id="_parent_dropdown_relationship" style="width: 100%">
2406
+ <option value=""><?php _e( 'No Selected', 'ultimate-member' ) ?></option>
2407
+
2408
+ <?php if ( UM()->builtin()->custom_fields ) {
2409
+ foreach ( UM()->builtin()->custom_fields as $field_key => $array ) {
2410
+ if ( in_array( $array['type'], array( 'select' ) ) && ( ! isset( $field_args['metakey'] ) || $field_args['metakey'] != $array['metakey'] ) && isset( $array['title'] ) ) { ?>
2411
+ <option value="<?php echo esc_attr( $array['metakey'] ) ?>" <?php selected( $array['metakey'], $this->edit_mode_value ) ?>><?php echo $array['title'] ?></option>
2412
+ <?php }
2413
+ }
2414
+ } ?>
2415
+ </select>
2416
+ </p>
2417
+
2418
+ <?php
2419
+ break;
2420
+
2421
+
2422
+ }
2423
+
2424
+ }
2425
+
2426
+ }
2427
+ }
includes/admin/core/class-admin-notices.php CHANGED
@@ -48,7 +48,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
48
  $this->need_upgrade();
49
  $this->check_wrong_licenses();
50
 
51
- $this->reviews_notice();
 
52
 
53
  //$this->future_changed();
54
 
48
  $this->need_upgrade();
49
  $this->check_wrong_licenses();
50
 
51
+ // removed for now to avoid the bad reviews
52
+ //$this->reviews_notice();
53
 
54
  //$this->future_changed();
55
 
includes/admin/core/class-admin-settings.php CHANGED
@@ -1,3437 +1,3455 @@
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_access_post_title',
507
- 'type' => 'text',
508
- 'label' => __( 'Restricted Access Post Title', 'ultimate-member' ),
509
- 'tooltip' => __( 'This is the post title shown to users that do not have permission to view the content', 'ultimate-member' ),
510
- ),
511
- array(
512
- 'id' => 'restricted_access_message',
513
- 'type' => 'wp_editor',
514
- 'label' => __( 'Restricted Access Message', 'ultimate-member' ),
515
- 'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ),
516
- ),
517
- );
518
-
519
- $settings_map = array_merge(
520
- $settings_map,
521
- array(
522
- 'accessible' => array(
523
- 'sanitize' => 'int',
524
- ),
525
- 'access_redirect' => array(
526
- 'sanitize' => 'url',
527
- ),
528
- 'access_exclude_uris' => array(
529
- 'sanitize' => 'url',
530
- ),
531
- 'home_page_accessible' => array(
532
- 'sanitize' => 'bool',
533
- ),
534
- 'category_page_accessible' => array(
535
- 'sanitize' => 'bool',
536
- ),
537
- 'restricted_access_post_title' => array(
538
- 'sanitize' => 'text',
539
- ),
540
- 'restricted_access_message' => array(
541
- 'sanitize' => 'wp_kses',
542
- ),
543
- )
544
- );
545
-
546
- global $wp_version;
547
- if ( version_compare( $wp_version, '5.0', '>=' ) ) {
548
- $access_fields = array_merge(
549
- $access_fields,
550
- array(
551
- array(
552
- 'id' => 'restricted_blocks',
553
- 'type' => 'checkbox',
554
- 'label' => __( 'Enable the "Content Restriction" settings for the Gutenberg Blocks', 'ultimate-member' ),
555
- ),
556
- array(
557
- 'id' => 'restricted_block_message',
558
- 'type' => 'textarea',
559
- 'label' => __( 'Restricted Access Block Message', 'ultimate-member' ),
560
- 'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ),
561
- 'conditional' => array( 'restricted_blocks', '=', 1 ),
562
- ),
563
- )
564
- );
565
-
566
- $settings_map['restricted_blocks'] = array(
567
- 'sanitize' => 'bool',
568
- );
569
- $settings_map['restricted_block_message'] = array(
570
- 'sanitize' => 'textarea',
571
- );
572
- }
573
-
574
- $access_fields = array_merge(
575
- $access_fields,
576
- array(
577
- array(
578
- 'id' => 'restricted_access_post_metabox',
579
- 'type' => 'hidden',
580
- 'value' => '',
581
- ),
582
- array(
583
- 'id' => 'restricted_access_taxonomy_metabox',
584
- 'type' => 'hidden',
585
- 'value' => '',
586
- ),
587
- array(
588
- 'id' => 'restricted_access_post_metabox',
589
- 'type' => 'multi_checkbox',
590
- 'label' => __( 'Enable the "Content Restriction" settings for post types', 'ultimate-member' ),
591
- 'tooltip' => __( 'Check post types for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
592
- 'options' => $post_types_options,
593
- 'columns' => 3,
594
- 'value' => $restricted_access_post_metabox_value,
595
- 'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ),
596
- ),
597
- array(
598
- 'id' => 'restricted_access_taxonomy_metabox',
599
- 'type' => 'multi_checkbox',
600
- 'label' => __( 'Enable the "Content Restriction" settings for taxonomies', 'ultimate-member' ),
601
- 'tooltip' => __( 'Check taxonomies for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
602
- 'options' => $taxonomies_options,
603
- 'columns' => 3,
604
- 'value' => $restricted_access_taxonomy_metabox_value,
605
- 'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ),
606
- ),
607
- )
608
- );
609
-
610
- $settings_map = array_merge(
611
- $settings_map,
612
- array(
613
- 'restricted_access_post_metabox' => array(
614
- 'sanitize' => 'key',
615
- ),
616
- 'restricted_access_taxonomy_metabox' => array(
617
- 'sanitize' => 'key',
618
- ),
619
- )
620
- );
621
-
622
- $latest_update = get_option( 'um_member_directory_update_meta', false );
623
- $latest_truncate = get_option( 'um_member_directory_truncated', false );
624
-
625
- $same_page_update = array(
626
- 'id' => 'member_directory_own_table',
627
- 'type' => 'same_page_update',
628
- 'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ),
629
- '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' ),
630
- );
631
-
632
- if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) {
633
- $same_page_update['upgrade_cb'] = 'sync_metatable';
634
- $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>
635
- <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>
636
- <p>' . __( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ) . '</p>';
637
- }
638
-
639
- $settings_map = array_merge(
640
- $settings_map,
641
- array(
642
- 'permalink_base' => array(
643
- 'sanitize' => 'key',
644
- ),
645
- 'display_name' => array(
646
- 'sanitize' => 'key',
647
- ),
648
- 'display_name_field' => array(
649
- 'sanitize' => 'text',
650
- ),
651
- 'author_redirect' => array(
652
- 'sanitize' => 'bool',
653
- ),
654
- 'members_page' => array(
655
- 'sanitize' => 'bool',
656
- ),
657
- 'use_gravatars' => array(
658
- 'sanitize' => 'bool',
659
- ),
660
- 'use_um_gravatar_default_builtin_image' => array(
661
- 'sanitize' => 'key',
662
- ),
663
- 'use_um_gravatar_default_image' => array(
664
- 'sanitize' => 'bool',
665
- ),
666
- 'reset_require_strongpass' => array(
667
- 'sanitize' => 'bool',
668
- ),
669
- 'profile_noindex' => array(
670
- 'sanitize' => 'bool',
671
- ),
672
- 'activation_link_expiry_time' => array(
673
- 'sanitize' => 'absint',
674
- ),
675
- 'account_tab_password' => array(
676
- 'sanitize' => 'bool',
677
- ),
678
- 'account_tab_privacy' => array(
679
- 'sanitize' => 'bool',
680
- ),
681
- 'account_tab_notifications' => array(
682
- 'sanitize' => 'bool',
683
- ),
684
- 'account_tab_delete' => array(
685
- 'sanitize' => 'bool',
686
- ),
687
- 'delete_account_text' => array(
688
- 'sanitize' => 'textarea',
689
- ),
690
- 'delete_account_no_pass_required_text' => array(
691
- 'sanitize' => 'textarea',
692
- ),
693
- 'account_name' => array(
694
- 'sanitize' => 'bool',
695
- ),
696
- 'account_name_disable' => array(
697
- 'sanitize' => 'bool',
698
- ),
699
- 'account_name_require' => array(
700
- 'sanitize' => 'bool',
701
- ),
702
- 'account_email' => array(
703
- 'sanitize' => 'bool',
704
- ),
705
- 'account_general_password' => array(
706
- 'sanitize' => 'bool',
707
- ),
708
- 'account_require_strongpass' => array(
709
- 'sanitize' => 'bool',
710
- ),
711
- 'account_hide_in_directory' => array(
712
- 'sanitize' => 'bool',
713
- ),
714
- 'account_hide_in_directory_default' => array(
715
- 'sanitize' => 'text',
716
- ),
717
- 'profile_photo_max_size' => array(
718
- 'sanitize' => 'absint',
719
- ),
720
- 'cover_photo_max_size' => array(
721
- 'sanitize' => 'absint',
722
- ),
723
- 'photo_thumb_sizes' => array(
724
- 'sanitize' => 'absint',
725
- ),
726
- 'cover_thumb_sizes' => array(
727
- 'sanitize' => 'absint',
728
- ),
729
- 'image_orientation_by_exif' => array(
730
- 'sanitize' => 'bool',
731
- ),
732
- 'image_compression' => array(
733
- 'sanitize' => 'absint',
734
- ),
735
- 'image_max_width' => array(
736
- 'sanitize' => 'absint',
737
- ),
738
- 'cover_min_width' => array(
739
- 'sanitize' => 'absint',
740
- ),
741
- 'enable_reset_password_limit' => array(
742
- 'sanitize' => 'bool',
743
- ),
744
- 'reset_password_limit_number' => array(
745
- 'sanitize' => 'absint',
746
- ),
747
- 'blocked_emails' => array(
748
- 'sanitize' => 'textarea',
749
- ),
750
- 'blocked_words' => array(
751
- 'sanitize' => 'textarea',
752
- ),
753
- 'admin_email' => array(
754
- 'sanitize' => 'text',
755
- ),
756
- 'mail_from' => array(
757
- 'sanitize' => 'text',
758
- ),
759
- 'mail_from_addr' => array(
760
- 'sanitize' => 'text',
761
- ),
762
- 'email_html' => array(
763
- 'sanitize' => 'bool',
764
- ),
765
- 'profile_template' => array(
766
- 'sanitize' => 'text',
767
- ),
768
- 'profile_max_width' => array(
769
- 'sanitize' => 'text',
770
- ),
771
- 'profile_area_max_width' => array(
772
- 'sanitize' => 'text',
773
- ),
774
- 'profile_icons' => array(
775
- 'sanitize' => 'key',
776
- ),
777
- 'profile_primary_btn_word' => array(
778
- 'sanitize' => 'text',
779
- ),
780
- 'profile_secondary_btn' => array(
781
- 'sanitize' => 'bool',
782
- ),
783
- 'profile_secondary_btn_word' => array(
784
- 'sanitize' => 'text',
785
- ),
786
- 'default_avatar' => array(
787
- 'sanitize' => 'url',
788
- ),
789
- 'default_cover' => array(
790
- 'sanitize' => 'url',
791
- ),
792
- 'disable_profile_photo_upload' => array(
793
- 'sanitize' => 'bool',
794
- ),
795
- 'profile_photosize' => array(
796
- 'sanitize' => array( UM()->admin(), 'sanitize_photosize' ),
797
- ),
798
- 'profile_cover_enabled' => array(
799
- 'sanitize' => 'bool',
800
- ),
801
- 'profile_coversize' => array(
802
- 'sanitize' => array( UM()->admin(), 'sanitize_cover_photosize' ),
803
- ),
804
- 'profile_cover_ratio' => array(
805
- 'sanitize' => 'text',
806
- ),
807
- 'profile_show_metaicon' => array(
808
- 'sanitize' => 'bool',
809
- ),
810
- 'profile_show_name' => array(
811
- 'sanitize' => 'bool',
812
- ),
813
- 'profile_show_social_links' => array(
814
- 'sanitize' => 'bool',
815
- ),
816
- 'profile_show_bio' => array(
817
- 'sanitize' => 'bool',
818
- ),
819
- 'profile_show_html_bio' => array(
820
- 'sanitize' => 'bool',
821
- ),
822
- 'profile_bio_maxchars' => array(
823
- 'sanitize' => 'absint',
824
- ),
825
- 'profile_header_menu' => array(
826
- 'sanitize' => 'key',
827
- ),
828
- 'profile_empty_text' => array(
829
- 'sanitize' => 'bool',
830
- ),
831
- 'profile_empty_text_emo' => array(
832
- 'sanitize' => 'bool',
833
- ),
834
- 'register_template' => array(
835
- 'sanitize' => 'text',
836
- ),
837
- 'register_max_width' => array(
838
- 'sanitize' => 'text',
839
- ),
840
- 'register_align' => array(
841
- 'sanitize' => 'key',
842
- ),
843
- 'register_icons' => array(
844
- 'sanitize' => 'key',
845
- ),
846
- 'register_primary_btn_word' => array(
847
- 'sanitize' => 'text',
848
- ),
849
- 'register_secondary_btn' => array(
850
- 'sanitize' => 'bool',
851
- ),
852
- 'register_secondary_btn_word' => array(
853
- 'sanitize' => 'text',
854
- ),
855
- 'register_secondary_btn_url' => array(
856
- 'sanitize' => 'url',
857
- ),
858
- 'register_role' => array(
859
- 'sanitize' => 'key',
860
- ),
861
- 'login_template' => array(
862
- 'sanitize' => 'text',
863
- ),
864
- 'login_max_width' => array(
865
- 'sanitize' => 'text',
866
- ),
867
- 'login_align' => array(
868
- 'sanitize' => 'key',
869
- ),
870
- 'login_icons' => array(
871
- 'sanitize' => 'key',
872
- ),
873
- 'login_primary_btn_word' => array(
874
- 'sanitize' => 'text',
875
- ),
876
- 'login_secondary_btn' => array(
877
- 'sanitize' => 'bool',
878
- ),
879
- 'login_secondary_btn_word' => array(
880
- 'sanitize' => 'text',
881
- ),
882
- 'login_secondary_btn_url' => array(
883
- 'sanitize' => 'url',
884
- ),
885
- 'login_forgot_pass_link' => array(
886
- 'sanitize' => 'bool',
887
- ),
888
- 'login_show_rememberme' => array(
889
- 'sanitize' => 'bool',
890
- ),
891
- 'form_asterisk' => array(
892
- 'sanitize' => 'bool',
893
- ),
894
- 'profile_title' => array(
895
- 'sanitize' => 'text',
896
- ),
897
- 'profile_desc' => array(
898
- 'sanitize' => 'textarea',
899
- ),
900
- 'um_profile_object_cache_stop' => array(
901
- 'sanitize' => 'bool',
902
- ),
903
- 'enable_blocks' => array(
904
- 'sanitize' => 'bool',
905
- ),
906
- 'rest_api_version' => array(
907
- 'sanitize' => 'text',
908
- ),
909
- 'uninstall_on_delete' => array(
910
- 'sanitize' => 'bool',
911
- ),
912
- )
913
- );
914
-
915
- $this->settings_map = apply_filters( 'um_settings_map', $settings_map );
916
-
917
- /**
918
- * UM hook
919
- *
920
- * @type filter
921
- * @title um_settings_structure
922
- * @description Extend UM Settings
923
- * @input_vars
924
- * [{"var":"$settings","type":"array","desc":"UM Settings"}]
925
- * @change_log
926
- * ["Since: 2.0"]
927
- * @usage add_filter( 'um_settings_structure', 'function_name', 10, 1 );
928
- * @example
929
- * <?php
930
- * add_filter( 'um_settings_structure', 'my_settings_structure', 10, 1 );
931
- * function my_settings_structure( $settings ) {
932
- * // your code here
933
- * return $settings;
934
- * }
935
- * ?>
936
- */
937
- $this->settings_structure = apply_filters(
938
- 'um_settings_structure',
939
- array(
940
- '' => array(
941
- 'title' => __( 'General', 'ultimate-member' ),
942
- 'sections' => array(
943
- '' => array(
944
- 'title' => __( 'Pages', 'ultimate-member' ),
945
- 'fields' => $general_pages_fields,
946
- ),
947
- 'users' => array(
948
- 'title' => __( 'Users', 'ultimate-member' ),
949
- 'fields' => array(
950
- array(
951
- 'id' => 'permalink_base',
952
- 'type' => 'select',
953
- 'size' => 'small',
954
- 'label' => __( 'Profile Permalink Base', 'ultimate-member' ),
955
- // translators: %s: Profile page URL
956
- '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' ) ) ),
957
- 'options' => array(
958
- 'user_login' => __( 'Username', 'ultimate-member' ),
959
- 'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ),
960
- 'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ),
961
- 'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ),
962
- 'user_id' => __( 'User ID', 'ultimate-member' ),
963
- ),
964
- 'placeholder' => __( 'Select...', 'ultimate-member' ),
965
- ),
966
- array(
967
- 'id' => 'display_name',
968
- 'type' => 'select',
969
- 'size' => 'medium',
970
- 'label' => __( 'User Display Name', 'ultimate-member' ),
971
- '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' ),
972
- 'options' => array(
973
- 'default' => __( 'Default WP Display Name', 'ultimate-member' ),
974
- 'nickname' => __( 'Nickname', 'ultimate-member' ),
975
- 'username' => __( 'Username', 'ultimate-member' ),
976
- 'full_name' => __( 'First name & last name', 'ultimate-member' ),
977
- 'sur_name' => __( 'Last name & first name', 'ultimate-member' ),
978
- 'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ),
979
- 'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ),
980
- 'first_name' => __( 'First name only', 'ultimate-member' ),
981
- 'field' => __( 'Custom field(s)', 'ultimate-member' ),
982
- ),
983
- 'placeholder' => __( 'Select...', 'ultimate-member' ),
984
- ),
985
- array(
986
- 'id' => 'display_name_field',
987
- 'type' => 'text',
988
- 'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ),
989
- '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' ),
990
- 'conditional' => array( 'display_name', '=', 'field' ),
991
- ),
992
- array(
993
- 'id' => 'author_redirect',
994
- 'type' => 'checkbox',
995
- 'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ),
996
- 'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ),
997
- ),
998
- array(
999
- 'id' => 'members_page',
1000
- 'type' => 'checkbox',
1001
- 'label' => __( 'Enable Members Directory', 'ultimate-member' ),
1002
- 'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ),
1003
- ),
1004
- array(
1005
- 'id' => 'use_gravatars',
1006
- 'type' => 'checkbox',
1007
- 'label' => __( 'Use Gravatars?', 'ultimate-member' ),
1008
- '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' ),
1009
- ),
1010
- array(
1011
- 'id' => 'use_um_gravatar_default_builtin_image',
1012
- 'type' => 'select',
1013
- 'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ),
1014
- 'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ),
1015
- 'options' => array(
1016
- 'default' => __( 'Default', 'ultimate-member' ),
1017
- '404' => __( '404 ( File Not Found response )', 'ultimate-member' ),
1018
- 'mm' => __( 'Mystery Man', 'ultimate-member' ),
1019
- 'identicon' => __( 'Identicon', 'ultimate-member' ),
1020
- 'monsterid' => __( 'Monsterid', 'ultimate-member' ),
1021
- 'wavatar' => __( 'Wavatar', 'ultimate-member' ),
1022
- 'retro' => __( 'Retro', 'ultimate-member' ),
1023
- 'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ),
1024
- ),
1025
- 'conditional' => array( 'use_gravatars', '=', 1 ),
1026
- 'size' => 'medium',
1027
- ),
1028
- array(
1029
- 'id' => 'use_um_gravatar_default_image',
1030
- 'type' => 'checkbox',
1031
- 'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ),
1032
- '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' ),
1033
- 'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ),
1034
- ),
1035
- array(
1036
- 'id' => 'reset_require_strongpass',
1037
- 'type' => 'checkbox',
1038
- 'label' => __( 'Require a strong password? (when user resets password only)', 'ultimate-member' ),
1039
- 'tooltip' => __( 'Enable or disable a strong password rules on password reset and change procedure', 'ultimate-member' ),
1040
- ),
1041
- array(
1042
- 'id' => 'profile_noindex',
1043
- 'type' => 'select',
1044
- 'size' => 'small',
1045
- 'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
1046
- 'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ),
1047
- 'options' => array(
1048
- '0' => __( 'No', 'ultimate-member' ),
1049
- '1' => __( 'Yes', 'ultimate-member' ),
1050
- ),
1051
- ),
1052
- array(
1053
- 'id' => 'activation_link_expiry_time',
1054
- 'type' => 'number',
1055
- 'label' => __( 'Activation link lifetime', 'ultimate-member' ),
1056
- 'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ),
1057
- 'size' => 'small',
1058
- ),
1059
- ),
1060
- ),
1061
- 'account' => array(
1062
- 'title' => __( 'Account', 'ultimate-member' ),
1063
- 'fields' => array(
1064
- array(
1065
- 'id' => 'account_tab_password',
1066
- 'type' => 'checkbox',
1067
- 'label' => __( 'Password Account Tab', 'ultimate-member' ),
1068
- 'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ),
1069
- ),
1070
- array(
1071
- 'id' => 'account_tab_privacy',
1072
- 'type' => 'checkbox',
1073
- 'label' => __( 'Privacy Account Tab', 'ultimate-member' ),
1074
- 'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ),
1075
- ),
1076
- array(
1077
- 'id' => 'account_tab_notifications',
1078
- 'type' => 'checkbox',
1079
- 'label' => __( 'Notifications Account Tab', 'ultimate-member' ),
1080
- 'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ),
1081
- ),
1082
- array(
1083
- 'id' => 'account_tab_delete',
1084
- 'type' => 'checkbox',
1085
- 'label' => __( 'Delete Account Tab', 'ultimate-member' ),
1086
- 'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ),
1087
- ),
1088
- array(
1089
- 'id' => 'delete_account_text',
1090
- 'type' => 'textarea', // bug with wp 4.4? should be editor
1091
- 'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ),
1092
- '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' ),
1093
- 'args' => array(
1094
- 'textarea_rows' => 6,
1095
- ),
1096
- ),
1097
- array(
1098
- 'id' => 'delete_account_no_pass_required_text',
1099
- 'type' => 'textarea',
1100
- 'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ),
1101
- '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' ),
1102
- 'args' => array(
1103
- 'textarea_rows' => 6,
1104
- ),
1105
- ),
1106
- array(
1107
- 'id' => 'account_name',
1108
- 'type' => 'checkbox',
1109
- 'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ),
1110
- 'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ),
1111
- ),
1112
- array(
1113
- 'id' => 'account_name_disable',
1114
- 'type' => 'checkbox',
1115
- 'label' => __( 'Disable First & Last Name fields', 'ultimate-member' ),
1116
- 'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ),
1117
- 'conditional' => array( 'account_name', '=', '1' ),
1118
- ),
1119
- array(
1120
- 'id' => 'account_name_require',
1121
- 'type' => 'checkbox',
1122
- 'label' => __( 'Require First & Last Name', 'ultimate-member' ),
1123
- 'tooltip' => __( 'Require first and last name?', 'ultimate-member' ),
1124
- 'conditional' => array( 'account_name', '=', '1' ),
1125
- ),
1126
- array(
1127
- 'id' => 'account_email',
1128
- 'type' => 'checkbox',
1129
- 'label' => __( 'Allow users to change e-mail', 'ultimate-member' ),
1130
- 'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ),
1131
- ),
1132
- array(
1133
- 'id' => 'account_general_password',
1134
- 'type' => 'checkbox',
1135
- 'label' => __( 'Password is required?', 'ultimate-member' ),
1136
- 'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ),
1137
- ),
1138
- array(
1139
- 'id' => 'account_require_strongpass',
1140
- 'type' => 'checkbox',
1141
- 'label' => __( 'Require a strong password?', 'ultimate-member' ),
1142
- 'tooltip' => __( 'Enable or disable a strong password rules on account page / change password tab', 'ultimate-member' ),
1143
- ),
1144
- array(
1145
- 'id' => 'account_hide_in_directory',
1146
- 'type' => 'checkbox',
1147
- 'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ),
1148
- 'tooltip' => __( 'Whether to allow users changing their profile visibility from member directory in account page.', 'ultimate-member' ),
1149
- 'conditional' => array( 'account_tab_privacy', '=', '1' ),
1150
- ),
1151
- array(
1152
- 'id' => 'account_hide_in_directory_default',
1153
- 'type' => 'select',
1154
- 'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ),
1155
- 'tooltip' => __( 'Set default value for the "Hide my profile from directory" option', 'ultimate-member' ),
1156
- 'options' => array(
1157
- 'No' => __( 'No', 'ultimate-member' ),
1158
- 'Yes' => __( 'Yes', 'ultimate-member' ),
1159
- ),
1160
- 'size' => 'small',
1161
- 'conditional' => array( 'account_hide_in_directory', '=', '1' ),
1162
- ),
1163
- ),
1164
- ),
1165
- 'uploads' => array(
1166
- 'title' => __( 'Uploads', 'ultimate-member' ),
1167
- 'fields' => array(
1168
- array(
1169
- 'id' => 'profile_photo_max_size',
1170
- 'type' => 'text',
1171
- 'size' => 'small',
1172
- 'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ),
1173
- 'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ),
1174
- ),
1175
- array(
1176
- 'id' => 'cover_photo_max_size',
1177
- 'type' => 'text',
1178
- 'size' => 'small',
1179
- 'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ),
1180
- 'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ),
1181
- ),
1182
- array(
1183
- 'id' => 'photo_thumb_sizes',
1184
- 'type' => 'multi_text',
1185
- 'size' => 'small',
1186
- 'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ),
1187
- 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ),
1188
- 'validate' => 'numeric',
1189
- 'add_text' => __( 'Add New Size', 'ultimate-member' ),
1190
- 'show_default_number' => 1,
1191
- ),
1192
- array(
1193
- 'id' => 'cover_thumb_sizes',
1194
- 'type' => 'multi_text',
1195
- 'size' => 'small',
1196
- 'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ),
1197
- 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ),
1198
- 'validate' => 'numeric',
1199
- 'add_text' => __( 'Add New Size', 'ultimate-member' ),
1200
- 'show_default_number' => 1,
1201
- ),
1202
- array(
1203
- 'id' => 'image_orientation_by_exif',
1204
- 'type' => 'checkbox',
1205
- 'label' => __( 'Change image orientation', 'ultimate-member' ),
1206
- 'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ),
1207
- ),
1208
- array(
1209
- 'id' => 'image_compression',
1210
- 'type' => 'text',
1211
- 'size' => 'small',
1212
- 'label' => __( 'Image Quality', 'ultimate-member' ),
1213
- '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' ),
1214
- ),
1215
-
1216
- array(
1217
- 'id' => 'image_max_width',
1218
- 'type' => 'text',
1219
- 'size' => 'small',
1220
- 'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ),
1221
- 'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ),
1222
- ),
1223
-
1224
- array(
1225
- 'id' => 'cover_min_width',
1226
- 'type' => 'text',
1227
- 'size' => 'small',
1228
- 'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ),
1229
- 'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ),
1230
- ),
1231
- ),
1232
- ),
1233
- ),
1234
- ),
1235
- 'access' => array(
1236
- 'title' => __( 'Access', 'ultimate-member' ),
1237
- 'sections' => array(
1238
- '' => array(
1239
- 'title' => __( 'Restriction Content', 'ultimate-member' ),
1240
- 'fields' => $access_fields,
1241
- ),
1242
- 'other' => array(
1243
- 'title' => __( 'Other', 'ultimate-member' ),
1244
- 'fields' => array(
1245
- array(
1246
- 'id' => 'enable_reset_password_limit',
1247
- 'type' => 'checkbox',
1248
- 'label' => __( 'Enable the Reset Password Limit?', 'ultimate-member' ),
1249
- ),
1250
- array(
1251
- 'id' => 'reset_password_limit_number',
1252
- 'type' => 'text',
1253
- 'label' => __( 'Reset Password Limit', 'ultimate-member' ),
1254
- 'tooltip' => __( 'Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.', 'ultimate-member' ),
1255
- 'validate' => 'numeric',
1256
- 'conditional' => array( 'enable_reset_password_limit', '=', 1 ),
1257
- 'size' => 'small',
1258
- ),
1259
- array(
1260
- 'id' => 'blocked_emails',
1261
- 'type' => 'textarea',
1262
- 'label' => __( 'Blocked Email Addresses', 'ultimate-member' ),
1263
- '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' ),
1264
- ),
1265
- array(
1266
- 'id' => 'blocked_words',
1267
- 'type' => 'textarea',
1268
- 'label' => __( 'Blacklist Words', 'ultimate-member' ),
1269
- 'tooltip' => __( 'This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username', 'ultimate-member' ),
1270
- ),
1271
- ),
1272
- ),
1273
- ),
1274
- ),
1275
- 'email' => array(
1276
- 'title' => __( 'Email', 'ultimate-member' ),
1277
- 'fields' => array(
1278
- array(
1279
- 'id' => 'admin_email',
1280
- 'type' => 'text',
1281
- 'label' => __( 'Admin E-mail Address', 'ultimate-member' ),
1282
- 'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
1283
- ),
1284
- array(
1285
- 'id' => 'mail_from',
1286
- 'type' => 'text',
1287
- 'label' => __( 'Mail appears from', 'ultimate-member' ),
1288
- 'tooltip' => __( 'e.g. Site Name', 'ultimate-member' ),
1289
- ),
1290
- array(
1291
- 'id' => 'mail_from_addr',
1292
- 'type' => 'text',
1293
- 'label' => __( 'Mail appears from address', 'ultimate-member' ),
1294
- 'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
1295
- ),
1296
- array(
1297
- 'id' => 'email_html',
1298
- 'type' => 'checkbox',
1299
- 'label' => __( 'Use HTML for E-mails?', 'ultimate-member' ),
1300
- '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' ),
1301
- ),
1302
- ),
1303
- ),
1304
- 'appearance' => array(
1305
- 'title' => __( 'Appearance', 'ultimate-member' ),
1306
- 'sections' => array(
1307
- '' => array(
1308
- 'title' => __( 'Profile', 'ultimate-member' ),
1309
- 'fields' => array(
1310
- array(
1311
- 'id' => 'profile_template',
1312
- 'type' => 'select',
1313
- 'label' => __( 'Profile Default Template', 'ultimate-member' ),
1314
- 'tooltip' => __( 'This will be the default template to output profile', 'ultimate-member' ),
1315
- 'default' => um_get_metadefault( 'profile_template' ),
1316
- 'options' => UM()->shortcodes()->get_templates( 'profile' ),
1317
- 'size' => 'small',
1318
- ),
1319
- array(
1320
- 'id' => 'profile_max_width',
1321
- 'type' => 'text',
1322
- 'label' => __( 'Profile Maximum Width', 'ultimate-member' ),
1323
- 'default' => um_get_metadefault( 'profile_max_width' ),
1324
- 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1325
- 'size' => 'small',
1326
- ),
1327
- array(
1328
- 'id' => 'profile_area_max_width',
1329
- 'type' => 'text',
1330
- 'label' => __( 'Profile Area Maximum Width', 'ultimate-member' ),
1331
- 'default' => um_get_metadefault( 'profile_area_max_width' ),
1332
- 'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
1333
- 'size' => 'small',
1334
- ),
1335
- array(
1336
- 'id' => 'profile_icons',
1337
- 'type' => 'select',
1338
- 'label' => __( 'Profile Field Icons', 'ultimate-member' ),
1339
- 'tooltip' => __( 'This is applicable for edit mode only', 'ultimate-member' ),
1340
- 'default' => um_get_metadefault( 'profile_icons' ),
1341
- 'options' => array(
1342
- 'field' => __( 'Show inside text field', 'ultimate-member' ),
1343
- 'label' => __( 'Show with label', 'ultimate-member' ),
1344
- 'off' => __( 'Turn off', 'ultimate-member' ),
1345
- ),
1346
- 'size' => 'small',
1347
- ),
1348
- array(
1349
- 'id' => 'profile_primary_btn_word',
1350
- 'type' => 'text',
1351
- 'label' => __( 'Profile Primary Button Text', 'ultimate-member' ),
1352
- 'default' => um_get_metadefault( 'profile_primary_btn_word' ),
1353
- 'tooltip' => __( 'The text that is used for updating profile button', 'ultimate-member' ),
1354
- 'size' => 'medium',
1355
- ),
1356
- array(
1357
- 'id' => 'profile_secondary_btn',
1358
- 'type' => 'checkbox',
1359
- 'label' => __( 'Profile Secondary Button', 'ultimate-member' ),
1360
- 'default' => um_get_metadefault( 'profile_secondary_btn' ),
1361
- 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1362
- ),
1363
- array(
1364
- 'id' => 'profile_secondary_btn_word',
1365
- 'type' => 'text',
1366
- 'label' => __( 'Profile Secondary Button Text', 'ultimate-member' ),
1367
- 'default' => um_get_metadefault( 'profile_secondary_btn_word' ),
1368
- 'tooltip' => __( 'The text that is used for cancelling update profile button', 'ultimate-member' ),
1369
- 'conditional' => array( 'profile_secondary_btn', '=', 1 ),
1370
- 'size' => 'medium',
1371
- ),
1372
- array(
1373
- 'id' => 'default_avatar',
1374
- 'type' => 'media',
1375
- 'label' => __( 'Default Profile Photo', 'ultimate-member' ),
1376
- 'tooltip' => __( 'You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member' ),
1377
- 'upload_frame_title' => __( 'Select Default Profile Photo', 'ultimate-member' ),
1378
- 'default' => array(
1379
- 'url' => um_url . 'assets/img/default_avatar.jpg',
1380
- ),
1381
- ),
1382
- array(
1383
- 'id' => 'default_cover',
1384
- 'type' => 'media',
1385
- 'url' => true,
1386
- 'preview' => false,
1387
- 'label' => __( 'Default Cover Photo', 'ultimate-member' ),
1388
- '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' ),
1389
- 'upload_frame_title' => __( 'Select Default Cover Photo', 'ultimate-member' ),
1390
- ),
1391
- array(
1392
- 'id' => 'disable_profile_photo_upload',
1393
- 'type' => 'checkbox',
1394
- 'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
1395
- 'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
1396
- 'default' => um_get_metadefault( 'disable_profile_photo_upload' ),
1397
- ),
1398
- array(
1399
- 'id' => 'profile_photosize',
1400
- 'type' => 'select',
1401
- 'label' => __( 'Profile Photo Size', 'ultimate-member' ),
1402
- 'default' => um_get_metadefault( 'profile_photosize' ),
1403
- 'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
1404
- 'tooltip' => __( 'The global default of profile photo size. This can be overridden by individual form settings', 'ultimate-member' ),
1405
- 'size' => 'small',
1406
- ),
1407
- array(
1408
- 'id' => 'profile_cover_enabled',
1409
- 'type' => 'checkbox',
1410
- 'label' => __( 'Profile Cover Photos', 'ultimate-member' ),
1411
- 'default' => um_get_metadefault( 'profile_cover_enabled' ),
1412
- 'tooltip' => __( 'Switch on/off the profile cover photos', 'ultimate-member' ),
1413
- ),
1414
- array(
1415
- 'id' => 'profile_coversize',
1416
- 'type' => 'select',
1417
- 'label' => __( 'Profile Cover Size', 'ultimate-member' ),
1418
- 'default' => um_get_metadefault( 'profile_coversize' ),
1419
- 'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
1420
- 'tooltip' => __( 'The global default width of cover photo size. This can be overridden by individual form settings', 'ultimate-member' ),
1421
- 'conditional' => array( 'profile_cover_enabled', '=', 1 ),
1422
- 'size' => 'small',
1423
- ),
1424
- array(
1425
- 'id' => 'profile_cover_ratio',
1426
- 'type' => 'select',
1427
- 'label' => __( 'Profile Cover Ratio', 'ultimate-member' ),
1428
- 'tooltip' => __( 'Choose global ratio for cover photos of profiles', 'ultimate-member' ),
1429
- 'default' => um_get_metadefault( 'profile_cover_ratio' ),
1430
- 'options' => array(
1431
- '1.6:1' => '1.6:1',
1432
- '2.7:1' => '2.7:1',
1433
- '2.2:1' => '2.2:1',
1434
- '3.2:1' => '3.2:1',
1435
- ),
1436
- 'conditional' => array( 'profile_cover_enabled', '=', 1 ),
1437
- 'size' => 'small',
1438
- ),
1439
- array(
1440
- 'id' => 'profile_show_metaicon',
1441
- 'type' => 'checkbox',
1442
- 'label' => __( 'Profile Header Meta Text Icon', 'ultimate-member' ),
1443
- 'default' => 0,
1444
- 'tooltip' => __( 'Display field icons for related user meta fields in header or not', 'ultimate-member' ),
1445
- ),
1446
- array(
1447
- 'id' => 'profile_show_name',
1448
- 'type' => 'checkbox',
1449
- 'label' => __( 'Show display name in profile header', 'ultimate-member' ),
1450
- 'default' => um_get_metadefault( 'profile_show_name' ),
1451
- 'tooltip' => __( 'Switch on/off the user name on profile header', 'ultimate-member' ),
1452
- ),
1453
- array(
1454
- 'id' => 'profile_show_social_links',
1455
- 'type' => 'checkbox',
1456
- 'label' => __( 'Show social links in profile header', 'ultimate-member' ),
1457
- 'default' => um_get_metadefault( 'profile_show_social_links' ),
1458
- 'tooltip' => __( 'Switch on/off the social links on profile header', 'ultimate-member' ),
1459
- ),
1460
- array(
1461
- 'id' => 'profile_show_bio',
1462
- 'type' => 'checkbox',
1463
- 'label' => __( 'Show user description in header', 'ultimate-member' ),
1464
- 'default' => um_get_metadefault( 'profile_show_bio' ),
1465
- 'tooltip' => __( 'Switch on/off the user description on profile header', 'ultimate-member' ),
1466
- ),
1467
- array(
1468
- 'id' => 'profile_show_html_bio',
1469
- 'type' => 'checkbox',
1470
- 'label' => __( 'Enable HTML support for user description', 'ultimate-member' ),
1471
- 'tooltip' => __( 'Switch on/off to enable/disable support for html tags on user description.', 'ultimate-member' ),
1472
- ),
1473
- array(
1474
- 'id' => 'profile_bio_maxchars',
1475
- 'type' => 'text',
1476
- 'label' => __( 'User description maximum chars', 'ultimate-member' ),
1477
- 'default' => um_get_metadefault( 'profile_bio_maxchars' ),
1478
- 'tooltip' => __( 'Maximum number of characters to allow in user description field in header.', 'ultimate-member' ),
1479
- 'conditional' => array( 'profile_show_bio', '=', 1 ),
1480
- 'size' => 'small',
1481
- ),
1482
- array(
1483
- 'id' => 'profile_header_menu',
1484
- 'type' => 'select',
1485
- 'label' => __( 'Profile Header Menu Position', 'ultimate-member' ),
1486
- 'default' => um_get_metadefault( 'profile_header_menu' ),
1487
- 'tooltip' => __( 'For incompatible themes, please make the menu open from left instead of bottom by default.', 'ultimate-member' ),
1488
- 'options' => array(
1489
- 'bc' => __( 'Bottom of Icon', 'ultimate-member' ),
1490
- 'lc' => __( 'Left of Icon (right for RTL)', 'ultimate-member' ),
1491
- ),
1492
- 'size' => 'small',
1493
- ),
1494
- array(
1495
- 'id' => 'profile_empty_text',
1496
- 'type' => 'checkbox',
1497
- 'label' => __( 'Show a custom message if profile is empty', 'ultimate-member' ),
1498
- 'default' => um_get_metadefault( 'profile_empty_text' ),
1499
- 'tooltip' => __( 'Switch on/off the custom message that appears when the profile is empty', 'ultimate-member' ),
1500
- ),
1501
- array(
1502
- 'id' => 'profile_empty_text_emo',
1503
- 'type' => 'checkbox',
1504
- 'label' => __( 'Show the emoticon', 'ultimate-member' ),
1505
- 'default' => um_get_metadefault( 'profile_empty_text_emo' ),
1506
- 'tooltip' => __( 'Switch on/off the emoticon (sad face) that appears above the message', 'ultimate-member' ),
1507
- 'conditional' => array( 'profile_empty_text', '=', 1 ),
1508
- ),
1509
- ),
1510
- ),
1511
- 'profile_menu' => array(
1512
- 'title' => __( 'Profile Menu', 'ultimate-member' ),
1513
- 'fields' => $appearances_profile_menu_fields,
1514
- ),
1515
- 'registration_form' => array(
1516
- 'title' => __( 'Registration Form', 'ultimate-member' ),
1517
- 'fields' => array(
1518
- array(
1519
- 'id' => 'register_template',
1520
- 'type' => 'select',
1521
- 'label' => __( 'Registration Default Template', 'ultimate-member' ),
1522
- 'tooltip' => __( 'This will be the default template to output registration', 'ultimate-member' ),
1523
- 'default' => um_get_metadefault( 'register_template' ),
1524
- 'options' => UM()->shortcodes()->get_templates( 'register' ),
1525
- 'size' => 'small',
1526
- ),
1527
- array(
1528
- 'id' => 'register_max_width',
1529
- 'type' => 'text',
1530
- 'label' => __( 'Registration Maximum Width', 'ultimate-member' ),
1531
- 'default' => um_get_metadefault( 'register_max_width' ),
1532
- 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1533
- 'size' => 'small',
1534
- ),
1535
- array(
1536
- 'id' => 'register_align',
1537
- 'type' => 'select',
1538
- 'label' => __( 'Registration Shortcode Alignment', 'ultimate-member' ),
1539
- 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
1540
- 'default' => um_get_metadefault( 'register_align' ),
1541
- 'options' => array(
1542
- 'center' => __( 'Centered', 'ultimate-member' ),
1543
- 'left' => __( 'Left aligned', 'ultimate-member' ),
1544
- 'right' => __( 'Right aligned', 'ultimate-member' ),
1545
- ),
1546
- 'size' => 'small',
1547
- ),
1548
- array(
1549
- 'id' => 'register_icons',
1550
- 'type' => 'select',
1551
- 'label' => __( 'Registration Field Icons', 'ultimate-member' ),
1552
- 'tooltip' => __( 'This controls the display of field icons in the registration form', 'ultimate-member' ),
1553
- 'default' => um_get_metadefault( 'register_icons' ),
1554
- 'options' => array(
1555
- 'field' => __( 'Show inside text field', 'ultimate-member' ),
1556
- 'label' => __( 'Show with label', 'ultimate-member' ),
1557
- 'off' => __( 'Turn off', 'ultimate-member' ),
1558
- ),
1559
- 'size' => 'small',
1560
- ),
1561
- array(
1562
- 'id' => 'register_primary_btn_word',
1563
- 'type' => 'text',
1564
- 'label' => __( 'Registration Primary Button Text', 'ultimate-member' ),
1565
- 'default' => um_get_metadefault( 'register_primary_btn_word' ),
1566
- 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
1567
- 'size' => 'medium',
1568
- ),
1569
- array(
1570
- 'id' => 'register_secondary_btn',
1571
- 'type' => 'checkbox',
1572
- 'label' => __( 'Registration Secondary Button', 'ultimate-member' ),
1573
- 'default' => 1,
1574
- 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1575
- ),
1576
- array(
1577
- 'id' => 'register_secondary_btn_word',
1578
- 'type' => 'text',
1579
- 'label' => __( 'Registration Secondary Button Text', 'ultimate-member' ),
1580
- 'default' => um_get_metadefault( 'register_secondary_btn_word' ),
1581
- 'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
1582
- 'conditional' => array( 'register_secondary_btn', '=', 1 ),
1583
- 'size' => 'medium',
1584
- ),
1585
- array(
1586
- 'id' => 'register_secondary_btn_url',
1587
- 'type' => 'text',
1588
- 'label' => __( 'Registration Secondary Button URL', 'ultimate-member' ),
1589
- 'default' => um_get_metadefault( 'register_secondary_btn_url' ),
1590
- 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
1591
- 'conditional' => array( 'register_secondary_btn', '=', 1 ),
1592
- 'size' => 'medium',
1593
- ),
1594
- array(
1595
- 'id' => 'register_role',
1596
- 'type' => 'select',
1597
- 'label' => __( 'Registration Default Role', 'ultimate-member' ),
1598
- 'tooltip' => __( 'This will be the default role assigned to users registering thru registration form', 'ultimate-member' ),
1599
- 'default' => um_get_metadefault( 'register_role' ),
1600
- 'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
1601
- 'size' => 'small',
1602
- ),
1603
- ),
1604
- ),
1605
- 'login_form' => array(
1606
- 'title' => __( 'Login Form', 'ultimate-member' ),
1607
- 'fields' => array(
1608
- array(
1609
- 'id' => 'login_template',
1610
- 'type' => 'select',
1611
- 'label' => __( 'Login Default Template', 'ultimate-member' ),
1612
- 'tooltip' => __( 'This will be the default template to output login', 'ultimate-member' ),
1613
- 'default' => um_get_metadefault( 'login_template' ),
1614
- 'options' => UM()->shortcodes()->get_templates( 'login' ),
1615
- 'size' => 'small',
1616
- ),
1617
- array(
1618
- 'id' => 'login_max_width',
1619
- 'type' => 'text',
1620
- 'label' => __( 'Login Maximum Width', 'ultimate-member' ),
1621
- 'default' => um_get_metadefault( 'login_max_width' ),
1622
- 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1623
- 'size' => 'small',
1624
- ),
1625
- array(
1626
- 'id' => 'login_align',
1627
- 'type' => 'select',
1628
- 'label' => __( 'Login Shortcode Alignment', 'ultimate-member' ),
1629
- 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
1630
- 'default' => um_get_metadefault( 'login_align' ),
1631
- 'options' => array(
1632
- 'center' => __( 'Centered', 'ultimate-member' ),
1633
- 'left' => __( 'Left aligned', 'ultimate-member' ),
1634
- 'right' => __( 'Right aligned', 'ultimate-member' ),
1635
- ),
1636
- 'size' => 'small',
1637
- ),
1638
- array(
1639
- 'id' => 'login_icons',
1640
- 'type' => 'select',
1641
- 'label' => __( 'Login Field Icons', 'ultimate-member' ),
1642
- 'tooltip' => __( 'This controls the display of field icons in the login form', 'ultimate-member' ),
1643
- 'default' => um_get_metadefault( 'login_icons' ),
1644
- 'options' => array(
1645
- 'field' => __( 'Show inside text field', 'ultimate-member' ),
1646
- 'label' => __( 'Show with label', 'ultimate-member' ),
1647
- 'off' => __( 'Turn off', 'ultimate-member' ),
1648
- ),
1649
- 'size' => 'small',
1650
- ),
1651
- array(
1652
- 'id' => 'login_primary_btn_word',
1653
- 'type' => 'text',
1654
- 'label' => __( 'Login Primary Button Text', 'ultimate-member' ),
1655
- 'default' => um_get_metadefault( 'login_primary_btn_word' ),
1656
- 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
1657
- 'size' => 'medium',
1658
- ),
1659
- array(
1660
- 'id' => 'login_secondary_btn',
1661
- 'type' => 'checkbox',
1662
- 'label' => __( 'Login Secondary Button', 'ultimate-member' ),
1663
- 'default' => 1,
1664
- 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1665
- ),
1666
- array(
1667
- 'id' => 'login_secondary_btn_word',
1668
- 'type' => 'text',
1669
- 'label' => __( 'Login Secondary Button Text', 'ultimate-member' ),
1670
- 'default' => um_get_metadefault( 'login_secondary_btn_word' ),
1671
- 'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
1672
- 'conditional' => array( 'login_secondary_btn', '=', 1 ),
1673
- 'size' => 'medium',
1674
- ),
1675
- array(
1676
- 'id' => 'login_secondary_btn_url',
1677
- 'type' => 'text',
1678
- 'label' => __( 'Login Secondary Button URL', 'ultimate-member' ),
1679
- 'default' => um_get_metadefault( 'login_secondary_btn_url' ),
1680
- 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
1681
- 'conditional' => array( 'login_secondary_btn', '=', 1 ),
1682
- 'size' => 'medium',
1683
- ),
1684
- array(
1685
- 'id' => 'login_forgot_pass_link',
1686
- 'type' => 'checkbox',
1687
- 'label' => __( 'Login Forgot Password Link', 'ultimate-member' ),
1688
- 'default' => 1,
1689
- 'tooltip' => __( 'Switch on/off the forgot password link in login form', 'ultimate-member' ),
1690
- ),
1691
- array(
1692
- 'id' => 'login_show_rememberme',
1693
- 'type' => 'checkbox',
1694
- 'label' => __( 'Show "Remember Me"', 'ultimate-member' ),
1695
- 'default' => 1,
1696
- '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' ),
1697
- ),
1698
- ),
1699
- ),
1700
- ),
1701
- ),
1702
- 'extensions' => array(
1703
- 'title' => __( 'Extensions', 'ultimate-member' ),
1704
- ),
1705
- 'licenses' => array(
1706
- 'title' => __( 'Licenses', 'ultimate-member' ),
1707
- ),
1708
- 'misc' => array(
1709
- 'title' => __( 'Misc', 'ultimate-member' ),
1710
- 'fields' => array(
1711
- array(
1712
- 'id' => 'form_asterisk',
1713
- 'type' => 'checkbox',
1714
- 'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ),
1715
- ),
1716
- array(
1717
- 'id' => 'profile_title',
1718
- 'type' => 'text',
1719
- 'label' => __( 'User Profile Title', 'ultimate-member' ),
1720
- 'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ),
1721
- 'size' => 'medium',
1722
- ),
1723
- array(
1724
- 'id' => 'profile_desc',
1725
- 'type' => 'textarea',
1726
- 'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ),
1727
- 'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ),
1728
- 'args' => array(
1729
- 'textarea_rows' => 6,
1730
- ),
1731
- ),
1732
- array(
1733
- 'id' => 'um_profile_object_cache_stop',
1734
- 'type' => 'checkbox',
1735
- 'label' => __( 'Disable Cache User Profile', 'ultimate-member' ),
1736
- 'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ),
1737
- ),
1738
- array(
1739
- 'id' => 'enable_blocks',
1740
- 'type' => 'checkbox',
1741
- 'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ),
1742
- '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' ),
1743
- ),
1744
- array(
1745
- 'id' => 'rest_api_version',
1746
- 'type' => 'select',
1747
- 'label' => __( 'REST API version', 'ultimate-member' ),
1748
- 'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ),
1749
- 'options' => array(
1750
- '1.0' => __( '1.0 version', 'ultimate-member' ),
1751
- '2.0' => __( '2.0 version', 'ultimate-member' ),
1752
- ),
1753
- ),
1754
- $same_page_update,
1755
- array(
1756
- 'id' => 'uninstall_on_delete',
1757
- 'type' => 'checkbox',
1758
- 'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ),
1759
- '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' ),
1760
- ),
1761
- ),
1762
- ),
1763
- 'install_info' => array(
1764
- 'title' => __( 'Install Info', 'ultimate-member' ),
1765
- 'fields' => array(
1766
- array(
1767
- 'type' => 'install_info',
1768
- ),
1769
- ),
1770
- ),
1771
- )
1772
- );
1773
-
1774
- }
1775
-
1776
-
1777
- /**
1778
- * @param array $settings
1779
- *
1780
- * @return array
1781
- */
1782
- public function sorting_licenses_options( $settings ) {
1783
- //sorting licenses
1784
- if ( empty( $settings['licenses']['fields'] ) ) {
1785
- return $settings;
1786
- }
1787
-
1788
- $licenses = $settings['licenses']['fields'];
1789
- @uasort( $licenses, function( $a, $b ) {
1790
- return strnatcasecmp( $a['label'], $b['label'] );
1791
- } );
1792
- $settings['licenses']['fields'] = $licenses;
1793
-
1794
- //sorting extensions
1795
- if ( empty( $settings['extensions']['sections'] ) ) {
1796
- return $settings;
1797
- }
1798
-
1799
- $extensions = $settings['extensions']['sections'];
1800
- @uasort( $extensions, function( $a, $b ) {
1801
- return strnatcasecmp( $a['title'], $b['title'] );
1802
- } );
1803
-
1804
- $keys = array_keys( $extensions );
1805
- if ( $keys[0] !== '' ) {
1806
- $new_key = strtolower( str_replace( ' ', '_', $extensions['']['title'] ) );
1807
- $temp = $extensions[''];
1808
- $extensions[ $new_key ] = $temp;
1809
- $extensions[''] = $extensions[ $keys[0] ];
1810
- unset( $extensions[ $keys[0] ] );
1811
- @uasort( $extensions, function( $a, $b ) {
1812
- return strnatcasecmp( $a['title'], $b['title'] );
1813
- } );
1814
- }
1815
-
1816
- $settings['extensions']['sections'] = $extensions;
1817
-
1818
- return $settings;
1819
- }
1820
-
1821
-
1822
- /**
1823
- * @param $tab
1824
- * @param $section
1825
- *
1826
- * @return array
1827
- */
1828
- function get_section_fields( $tab, $section ) {
1829
-
1830
- if ( empty( $this->settings_structure[ $tab ] ) ) {
1831
- return array();
1832
- }
1833
-
1834
- if ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
1835
- return $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
1836
- } elseif ( ! empty( $this->settings_structure[ $tab ]['fields'] ) ) {
1837
- return $this->settings_structure[ $tab ]['fields'];
1838
- }
1839
-
1840
- return array();
1841
- }
1842
-
1843
-
1844
- /**
1845
- * Setup admin menu
1846
- */
1847
- function primary_admin_menu() {
1848
- add_submenu_page( 'ultimatemember', __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( &$this, 'settings_page' ) );
1849
- }
1850
-
1851
-
1852
- /**
1853
- * Settings page callback
1854
- */
1855
- function settings_page() {
1856
- $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
1857
- $current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
1858
-
1859
- $settings_struct = $this->settings_structure[ $current_tab ];
1860
-
1861
- //remove not option hidden fields
1862
- if ( ! empty( $settings_struct['fields'] ) ) {
1863
- foreach ( $settings_struct['fields'] as $field_key => $field_options ) {
1864
-
1865
- if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
1866
- unset( $settings_struct['fields'][ $field_key ] );
1867
- }
1868
-
1869
- }
1870
- }
1871
-
1872
- if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) ) {
1873
- um_js_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) );
1874
- }
1875
-
1876
- if ( ! empty( $settings_struct['sections'] ) ) {
1877
- if ( empty( $settings_struct['sections'][ $current_subtab ] ) ) {
1878
- um_js_redirect( add_query_arg( array( 'page' => 'um_options', 'tab' => $current_tab ), admin_url( 'admin.php' ) ) );
1879
- }
1880
- }
1881
-
1882
- echo '<div id="um-settings-wrap" class="wrap"><h2>' . __( 'Ultimate Member - Settings', 'ultimate-member' ) . '</h2>';
1883
-
1884
- echo $this->generate_tabs_menu() . $this->generate_subtabs_menu( $current_tab );
1885
-
1886
- /**
1887
- * UM hook
1888
- *
1889
- * @type action
1890
- * @title um_settings_page_before_{$current_tab}_{$current_subtab}_content
1891
- * @description Show some content before settings page content
1892
- * @change_log
1893
- * ["Since: 2.0"]
1894
- * @usage add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'function_name', 10 );
1895
- * @example
1896
- * <?php
1897
- * add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'my_settings_page_before', 10 );
1898
- * function my_settings_page_before() {
1899
- * // your code here
1900
- * }
1901
- * ?>
1902
- */
1903
- do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" );
1904
-
1905
- 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 ) ) ) {
1906
-
1907
- /**
1908
- * UM hook
1909
- *
1910
- * @type action
1911
- * @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
1912
- * @description Show some content before section content at settings page
1913
- * @change_log
1914
- * ["Since: 2.0"]
1915
- * @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
1916
- * @example
1917
- * <?php
1918
- * add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
1919
- * function my_settings_page_before_section() {
1920
- * // your code here
1921
- * }
1922
- * ?>
1923
- */
1924
- do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
1925
-
1926
- $section_fields = $this->get_section_fields( $current_tab, $current_subtab );
1927
- $settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
1928
-
1929
- /**
1930
- * UM hook
1931
- *
1932
- * @type filter
1933
- * @title um_settings_section_{$current_tab}_{$current_subtab}_content
1934
- *
1935
- * @description Render settings section
1936
- * @input_vars
1937
- * [{"var":"$content","type":"string","desc":"Section content"},
1938
- * {"var":"$section_fields","type":"array","desc":"Section Fields"}]
1939
- * @change_log
1940
- * ["Since: 2.0"]
1941
- * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
1942
- * @example
1943
- * <?php
1944
- * add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
1945
- * function my_settings_section( $content ) {
1946
- * // your code here
1947
- * return $content;
1948
- * }
1949
- * ?>
1950
- */
1951
- echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
1952
- $settings_section,
1953
- $section_fields
1954
- );
1955
-
1956
- } else { ?>
1957
-
1958
- <form method="post" action="" name="um-settings-form" id="um-settings-form">
1959
- <input type="hidden" value="save" name="um-settings-action" />
1960
-
1961
- <?php
1962
- /**
1963
- * UM hook
1964
- *
1965
- * @type action
1966
- * @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
1967
- * @description Show some content before section content at settings page
1968
- * @change_log
1969
- * ["Since: 2.0"]
1970
- * @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
1971
- * @example
1972
- * <?php
1973
- * add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
1974
- * function my_settings_page_before_section() {
1975
- * // your code here
1976
- * }
1977
- * ?>
1978
- */
1979
- do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
1980
-
1981
- $section_fields = $this->get_section_fields( $current_tab, $current_subtab );
1982
- $settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
1983
-
1984
- /**
1985
- * UM hook
1986
- *
1987
- * @type filter
1988
- * @title um_settings_section_{$current_tab}_{$current_subtab}_content
1989
- * @description Render settings section
1990
- * @input_vars
1991
- * [{"var":"$content","type":"string","desc":"Section content"},
1992
- * {"var":"$section_fields","type":"array","desc":"Section Fields"}]
1993
- * @change_log
1994
- * ["Since: 2.0"]
1995
- * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
1996
- * @example
1997
- * <?php
1998
- * add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
1999
- * function my_settings_section( $content ) {
2000
- * // your code here
2001
- * return $content;
2002
- * }
2003
- * ?>
2004
- */
2005
- echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
2006
- $settings_section,
2007
- $section_fields
2008
- ); ?>
2009
-
2010
-
2011
- <p class="submit">
2012
- <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save Changes', 'ultimate-member' ) ?>" />
2013
- <?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
2014
- <input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
2015
- </p>
2016
- </form>
2017
-
2018
- <?php }
2019
- }
2020
-
2021
-
2022
- /**
2023
- * Generate pages tabs
2024
- *
2025
- * @param string $page
2026
- * @return string
2027
- */
2028
- function generate_tabs_menu( $page = 'settings' ) {
2029
-
2030
- $tabs = '<h2 class="nav-tab-wrapper um-nav-tab-wrapper">';
2031
-
2032
- switch( $page ) {
2033
- case 'settings':
2034
- $menu_tabs = array();
2035
- foreach ( $this->settings_structure as $slug => $tab ) {
2036
- if ( ! empty( $tab['fields'] ) ) {
2037
- foreach ( $tab['fields'] as $field_key => $field_options ) {
2038
- if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
2039
- unset( $tab['fields'][ $field_key ] );
2040
- }
2041
- }
2042
- }
2043
-
2044
- if ( ! empty( $tab['fields'] ) || ! empty( $tab['sections'] ) ) {
2045
- $menu_tabs[ $slug ] = $tab['title'];
2046
- }
2047
- }
2048
-
2049
- $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
2050
- foreach ( $menu_tabs as $name => $label ) {
2051
- $active = ( $current_tab == $name ) ? 'nav-tab-active' : '';
2052
- $tabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $name ) ? '' : '&tab=' . $name ) ) ) . '" class="nav-tab ' . esc_attr( $active ) . '">' .
2053
- $label .
2054
- '</a>';
2055
- }
2056
-
2057
- break;
2058
- default:
2059
- /**
2060
- * UM hook
2061
- *
2062
- * @type filter
2063
- * @title um_generate_tabs_menu_{$page}
2064
- * @description Generate tabs menu
2065
- * @input_vars
2066
- * [{"var":"$tabs","type":"array","desc":"UM menu tabs"}]
2067
- * @change_log
2068
- * ["Since: 2.0"]
2069
- * @usage add_filter( 'um_generate_tabs_menu_{$page}', 'function_name', 10, 1 );
2070
- * @example
2071
- * <?php
2072
- * add_filter( 'um_generate_tabs_menu_{$page}', 'my_tabs_menu', 10, 1 );
2073
- * function my_tabs_menu( $tabs ) {
2074
- * // your code here
2075
- * return $tabs;
2076
- * }
2077
- * ?>
2078
- */
2079
- $tabs = apply_filters( 'um_generate_tabs_menu_' . $page, $tabs );
2080
- break;
2081
- }
2082
-
2083
- return $tabs . '</h2>';
2084
- }
2085
-
2086
-
2087
- /**
2088
- * @param string $tab
2089
- *
2090
- * @return string
2091
- */
2092
- function generate_subtabs_menu( $tab = '' ) {
2093
- if ( empty( $this->settings_structure[ $tab ]['sections'] ) ) {
2094
- return '';
2095
- }
2096
-
2097
- $menu_subtabs = array();
2098
- foreach ( $this->settings_structure[ $tab ]['sections'] as $slug => $subtab ) {
2099
- $menu_subtabs[ $slug ] = $subtab['title'];
2100
- }
2101
-
2102
- $subtabs = '<div><ul class="subsubsub">';
2103
-
2104
- $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
2105
- $current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
2106
- foreach ( $menu_subtabs as $name => $label ) {
2107
- $active = ( $current_subtab == $name ) ? 'current' : '';
2108
- $subtabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $current_tab ) ? '' : '&tab=' . $current_tab ) . ( empty( $name ) ? '' : '&section=' . $name ) ) ) . '" class="' . $active . '">'
2109
- . $label .
2110
- '</a> | ';
2111
- }
2112
-
2113
- return substr( $subtabs, 0, -3 ) . '</ul></div>';
2114
- }
2115
-
2116
-
2117
- /**
2118
- * Handler for settings forms
2119
- * when "Save Settings" button click
2120
- *
2121
- */
2122
- function save_settings_handler() {
2123
-
2124
- if ( isset( $_POST['um-settings-action'] ) && 'save' === sanitize_key( $_POST['um-settings-action'] ) && ! empty( $_POST['um_options'] ) ) {
2125
-
2126
- $nonce = ! empty( $_POST['__umnonce'] ) ? $_POST['__umnonce'] : '';
2127
-
2128
- if ( ( ! wp_verify_nonce( $nonce, 'um-settings-nonce' ) || empty( $nonce ) ) || ! current_user_can( 'manage_options' ) ) {
2129
- // This nonce is not valid.
2130
- wp_die( __( 'Security Check', 'ultimate-member' ) );
2131
- }
2132
-
2133
- /**
2134
- * UM hook
2135
- *
2136
- * @type action
2137
- * @title um_settings_before_save
2138
- * @description Before settings save action
2139
- * @change_log
2140
- * ["Since: 2.0"]
2141
- * @usage add_action( 'um_settings_before_save', 'function_name', 10 );
2142
- * @example
2143
- * <?php
2144
- * add_action( 'um_settings_before_save', 'my_settings_before_save', 10 );
2145
- * function my_settings_before_save() {
2146
- * // your code here
2147
- * }
2148
- * ?>
2149
- */
2150
- do_action( "um_settings_before_save" );
2151
-
2152
- /**
2153
- * UM hook
2154
- *
2155
- * @type filter
2156
- * @title um_change_settings_before_save
2157
- * @description Change settings before save
2158
- * @input_vars
2159
- * [{"var":"$settings","type":"array","desc":"UM Settings on save"}]
2160
- * @change_log
2161
- * ["Since: 2.0"]
2162
- * @usage add_filter( 'um_change_settings_before_save', 'function_name', 10, 1 );
2163
- * @example
2164
- * <?php
2165
- * add_filter( 'um_change_settings_before_save', 'my_change_settings_before_save', 10, 1 );
2166
- * function my_change_settings_before_save( $settings ) {
2167
- * // your code here
2168
- * return $settings;
2169
- * }
2170
- * ?>
2171
- */
2172
- $settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] );
2173
-
2174
- $settings = UM()->admin()->sanitize_options( $settings );
2175
-
2176
- foreach ( $settings as $key => $value ) {
2177
- UM()->options()->update( $key, $value );
2178
- }
2179
-
2180
- /**
2181
- * UM hook
2182
- *
2183
- * @type action
2184
- * @title um_settings_save
2185
- * @description After settings save action
2186
- * @change_log
2187
- * ["Since: 2.0"]
2188
- * @usage add_action( 'um_settings_save', 'function_name', 10 );
2189
- * @example
2190
- * <?php
2191
- * add_action( 'um_settings_save', 'my_settings_save', 10 );
2192
- * function my_settings_save() {
2193
- * // your code here
2194
- * }
2195
- * ?>
2196
- */
2197
- do_action( 'um_settings_save' );
2198
-
2199
- //redirect after save settings
2200
- $arg = array(
2201
- 'page' => 'um_options',
2202
- );
2203
-
2204
- if ( ! empty( $_GET['tab'] ) ) {
2205
- $arg['tab'] = sanitize_key( $_GET['tab'] );
2206
- }
2207
-
2208
- if ( ! empty( $_GET['section'] ) ) {
2209
- $arg['section'] = sanitize_key( $_GET['section'] );
2210
- }
2211
-
2212
- um_js_redirect( add_query_arg( $arg, admin_url( 'admin.php' ) ) );
2213
- }
2214
- }
2215
-
2216
-
2217
- function set_default_if_empty( $settings ) {
2218
- $tab = '';
2219
- if ( ! empty( $_GET['tab'] ) ) {
2220
- $tab = sanitize_key( $_GET['tab'] );
2221
- }
2222
-
2223
- $section = '';
2224
- if ( ! empty( $_GET['section'] ) ) {
2225
- $section = sanitize_key( $_GET['section'] );
2226
- }
2227
-
2228
-
2229
- if ( 'access' === $tab && empty( $section ) ) {
2230
- if ( ! array_key_exists( 'access_exclude_uris', $settings ) ) {
2231
- $settings['access_exclude_uris'] = array();
2232
- }
2233
- }
2234
-
2235
- return $settings;
2236
- }
2237
-
2238
-
2239
- /**
2240
- * Remove empty values from multi text fields
2241
- *
2242
- * @param $settings
2243
- * @return array
2244
- */
2245
- function remove_empty_values( $settings ) {
2246
- $tab = '';
2247
- if ( ! empty( $_GET['tab'] ) ) {
2248
- $tab = sanitize_key( $_GET['tab'] );
2249
- }
2250
-
2251
- $section = '';
2252
- if ( ! empty( $_GET['section'] ) ) {
2253
- $section = sanitize_key( $_GET['section'] );
2254
- }
2255
-
2256
- if ( isset( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
2257
- $fields = $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
2258
- } else {
2259
- $fields = $this->settings_structure[ $tab ]['fields'];
2260
- }
2261
-
2262
- if ( empty( $fields ) ) {
2263
- return $settings;
2264
- }
2265
-
2266
-
2267
- $filtered_settings = array();
2268
- foreach ( $settings as $key => $value ) {
2269
-
2270
- $filtered_settings[ $key ] = $value;
2271
-
2272
- foreach ( $fields as $field ) {
2273
- if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) {
2274
- $filtered_settings[ $key ] = array_filter( $settings[ $key ] );
2275
- }
2276
- }
2277
- }
2278
-
2279
- return $filtered_settings;
2280
- }
2281
-
2282
-
2283
- /**
2284
- *
2285
- */
2286
- function check_permalinks_changes() {
2287
- if ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
2288
- if ( UM()->options()->get( 'permalink_base' ) !== $_POST['um_options']['permalink_base'] ) {
2289
- $this->need_change_permalinks = true;
2290
- }
2291
- }
2292
-
2293
- // set variable if gravatar settings were changed
2294
- // update for um_member_directory_data metakey
2295
- if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
2296
- $use_gravatar = UM()->options()->get( 'use_gravatars' );
2297
- if ( ( empty( $use_gravatar ) && ! empty( $_POST['um_options']['use_gravatars'] ) ) || ( ! empty( $use_gravatar ) && empty( $_POST['um_options']['use_gravatars'] ) ) ) {
2298
- $this->gravatar_changed = true;
2299
- }
2300
- }
2301
- }
2302
-
2303
-
2304
- /**
2305
- *
2306
- */
2307
- function on_settings_save() {
2308
- if ( ! empty( $_POST['um_options'] ) ) {
2309
-
2310
- if ( ! empty( $_POST['um_options']['pages_settings'] ) ) {
2311
- $post_ids = new \WP_Query( array(
2312
- 'post_type' => 'page',
2313
- 'meta_query' => array(
2314
- array(
2315
- 'key' => '_um_core',
2316
- 'compare' => 'EXISTS'
2317
- )
2318
- ),
2319
- 'posts_per_page' => -1,
2320
- 'fields' => 'ids'
2321
- ) );
2322
-
2323
- $post_ids = $post_ids->get_posts();
2324
-
2325
- if ( ! empty( $post_ids ) ) {
2326
- foreach ( $post_ids as $post_id ) {
2327
- delete_post_meta( $post_id, '_um_core' );
2328
- }
2329
- }
2330
-
2331
- foreach ( $_POST['um_options'] as $option_slug => $post_id ) {
2332
- $slug = str_replace( 'core_', '', $option_slug );
2333
- update_post_meta( $post_id, '_um_core', $slug );
2334
- }
2335
-
2336
- // reset rewrite rules after re-save pages
2337
- UM()->rewrite()->reset_rules();
2338
-
2339
- } elseif ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
2340
- if ( ! empty( $this->need_change_permalinks ) ) {
2341
- $users = get_users( array(
2342
- 'fields' => 'ids',
2343
- ) );
2344
- if ( ! empty( $users ) ) {
2345
- foreach ( $users as $user_id ) {
2346
- UM()->user()->generate_profile_slug( $user_id );
2347
- }
2348
- }
2349
- }
2350
-
2351
-
2352
- // update for um_member_directory_data metakey
2353
- if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
2354
- if ( $this->gravatar_changed ) {
2355
- global $wpdb;
2356
-
2357
- if ( ! empty( $_POST['um_options']['use_gravatars'] ) ) {
2358
-
2359
- $results = $wpdb->get_col(
2360
- "SELECT u.ID FROM {$wpdb->users} AS u
2361
- LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'synced_gravatar_hashed_id' )
2362
- LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2363
- WHERE um.meta_value != '' AND um.meta_value IS NOT NULL AND
2364
- um2.meta_value LIKE '%s:13:\"profile_photo\";b:0;%'"
2365
- );
2366
-
2367
- } else {
2368
-
2369
- $results = $wpdb->get_col(
2370
- "SELECT u.ID FROM {$wpdb->users} AS u
2371
- LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND ( um.meta_key = 'synced_profile_photo' || um.meta_key = 'profile_photo' ) )
2372
- LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2373
- WHERE ( um.meta_value IS NULL OR um.meta_value = '' ) AND
2374
- um2.meta_value LIKE '%s:13:\"profile_photo\";b:1;%'"
2375
- );
2376
-
2377
- }
2378
-
2379
- if ( ! empty( $results ) ) {
2380
- foreach ( $results as $user_id ) {
2381
- $md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
2382
- if ( ! empty( $md_data ) ) {
2383
- $md_data['profile_photo'] = ! empty( $_POST['um_options']['use_gravatars'] );
2384
- update_user_meta( $user_id, 'um_member_directory_data', $md_data );
2385
- }
2386
- }
2387
- }
2388
- }
2389
- }
2390
-
2391
- } elseif ( isset( $_POST['um_options']['member_directory_own_table'] ) ) {
2392
- if ( empty( $_POST['um_options']['member_directory_own_table'] ) ) {
2393
- global $wpdb;
2394
-
2395
- $results = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}um_metadata LIMIT 1", ARRAY_A );
2396
-
2397
- if ( ! empty( $results ) ) {
2398
- $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}um_metadata" );
2399
- }
2400
-
2401
- update_option( 'um_member_directory_truncated', time() );
2402
- }
2403
- } elseif ( isset( $_POST['um_options']['account_hide_in_directory_default'] ) ) {
2404
-
2405
- global $wpdb;
2406
-
2407
- if ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) {
2408
-
2409
- $results = $wpdb->get_col(
2410
- "SELECT u.ID FROM {$wpdb->users} AS u
2411
- LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
2412
- LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2413
- WHERE um.meta_value IS NULL AND
2414
- um2.meta_value LIKE '%s:15:\"hide_in_members\";b:1;%'"
2415
- );
2416
-
2417
- } else {
2418
-
2419
- $results = $wpdb->get_col(
2420
- "SELECT u.ID FROM {$wpdb->users} AS u
2421
- LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
2422
- LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2423
- WHERE um.meta_value IS NULL AND
2424
- um2.meta_value LIKE '%s:15:\"hide_in_members\";b:0;%'"
2425
- );
2426
-
2427
- }
2428
-
2429
- if ( ! empty( $results ) ) {
2430
- foreach ( $results as $user_id ) {
2431
- $md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
2432
- if ( ! empty( $md_data ) ) {
2433
- $md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) ? false : true;
2434
- update_user_meta( $user_id, 'um_member_directory_data', $md_data );
2435
- }
2436
- }
2437
- }
2438
-
2439
- }
2440
- }
2441
- }
2442
-
2443
-
2444
- /**
2445
- *
2446
- */
2447
- function before_licenses_save() {
2448
- if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
2449
- return;
2450
- }
2451
-
2452
- foreach ( $_POST['um_options'] as $key => $value ) {
2453
- $this->previous_licenses[ sanitize_key( $key ) ] = UM()->options()->get( $key );
2454
- }
2455
- }
2456
-
2457
-
2458
- /**
2459
- *
2460
- */
2461
- function licenses_save() {
2462
- if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
2463
- return;
2464
- }
2465
-
2466
- foreach ( $_POST['um_options'] as $key => $value ) {
2467
- $key = sanitize_key( $key );
2468
- $value = sanitize_text_field( $value );
2469
-
2470
- $edd_action = '';
2471
- $license_key = '';
2472
- if ( empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) && $this->previous_licenses[ $key ] != $value ) ) {
2473
- $edd_action = 'activate_license';
2474
- $license_key = $value;
2475
- } elseif ( ! empty( $this->previous_licenses[ $key ] ) && empty( $value ) ) {
2476
- $edd_action = 'deactivate_license';
2477
- $license_key = $this->previous_licenses[ $key ];
2478
- } elseif ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) ) {
2479
- $edd_action = 'check_license';
2480
- $license_key = $value;
2481
- }
2482
-
2483
- if ( empty( $edd_action ) ) {
2484
- continue;
2485
- }
2486
-
2487
- $item_name = false;
2488
- $version = false;
2489
- $author = false;
2490
- foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) {
2491
- if ( $field_data['id'] == $key ) {
2492
- $item_name = ! empty( $field_data['item_name'] ) ? $field_data['item_name'] : false;
2493
- $version = ! empty( $field_data['version'] ) ? $field_data['version'] : false;
2494
- $author = ! empty( $field_data['author'] ) ? $field_data['author'] : false;
2495
- }
2496
- }
2497
-
2498
- $api_params = array(
2499
- 'edd_action' => $edd_action,
2500
- 'license' => $license_key,
2501
- 'item_name' => $item_name,
2502
- 'version' => $version,
2503
- 'author' => $author,
2504
- 'url' => home_url(),
2505
- );
2506
-
2507
- $request = wp_remote_post(
2508
- UM()->store_url,
2509
- array(
2510
- 'timeout' => UM()->request_timeout,
2511
- 'sslverify' => false,
2512
- 'body' => $api_params
2513
- )
2514
- );
2515
-
2516
- if ( ! is_wp_error( $request ) ) {
2517
- $request = json_decode( wp_remote_retrieve_body( $request ) );
2518
- } else {
2519
- $request = wp_remote_post(
2520
- UM()->store_url,
2521
- array(
2522
- 'timeout' => UM()->request_timeout,
2523
- 'sslverify' => true,
2524
- 'body' => $api_params
2525
- )
2526
- );
2527
-
2528
- if ( ! is_wp_error( $request ) ) {
2529
- $request = json_decode( wp_remote_retrieve_body( $request ) );
2530
- }
2531
- }
2532
-
2533
- $request = ( $request ) ? maybe_unserialize( $request ) : false;
2534
-
2535
- if ( $edd_action == 'activate_license' || $edd_action == 'check_license' ) {
2536
- update_option( "{$key}_edd_answer", $request );
2537
- } else {
2538
- delete_option( "{$key}_edd_answer" );
2539
- }
2540
-
2541
- }
2542
- }
2543
-
2544
-
2545
- /**
2546
- *
2547
- */
2548
- function settings_before_email_tab() {
2549
- $email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
2550
- $emails = UM()->config()->email_notifications;
2551
-
2552
- if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
2553
- include_once um_path . 'includes/admin/core/list-tables/emails-list-table.php';
2554
- }
2555
- }
2556
-
2557
-
2558
- /**
2559
- * @param $section
2560
- *
2561
- * @return string
2562
- */
2563
- function settings_email_tab( $section ) {
2564
- $email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
2565
- $emails = UM()->config()->email_notifications;
2566
-
2567
- if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
2568
- return $section;
2569
- }
2570
-
2571
- $in_theme = UM()->mail()->template_in_theme( $email_key );
2572
-
2573
- /**
2574
- * UM hook
2575
- *
2576
- * @type filter
2577
- * @title um_admin_settings_email_section_fields
2578
- * @description Extend UM Email Settings
2579
- * @input_vars
2580
- * [{"var":"$settings","type":"array","desc":"UM Email Settings"},
2581
- * {"var":"$email_key","type":"string","desc":"Email Key"}]
2582
- * @change_log
2583
- * ["Since: 2.0"]
2584
- * @usage add_filter( 'um_admin_settings_email_section_fields', 'function_name', 10, 2 );
2585
- * @example
2586
- * <?php
2587
- * add_filter( 'um_admin_settings_email_section_fields', 'my_admin_settings_email_section', 10, 2 );
2588
- * function my_admin_settings_email_section( $settings, $email_key ) {
2589
- * // your code here
2590
- * return $settings;
2591
- * }
2592
- * ?>
2593
- */
2594
- $section_fields = apply_filters( 'um_admin_settings_email_section_fields', array(
2595
- array(
2596
- 'id' => 'um_email_template',
2597
- 'type' => 'hidden',
2598
- 'value' => $email_key,
2599
- ),
2600
- array(
2601
- 'id' => $email_key . '_on',
2602
- 'type' => 'checkbox',
2603
- 'label' => $emails[ $email_key ]['title'],
2604
- 'tooltip' => $emails[ $email_key ]['description'],
2605
- ),
2606
- array(
2607
- 'id' => $email_key . '_sub',
2608
- 'type' => 'text',
2609
- 'label' => __( 'Subject Line', 'ultimate-member' ),
2610
- 'conditional' => array( $email_key . '_on', '=', 1 ),
2611
- 'tooltip' => __( 'This is the subject line of the e-mail', 'ultimate-member' ),
2612
- ),
2613
- array(
2614
- 'id' => $email_key,
2615
- 'type' => 'email_template',
2616
- 'label' => __( 'Message Body', 'ultimate-member' ),
2617
- 'conditional' => array( $email_key . '_on', '=', 1 ),
2618
- 'tooltip' => __( 'This is the content of the e-mail', 'ultimate-member' ),
2619
- 'value' => UM()->mail()->get_email_template( $email_key ),
2620
- 'in_theme' => $in_theme
2621
- ),
2622
- ), $email_key );
2623
-
2624
- return $this->render_settings_section( $section_fields, 'email', $email_key );
2625
- }
2626
-
2627
-
2628
- /**
2629
- *
2630
- */
2631
- function settings_appearance_profile_tab() {
2632
- wp_enqueue_media();
2633
- }
2634
-
2635
-
2636
- /**
2637
- * @param $html
2638
- * @param $section_fields
2639
- *
2640
- * @return string
2641
- */
2642
- function settings_licenses_tab( $html, $section_fields ) {
2643
- ob_start(); ?>
2644
-
2645
- <div class="wrap-licenses">
2646
- <input type="hidden" id="licenses_settings" name="licenses_settings" value="1">
2647
- <?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
2648
- <input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
2649
- <table class="form-table um-settings-section">
2650
- <tbody>
2651
- <?php foreach ( $section_fields as $field_data ) {
2652
- $option_value = UM()->options()->get( $field_data['id'] );
2653
- $value = isset( $option_value ) && ! empty( $option_value ) ? $option_value : ( isset( $field_data['default'] ) ? $field_data['default'] : '' );
2654
-
2655
- $license = get_option( "{$field_data['id']}_edd_answer" );
2656
-
2657
- if ( is_object( $license ) && ! empty( $value ) ) {
2658
- // activate_license 'invalid' on anything other than valid, so if there was an error capture it
2659
- if ( empty( $license->success ) ) {
2660
-
2661
- if ( ! empty( $license->error ) ) {
2662
- switch ( $license->error ) {
2663
-
2664
- case 'expired' :
2665
-
2666
- $class = 'expired';
2667
- $messages[] = sprintf(
2668
- __( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
2669
- date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
2670
- 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
2671
- );
2672
-
2673
- $license_status = 'license-' . $class . '-notice';
2674
-
2675
- break;
2676
-
2677
- case 'revoked' :
2678
-
2679
- $class = 'error';
2680
- $messages[] = sprintf(
2681
- __( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
2682
- 'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
2683
- );
2684
-
2685
- $license_status = 'license-' . $class . '-notice';
2686
-
2687
- break;
2688
-
2689
- case 'missing' :
2690
-
2691
- $class = 'error';
2692
- $messages[] = sprintf(
2693
- __( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
2694
- 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
2695
- );
2696
-
2697
- $license_status = 'license-' . $class . '-notice';
2698
-
2699
- break;
2700
-
2701
- case 'invalid' :
2702
- case 'site_inactive' :
2703
-
2704
- $class = 'error';
2705
- $messages[] = sprintf(
2706
- __( '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' ),
2707
- $field_data['item_name'],
2708
- 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
2709
- );
2710
-
2711
- $license_status = 'license-' . $class . '-notice';
2712
-
2713
- break;
2714
-
2715
- case 'item_name_mismatch' :
2716
-
2717
- $class = 'error';
2718
- $messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
2719
-
2720
- $license_status = 'license-' . $class . '-notice';
2721
-
2722
- break;
2723
-
2724
- case 'no_activations_left':
2725
-
2726
- $class = 'error';
2727
- $messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
2728
-
2729
- $license_status = 'license-' . $class . '-notice';
2730
-
2731
- break;
2732
-
2733
- case 'license_not_activable':
2734
-
2735
- $class = 'error';
2736
- $messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
2737
-
2738
- $license_status = 'license-' . $class . '-notice';
2739
- break;
2740
-
2741
- default :
2742
-
2743
- $class = 'error';
2744
- $error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
2745
- $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' );
2746
-
2747
- $license_status = 'license-' . $class . '-notice';
2748
- break;
2749
- }
2750
- } else {
2751
- $class = 'error';
2752
- $error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
2753
- $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' );
2754
-
2755
- $license_status = 'license-' . $class . '-notice';
2756
- }
2757
-
2758
- } elseif ( ! empty( $license->errors ) ) {
2759
-
2760
- $errors = array_keys( $license->errors );
2761
- $errors_data = array_values( $license->errors );
2762
-
2763
- $class = 'error';
2764
- $error = ! empty( $errors[0] ) ? $errors[0] : __( 'unknown_error', 'ultimate-member' );
2765
- $errors_data = ! empty( $errors_data[0][0] ) ? ', ' . $errors_data[0][0] : '';
2766
- $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' );
2767
-
2768
- $license_status = 'license-' . $class . '-notice';
2769
-
2770
- } else {
2771
-
2772
- switch( $license->license ) {
2773
-
2774
- case 'expired' :
2775
-
2776
- $class = 'expired';
2777
- $messages[] = sprintf(
2778
- __( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
2779
- date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
2780
- 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
2781
- );
2782
-
2783
- $license_status = 'license-' . $class . '-notice';
2784
-
2785
- break;
2786
-
2787
- case 'revoked' :
2788
-
2789
- $class = 'error';
2790
- $messages[] = sprintf(
2791
- __( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
2792
- 'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
2793
- );
2794
-
2795
- $license_status = 'license-' . $class . '-notice';
2796
-
2797
- break;
2798
-
2799
- case 'missing' :
2800
-
2801
- $class = 'error';
2802
- $messages[] = sprintf(
2803
- __( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
2804
- 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
2805
- );
2806
-
2807
- $license_status = 'license-' . $class . '-notice';
2808
-
2809
- break;
2810
-
2811
- case 'invalid' :
2812
- case 'site_inactive' :
2813
-
2814
- $class = 'error';
2815
- $messages[] = sprintf(
2816
- __( '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' ),
2817
- $field_data['item_name'],
2818
- 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
2819
- );
2820
-
2821
- $license_status = 'license-' . $class . '-notice';
2822
-
2823
- break;
2824
-
2825
- case 'item_name_mismatch' :
2826
-
2827
- $class = 'error';
2828
- $messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
2829
-
2830
- $license_status = 'license-' . $class . '-notice';
2831
-
2832
- break;
2833
-
2834
- case 'no_activations_left':
2835
-
2836
- $class = 'error';
2837
- $messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
2838
-
2839
- $license_status = 'license-' . $class . '-notice';
2840
-
2841
- break;
2842
-
2843
- case 'license_not_activable':
2844
-
2845
- $class = 'error';
2846
- $messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
2847
-
2848
- $license_status = 'license-' . $class . '-notice';
2849
- break;
2850
-
2851
- case 'valid' :
2852
- default:
2853
-
2854
- $class = 'valid';
2855
-
2856
- $now = current_time( 'timestamp' );
2857
- $expiration = strtotime( $license->expires, $now );
2858
-
2859
- if( 'lifetime' === $license->expires ) {
2860
-
2861
- $messages[] = __( 'License key never expires.', 'ultimate-member' );
2862
-
2863
- $license_status = 'license-lifetime-notice';
2864
-
2865
- } elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
2866
-
2867
- $messages[] = sprintf(
2868
- __( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank">Renew your license key</a>.', 'ultimate-member' ),
2869
- date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
2870
- 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
2871
- );
2872
-
2873
- $license_status = 'license-expires-soon-notice';
2874
-
2875
- } else {
2876
-
2877
- $messages[] = sprintf(
2878
- __( 'Your license key expires on %s.', 'ultimate-member' ),
2879
- date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
2880
- );
2881
-
2882
- $license_status = 'license-expiration-date-notice';
2883
-
2884
- }
2885
-
2886
- break;
2887
-
2888
- }
2889
-
2890
- }
2891
-
2892
- } else {
2893
- $class = 'empty';
2894
-
2895
- $messages[] = sprintf(
2896
- __( 'To receive updates, please enter your valid %s license key.', 'ultimate-member' ),
2897
- $field_data['item_name']
2898
- );
2899
-
2900
- $license_status = null;
2901
-
2902
- } ?>
2903
-
2904
- <tr class="um-settings-line">
2905
- <th><label for="um_options_<?php echo esc_attr( $field_data['id'] ) ?>"><?php echo esc_html( $field_data['label'] ) ?></label></th>
2906
- <td>
2907
- <form method="post" action="" name="um-settings-form" class="um-settings-form">
2908
- <input type="hidden" value="save" name="um-settings-action" />
2909
- <input type="hidden" name="licenses_settings" value="1" />
2910
- <?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
2911
- <input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
2912
- <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'] ) ?>" />
2913
- <?php if ( ! empty( $field_data['description'] ) ) { ?>
2914
- <div class="description"><?php echo $field_data['description'] ?></div>
2915
- <?php } ?>
2916
-
2917
- <?php if ( ! empty( $value ) && ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) ) { ?>
2918
- <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' ) ?>"/>
2919
- <?php } elseif ( empty( $value ) ) { ?>
2920
- <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Activate', 'ultimate-member' ) ?>" />
2921
- <?php } else { ?>
2922
- <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Re-Activate', 'ultimate-member' ) ?>" />
2923
- <?php }
2924
-
2925
- if ( ! empty( $messages ) ) {
2926
- foreach ( $messages as $message ) { ?>
2927
- <div class="edd-license-data edd-license-<?php echo esc_attr( $class . ' ' . $license_status ) ?>">
2928
- <p><?php echo $message ?></p>
2929
- </div>
2930
- <?php }
2931
- } ?>
2932
- </form>
2933
- </td>
2934
- </tr>
2935
- <?php } ?>
2936
- </tbody>
2937
- </table>
2938
- </div>
2939
- <?php $section = ob_get_clean();
2940
-
2941
- return $section;
2942
- }
2943
-
2944
-
2945
- /**
2946
- * @param $html
2947
- * @param $section_fields
2948
- */
2949
- function settings_install_info_tab( $html, $section_fields ) {
2950
- global $wpdb;
2951
-
2952
- if ( ! class_exists( '\Browser' ) )
2953
- require_once um_path . 'includes/lib/browser.php';
2954
-
2955
- // Detect browser
2956
- $browser = new \Browser();
2957
-
2958
- // Get theme info
2959
- $theme_data = wp_get_theme();
2960
- $theme = $theme_data->Name . ' ' . $theme_data->Version;
2961
-
2962
- // Identify Hosting Provider
2963
- $host = um_get_host();
2964
-
2965
- um_fetch_user( get_current_user_id() );
2966
-
2967
- if ( isset( $this->content ) ) {
2968
- echo $this->content;
2969
- } else { ?>
2970
-
2971
- <h3>Install Info</h3>
2972
-
2973
- <form action="" method="post" dir="ltr">
2974
- <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' ); ?>">
2975
- ### Begin Install Info ###
2976
-
2977
- ## Please include this information when posting support requests ##
2978
-
2979
- <?php
2980
- /**
2981
- * UM hook
2982
- *
2983
- * @type action
2984
- * @title um_install_info_before
2985
- * @description Before install info settings
2986
- * @change_log
2987
- * ["Since: 2.0"]
2988
- * @usage add_action( 'um_install_info_before', 'function_name', 10 );
2989
- * @example
2990
- * <?php
2991
- * add_action( 'um_install_info_before', 'my_install_info_before', 10 );
2992
- * function my_install_info_before() {
2993
- * // your code here
2994
- * }
2995
- * ?>
2996
- */
2997
- do_action( 'um_install_info_before' ); ?>
2998
-
2999
- --- Site Info ---
3000
-
3001
- Site URL: <?php echo site_url() . "\n"; ?>
3002
- Home URL: <?php echo home_url() . "\n"; ?>
3003
- Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
3004
-
3005
- --- Hosting Provider ---
3006
-
3007
- <?php if( $host ) : ?>
3008
- Host: <?php echo $host . "\n"; ?>
3009
- <?php endif; ?>
3010
-
3011
- --- User Browser ---
3012
-
3013
- <?php echo $browser ; ?>
3014
-
3015
- ---- Current User Details --
3016
-
3017
- <?php $user = wp_get_current_user(); ?>
3018
- Role: <?php echo implode( ', ', um_user( 'roles' ) ). "\n"; ?>
3019
-
3020
-
3021
- --- WordPress Configurations ---
3022
-
3023
- Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
3024
- Language: <?php echo get_locale()."\n"; ?>
3025
- Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
3026
- Active Theme: <?php echo $theme . "\n"; ?>
3027
- <?php $show_on_front = get_option( 'show_on_front' ); ?>
3028
- <?php if( $show_on_front == "posts" ): ?>
3029
- Show On Front: <?php echo get_option( 'show_on_front' ) . "/static\n" ?>
3030
- <?php elseif( $show_on_front == "page" ): ?>
3031
- Page On Front: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
3032
- Page For Posts: <?php $id = get_option( 'page_for_posts' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
3033
- <?php endif; ?>
3034
- ABSPATH: <?php echo ABSPATH."\n"; ?>
3035
- <?php $wp_count_posts = wp_count_posts(); ?>
3036
- All Posts/Pages: <?php echo array_sum((array)$wp_count_posts)."\n";?>
3037
- <?php
3038
- $request['cmd'] = '_notify-validate';
3039
-
3040
- $params = array(
3041
- 'sslverify' => false,
3042
- 'timeout' => 60,
3043
- 'user-agent' => 'UltimateMember/' . ultimatemember_version,
3044
- 'body' => $request
3045
- );
3046
-
3047
- $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
3048
-
3049
- if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
3050
- $WP_REMOTE_POST = 'wp_remote_post() works' . "\n";
3051
- } else {
3052
- $WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n";
3053
- }
3054
- ?>
3055
- WP Remote Post: <?php echo $WP_REMOTE_POST; ?>
3056
- WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
3057
- 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"; ?>
3058
- Memory Limit: <?php echo ( um_let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>
3059
-
3060
-
3061
- --- UM Configurations ---
3062
-
3063
- Version: <?php echo ultimatemember_version . "\n"; ?>
3064
- Upgraded From: <?php echo get_option( 'um_last_version_upgrade', 'None' ) . "\n"; ?>
3065
- Current URL Method: <?php echo UM()->options()->get( 'current_url_method' ). "\n"; ?>
3066
- Cache User Profile: <?php if( UM()->options()->get( 'um_profile_object_cache_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
3067
- Generate Slugs on Directories: <?php if( UM()->options()->get( 'um_generate_slug_in_directory' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
3068
- Force UTF-8 Encoding: <?php if( UM()->options()->get( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3069
- JS/CSS Compression: <?php if ( defined('SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3070
- <?php if( is_multisite() ): ?>
3071
- Network Structure: <?php echo UM()->options()->get( 'network_permalink_structure' ). "\n"; ?>
3072
- <?php endif; ?>
3073
- Port Forwarding in URL: <?php if( UM()->options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3074
- Exclude CSS/JS on Home: <?php if( UM()->options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3075
-
3076
-
3077
- --- UM Pages Configuration ---
3078
-
3079
- <?php
3080
- /**
3081
- * UM hook
3082
- *
3083
- * @type action
3084
- * @title um_install_info_before_page_config
3085
- * @description Before page config install info
3086
- * @change_log
3087
- * ["Since: 2.0"]
3088
- * @usage add_action( 'um_install_info_before_page_config', 'function_name', 10 );
3089
- * @example
3090
- * <?php
3091
- * add_action( 'um_install_info_before_page_config', 'my_install_info_before_page_config', 10 );
3092
- * function my_install_info_before_page_config() {
3093
- * // your code here
3094
- * }
3095
- * ?>
3096
- */
3097
- do_action( "um_install_info_before_page_config" ); ?>
3098
- User: <?php echo get_permalink( UM()->options()->get('core_user') ) . "\n"; ?>
3099
- Account: <?php echo get_permalink( UM()->options()->get('core_account') ) . "\n"; ?>
3100
- Members: <?php echo get_permalink( UM()->options()->get('core_members') ) . "\n"; ?>
3101
- Register: <?php echo get_permalink( UM()->options()->get('core_register') ) . "\n"; ?>
3102
- Login: <?php echo get_permalink( UM()->options()->get('core_login') ) . "\n"; ?>
3103
- Logout: <?php echo get_permalink( UM()->options()->get('core_logout') ) . "\n"; ?>
3104
- Password Reset: <?php echo get_permalink( UM()->options()->get('core_password-reset') ) . "\n"; ?>
3105
- <?php
3106
- /**
3107
- * UM hook
3108
- *
3109
- * @type action
3110
- * @title um_install_info_after_page_config
3111
- * @description After page config install info
3112
- * @change_log
3113
- * ["Since: 2.0"]
3114
- * @usage add_action( 'um_install_info_after_page_config', 'function_name', 10 );
3115
- * @example
3116
- * <?php
3117
- * add_action( 'um_install_info_after_page_config', 'my_install_info_after_page_config', 10 );
3118
- * function my_install_info_after_page_config() {
3119
- * // your code here
3120
- * }
3121
- * ?>
3122
- */
3123
- do_action( "um_install_info_after_page_config" ); ?>
3124
-
3125
-
3126
- --- UM Users Configuration ---
3127
-
3128
- Default New User Role: <?php echo UM()->options()->get('register_role') . "\n"; ?>
3129
- Profile Permalink Base: <?php echo UM()->options()->get('permalink_base') . "\n"; ?>
3130
- User Display Name: <?php echo UM()->options()->get('display_name') . "\n"; ?>
3131
- Force Name to Uppercase: <?php echo $this->info_value( UM()->options()->get('force_display_name_capitlized'), 'yesno', true ); ?>
3132
- Redirect author to profile: <?php echo $this->info_value( UM()->options()->get('author_redirect'), 'yesno', true ); ?>
3133
- Enable Members Directory: <?php echo $this->info_value( UM()->options()->get('members_page'), 'yesno', true ); ?>
3134
- Use Gravatars: <?php echo $this->info_value( UM()->options()->get('use_gravatars'), 'yesno', true ); ?>
3135
- <?php if( UM()->options()->get('use_gravatars') ): ?>Gravatar builtin image: <?php echo UM()->options()->get('use_um_gravatar_default_builtin_image') . "\n"; ?>
3136
- UM Avatar as blank Gravatar: <?php echo $this->info_value( UM()->options()->get('use_um_gravatar_default_image'), 'yesno', true ); ?><?php endif; ?>
3137
- Require a strong password: <?php echo $this->info_value( UM()->options()->get('reset_require_strongpass'), 'onoff', true ); ?>
3138
-
3139
-
3140
- --- UM Access Configuration ---
3141
-
3142
- Panic Key: <?php echo UM()->options()->get('panic_key') . "\n"; ?>
3143
- Global Site Access: <?php $arr = array('Site accessible to Everyone','','Site accessible to Logged In Users'); echo $arr[ (int) UM()->options()->get('accessible') ] . "\n"; ?>
3144
- <?php if( UM()->options()->get('accessible') == 2 ) { ?>
3145
- Custom Redirect URL: <?php echo UM()->options()->get('access_redirect')."\n";?>
3146
- 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";?>
3147
- <?php } ?>
3148
- Backend Login Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_login'), 'yesno', true ); ?>
3149
- <?php if( ! UM()->options()->get('wpadmin_login') ) { ?>
3150
- 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"; }?>
3151
- <?php } ?>
3152
- Backend Register Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_register'), 'yesno', true ); ?>
3153
- <?php if( ! UM()->options()->get('wpadmin_register') ) { ?>
3154
- 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"; }?>
3155
- <?php } ?>
3156
- Access Control widget for Admins only: <?php echo $this->info_value( UM()->options()->get('access_widget_admin_only'), 'yesno', true ); ?>
3157
- Enable the Reset Password Limit: <?php echo $this->info_value( UM()->options()->get('enable_reset_password_limit'), 'yesno', true ); ?>
3158
- <?php if( UM()->options()->get('enable_reset_password_limit') ) { ?>
3159
- Reset Password Limit: <?php echo UM()->options()->get('reset_password_limit_number') ?>
3160
- Disable Reset Password Limit for Admins: <?php echo $this->info_value( UM()->options()->get('disable_admin_reset_password_limit'), 'yesno', true ) ?>
3161
- <?php } ?>
3162
- <?php $wpadmin_allow_ips = UM()->options()->get( 'wpadmin_allow_ips' ); if( ! empty( $wpadmin_allow_ips ) ) { ?>
3163
- Whitelisted Backend IPs: <?php echo count( explode("\n",trim(UM()->options()->get('wpadmin_allow_ips') ) ) )."\n"; ?>
3164
- <?php } ?>
3165
- <?php $blocked_ips = UM()->options()->get('blocked_ips'); if( ! empty( $blocked_ips ) ){ ?>
3166
- Blocked IP Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_ips') ) )."\n"; ?>
3167
- <?php } ?>
3168
- <?php $blocked_emails = UM()->options()->get('blocked_emails'); if( ! empty( $blocked_emails ) ){ ?>
3169
- Blocked Email Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_emails') ) )."\n"; ?>
3170
- <?php } ?>
3171
- <?php $blocked_words = UM()->options()->get('blocked_words'); if( ! empty( $blocked_words ) ){ ?>
3172
- Blacklist Words: <?php echo count( explode("\n",UM()->options()->get('blocked_words') ) )."\n"; ?>
3173
- <?php } ?>
3174
-
3175
-
3176
- --- UM Email Configurations ---
3177
-
3178
- 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";?>
3179
- 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";?>
3180
- Use HTML for E-mails: <?php echo $this->info_value( UM()->options()->get('email_html'), 'yesno', true ); ?>
3181
- Account Welcome Email: <?php echo $this->info_value( UM()->options()->get('welcome_email_on'), 'yesno', true ); ?>
3182
- Account Activation Email: <?php echo $this->info_value( UM()->options()->get('checkmail_email_on'), 'yesno', true ); ?>
3183
- Pending Review Email: <?php echo $this->info_value( UM()->options()->get('pending_email_on'), 'yesno', true ); ?>
3184
- Account Approved Email: <?php echo $this->info_value( UM()->options()->get('approved_email_on'), 'yesno', true ); ?>
3185
- Account Rejected Email: <?php echo $this->info_value( UM()->options()->get('rejected_email_on'), 'yesno', true ); ?>
3186
- Account Deactivated Email: <?php echo $this->info_value( UM()->options()->get('inactive_email_on'), 'yesno', true ); ?>
3187
- Account Deleted Email: <?php echo $this->info_value( UM()->options()->get('deletion_email_on'), 'yesno', true ); ?>
3188
- Password Reset Email: <?php echo $this->info_value( UM()->options()->get('resetpw_email_on'), 'yesno', true ); ?>
3189
- Password Changed Email: <?php echo $this->info_value( UM()->options()->get('changedpw_email_on'), 'yesno', true ); ?>
3190
-
3191
-
3192
- --- UM Total Users ---
3193
-
3194
- <?php $result = count_users();
3195
- echo 'All Users('.$result['total_users'].")\n";
3196
- foreach( $result['avail_roles'] as $role => $count ) {
3197
- echo $role."(".$count.")\n";
3198
- } ?>
3199
-
3200
-
3201
- --- UM Roles ---
3202
-
3203
- <?php foreach( UM()->roles()->get_roles() as $role_id => $role ) {
3204
- echo $role." ({$role_id})\n";
3205
- } ?>
3206
-
3207
-
3208
- --- UM Custom Templates ---
3209
-
3210
- <?php // Show templates that have been copied to the theme's edd_templates dir
3211
- $dir = get_stylesheet_directory() . '/ultimate-member/templates/*.php';
3212
- if ( ! empty( $dir ) ) {
3213
- $found = glob( $dir );
3214
- if ( ! empty( $found ) ) {
3215
- foreach ( glob( $dir ) as $file ) {
3216
- echo "File: " . $file . "\n";
3217
- }
3218
- } else {
3219
- echo 'N/A'."\n";
3220
- }
3221
- } ?>
3222
-
3223
-
3224
- --- UM Email HTML Templates ---
3225
-
3226
- <?php $dir = get_stylesheet_directory() . '/ultimate-member/templates/emails/*.html';
3227
-
3228
- if ( ! empty( $dir ) ) {
3229
- $found = glob( $dir );
3230
- if ( ! empty( $found ) ){
3231
- foreach ( glob( $dir ) as $file ) {
3232
- echo "File: ". $file . "\n";
3233
- }
3234
- } else {
3235
- echo 'N/A'."\n";
3236
- }
3237
- } ?>
3238
-
3239
-
3240
- --- Web Server Configurations ---
3241
-
3242
- PHP Version: <?php echo PHP_VERSION . "\n"; ?>
3243
- MySQL Version: <?php echo $wpdb->db_version() . "\n"; ?>
3244
- Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
3245
-
3246
-
3247
- --- PHP Configurations ---
3248
-
3249
- PHP Memory Limit: <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
3250
- PHP Upload Max Size: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
3251
- PHP Post Max Size: <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
3252
- PHP Upload Max Filesize: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
3253
- PHP Time Limit: <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
3254
- PHP Max Input Vars: <?php echo ini_get( 'max_input_vars' ) . "\n"; ?>
3255
- PHP Arg Separator: <?php echo ini_get( 'arg_separator.output' ) . "\n"; ?>
3256
- PHP Allow URL File Open: <?php echo ini_get( 'allow_url_fopen' ) ? "Yes\n" : "No\n"; ?>
3257
-
3258
-
3259
- --- Web Server Extensions/Modules ---
3260
-
3261
- DISPLAY ERRORS: <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
3262
- FSOCKOPEN: <?php echo ( function_exists( 'fsockopen' ) ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; ?><?php echo "\n"; ?>
3263
- cURL: <?php echo ( function_exists( 'curl_init' ) ) ? 'Your server supports cURL.' : 'Your server does not support cURL.'; ?><?php echo "\n"; ?>
3264
- 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"; ?>
3265
- SUHOSIN: <?php echo ( extension_loaded( 'suhosin' ) ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; ?><?php echo "\n"; ?>
3266
- 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"; ?>
3267
- 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"; ?>
3268
- 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"; ?>
3269
-
3270
-
3271
- --- Session Configurations ---
3272
-
3273
- Session: <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; ?><?php echo "\n"; ?>
3274
- Session Name: <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
3275
- Cookie Path: <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
3276
- Save Path: <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
3277
- Use Cookies: <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
3278
- Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
3279
-
3280
-
3281
- --- WordPress Active Plugins ---
3282
-
3283
- <?php $plugins = get_plugins();
3284
- $active_plugins = get_option( 'active_plugins', array() );
3285
-
3286
- foreach ( $plugins as $plugin_path => $plugin ) {
3287
- // If the plugin isn't active, don't show it.
3288
- if ( ! in_array( $plugin_path, $active_plugins ) )
3289
- continue;
3290
-
3291
- echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
3292
- }
3293
-
3294
- if ( is_multisite() ) { ?>
3295
-
3296
- --- WordPress Network Active Plugins ---
3297
-
3298
- <?php $plugins = wp_get_active_network_plugins();
3299
- $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
3300
-
3301
- foreach ( $plugins as $plugin_path ) {
3302
- $plugin_base = plugin_basename( $plugin_path );
3303
-
3304
- // If the plugin isn't active, don't show it.
3305
- if ( ! array_key_exists( $plugin_base, $active_plugins ) )
3306
- continue;
3307
-
3308
- $plugin = get_plugin_data( $plugin_path );
3309
-
3310
- echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n";
3311
- }
3312
-
3313
- }
3314
-
3315
- /**
3316
- * UM hook
3317
- *
3318
- * @type action
3319
- * @title um_install_info_after
3320
- * @description After install info
3321
- * @change_log
3322
- * ["Since: 2.0"]
3323
- * @usage add_action( 'um_install_info_after', 'function_name', 10 );
3324
- * @example
3325
- * <?php
3326
- * add_action( 'um_install_info_after', 'my_install_info_after', 10 );
3327
- * function my_install_info_after() {
3328
- * // your code here
3329
- * }
3330
- * ?>
3331
- */
3332
- do_action( 'um_install_info_after' ); ?>
3333
-
3334
- ### End Install Info ###
3335
- </textarea>
3336
- <p class="submit">
3337
- <input type="hidden" name="um-addon-hook" value="download_install_info" />
3338
- <?php submit_button( 'Download Install Info File', 'primary', 'download_install_info', false ); ?>
3339
- </p>
3340
- </form>
3341
-
3342
- <?php }
3343
- }
3344
-
3345
-
3346
- /**
3347
- *
3348
- */
3349
- function um_download_install_info() {
3350
- if ( ! empty( $_POST['download_install_info'] ) ) {
3351
- nocache_headers();
3352
-
3353
- header( "Content-type: text/plain" );
3354
- header( 'Content-Disposition: attachment; filename="ultimatemember-install-info.txt"' );
3355
-
3356
- echo wp_strip_all_tags( sanitize_textarea_field( $_POST['um-install-info'] ) );
3357
- exit;
3358
- }
3359
- }
3360
-
3361
-
3362
- /**
3363
- * @param string $raw_value
3364
- * @param string $type
3365
- * @param string $default
3366
- *
3367
- * @return string
3368
- */
3369
- function info_value( $raw_value = '', $type = 'yesno', $default = '' ) {
3370
-
3371
- if ( $type == 'yesno' ) {
3372
- $raw_value = ( $default == $raw_value ) ? "Yes" : "No";
3373
- } elseif( $type == 'onoff' ) {
3374
- $raw_value = ( $default == $raw_value ) ? "On" : "Off";
3375
- }
3376
-
3377
- return $raw_value."\n";
3378
- }
3379
-
3380
-
3381
- /**
3382
- * Render settings section
3383
- *
3384
- * @param array $section_fields
3385
- * @param string $current_tab
3386
- * @param string $current_subtab
3387
- *
3388
- * @return string
3389
- */
3390
- function render_settings_section( $section_fields, $current_tab, $current_subtab ) {
3391
- ob_start();
3392
-
3393
- UM()->admin_forms_settings( array(
3394
- 'class' => 'um_options-' . $current_tab . '-' . $current_subtab . ' um-third-column',
3395
- 'prefix_id' => 'um_options',
3396
- 'fields' => $section_fields
3397
- ) )->render_form(); ?>
3398
-
3399
- <?php $section = ob_get_clean();
3400
-
3401
- return $section;
3402
- }
3403
-
3404
-
3405
- /**
3406
- * @param array $settings
3407
- *
3408
- * @return array
3409
- */
3410
- function save_email_templates( $settings ) {
3411
-
3412
- if ( empty( $settings['um_email_template'] ) ) {
3413
- return $settings;
3414
- }
3415
-
3416
- $template = $settings['um_email_template'];
3417
- $content = wp_kses_post( stripslashes( $settings[ $template ] ) );
3418
-
3419
- $theme_template_path = UM()->mail()->get_template_file( 'theme', $template );
3420
-
3421
- if ( ! file_exists( $theme_template_path ) ) {
3422
- UM()->mail()->copy_email_template( $template );
3423
- }
3424
-
3425
- $fp = fopen( $theme_template_path, "w" );
3426
- $result = fputs( $fp, $content );
3427
- fclose( $fp );
3428
-
3429
- if ( $result !== false ) {
3430
- unset( $settings['um_email_template'] );
3431
- unset( $settings[ $template ] );
3432
- }
3433
-
3434
- return $settings;
3435
- }
3436
- }
3437
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ 'reset_require_strongpass' => array(
677
+ 'sanitize' => 'bool',
678
+ ),
679
+ 'profile_noindex' => array(
680
+ 'sanitize' => 'bool',
681
+ ),
682
+ 'activation_link_expiry_time' => array(
683
+ 'sanitize' => 'absint',
684
+ ),
685
+ 'account_tab_password' => array(
686
+ 'sanitize' => 'bool',
687
+ ),
688
+ 'account_tab_privacy' => array(
689
+ 'sanitize' => 'bool',
690
+ ),
691
+ 'account_tab_notifications' => array(
692
+ 'sanitize' => 'bool',
693
+ ),
694
+ 'account_tab_delete' => array(
695
+ 'sanitize' => 'bool',
696
+ ),
697
+ 'delete_account_text' => array(
698
+ 'sanitize' => 'textarea',
699
+ ),
700
+ 'delete_account_no_pass_required_text' => array(
701
+ 'sanitize' => 'textarea',
702
+ ),
703
+ 'account_name' => array(
704
+ 'sanitize' => 'bool',
705
+ ),
706
+ 'account_name_disable' => array(
707
+ 'sanitize' => 'bool',
708
+ ),
709
+ 'account_name_require' => array(
710
+ 'sanitize' => 'bool',
711
+ ),
712
+ 'account_email' => array(
713
+ 'sanitize' => 'bool',
714
+ ),
715
+ 'account_general_password' => array(
716
+ 'sanitize' => 'bool',
717
+ ),
718
+ 'account_require_strongpass' => array(
719
+ 'sanitize' => 'bool',
720
+ ),
721
+ 'account_hide_in_directory' => array(
722
+ 'sanitize' => 'bool',
723
+ ),
724
+ 'account_hide_in_directory_default' => array(
725
+ 'sanitize' => 'text',
726
+ ),
727
+ 'profile_photo_max_size' => array(
728
+ 'sanitize' => 'absint',
729
+ ),
730
+ 'cover_photo_max_size' => array(
731
+ 'sanitize' => 'absint',
732
+ ),
733
+ 'photo_thumb_sizes' => array(
734
+ 'sanitize' => 'absint',
735
+ ),
736
+ 'cover_thumb_sizes' => array(
737
+ 'sanitize' => 'absint',
738
+ ),
739
+ 'image_orientation_by_exif' => array(
740
+ 'sanitize' => 'bool',
741
+ ),
742
+ 'image_compression' => array(
743
+ 'sanitize' => 'absint',
744
+ ),
745
+ 'image_max_width' => array(
746
+ 'sanitize' => 'absint',
747
+ ),
748
+ 'cover_min_width' => array(
749
+ 'sanitize' => 'absint',
750
+ ),
751
+ 'enable_reset_password_limit' => array(
752
+ 'sanitize' => 'bool',
753
+ ),
754
+ 'reset_password_limit_number' => array(
755
+ 'sanitize' => 'absint',
756
+ ),
757
+ 'blocked_emails' => array(
758
+ 'sanitize' => 'textarea',
759
+ ),
760
+ 'blocked_words' => array(
761
+ 'sanitize' => 'textarea',
762
+ ),
763
+ 'admin_email' => array(
764
+ 'sanitize' => 'text',
765
+ ),
766
+ 'mail_from' => array(
767
+ 'sanitize' => 'text',
768
+ ),
769
+ 'mail_from_addr' => array(
770
+ 'sanitize' => 'text',
771
+ ),
772
+ 'email_html' => array(
773
+ 'sanitize' => 'bool',
774
+ ),
775
+ 'profile_template' => array(
776
+ 'sanitize' => 'text',
777
+ ),
778
+ 'profile_max_width' => array(
779
+ 'sanitize' => 'text',
780
+ ),
781
+ 'profile_area_max_width' => array(
782
+ 'sanitize' => 'text',
783
+ ),
784
+ 'profile_icons' => array(
785
+ 'sanitize' => 'key',
786
+ ),
787
+ 'profile_primary_btn_word' => array(
788
+ 'sanitize' => 'text',
789
+ ),
790
+ 'profile_secondary_btn' => array(
791
+ 'sanitize' => 'bool',
792
+ ),
793
+ 'profile_secondary_btn_word' => array(
794
+ 'sanitize' => 'text',
795
+ ),
796
+ 'default_avatar' => array(
797
+ 'sanitize' => 'url',
798
+ ),
799
+ 'default_cover' => array(
800
+ 'sanitize' => 'url',
801
+ ),
802
+ 'disable_profile_photo_upload' => array(
803
+ 'sanitize' => 'bool',
804
+ ),
805
+ 'profile_photosize' => array(
806
+ 'sanitize' => array( UM()->admin(), 'sanitize_photosize' ),
807
+ ),
808
+ 'profile_cover_enabled' => array(
809
+ 'sanitize' => 'bool',
810
+ ),
811
+ 'profile_coversize' => array(
812
+ 'sanitize' => array( UM()->admin(), 'sanitize_cover_photosize' ),
813
+ ),
814
+ 'profile_cover_ratio' => array(
815
+ 'sanitize' => 'text',
816
+ ),
817
+ 'profile_show_metaicon' => array(
818
+ 'sanitize' => 'bool',
819
+ ),
820
+ 'profile_show_name' => array(
821
+ 'sanitize' => 'bool',
822
+ ),
823
+ 'profile_show_social_links' => array(
824
+ 'sanitize' => 'bool',
825
+ ),
826
+ 'profile_show_bio' => array(
827
+ 'sanitize' => 'bool',
828
+ ),
829
+ 'profile_show_html_bio' => array(
830
+ 'sanitize' => 'bool',
831
+ ),
832
+ 'profile_bio_maxchars' => array(
833
+ 'sanitize' => 'absint',
834
+ ),
835
+ 'profile_header_menu' => array(
836
+ 'sanitize' => 'key',
837
+ ),
838
+ 'profile_empty_text' => array(
839
+ 'sanitize' => 'bool',
840
+ ),
841
+ 'profile_empty_text_emo' => array(
842
+ 'sanitize' => 'bool',
843
+ ),
844
+ 'register_template' => array(
845
+ 'sanitize' => 'text',
846
+ ),
847
+ 'register_max_width' => array(
848
+ 'sanitize' => 'text',
849
+ ),
850
+ 'register_align' => array(
851
+ 'sanitize' => 'key',
852
+ ),
853
+ 'register_icons' => array(
854
+ 'sanitize' => 'key',
855
+ ),
856
+ 'register_primary_btn_word' => array(
857
+ 'sanitize' => 'text',
858
+ ),
859
+ 'register_secondary_btn' => array(
860
+ 'sanitize' => 'bool',
861
+ ),
862
+ 'register_secondary_btn_word' => array(
863
+ 'sanitize' => 'text',
864
+ ),
865
+ 'register_secondary_btn_url' => array(
866
+ 'sanitize' => 'url',
867
+ ),
868
+ 'register_role' => array(
869
+ 'sanitize' => 'key',
870
+ ),
871
+ 'login_template' => array(
872
+ 'sanitize' => 'text',
873
+ ),
874
+ 'login_max_width' => array(
875
+ 'sanitize' => 'text',
876
+ ),
877
+ 'login_align' => array(
878
+ 'sanitize' => 'key',
879
+ ),
880
+ 'login_icons' => array(
881
+ 'sanitize' => 'key',
882
+ ),
883
+ 'login_primary_btn_word' => array(
884
+ 'sanitize' => 'text',
885
+ ),
886
+ 'login_secondary_btn' => array(
887
+ 'sanitize' => 'bool',
888
+ ),
889
+ 'login_secondary_btn_word' => array(
890
+ 'sanitize' => 'text',
891
+ ),
892
+ 'login_secondary_btn_url' => array(
893
+ 'sanitize' => 'url',
894
+ ),
895
+ 'login_forgot_pass_link' => array(
896
+ 'sanitize' => 'bool',
897
+ ),
898
+ 'login_show_rememberme' => array(
899
+ 'sanitize' => 'bool',
900
+ ),
901
+ 'form_asterisk' => array(
902
+ 'sanitize' => 'bool',
903
+ ),
904
+ 'profile_title' => array(
905
+ 'sanitize' => 'text',
906
+ ),
907
+ 'profile_desc' => array(
908
+ 'sanitize' => 'textarea',
909
+ ),
910
+ 'um_profile_object_cache_stop' => array(
911
+ 'sanitize' => 'bool',
912
+ ),
913
+ 'enable_blocks' => array(
914
+ 'sanitize' => 'bool',
915
+ ),
916
+ 'rest_api_version' => array(
917
+ 'sanitize' => 'text',
918
+ ),
919
+ 'uninstall_on_delete' => array(
920
+ 'sanitize' => 'bool',
921
+ ),
922
+ )
923
+ );
924
+
925
+ $this->settings_map = apply_filters( 'um_settings_map', $settings_map );
926
+
927
+ /**
928
+ * UM hook
929
+ *
930
+ * @type filter
931
+ * @title um_settings_structure
932
+ * @description Extend UM Settings
933
+ * @input_vars
934
+ * [{"var":"$settings","type":"array","desc":"UM Settings"}]
935
+ * @change_log
936
+ * ["Since: 2.0"]
937
+ * @usage add_filter( 'um_settings_structure', 'function_name', 10, 1 );
938
+ * @example
939
+ * <?php
940
+ * add_filter( 'um_settings_structure', 'my_settings_structure', 10, 1 );
941
+ * function my_settings_structure( $settings ) {
942
+ * // your code here
943
+ * return $settings;
944
+ * }
945
+ * ?>
946
+ */
947
+ $this->settings_structure = apply_filters(
948
+ 'um_settings_structure',
949
+ array(
950
+ '' => array(
951
+ 'title' => __( 'General', 'ultimate-member' ),
952
+ 'sections' => array(
953
+ '' => array(
954
+ 'title' => __( 'Pages', 'ultimate-member' ),
955
+ 'fields' => $general_pages_fields,
956
+ ),
957
+ 'users' => array(
958
+ 'title' => __( 'Users', 'ultimate-member' ),
959
+ 'fields' => array(
960
+ array(
961
+ 'id' => 'permalink_base',
962
+ 'type' => 'select',
963
+ 'size' => 'small',
964
+ 'label' => __( 'Profile Permalink Base', 'ultimate-member' ),
965
+ // translators: %s: Profile page URL
966
+ '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' ) ) ),
967
+ 'options' => array(
968
+ 'user_login' => __( 'Username', 'ultimate-member' ),
969
+ 'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ),
970
+ 'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ),
971
+ 'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ),
972
+ 'user_id' => __( 'User ID', 'ultimate-member' ),
973
+ ),
974
+ 'placeholder' => __( 'Select...', 'ultimate-member' ),
975
+ ),
976
+ array(
977
+ 'id' => 'display_name',
978
+ 'type' => 'select',
979
+ 'size' => 'medium',
980
+ 'label' => __( 'User Display Name', 'ultimate-member' ),
981
+ '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' ),
982
+ 'options' => array(
983
+ 'default' => __( 'Default WP Display Name', 'ultimate-member' ),
984
+ 'nickname' => __( 'Nickname', 'ultimate-member' ),
985
+ 'username' => __( 'Username', 'ultimate-member' ),
986
+ 'full_name' => __( 'First name & last name', 'ultimate-member' ),
987
+ 'sur_name' => __( 'Last name & first name', 'ultimate-member' ),
988
+ 'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ),
989
+ 'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ),
990
+ 'first_name' => __( 'First name only', 'ultimate-member' ),
991
+ 'field' => __( 'Custom field(s)', 'ultimate-member' ),
992
+ ),
993
+ 'placeholder' => __( 'Select...', 'ultimate-member' ),
994
+ ),
995
+ array(
996
+ 'id' => 'display_name_field',
997
+ 'type' => 'text',
998
+ 'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ),
999
+ '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' ),
1000
+ 'conditional' => array( 'display_name', '=', 'field' ),
1001
+ ),
1002
+ array(
1003
+ 'id' => 'author_redirect',
1004
+ 'type' => 'checkbox',
1005
+ 'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ),
1006
+ 'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ),
1007
+ ),
1008
+ array(
1009
+ 'id' => 'members_page',
1010
+ 'type' => 'checkbox',
1011
+ 'label' => __( 'Enable Members Directory', 'ultimate-member' ),
1012
+ 'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ),
1013
+ ),
1014
+ array(
1015
+ 'id' => 'use_gravatars',
1016
+ 'type' => 'checkbox',
1017
+ 'label' => __( 'Use Gravatars?', 'ultimate-member' ),
1018
+ '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' ),
1019
+ ),
1020
+ array(
1021
+ 'id' => 'use_um_gravatar_default_builtin_image',
1022
+ 'type' => 'select',
1023
+ 'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ),
1024
+ 'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ),
1025
+ 'options' => array(
1026
+ 'default' => __( 'Default', 'ultimate-member' ),
1027
+ '404' => __( '404 ( File Not Found response )', 'ultimate-member' ),
1028
+ 'mm' => __( 'Mystery Man', 'ultimate-member' ),
1029
+ 'identicon' => __( 'Identicon', 'ultimate-member' ),
1030
+ 'monsterid' => __( 'Monsterid', 'ultimate-member' ),
1031
+ 'wavatar' => __( 'Wavatar', 'ultimate-member' ),
1032
+ 'retro' => __( 'Retro', 'ultimate-member' ),
1033
+ 'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ),
1034
+ ),
1035
+ 'conditional' => array( 'use_gravatars', '=', 1 ),
1036
+ 'size' => 'medium',
1037
+ ),
1038
+ array(
1039
+ 'id' => 'use_um_gravatar_default_image',
1040
+ 'type' => 'checkbox',
1041
+ 'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ),
1042
+ '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' ),
1043
+ 'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ),
1044
+ ),
1045
+ array(
1046
+ 'id' => 'reset_require_strongpass',
1047
+ 'type' => 'checkbox',
1048
+ 'label' => __( 'Require a strong password? (when user resets password only)', 'ultimate-member' ),
1049
+ 'tooltip' => __( 'Enable or disable a strong password rules on password reset and change procedure', 'ultimate-member' ),
1050
+ ),
1051
+ array(
1052
+ 'id' => 'profile_noindex',
1053
+ 'type' => 'select',
1054
+ 'size' => 'small',
1055
+ 'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
1056
+ 'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ),
1057
+ 'options' => array(
1058
+ '0' => __( 'No', 'ultimate-member' ),
1059
+ '1' => __( 'Yes', 'ultimate-member' ),
1060
+ ),
1061
+ ),
1062
+ array(
1063
+ 'id' => 'activation_link_expiry_time',
1064
+ 'type' => 'number',
1065
+ 'label' => __( 'Activation link lifetime', 'ultimate-member' ),
1066
+ 'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ),
1067
+ 'size' => 'small',
1068
+ ),
1069
+ ),
1070
+ ),
1071
+ 'account' => array(
1072
+ 'title' => __( 'Account', 'ultimate-member' ),
1073
+ 'fields' => array(
1074
+ array(
1075
+ 'id' => 'account_tab_password',
1076
+ 'type' => 'checkbox',
1077
+ 'label' => __( 'Password Account Tab', 'ultimate-member' ),
1078
+ 'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ),
1079
+ ),
1080
+ array(
1081
+ 'id' => 'account_tab_privacy',
1082
+ 'type' => 'checkbox',
1083
+ 'label' => __( 'Privacy Account Tab', 'ultimate-member' ),
1084
+ 'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ),
1085
+ ),
1086
+ array(
1087
+ 'id' => 'account_tab_notifications',
1088
+ 'type' => 'checkbox',
1089
+ 'label' => __( 'Notifications Account Tab', 'ultimate-member' ),
1090
+ 'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ),
1091
+ ),
1092
+ array(
1093
+ 'id' => 'account_tab_delete',
1094
+ 'type' => 'checkbox',
1095
+ 'label' => __( 'Delete Account Tab', 'ultimate-member' ),
1096
+ 'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ),
1097
+ ),
1098
+ array(
1099
+ 'id' => 'delete_account_text',
1100
+ 'type' => 'textarea', // bug with wp 4.4? should be editor
1101
+ 'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ),
1102
+ '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' ),
1103
+ 'args' => array(
1104
+ 'textarea_rows' => 6,
1105
+ ),
1106
+ ),
1107
+ array(
1108
+ 'id' => 'delete_account_no_pass_required_text',
1109
+ 'type' => 'textarea',
1110
+ 'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ),
1111
+ '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' ),
1112
+ 'args' => array(
1113
+ 'textarea_rows' => 6,
1114
+ ),
1115
+ ),
1116
+ array(
1117
+ 'id' => 'account_name',
1118
+ 'type' => 'checkbox',
1119
+ 'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ),
1120
+ 'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ),
1121
+ ),
1122
+ array(
1123
+ 'id' => 'account_name_disable',
1124
+ 'type' => 'checkbox',
1125
+ 'label' => __( 'Disable First & Last Name fields', 'ultimate-member' ),
1126
+ 'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ),
1127
+ 'conditional' => array( 'account_name', '=', '1' ),
1128
+ ),
1129
+ array(
1130
+ 'id' => 'account_name_require',
1131
+ 'type' => 'checkbox',
1132
+ 'label' => __( 'Require First & Last Name', 'ultimate-member' ),
1133
+ 'tooltip' => __( 'Require first and last name?', 'ultimate-member' ),
1134
+ 'conditional' => array( 'account_name', '=', '1' ),
1135
+ ),
1136
+ array(
1137
+ 'id' => 'account_email',
1138
+ 'type' => 'checkbox',
1139
+ 'label' => __( 'Allow users to change e-mail', 'ultimate-member' ),
1140
+ 'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ),
1141
+ ),
1142
+ array(
1143
+ 'id' => 'account_general_password',
1144
+ 'type' => 'checkbox',
1145
+ 'label' => __( 'Password is required?', 'ultimate-member' ),
1146
+ 'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ),
1147
+ ),
1148
+ array(
1149
+ 'id' => 'account_require_strongpass',
1150
+ 'type' => 'checkbox',
1151
+ 'label' => __( 'Require a strong password?', 'ultimate-member' ),
1152
+ 'tooltip' => __( 'Enable or disable a strong password rules on account page / change password tab', 'ultimate-member' ),
1153
+ ),
1154
+ array(
1155
+ 'id' => 'account_hide_in_directory',
1156
+ 'type' => 'checkbox',
1157
+ 'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ),
1158
+ 'tooltip' => __( 'Whether to allow users changing their profile visibility from member directory in account page.', 'ultimate-member' ),
1159
+ 'conditional' => array( 'account_tab_privacy', '=', '1' ),
1160
+ ),
1161
+ array(
1162
+ 'id' => 'account_hide_in_directory_default',
1163
+ 'type' => 'select',
1164
+ 'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ),
1165
+ 'tooltip' => __( 'Set default value for the "Hide my profile from directory" option', 'ultimate-member' ),
1166
+ 'options' => array(
1167
+ 'No' => __( 'No', 'ultimate-member' ),
1168
+ 'Yes' => __( 'Yes', 'ultimate-member' ),
1169
+ ),
1170
+ 'size' => 'small',
1171
+ 'conditional' => array( 'account_hide_in_directory', '=', '1' ),
1172
+ ),
1173
+ ),
1174
+ ),
1175
+ 'uploads' => array(
1176
+ 'title' => __( 'Uploads', 'ultimate-member' ),
1177
+ 'fields' => array(
1178
+ array(
1179
+ 'id' => 'profile_photo_max_size',
1180
+ 'type' => 'text',
1181
+ 'size' => 'small',
1182
+ 'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ),
1183
+ 'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ),
1184
+ ),
1185
+ array(
1186
+ 'id' => 'cover_photo_max_size',
1187
+ 'type' => 'text',
1188
+ 'size' => 'small',
1189
+ 'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ),
1190
+ 'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ),
1191
+ ),
1192
+ array(
1193
+ 'id' => 'photo_thumb_sizes',
1194
+ 'type' => 'multi_text',
1195
+ 'size' => 'small',
1196
+ 'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ),
1197
+ 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ),
1198
+ 'validate' => 'numeric',
1199
+ 'add_text' => __( 'Add New Size', 'ultimate-member' ),
1200
+ 'show_default_number' => 1,
1201
+ ),
1202
+ array(
1203
+ 'id' => 'cover_thumb_sizes',
1204
+ 'type' => 'multi_text',
1205
+ 'size' => 'small',
1206
+ 'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ),
1207
+ 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ),
1208
+ 'validate' => 'numeric',
1209
+ 'add_text' => __( 'Add New Size', 'ultimate-member' ),
1210
+ 'show_default_number' => 1,
1211
+ ),
1212
+ array(
1213
+ 'id' => 'image_orientation_by_exif',
1214
+ 'type' => 'checkbox',
1215
+ 'label' => __( 'Change image orientation', 'ultimate-member' ),
1216
+ 'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ),
1217
+ ),
1218
+ array(
1219
+ 'id' => 'image_compression',
1220
+ 'type' => 'text',
1221
+ 'size' => 'small',
1222
+ 'label' => __( 'Image Quality', 'ultimate-member' ),
1223
+ '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' ),
1224
+ ),
1225
+
1226
+ array(
1227
+ 'id' => 'image_max_width',
1228
+ 'type' => 'text',
1229
+ 'size' => 'small',
1230
+ 'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ),
1231
+ 'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ),
1232
+ ),
1233
+
1234
+ array(
1235
+ 'id' => 'cover_min_width',
1236
+ 'type' => 'text',
1237
+ 'size' => 'small',
1238
+ 'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ),
1239
+ 'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ),
1240
+ ),
1241
+ ),
1242
+ ),
1243
+ ),
1244
+ ),
1245
+ 'access' => array(
1246
+ 'title' => __( 'Access', 'ultimate-member' ),
1247
+ 'sections' => array(
1248
+ '' => array(
1249
+ 'title' => __( 'Restriction Content', 'ultimate-member' ),
1250
+ 'fields' => $access_fields,
1251
+ ),
1252
+ 'other' => array(
1253
+ 'title' => __( 'Other', 'ultimate-member' ),
1254
+ 'fields' => array(
1255
+ array(
1256
+ 'id' => 'enable_reset_password_limit',
1257
+ 'type' => 'checkbox',
1258
+ 'label' => __( 'Enable the Reset Password Limit?', 'ultimate-member' ),
1259
+ ),
1260
+ array(
1261
+ 'id' => 'reset_password_limit_number',
1262
+ 'type' => 'text',
1263
+ 'label' => __( 'Reset Password Limit', 'ultimate-member' ),
1264
+ 'tooltip' => __( 'Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.', 'ultimate-member' ),
1265
+ 'validate' => 'numeric',
1266
+ 'conditional' => array( 'enable_reset_password_limit', '=', 1 ),
1267
+ 'size' => 'small',
1268
+ ),
1269
+ array(
1270
+ 'id' => 'blocked_emails',
1271
+ 'type' => 'textarea',
1272
+ 'label' => __( 'Blocked Email Addresses', 'ultimate-member' ),
1273
+ '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' ),
1274
+ ),
1275
+ array(
1276
+ 'id' => 'blocked_words',
1277
+ 'type' => 'textarea',
1278
+ 'label' => __( 'Blacklist Words', 'ultimate-member' ),
1279
+ 'tooltip' => __( 'This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username', 'ultimate-member' ),
1280
+ ),
1281
+ ),
1282
+ ),
1283
+ ),
1284
+ ),
1285
+ 'email' => array(
1286
+ 'title' => __( 'Email', 'ultimate-member' ),
1287
+ 'fields' => array(
1288
+ array(
1289
+ 'id' => 'admin_email',
1290
+ 'type' => 'text',
1291
+ 'label' => __( 'Admin E-mail Address', 'ultimate-member' ),
1292
+ 'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
1293
+ ),
1294
+ array(
1295
+ 'id' => 'mail_from',
1296
+ 'type' => 'text',
1297
+ 'label' => __( 'Mail appears from', 'ultimate-member' ),
1298
+ 'tooltip' => __( 'e.g. Site Name', 'ultimate-member' ),
1299
+ ),
1300
+ array(
1301
+ 'id' => 'mail_from_addr',
1302
+ 'type' => 'text',
1303
+ 'label' => __( 'Mail appears from address', 'ultimate-member' ),
1304
+ 'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
1305
+ ),
1306
+ array(
1307
+ 'id' => 'email_html',
1308
+ 'type' => 'checkbox',
1309
+ 'label' => __( 'Use HTML for E-mails?', 'ultimate-member' ),
1310
+ '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' ),
1311
+ ),
1312
+ ),
1313
+ ),
1314
+ 'appearance' => array(
1315
+ 'title' => __( 'Appearance', 'ultimate-member' ),
1316
+ 'sections' => array(
1317
+ '' => array(
1318
+ 'title' => __( 'Profile', 'ultimate-member' ),
1319
+ 'fields' => array(
1320
+ array(
1321
+ 'id' => 'profile_template',
1322
+ 'type' => 'select',
1323
+ 'label' => __( 'Profile Default Template', 'ultimate-member' ),
1324
+ 'tooltip' => __( 'This will be the default template to output profile', 'ultimate-member' ),
1325
+ 'default' => um_get_metadefault( 'profile_template' ),
1326
+ 'options' => UM()->shortcodes()->get_templates( 'profile' ),
1327
+ 'size' => 'small',
1328
+ ),
1329
+ array(
1330
+ 'id' => 'profile_max_width',
1331
+ 'type' => 'text',
1332
+ 'label' => __( 'Profile Maximum Width', 'ultimate-member' ),
1333
+ 'default' => um_get_metadefault( 'profile_max_width' ),
1334
+ 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1335
+ 'size' => 'small',
1336
+ ),
1337
+ array(
1338
+ 'id' => 'profile_area_max_width',
1339
+ 'type' => 'text',
1340
+ 'label' => __( 'Profile Area Maximum Width', 'ultimate-member' ),
1341
+ 'default' => um_get_metadefault( 'profile_area_max_width' ),
1342
+ 'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
1343
+ 'size' => 'small',
1344
+ ),
1345
+ array(
1346
+ 'id' => 'profile_icons',
1347
+ 'type' => 'select',
1348
+ 'label' => __( 'Profile Field Icons', 'ultimate-member' ),
1349
+ 'tooltip' => __( 'This is applicable for edit mode only', 'ultimate-member' ),
1350
+ 'default' => um_get_metadefault( 'profile_icons' ),
1351
+ 'options' => array(
1352
+ 'field' => __( 'Show inside text field', 'ultimate-member' ),
1353
+ 'label' => __( 'Show with label', 'ultimate-member' ),
1354
+ 'off' => __( 'Turn off', 'ultimate-member' ),
1355
+ ),
1356
+ 'size' => 'small',
1357
+ ),
1358
+ array(
1359
+ 'id' => 'profile_primary_btn_word',
1360
+ 'type' => 'text',
1361
+ 'label' => __( 'Profile Primary Button Text', 'ultimate-member' ),
1362
+ 'default' => um_get_metadefault( 'profile_primary_btn_word' ),
1363
+ 'tooltip' => __( 'The text that is used for updating profile button', 'ultimate-member' ),
1364
+ 'size' => 'medium',
1365
+ ),
1366
+ array(
1367
+ 'id' => 'profile_secondary_btn',
1368
+ 'type' => 'checkbox',
1369
+ 'label' => __( 'Profile Secondary Button', 'ultimate-member' ),
1370
+ 'default' => um_get_metadefault( 'profile_secondary_btn' ),
1371
+ 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1372
+ ),
1373
+ array(
1374
+ 'id' => 'profile_secondary_btn_word',
1375
+ 'type' => 'text',
1376
+ 'label' => __( 'Profile Secondary Button Text', 'ultimate-member' ),
1377
+ 'default' => um_get_metadefault( 'profile_secondary_btn_word' ),
1378
+ 'tooltip' => __( 'The text that is used for cancelling update profile button', 'ultimate-member' ),
1379
+ 'conditional' => array( 'profile_secondary_btn', '=', 1 ),
1380
+ 'size' => 'medium',
1381
+ ),
1382
+ array(
1383
+ 'id' => 'default_avatar',
1384
+ 'type' => 'media',
1385
+ 'label' => __( 'Default Profile Photo', 'ultimate-member' ),
1386
+ 'tooltip' => __( 'You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member' ),
1387
+ 'upload_frame_title' => __( 'Select Default Profile Photo', 'ultimate-member' ),
1388
+ 'default' => array(
1389
+ 'url' => um_url . 'assets/img/default_avatar.jpg',
1390
+ ),
1391
+ ),
1392
+ array(
1393
+ 'id' => 'default_cover',
1394
+ 'type' => 'media',
1395
+ 'url' => true,
1396
+ 'preview' => false,
1397
+ 'label' => __( 'Default Cover Photo', 'ultimate-member' ),
1398
+ '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' ),
1399
+ 'upload_frame_title' => __( 'Select Default Cover Photo', 'ultimate-member' ),
1400
+ ),
1401
+ array(
1402
+ 'id' => 'disable_profile_photo_upload',
1403
+ 'type' => 'checkbox',
1404
+ 'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
1405
+ 'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
1406
+ 'default' => um_get_metadefault( 'disable_profile_photo_upload' ),
1407
+ ),
1408
+ array(
1409
+ 'id' => 'profile_photosize',
1410
+ 'type' => 'select',
1411
+ 'label' => __( 'Profile Photo Size', 'ultimate-member' ),
1412
+ 'default' => um_get_metadefault( 'profile_photosize' ),
1413
+ 'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
1414
+ 'tooltip' => __( 'The global default of profile photo size. This can be overridden by individual form settings', 'ultimate-member' ),
1415
+ 'size' => 'small',
1416
+ ),
1417
+ array(
1418
+ 'id' => 'profile_cover_enabled',
1419
+ 'type' => 'checkbox',
1420
+ 'label' => __( 'Profile Cover Photos', 'ultimate-member' ),
1421
+ 'default' => um_get_metadefault( 'profile_cover_enabled' ),
1422
+ 'tooltip' => __( 'Switch on/off the profile cover photos', 'ultimate-member' ),
1423
+ ),
1424
+ array(
1425
+ 'id' => 'profile_coversize',
1426
+ 'type' => 'select',
1427
+ 'label' => __( 'Profile Cover Size', 'ultimate-member' ),
1428
+ 'default' => um_get_metadefault( 'profile_coversize' ),
1429
+ 'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
1430
+ 'tooltip' => __( 'The global default width of cover photo size. This can be overridden by individual form settings', 'ultimate-member' ),
1431
+ 'conditional' => array( 'profile_cover_enabled', '=', 1 ),
1432
+ 'size' => 'small',
1433
+ ),
1434
+ array(
1435
+ 'id' => 'profile_cover_ratio',
1436
+ 'type' => 'select',
1437
+ 'label' => __( 'Profile Cover Ratio', 'ultimate-member' ),
1438
+ 'tooltip' => __( 'Choose global ratio for cover photos of profiles', 'ultimate-member' ),
1439
+ 'default' => um_get_metadefault( 'profile_cover_ratio' ),
1440
+ 'options' => array(
1441
+ '1.6:1' => '1.6:1',
1442
+ '2.7:1' => '2.7:1',
1443
+ '2.2:1' => '2.2:1',
1444
+ '3.2:1' => '3.2:1',
1445
+ ),
1446
+ 'conditional' => array( 'profile_cover_enabled', '=', 1 ),
1447
+ 'size' => 'small',
1448
+ ),
1449
+ array(
1450
+ 'id' => 'profile_show_metaicon',
1451
+ 'type' => 'checkbox',
1452
+ 'label' => __( 'Profile Header Meta Text Icon', 'ultimate-member' ),
1453
+ 'default' => 0,
1454
+ 'tooltip' => __( 'Display field icons for related user meta fields in header or not', 'ultimate-member' ),
1455
+ ),
1456
+ array(
1457
+ 'id' => 'profile_show_name',
1458
+ 'type' => 'checkbox',
1459
+ 'label' => __( 'Show display name in profile header', 'ultimate-member' ),
1460
+ 'default' => um_get_metadefault( 'profile_show_name' ),
1461
+ 'tooltip' => __( 'Switch on/off the user name on profile header', 'ultimate-member' ),
1462
+ ),
1463
+ array(
1464
+ 'id' => 'profile_show_social_links',
1465
+ 'type' => 'checkbox',
1466
+ 'label' => __( 'Show social links in profile header', 'ultimate-member' ),
1467
+ 'default' => um_get_metadefault( 'profile_show_social_links' ),
1468
+ 'tooltip' => __( 'Switch on/off the social links on profile header', 'ultimate-member' ),
1469
+ ),
1470
+ array(
1471
+ 'id' => 'profile_show_bio',
1472
+ 'type' => 'checkbox',
1473
+ 'label' => __( 'Show user description in header', 'ultimate-member' ),
1474
+ 'default' => um_get_metadefault( 'profile_show_bio' ),
1475
+ 'tooltip' => __( 'Switch on/off the user description on profile header', 'ultimate-member' ),
1476
+ ),
1477
+ array(
1478
+ 'id' => 'profile_show_html_bio',
1479
+ 'type' => 'checkbox',
1480
+ 'label' => __( 'Enable HTML support for user description', 'ultimate-member' ),
1481
+ 'tooltip' => __( 'Switch on/off to enable/disable support for html tags on user description.', 'ultimate-member' ),
1482
+ ),
1483
+ array(
1484
+ 'id' => 'profile_bio_maxchars',
1485
+ 'type' => 'text',
1486
+ 'label' => __( 'User description maximum chars', 'ultimate-member' ),
1487
+ 'default' => um_get_metadefault( 'profile_bio_maxchars' ),
1488
+ 'tooltip' => __( 'Maximum number of characters to allow in user description field in header.', 'ultimate-member' ),
1489
+ 'conditional' => array( 'profile_show_bio', '=', 1 ),
1490
+ 'size' => 'small',
1491
+ ),
1492
+ array(
1493
+ 'id' => 'profile_header_menu',
1494
+ 'type' => 'select',
1495
+ 'label' => __( 'Profile Header Menu Position', 'ultimate-member' ),
1496
+ 'default' => um_get_metadefault( 'profile_header_menu' ),
1497
+ 'tooltip' => __( 'For incompatible themes, please make the menu open from left instead of bottom by default.', 'ultimate-member' ),
1498
+ 'options' => array(
1499
+ 'bc' => __( 'Bottom of Icon', 'ultimate-member' ),
1500
+ 'lc' => __( 'Left of Icon (right for RTL)', 'ultimate-member' ),
1501
+ ),
1502
+ 'size' => 'small',
1503
+ ),
1504
+ array(
1505
+ 'id' => 'profile_empty_text',
1506
+ 'type' => 'checkbox',
1507
+ 'label' => __( 'Show a custom message if profile is empty', 'ultimate-member' ),
1508
+ 'default' => um_get_metadefault( 'profile_empty_text' ),
1509
+ 'tooltip' => __( 'Switch on/off the custom message that appears when the profile is empty', 'ultimate-member' ),
1510
+ ),
1511
+ array(
1512
+ 'id' => 'profile_empty_text_emo',
1513
+ 'type' => 'checkbox',
1514
+ 'label' => __( 'Show the emoticon', 'ultimate-member' ),
1515
+ 'default' => um_get_metadefault( 'profile_empty_text_emo' ),
1516
+ 'tooltip' => __( 'Switch on/off the emoticon (sad face) that appears above the message', 'ultimate-member' ),
1517
+ 'conditional' => array( 'profile_empty_text', '=', 1 ),
1518
+ ),
1519
+ ),
1520
+ ),
1521
+ 'profile_menu' => array(
1522
+ 'title' => __( 'Profile Menu', 'ultimate-member' ),
1523
+ 'fields' => $appearances_profile_menu_fields,
1524
+ ),
1525
+ 'registration_form' => array(
1526
+ 'title' => __( 'Registration Form', 'ultimate-member' ),
1527
+ 'fields' => array(
1528
+ array(
1529
+ 'id' => 'register_template',
1530
+ 'type' => 'select',
1531
+ 'label' => __( 'Registration Default Template', 'ultimate-member' ),
1532
+ 'tooltip' => __( 'This will be the default template to output registration', 'ultimate-member' ),
1533
+ 'default' => um_get_metadefault( 'register_template' ),
1534
+ 'options' => UM()->shortcodes()->get_templates( 'register' ),
1535
+ 'size' => 'small',
1536
+ ),
1537
+ array(
1538
+ 'id' => 'register_max_width',
1539
+ 'type' => 'text',
1540
+ 'label' => __( 'Registration Maximum Width', 'ultimate-member' ),
1541
+ 'default' => um_get_metadefault( 'register_max_width' ),
1542
+ 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1543
+ 'size' => 'small',
1544
+ ),
1545
+ array(
1546
+ 'id' => 'register_align',
1547
+ 'type' => 'select',
1548
+ 'label' => __( 'Registration Shortcode Alignment', 'ultimate-member' ),
1549
+ 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
1550
+ 'default' => um_get_metadefault( 'register_align' ),
1551
+ 'options' => array(
1552
+ 'center' => __( 'Centered', 'ultimate-member' ),
1553
+ 'left' => __( 'Left aligned', 'ultimate-member' ),
1554
+ 'right' => __( 'Right aligned', 'ultimate-member' ),
1555
+ ),
1556
+ 'size' => 'small',
1557
+ ),
1558
+ array(
1559
+ 'id' => 'register_icons',
1560
+ 'type' => 'select',
1561
+ 'label' => __( 'Registration Field Icons', 'ultimate-member' ),
1562
+ 'tooltip' => __( 'This controls the display of field icons in the registration form', 'ultimate-member' ),
1563
+ 'default' => um_get_metadefault( 'register_icons' ),
1564
+ 'options' => array(
1565
+ 'field' => __( 'Show inside text field', 'ultimate-member' ),
1566
+ 'label' => __( 'Show with label', 'ultimate-member' ),
1567
+ 'off' => __( 'Turn off', 'ultimate-member' ),
1568
+ ),
1569
+ 'size' => 'small',
1570
+ ),
1571
+ array(
1572
+ 'id' => 'register_primary_btn_word',
1573
+ 'type' => 'text',
1574
+ 'label' => __( 'Registration Primary Button Text', 'ultimate-member' ),
1575
+ 'default' => um_get_metadefault( 'register_primary_btn_word' ),
1576
+ 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
1577
+ 'size' => 'medium',
1578
+ ),
1579
+ array(
1580
+ 'id' => 'register_secondary_btn',
1581
+ 'type' => 'checkbox',
1582
+ 'label' => __( 'Registration Secondary Button', 'ultimate-member' ),
1583
+ 'default' => 1,
1584
+ 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1585
+ ),
1586
+ array(
1587
+ 'id' => 'register_secondary_btn_word',
1588
+ 'type' => 'text',
1589
+ 'label' => __( 'Registration Secondary Button Text', 'ultimate-member' ),
1590
+ 'default' => um_get_metadefault( 'register_secondary_btn_word' ),
1591
+ 'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
1592
+ 'conditional' => array( 'register_secondary_btn', '=', 1 ),
1593
+ 'size' => 'medium',
1594
+ ),
1595
+ array(
1596
+ 'id' => 'register_secondary_btn_url',
1597
+ 'type' => 'text',
1598
+ 'label' => __( 'Registration Secondary Button URL', 'ultimate-member' ),
1599
+ 'default' => um_get_metadefault( 'register_secondary_btn_url' ),
1600
+ 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
1601
+ 'conditional' => array( 'register_secondary_btn', '=', 1 ),
1602
+ 'size' => 'medium',
1603
+ ),
1604
+ array(
1605
+ 'id' => 'register_role',
1606
+ 'type' => 'select',
1607
+ 'label' => __( 'Registration Default Role', 'ultimate-member' ),
1608
+ 'tooltip' => __( 'This will be the default role assigned to users registering thru registration form', 'ultimate-member' ),
1609
+ 'default' => um_get_metadefault( 'register_role' ),
1610
+ 'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
1611
+ 'size' => 'small',
1612
+ ),
1613
+ ),
1614
+ ),
1615
+ 'login_form' => array(
1616
+ 'title' => __( 'Login Form', 'ultimate-member' ),
1617
+ 'fields' => array(
1618
+ array(
1619
+ 'id' => 'login_template',
1620
+ 'type' => 'select',
1621
+ 'label' => __( 'Login Default Template', 'ultimate-member' ),
1622
+ 'tooltip' => __( 'This will be the default template to output login', 'ultimate-member' ),
1623
+ 'default' => um_get_metadefault( 'login_template' ),
1624
+ 'options' => UM()->shortcodes()->get_templates( 'login' ),
1625
+ 'size' => 'small',
1626
+ ),
1627
+ array(
1628
+ 'id' => 'login_max_width',
1629
+ 'type' => 'text',
1630
+ 'label' => __( 'Login Maximum Width', 'ultimate-member' ),
1631
+ 'default' => um_get_metadefault( 'login_max_width' ),
1632
+ 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1633
+ 'size' => 'small',
1634
+ ),
1635
+ array(
1636
+ 'id' => 'login_align',
1637
+ 'type' => 'select',
1638
+ 'label' => __( 'Login Shortcode Alignment', 'ultimate-member' ),
1639
+ 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
1640
+ 'default' => um_get_metadefault( 'login_align' ),
1641
+ 'options' => array(
1642
+ 'center' => __( 'Centered', 'ultimate-member' ),
1643
+ 'left' => __( 'Left aligned', 'ultimate-member' ),
1644
+ 'right' => __( 'Right aligned', 'ultimate-member' ),
1645
+ ),
1646
+ 'size' => 'small',
1647
+ ),
1648
+ array(
1649
+ 'id' => 'login_icons',
1650
+ 'type' => 'select',
1651
+ 'label' => __( 'Login Field Icons', 'ultimate-member' ),
1652
+ 'tooltip' => __( 'This controls the display of field icons in the login form', 'ultimate-member' ),
1653
+ 'default' => um_get_metadefault( 'login_icons' ),
1654
+ 'options' => array(
1655
+ 'field' => __( 'Show inside text field', 'ultimate-member' ),
1656
+ 'label' => __( 'Show with label', 'ultimate-member' ),
1657
+ 'off' => __( 'Turn off', 'ultimate-member' ),
1658
+ ),
1659
+ 'size' => 'small',
1660
+ ),
1661
+ array(
1662
+ 'id' => 'login_primary_btn_word',
1663
+ 'type' => 'text',
1664
+ 'label' => __( 'Login Primary Button Text', 'ultimate-member' ),
1665
+ 'default' => um_get_metadefault( 'login_primary_btn_word' ),
1666
+ 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
1667
+ 'size' => 'medium',
1668
+ ),
1669
+ array(
1670
+ 'id' => 'login_secondary_btn',
1671
+ 'type' => 'checkbox',
1672
+ 'label' => __( 'Login Secondary Button', 'ultimate-member' ),
1673
+ 'default' => 1,
1674
+ 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1675
+ ),
1676
+ array(
1677
+ 'id' => 'login_secondary_btn_word',
1678
+ 'type' => 'text',
1679
+ 'label' => __( 'Login Secondary Button Text', 'ultimate-member' ),
1680
+ 'default' => um_get_metadefault( 'login_secondary_btn_word' ),
1681
+ 'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
1682
+ 'conditional' => array( 'login_secondary_btn', '=', 1 ),
1683
+ 'size' => 'medium',
1684
+ ),
1685
+ array(
1686
+ 'id' => 'login_secondary_btn_url',
1687
+ 'type' => 'text',
1688
+ 'label' => __( 'Login Secondary Button URL', 'ultimate-member' ),
1689
+ 'default' => um_get_metadefault( 'login_secondary_btn_url' ),
1690
+ 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
1691
+ 'conditional' => array( 'login_secondary_btn', '=', 1 ),
1692
+ 'size' => 'medium',
1693
+ ),
1694
+ array(
1695
+ 'id' => 'login_forgot_pass_link',
1696
+ 'type' => 'checkbox',
1697
+ 'label' => __( 'Login Forgot Password Link', 'ultimate-member' ),
1698
+ 'default' => 1,
1699
+ 'tooltip' => __( 'Switch on/off the forgot password link in login form', 'ultimate-member' ),
1700
+ ),
1701
+ array(
1702
+ 'id' => 'login_show_rememberme',
1703
+ 'type' => 'checkbox',
1704
+ 'label' => __( 'Show "Remember Me"', 'ultimate-member' ),
1705
+ 'default' => 1,
1706
+ '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' ),
1707
+ ),
1708
+ ),
1709
+ ),
1710
+ ),
1711
+ ),
1712
+ 'extensions' => array(
1713
+ 'title' => __( 'Extensions', 'ultimate-member' ),
1714
+ ),
1715
+ 'licenses' => array(
1716
+ 'title' => __( 'Licenses', 'ultimate-member' ),
1717
+ ),
1718
+ 'misc' => array(
1719
+ 'title' => __( 'Misc', 'ultimate-member' ),
1720
+ 'fields' => array(
1721
+ array(
1722
+ 'id' => 'form_asterisk',
1723
+ 'type' => 'checkbox',
1724
+ 'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ),
1725
+ ),
1726
+ array(
1727
+ 'id' => 'profile_title',
1728
+ 'type' => 'text',
1729
+ 'label' => __( 'User Profile Title', 'ultimate-member' ),
1730
+ 'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ),
1731
+ 'size' => 'medium',
1732
+ ),
1733
+ array(
1734
+ 'id' => 'profile_desc',
1735
+ 'type' => 'textarea',
1736
+ 'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ),
1737
+ 'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ),
1738
+ 'args' => array(
1739
+ 'textarea_rows' => 6,
1740
+ ),
1741
+ ),
1742
+ array(
1743
+ 'id' => 'um_profile_object_cache_stop',
1744
+ 'type' => 'checkbox',
1745
+ 'label' => __( 'Disable Cache User Profile', 'ultimate-member' ),
1746
+ 'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ),
1747
+ ),
1748
+ array(
1749
+ 'id' => 'enable_blocks',
1750
+ 'type' => 'checkbox',
1751
+ 'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ),
1752
+ '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' ),
1753
+ ),
1754
+ array(
1755
+ 'id' => 'rest_api_version',
1756
+ 'type' => 'select',
1757
+ 'label' => __( 'REST API version', 'ultimate-member' ),
1758
+ 'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ),
1759
+ 'options' => array(
1760
+ '1.0' => __( '1.0 version', 'ultimate-member' ),
1761
+ '2.0' => __( '2.0 version', 'ultimate-member' ),
1762
+ ),
1763
+ ),
1764
+ // backward compatibility option leave it disabled for better security and ability to exclude posts/terms pre-query
1765
+ // otherwise we filtering only results and restricted posts/terms can be visible
1766
+ array(
1767
+ 'id' => 'disable_restriction_pre_queries',
1768
+ 'type' => 'checkbox',
1769
+ 'label' => __( 'Disable pre-queries for restriction content logic (advanced)', 'ultimate-member' ),
1770
+ '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' ),
1771
+ ),
1772
+ $same_page_update,
1773
+ array(
1774
+ 'id' => 'uninstall_on_delete',
1775
+ 'type' => 'checkbox',
1776
+ 'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ),
1777
+ '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' ),
1778
+ ),
1779
+ ),
1780
+ ),
1781
+ 'install_info' => array(
1782
+ 'title' => __( 'Install Info', 'ultimate-member' ),
1783
+ 'fields' => array(
1784
+ array(
1785
+ 'type' => 'install_info',
1786
+ ),
1787
+ ),
1788
+ ),
1789
+ )
1790
+ );
1791
+
1792
+ }
1793
+
1794
+
1795
+ /**
1796
+ * @param array $settings
1797
+ *
1798
+ * @return array
1799
+ */
1800
+ public function sorting_licenses_options( $settings ) {
1801
+ //sorting licenses
1802
+ if ( empty( $settings['licenses']['fields'] ) ) {
1803
+ return $settings;
1804
+ }
1805
+
1806
+ $licenses = $settings['licenses']['fields'];
1807
+ @uasort( $licenses, function( $a, $b ) {
1808
+ return strnatcasecmp( $a['label'], $b['label'] );
1809
+ } );
1810
+ $settings['licenses']['fields'] = $licenses;
1811
+
1812
+ //sorting extensions
1813
+ if ( empty( $settings['extensions']['sections'] ) ) {
1814
+ return $settings;
1815
+ }
1816
+
1817
+ $extensions = $settings['extensions']['sections'];
1818
+ @uasort( $extensions, function( $a, $b ) {
1819
+ return strnatcasecmp( $a['title'], $b['title'] );
1820
+ } );
1821
+
1822
+ $keys = array_keys( $extensions );
1823
+ if ( $keys[0] !== '' ) {
1824
+ $new_key = strtolower( str_replace( ' ', '_', $extensions['']['title'] ) );
1825
+ $temp = $extensions[''];
1826
+ $extensions[ $new_key ] = $temp;
1827
+ $extensions[''] = $extensions[ $keys[0] ];
1828
+ unset( $extensions[ $keys[0] ] );
1829
+ @uasort( $extensions, function( $a, $b ) {
1830
+ return strnatcasecmp( $a['title'], $b['title'] );
1831
+ } );
1832
+ }
1833
+
1834
+ $settings['extensions']['sections'] = $extensions;
1835
+
1836
+ return $settings;
1837
+ }
1838
+
1839
+
1840
+ /**
1841
+ * @param $tab
1842
+ * @param $section
1843
+ *
1844
+ * @return array
1845
+ */
1846
+ function get_section_fields( $tab, $section ) {
1847
+
1848
+ if ( empty( $this->settings_structure[ $tab ] ) ) {
1849
+ return array();
1850
+ }
1851
+
1852
+ if ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
1853
+ return $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
1854
+ } elseif ( ! empty( $this->settings_structure[ $tab ]['fields'] ) ) {
1855
+ return $this->settings_structure[ $tab ]['fields'];
1856
+ }
1857
+
1858
+ return array();
1859
+ }
1860
+
1861
+
1862
+ /**
1863
+ * Setup admin menu
1864
+ */
1865
+ function primary_admin_menu() {
1866
+ add_submenu_page( 'ultimatemember', __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( &$this, 'settings_page' ) );
1867
+ }
1868
+
1869
+
1870
+ /**
1871
+ * Settings page callback
1872
+ */
1873
+ function settings_page() {
1874
+ $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
1875
+ $current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
1876
+
1877
+ $settings_struct = $this->settings_structure[ $current_tab ];
1878
+
1879
+ //remove not option hidden fields
1880
+ if ( ! empty( $settings_struct['fields'] ) ) {
1881
+ foreach ( $settings_struct['fields'] as $field_key => $field_options ) {
1882
+
1883
+ if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
1884
+ unset( $settings_struct['fields'][ $field_key ] );
1885
+ }
1886
+
1887
+ }
1888
+ }
1889
+
1890
+ if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) ) {
1891
+ um_js_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) );
1892
+ }
1893
+
1894
+ if ( ! empty( $settings_struct['sections'] ) ) {
1895
+ if ( empty( $settings_struct['sections'][ $current_subtab ] ) ) {
1896
+ um_js_redirect( add_query_arg( array( 'page' => 'um_options', 'tab' => $current_tab ), admin_url( 'admin.php' ) ) );
1897
+ }
1898
+ }
1899
+
1900
+ echo '<div id="um-settings-wrap" class="wrap"><h2>' . __( 'Ultimate Member - Settings', 'ultimate-member' ) . '</h2>';
1901
+
1902
+ echo $this->generate_tabs_menu() . $this->generate_subtabs_menu( $current_tab );
1903
+
1904
+ /**
1905
+ * UM hook
1906
+ *
1907
+ * @type action
1908
+ * @title um_settings_page_before_{$current_tab}_{$current_subtab}_content
1909
+ * @description Show some content before settings page content
1910
+ * @change_log
1911
+ * ["Since: 2.0"]
1912
+ * @usage add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'function_name', 10 );
1913
+ * @example
1914
+ * <?php
1915
+ * add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'my_settings_page_before', 10 );
1916
+ * function my_settings_page_before() {
1917
+ * // your code here
1918
+ * }
1919
+ * ?>
1920
+ */
1921
+ do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" );
1922
+
1923
+ 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 ) ) ) {
1924
+
1925
+ /**
1926
+ * UM hook
1927
+ *
1928
+ * @type action
1929
+ * @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
1930
+ * @description Show some content before section content at settings page
1931
+ * @change_log
1932
+ * ["Since: 2.0"]
1933
+ * @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
1934
+ * @example
1935
+ * <?php
1936
+ * add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
1937
+ * function my_settings_page_before_section() {
1938
+ * // your code here
1939
+ * }
1940
+ * ?>
1941
+ */
1942
+ do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
1943
+
1944
+ $section_fields = $this->get_section_fields( $current_tab, $current_subtab );
1945
+ $settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
1946
+
1947
+ /**
1948
+ * UM hook
1949
+ *
1950
+ * @type filter
1951
+ * @title um_settings_section_{$current_tab}_{$current_subtab}_content
1952
+ *
1953
+ * @description Render settings section
1954
+ * @input_vars
1955
+ * [{"var":"$content","type":"string","desc":"Section content"},
1956
+ * {"var":"$section_fields","type":"array","desc":"Section Fields"}]
1957
+ * @change_log
1958
+ * ["Since: 2.0"]
1959
+ * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
1960
+ * @example
1961
+ * <?php
1962
+ * add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
1963
+ * function my_settings_section( $content ) {
1964
+ * // your code here
1965
+ * return $content;
1966
+ * }
1967
+ * ?>
1968
+ */
1969
+ echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
1970
+ $settings_section,
1971
+ $section_fields
1972
+ );
1973
+
1974
+ } else { ?>
1975
+
1976
+ <form method="post" action="" name="um-settings-form" id="um-settings-form">
1977
+ <input type="hidden" value="save" name="um-settings-action" />
1978
+
1979
+ <?php
1980
+ /**
1981
+ * UM hook
1982
+ *
1983
+ * @type action
1984
+ * @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
1985
+ * @description Show some content before section content at settings page
1986
+ * @change_log
1987
+ * ["Since: 2.0"]
1988
+ * @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
1989
+ * @example
1990
+ * <?php
1991
+ * add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
1992
+ * function my_settings_page_before_section() {
1993
+ * // your code here
1994
+ * }
1995
+ * ?>
1996
+ */
1997
+ do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
1998
+
1999
+ $section_fields = $this->get_section_fields( $current_tab, $current_subtab );
2000
+ $settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
2001
+
2002
+ /**
2003
+ * UM hook
2004
+ *
2005
+ * @type filter
2006
+ * @title um_settings_section_{$current_tab}_{$current_subtab}_content
2007
+ * @description Render settings section
2008
+ * @input_vars
2009
+ * [{"var":"$content","type":"string","desc":"Section content"},
2010
+ * {"var":"$section_fields","type":"array","desc":"Section Fields"}]
2011
+ * @change_log
2012
+ * ["Since: 2.0"]
2013
+ * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
2014
+ * @example
2015
+ * <?php
2016
+ * add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
2017
+ * function my_settings_section( $content ) {
2018
+ * // your code here
2019
+ * return $content;
2020
+ * }
2021
+ * ?>
2022
+ */
2023
+ echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
2024
+ $settings_section,
2025
+ $section_fields
2026
+ ); ?>
2027
+
2028
+
2029
+ <p class="submit">
2030
+ <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save Changes', 'ultimate-member' ) ?>" />
2031
+ <?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
2032
+ <input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
2033
+ </p>
2034
+ </form>
2035
+
2036
+ <?php }
2037
+ }
2038
+
2039
+
2040
+ /**
2041
+ * Generate pages tabs
2042
+ *
2043
+ * @param string $page
2044
+ * @return string
2045
+ */
2046
+ function generate_tabs_menu( $page = 'settings' ) {
2047
+
2048
+ $tabs = '<h2 class="nav-tab-wrapper um-nav-tab-wrapper">';
2049
+
2050
+ switch( $page ) {
2051
+ case 'settings':
2052
+ $menu_tabs = array();
2053
+ foreach ( $this->settings_structure as $slug => $tab ) {
2054
+ if ( ! empty( $tab['fields'] ) ) {
2055
+ foreach ( $tab['fields'] as $field_key => $field_options ) {
2056
+ if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
2057
+ unset( $tab['fields'][ $field_key ] );
2058
+ }
2059
+ }
2060
+ }
2061
+
2062
+ if ( ! empty( $tab['fields'] ) || ! empty( $tab['sections'] ) ) {
2063
+ $menu_tabs[ $slug ] = $tab['title'];
2064
+ }
2065
+ }
2066
+
2067
+ $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
2068
+ foreach ( $menu_tabs as $name => $label ) {
2069
+ $active = ( $current_tab == $name ) ? 'nav-tab-active' : '';
2070
+ $tabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $name ) ? '' : '&tab=' . $name ) ) ) . '" class="nav-tab ' . esc_attr( $active ) . '">' .
2071
+ $label .
2072
+ '</a>';
2073
+ }
2074
+
2075
+ break;
2076
+ default:
2077
+ /**
2078
+ * UM hook
2079
+ *
2080
+ * @type filter
2081
+ * @title um_generate_tabs_menu_{$page}
2082
+ * @description Generate tabs menu
2083
+ * @input_vars
2084
+ * [{"var":"$tabs","type":"array","desc":"UM menu tabs"}]
2085
+ * @change_log
2086
+ * ["Since: 2.0"]
2087
+ * @usage add_filter( 'um_generate_tabs_menu_{$page}', 'function_name', 10, 1 );
2088
+ * @example
2089
+ * <?php
2090
+ * add_filter( 'um_generate_tabs_menu_{$page}', 'my_tabs_menu', 10, 1 );
2091
+ * function my_tabs_menu( $tabs ) {
2092
+ * // your code here
2093
+ * return $tabs;
2094
+ * }
2095
+ * ?>
2096
+ */
2097
+ $tabs = apply_filters( 'um_generate_tabs_menu_' . $page, $tabs );
2098
+ break;
2099
+ }
2100
+
2101
+ return $tabs . '</h2>';
2102
+ }
2103
+
2104
+
2105
+ /**
2106
+ * @param string $tab
2107
+ *
2108
+ * @return string
2109
+ */
2110
+ function generate_subtabs_menu( $tab = '' ) {
2111
+ if ( empty( $this->settings_structure[ $tab ]['sections'] ) ) {
2112
+ return '';
2113
+ }
2114
+
2115
+ $menu_subtabs = array();
2116
+ foreach ( $this->settings_structure[ $tab ]['sections'] as $slug => $subtab ) {
2117
+ $menu_subtabs[ $slug ] = $subtab['title'];
2118
+ }
2119
+
2120
+ $subtabs = '<div><ul class="subsubsub">';
2121
+
2122
+ $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
2123
+ $current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
2124
+ foreach ( $menu_subtabs as $name => $label ) {
2125
+ $active = ( $current_subtab == $name ) ? 'current' : '';
2126
+ $subtabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $current_tab ) ? '' : '&tab=' . $current_tab ) . ( empty( $name ) ? '' : '&section=' . $name ) ) ) . '" class="' . $active . '">'
2127
+ . $label .
2128
+ '</a> | ';
2129
+ }
2130
+
2131
+ return substr( $subtabs, 0, -3 ) . '</ul></div>';
2132
+ }
2133
+
2134
+
2135
+ /**
2136
+ * Handler for settings forms
2137
+ * when "Save Settings" button click
2138
+ *
2139
+ */
2140
+ function save_settings_handler() {
2141
+
2142
+ if ( isset( $_POST['um-settings-action'] ) && 'save' === sanitize_key( $_POST['um-settings-action'] ) && ! empty( $_POST['um_options'] ) ) {
2143
+
2144
+ $nonce = ! empty( $_POST['__umnonce'] ) ? $_POST['__umnonce'] : '';
2145
+
2146
+ if ( ( ! wp_verify_nonce( $nonce, 'um-settings-nonce' ) || empty( $nonce ) ) || ! current_user_can( 'manage_options' ) ) {
2147
+ // This nonce is not valid.
2148
+ wp_die( __( 'Security Check', 'ultimate-member' ) );
2149
+ }
2150
+
2151
+ /**
2152
+ * UM hook
2153
+ *
2154
+ * @type action
2155
+ * @title um_settings_before_save
2156
+ * @description Before settings save action
2157
+ * @change_log
2158
+ * ["Since: 2.0"]
2159
+ * @usage add_action( 'um_settings_before_save', 'function_name', 10 );
2160
+ * @example
2161
+ * <?php
2162
+ * add_action( 'um_settings_before_save', 'my_settings_before_save', 10 );
2163
+ * function my_settings_before_save() {
2164
+ * // your code here
2165
+ * }
2166
+ * ?>
2167
+ */
2168
+ do_action( "um_settings_before_save" );
2169
+
2170
+ /**
2171
+ * UM hook
2172
+ *
2173
+ * @type filter
2174
+ * @title um_change_settings_before_save
2175
+ * @description Change settings before save
2176
+ * @input_vars
2177
+ * [{"var":"$settings","type":"array","desc":"UM Settings on save"}]
2178
+ * @change_log
2179
+ * ["Since: 2.0"]
2180
+ * @usage add_filter( 'um_change_settings_before_save', 'function_name', 10, 1 );
2181
+ * @example
2182
+ * <?php
2183
+ * add_filter( 'um_change_settings_before_save', 'my_change_settings_before_save', 10, 1 );
2184
+ * function my_change_settings_before_save( $settings ) {
2185
+ * // your code here
2186
+ * return $settings;
2187
+ * }
2188
+ * ?>
2189
+ */
2190
+ $settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] );
2191
+
2192
+ $settings = UM()->admin()->sanitize_options( $settings );
2193
+
2194
+ foreach ( $settings as $key => $value ) {
2195
+ UM()->options()->update( $key, $value );
2196
+ }
2197
+
2198
+ /**
2199
+ * UM hook
2200
+ *
2201
+ * @type action
2202
+ * @title um_settings_save
2203
+ * @description After settings save action
2204
+ * @change_log
2205
+ * ["Since: 2.0"]
2206
+ * @usage add_action( 'um_settings_save', 'function_name', 10 );
2207
+ * @example
2208
+ * <?php
2209
+ * add_action( 'um_settings_save', 'my_settings_save', 10 );
2210
+ * function my_settings_save() {
2211
+ * // your code here
2212
+ * }
2213
+ * ?>
2214
+ */
2215
+ do_action( 'um_settings_save' );
2216
+
2217
+ //redirect after save settings
2218
+ $arg = array(
2219
+ 'page' => 'um_options',
2220
+ );
2221
+
2222
+ if ( ! empty( $_GET['tab'] ) ) {
2223
+ $arg['tab'] = sanitize_key( $_GET['tab'] );
2224
+ }
2225
+
2226
+ if ( ! empty( $_GET['section'] ) ) {
2227
+ $arg['section'] = sanitize_key( $_GET['section'] );
2228
+ }
2229
+
2230
+ um_js_redirect( add_query_arg( $arg, admin_url( 'admin.php' ) ) );
2231
+ }
2232
+ }
2233
+
2234
+
2235
+ function set_default_if_empty( $settings ) {
2236
+ $tab = '';
2237
+ if ( ! empty( $_GET['tab'] ) ) {
2238
+ $tab = sanitize_key( $_GET['tab'] );
2239
+ }
2240
+
2241
+ $section = '';
2242
+ if ( ! empty( $_GET['section'] ) ) {
2243
+ $section = sanitize_key( $_GET['section'] );
2244
+ }
2245
+
2246
+
2247
+ if ( 'access' === $tab && empty( $section ) ) {
2248
+ if ( ! array_key_exists( 'access_exclude_uris', $settings ) ) {
2249
+ $settings['access_exclude_uris'] = array();
2250
+ }
2251
+ }
2252
+
2253
+ return $settings;
2254
+ }
2255
+
2256
+
2257
+ /**
2258
+ * Remove empty values from multi text fields
2259
+ *
2260
+ * @param $settings
2261
+ * @return array
2262
+ */
2263
+ function remove_empty_values( $settings ) {
2264
+ $tab = '';
2265
+ if ( ! empty( $_GET['tab'] ) ) {
2266
+ $tab = sanitize_key( $_GET['tab'] );
2267
+ }
2268
+
2269
+ $section = '';
2270
+ if ( ! empty( $_GET['section'] ) ) {
2271
+ $section = sanitize_key( $_GET['section'] );
2272
+ }
2273
+
2274
+ if ( isset( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
2275
+ $fields = $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
2276
+ } else {
2277
+ $fields = $this->settings_structure[ $tab ]['fields'];
2278
+ }
2279
+
2280
+ if ( empty( $fields ) ) {
2281
+ return $settings;
2282
+ }
2283
+
2284
+
2285
+ $filtered_settings = array();
2286
+ foreach ( $settings as $key => $value ) {
2287
+
2288
+ $filtered_settings[ $key ] = $value;
2289
+
2290
+ foreach ( $fields as $field ) {
2291
+ if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) {
2292
+ $filtered_settings[ $key ] = array_filter( $settings[ $key ] );
2293
+ }
2294
+ }
2295
+ }
2296
+
2297
+ return $filtered_settings;
2298
+ }
2299
+
2300
+
2301
+ /**
2302
+ *
2303
+ */
2304
+ function check_permalinks_changes() {
2305
+ if ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
2306
+ if ( UM()->options()->get( 'permalink_base' ) !== $_POST['um_options']['permalink_base'] ) {
2307
+ $this->need_change_permalinks = true;
2308
+ }
2309
+ }
2310
+
2311
+ // set variable if gravatar settings were changed
2312
+ // update for um_member_directory_data metakey
2313
+ if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
2314
+ $use_gravatar = UM()->options()->get( 'use_gravatars' );
2315
+ if ( ( empty( $use_gravatar ) && ! empty( $_POST['um_options']['use_gravatars'] ) ) || ( ! empty( $use_gravatar ) && empty( $_POST['um_options']['use_gravatars'] ) ) ) {
2316
+ $this->gravatar_changed = true;
2317
+ }
2318
+ }
2319
+ }
2320
+
2321
+
2322
+ /**
2323
+ *
2324
+ */
2325
+ function on_settings_save() {
2326
+ if ( ! empty( $_POST['um_options'] ) ) {
2327
+
2328
+ if ( ! empty( $_POST['um_options']['pages_settings'] ) ) {
2329
+ $post_ids = new \WP_Query( array(
2330
+ 'post_type' => 'page',
2331
+ 'meta_query' => array(
2332
+ array(
2333
+ 'key' => '_um_core',
2334
+ 'compare' => 'EXISTS'
2335
+ )
2336
+ ),
2337
+ 'posts_per_page' => -1,
2338
+ 'fields' => 'ids'
2339
+ ) );
2340
+
2341
+ $post_ids = $post_ids->get_posts();
2342
+
2343
+ if ( ! empty( $post_ids ) ) {
2344
+ foreach ( $post_ids as $post_id ) {
2345
+ delete_post_meta( $post_id, '_um_core' );
2346
+ }
2347
+ }
2348
+
2349
+ foreach ( $_POST['um_options'] as $option_slug => $post_id ) {
2350
+ $slug = str_replace( 'core_', '', $option_slug );
2351
+ update_post_meta( $post_id, '_um_core', $slug );
2352
+ }
2353
+
2354
+ // reset rewrite rules after re-save pages
2355
+ UM()->rewrite()->reset_rules();
2356
+
2357
+ } elseif ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
2358
+ if ( ! empty( $this->need_change_permalinks ) ) {
2359
+ $users = get_users( array(
2360
+ 'fields' => 'ids',
2361
+ ) );
2362
+ if ( ! empty( $users ) ) {
2363
+ foreach ( $users as $user_id ) {
2364
+ UM()->user()->generate_profile_slug( $user_id );
2365
+ }
2366
+ }
2367
+ }
2368
+
2369
+
2370
+ // update for um_member_directory_data metakey
2371
+ if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
2372
+ if ( $this->gravatar_changed ) {
2373
+ global $wpdb;
2374
+
2375
+ if ( ! empty( $_POST['um_options']['use_gravatars'] ) ) {
2376
+
2377
+ $results = $wpdb->get_col(
2378
+ "SELECT u.ID FROM {$wpdb->users} AS u
2379
+ LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'synced_gravatar_hashed_id' )
2380
+ LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2381
+ WHERE um.meta_value != '' AND um.meta_value IS NOT NULL AND
2382
+ um2.meta_value LIKE '%s:13:\"profile_photo\";b:0;%'"
2383
+ );
2384
+
2385
+ } else {
2386
+
2387
+ $results = $wpdb->get_col(
2388
+ "SELECT u.ID FROM {$wpdb->users} AS u
2389
+ LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND ( um.meta_key = 'synced_profile_photo' || um.meta_key = 'profile_photo' ) )
2390
+ LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2391
+ WHERE ( um.meta_value IS NULL OR um.meta_value = '' ) AND
2392
+ um2.meta_value LIKE '%s:13:\"profile_photo\";b:1;%'"
2393
+ );
2394
+
2395
+ }
2396
+
2397
+ if ( ! empty( $results ) ) {
2398
+ foreach ( $results as $user_id ) {
2399
+ $md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
2400
+ if ( ! empty( $md_data ) ) {
2401
+ $md_data['profile_photo'] = ! empty( $_POST['um_options']['use_gravatars'] );
2402
+ update_user_meta( $user_id, 'um_member_directory_data', $md_data );
2403
+ }
2404
+ }
2405
+ }
2406
+ }
2407
+ }
2408
+
2409
+ } elseif ( isset( $_POST['um_options']['member_directory_own_table'] ) ) {
2410
+ if ( empty( $_POST['um_options']['member_directory_own_table'] ) ) {
2411
+ global $wpdb;
2412
+
2413
+ $results = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}um_metadata LIMIT 1", ARRAY_A );
2414
+
2415
+ if ( ! empty( $results ) ) {
2416
+ $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}um_metadata" );
2417
+ }
2418
+
2419
+ update_option( 'um_member_directory_truncated', time() );
2420
+ }
2421
+ } elseif ( isset( $_POST['um_options']['account_hide_in_directory_default'] ) ) {
2422
+
2423
+ global $wpdb;
2424
+
2425
+ if ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) {
2426
+
2427
+ $results = $wpdb->get_col(
2428
+ "SELECT u.ID FROM {$wpdb->users} AS u
2429
+ LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
2430
+ LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2431
+ WHERE um.meta_value IS NULL AND
2432
+ um2.meta_value LIKE '%s:15:\"hide_in_members\";b:1;%'"
2433
+ );
2434
+
2435
+ } else {
2436
+
2437
+ $results = $wpdb->get_col(
2438
+ "SELECT u.ID FROM {$wpdb->users} AS u
2439
+ LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
2440
+ LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
2441
+ WHERE um.meta_value IS NULL AND
2442
+ um2.meta_value LIKE '%s:15:\"hide_in_members\";b:0;%'"
2443
+ );
2444
+
2445
+ }
2446
+
2447
+ if ( ! empty( $results ) ) {
2448
+ foreach ( $results as $user_id ) {
2449
+ $md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
2450
+ if ( ! empty( $md_data ) ) {
2451
+ $md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) ? false : true;
2452
+ update_user_meta( $user_id, 'um_member_directory_data', $md_data );
2453
+ }
2454
+ }
2455
+ }
2456
+
2457
+ }
2458
+ }
2459
+ }
2460
+
2461
+
2462
+ /**
2463
+ *
2464
+ */
2465
+ function before_licenses_save() {
2466
+ if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
2467
+ return;
2468
+ }
2469
+
2470
+ foreach ( $_POST['um_options'] as $key => $value ) {
2471
+ $this->previous_licenses[ sanitize_key( $key ) ] = UM()->options()->get( $key );
2472
+ }
2473
+ }
2474
+
2475
+
2476
+ /**
2477
+ *
2478
+ */
2479
+ function licenses_save() {
2480
+ if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
2481
+ return;
2482
+ }
2483
+
2484
+ foreach ( $_POST['um_options'] as $key => $value ) {
2485
+ $key = sanitize_key( $key );
2486
+ $value = sanitize_text_field( $value );
2487
+
2488
+ $edd_action = '';
2489
+ $license_key = '';
2490
+ if ( empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) && $this->previous_licenses[ $key ] != $value ) ) {
2491
+ $edd_action = 'activate_license';
2492
+ $license_key = $value;
2493
+ } elseif ( ! empty( $this->previous_licenses[ $key ] ) && empty( $value ) ) {
2494
+ $edd_action = 'deactivate_license';
2495
+ $license_key = $this->previous_licenses[ $key ];
2496
+ } elseif ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) ) {
2497
+ $edd_action = 'check_license';
2498
+ $license_key = $value;
2499
+ }
2500
+
2501
+ if ( empty( $edd_action ) ) {
2502
+ continue;
2503
+ }
2504
+
2505
+ $item_name = false;
2506
+ $version = false;
2507
+ $author = false;
2508
+ foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) {
2509
+ if ( $field_data['id'] == $key ) {
2510
+ $item_name = ! empty( $field_data['item_name'] ) ? $field_data['item_name'] : false;
2511
+ $version = ! empty( $field_data['version'] ) ? $field_data['version'] : false;
2512
+ $author = ! empty( $field_data['author'] ) ? $field_data['author'] : false;
2513
+ }
2514
+ }
2515
+
2516
+ $api_params = array(
2517
+ 'edd_action' => $edd_action,
2518
+ 'license' => $license_key,
2519
+ 'item_name' => $item_name,
2520
+ 'version' => $version,
2521
+ 'author' => $author,
2522
+ 'url' => home_url(),
2523
+ );
2524
+
2525
+ $request = wp_remote_post(
2526
+ UM()->store_url,
2527
+ array(
2528
+ 'timeout' => UM()->request_timeout,
2529
+ 'sslverify' => false,
2530
+ 'body' => $api_params
2531
+ )
2532
+ );
2533
+
2534
+ if ( ! is_wp_error( $request ) ) {
2535
+ $request = json_decode( wp_remote_retrieve_body( $request ) );
2536
+ } else {
2537
+ $request = wp_remote_post(
2538
+ UM()->store_url,
2539
+ array(
2540
+ 'timeout' => UM()->request_timeout,
2541
+ 'sslverify' => true,
2542
+ 'body' => $api_params
2543
+ )
2544
+ );
2545
+
2546
+ if ( ! is_wp_error( $request ) ) {
2547
+ $request = json_decode( wp_remote_retrieve_body( $request ) );
2548
+ }
2549
+ }
2550
+
2551
+ $request = ( $request ) ? maybe_unserialize( $request ) : false;
2552
+
2553
+ if ( $edd_action == 'activate_license' || $edd_action == 'check_license' ) {
2554
+ update_option( "{$key}_edd_answer", $request );
2555
+ } else {
2556
+ delete_option( "{$key}_edd_answer" );
2557
+ }
2558
+
2559
+ }
2560
+ }
2561
+
2562
+
2563
+ /**
2564
+ *
2565
+ */
2566
+ function settings_before_email_tab() {
2567
+ $email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
2568
+ $emails = UM()->config()->email_notifications;
2569
+
2570
+ if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
2571
+ include_once um_path . 'includes/admin/core/list-tables/emails-list-table.php';
2572
+ }
2573
+ }
2574
+
2575
+
2576
+ /**
2577
+ * @param $section
2578
+ *
2579
+ * @return string
2580
+ */
2581
+ function settings_email_tab( $section ) {
2582
+ $email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
2583
+ $emails = UM()->config()->email_notifications;
2584
+
2585
+ if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
2586
+ return $section;
2587
+ }
2588
+
2589
+ $in_theme = UM()->mail()->template_in_theme( $email_key );
2590
+
2591
+ /**
2592
+ * UM hook
2593
+ *
2594
+ * @type filter
2595
+ * @title um_admin_settings_email_section_fields
2596
+ * @description Extend UM Email Settings
2597
+ * @input_vars
2598
+ * [{"var":"$settings","type":"array","desc":"UM Email Settings"},
2599
+ * {"var":"$email_key","type":"string","desc":"Email Key"}]
2600
+ * @change_log
2601
+ * ["Since: 2.0"]
2602
+ * @usage add_filter( 'um_admin_settings_email_section_fields', 'function_name', 10, 2 );
2603
+ * @example
2604
+ * <?php
2605
+ * add_filter( 'um_admin_settings_email_section_fields', 'my_admin_settings_email_section', 10, 2 );
2606
+ * function my_admin_settings_email_section( $settings, $email_key ) {
2607
+ * // your code here
2608
+ * return $settings;
2609
+ * }
2610
+ * ?>
2611
+ */
2612
+ $section_fields = apply_filters( 'um_admin_settings_email_section_fields', array(
2613
+ array(
2614
+ 'id' => 'um_email_template',
2615
+ 'type' => 'hidden',
2616
+ 'value' => $email_key,
2617
+ ),
2618
+ array(
2619
+ 'id' => $email_key . '_on',
2620
+ 'type' => 'checkbox',
2621
+ 'label' => $emails[ $email_key ]['title'],
2622
+ 'tooltip' => $emails[ $email_key ]['description'],
2623
+ ),
2624
+ array(
2625
+ 'id' => $email_key . '_sub',
2626
+ 'type' => 'text',
2627
+ 'label' => __( 'Subject Line', 'ultimate-member' ),
2628
+ 'conditional' => array( $email_key . '_on', '=', 1 ),
2629
+ 'tooltip' => __( 'This is the subject line of the e-mail', 'ultimate-member' ),
2630
+ ),
2631
+ array(
2632
+ 'id' => $email_key,
2633
+ 'type' => 'email_template',
2634
+ 'label' => __( 'Message Body', 'ultimate-member' ),
2635
+ 'conditional' => array( $email_key . '_on', '=', 1 ),
2636
+ 'tooltip' => __( 'This is the content of the e-mail', 'ultimate-member' ),
2637
+ 'value' => UM()->mail()->get_email_template( $email_key ),
2638
+ 'in_theme' => $in_theme
2639
+ ),
2640
+ ), $email_key );
2641
+
2642
+ return $this->render_settings_section( $section_fields, 'email', $email_key );
2643
+ }
2644
+
2645
+
2646
+ /**
2647
+ *
2648
+ */
2649
+ function settings_appearance_profile_tab() {
2650
+ wp_enqueue_media();
2651
+ }
2652
+
2653
+
2654
+ /**
2655
+ * @param $html
2656
+ * @param $section_fields
2657
+ *
2658
+ * @return string
2659
+ */
2660
+ function settings_licenses_tab( $html, $section_fields ) {
2661
+ ob_start(); ?>
2662
+
2663
+ <div class="wrap-licenses">
2664
+ <input type="hidden" id="licenses_settings" name="licenses_settings" value="1">
2665
+ <?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
2666
+ <input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
2667
+ <table class="form-table um-settings-section">
2668
+ <tbody>
2669
+ <?php foreach ( $section_fields as $field_data ) {
2670
+ $option_value = UM()->options()->get( $field_data['id'] );
2671
+ $value = isset( $option_value ) && ! empty( $option_value ) ? $option_value : ( isset( $field_data['default'] ) ? $field_data['default'] : '' );
2672
+
2673
+ $license = get_option( "{$field_data['id']}_edd_answer" );
2674
+
2675
+ if ( is_object( $license ) && ! empty( $value ) ) {
2676
+ // activate_license 'invalid' on anything other than valid, so if there was an error capture it
2677
+ if ( empty( $license->success ) ) {
2678
+
2679
+ if ( ! empty( $license->error ) ) {
2680
+ switch ( $license->error ) {
2681
+
2682
+ case 'expired' :
2683
+
2684
+ $class = 'expired';
2685
+ $messages[] = sprintf(
2686
+ __( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
2687
+ date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
2688
+ 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
2689
+ );
2690
+
2691
+ $license_status = 'license-' . $class . '-notice';
2692
+
2693
+ break;
2694
+
2695
+ case 'revoked' :
2696
+
2697
+ $class = 'error';
2698
+ $messages[] = sprintf(
2699
+ __( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
2700
+ 'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
2701
+ );
2702
+
2703
+ $license_status = 'license-' . $class . '-notice';
2704
+
2705
+ break;
2706
+
2707
+ case 'missing' :
2708
+
2709
+ $class = 'error';
2710
+ $messages[] = sprintf(
2711
+ __( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
2712
+ 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
2713
+ );
2714
+
2715
+ $license_status = 'license-' . $class . '-notice';
2716
+
2717
+ break;
2718
+
2719
+ case 'invalid' :
2720
+ case 'site_inactive' :
2721
+
2722
+ $class = 'error';
2723
+ $messages[] = sprintf(
2724
+ __( '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' ),
2725
+ $field_data['item_name'],
2726
+ 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
2727
+ );
2728
+
2729
+ $license_status = 'license-' . $class . '-notice';
2730
+
2731
+ break;
2732
+
2733
+ case 'item_name_mismatch' :
2734
+
2735
+ $class = 'error';
2736
+ $messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
2737
+
2738
+ $license_status = 'license-' . $class . '-notice';
2739
+
2740
+ break;
2741
+
2742
+ case 'no_activations_left':
2743
+
2744
+ $class = 'error';
2745
+ $messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
2746
+
2747
+ $license_status = 'license-' . $class . '-notice';
2748
+
2749
+ break;
2750
+
2751
+ case 'license_not_activable':
2752
+
2753
+ $class = 'error';
2754
+ $messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
2755
+
2756
+ $license_status = 'license-' . $class . '-notice';
2757
+ break;
2758
+
2759
+ default :
2760
+
2761
+ $class = 'error';
2762
+ $error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
2763
+ $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' );
2764
+
2765
+ $license_status = 'license-' . $class . '-notice';
2766
+ break;
2767
+ }
2768
+ } else {
2769
+ $class = 'error';
2770
+ $error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
2771
+ $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' );
2772
+
2773
+ $license_status = 'license-' . $class . '-notice';
2774
+ }
2775
+
2776
+ } elseif ( ! empty( $license->errors ) ) {
2777
+
2778
+ $errors = array_keys( $license->errors );
2779
+ $errors_data = array_values( $license->errors );
2780
+
2781
+ $class = 'error';
2782
+ $error = ! empty( $errors[0] ) ? $errors[0] : __( 'unknown_error', 'ultimate-member' );
2783
+ $errors_data = ! empty( $errors_data[0][0] ) ? ', ' . $errors_data[0][0] : '';
2784
+ $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' );
2785
+
2786
+ $license_status = 'license-' . $class . '-notice';
2787
+
2788
+ } else {
2789
+
2790
+ switch( $license->license ) {
2791
+
2792
+ case 'expired' :
2793
+
2794
+ $class = 'expired';
2795
+ $messages[] = sprintf(
2796
+ __( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
2797
+ date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
2798
+ 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
2799
+ );
2800
+
2801
+ $license_status = 'license-' . $class . '-notice';
2802
+
2803
+ break;
2804
+
2805
+ case 'revoked' :
2806
+
2807
+ $class = 'error';
2808
+ $messages[] = sprintf(
2809
+ __( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
2810
+ 'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
2811
+ );
2812
+
2813
+ $license_status = 'license-' . $class . '-notice';
2814
+
2815
+ break;
2816
+
2817
+ case 'missing' :
2818
+
2819
+ $class = 'error';
2820
+ $messages[] = sprintf(
2821
+ __( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
2822
+ 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
2823
+ );
2824
+
2825
+ $license_status = 'license-' . $class . '-notice';
2826
+
2827
+ break;
2828
+
2829
+ case 'invalid' :
2830
+ case 'site_inactive' :
2831
+
2832
+ $class = 'error';
2833
+ $messages[] = sprintf(
2834
+ __( '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' ),
2835
+ $field_data['item_name'],
2836
+ 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
2837
+ );
2838
+
2839
+ $license_status = 'license-' . $class . '-notice';
2840
+
2841
+ break;
2842
+
2843
+ case 'item_name_mismatch' :
2844
+
2845
+ $class = 'error';
2846
+ $messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
2847
+
2848
+ $license_status = 'license-' . $class . '-notice';
2849
+
2850
+ break;
2851
+
2852
+ case 'no_activations_left':
2853
+
2854
+ $class = 'error';
2855
+ $messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
2856
+
2857
+ $license_status = 'license-' . $class . '-notice';
2858
+
2859
+ break;
2860
+
2861
+ case 'license_not_activable':
2862
+
2863
+ $class = 'error';
2864
+ $messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
2865
+
2866
+ $license_status = 'license-' . $class . '-notice';
2867
+ break;
2868
+
2869
+ case 'valid' :
2870
+ default:
2871
+
2872
+ $class = 'valid';
2873
+
2874
+ $now = current_time( 'timestamp' );
2875
+ $expiration = strtotime( $license->expires, $now );
2876
+
2877
+ if( 'lifetime' === $license->expires ) {
2878
+
2879
+ $messages[] = __( 'License key never expires.', 'ultimate-member' );
2880
+
2881
+ $license_status = 'license-lifetime-notice';
2882
+
2883
+ } elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
2884
+
2885
+ $messages[] = sprintf(
2886
+ __( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank">Renew your license key</a>.', 'ultimate-member' ),
2887
+ date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
2888
+ 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
2889
+ );
2890
+
2891
+ $license_status = 'license-expires-soon-notice';
2892
+
2893
+ } else {
2894
+
2895
+ $messages[] = sprintf(
2896
+ __( 'Your license key expires on %s.', 'ultimate-member' ),
2897
+ date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
2898
+ );
2899
+
2900
+ $license_status = 'license-expiration-date-notice';
2901
+
2902
+ }
2903
+
2904
+ break;
2905
+
2906
+ }
2907
+
2908
+ }
2909
+
2910
+ } else {
2911
+ $class = 'empty';
2912
+
2913
+ $messages[] = sprintf(
2914
+ __( 'To receive updates, please enter your valid %s license key.', 'ultimate-member' ),
2915
+ $field_data['item_name']
2916
+ );
2917
+
2918
+ $license_status = null;
2919
+
2920
+ } ?>
2921
+
2922
+ <tr class="um-settings-line">
2923
+ <th><label for="um_options_<?php echo esc_attr( $field_data['id'] ) ?>"><?php echo esc_html( $field_data['label'] ) ?></label></th>
2924
+ <td>
2925
+ <form method="post" action="" name="um-settings-form" class="um-settings-form">
2926
+ <input type="hidden" value="save" name="um-settings-action" />
2927
+ <input type="hidden" name="licenses_settings" value="1" />
2928
+ <?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
2929
+ <input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
2930
+ <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'] ) ?>" />
2931
+ <?php if ( ! empty( $field_data['description'] ) ) { ?>
2932
+ <div class="description"><?php echo $field_data['description'] ?></div>
2933
+ <?php } ?>
2934
+
2935
+ <?php if ( ! empty( $value ) && ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) ) { ?>
2936
+ <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' ) ?>"/>
2937
+ <?php } elseif ( empty( $value ) ) { ?>
2938
+ <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Activate', 'ultimate-member' ) ?>" />
2939
+ <?php } else { ?>
2940
+ <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Re-Activate', 'ultimate-member' ) ?>" />
2941
+ <?php }
2942
+
2943
+ if ( ! empty( $messages ) ) {
2944
+ foreach ( $messages as $message ) { ?>
2945
+ <div class="edd-license-data edd-license-<?php echo esc_attr( $class . ' ' . $license_status ) ?>">
2946
+ <p><?php echo $message ?></p>
2947
+ </div>
2948
+ <?php }
2949
+ } ?>
2950
+ </form>
2951
+ </td>
2952
+ </tr>
2953
+ <?php } ?>
2954
+ </tbody>
2955
+ </table>
2956
+ </div>
2957
+ <?php $section = ob_get_clean();
2958
+
2959
+ return $section;
2960
+ }
2961
+
2962
+
2963
+ /**
2964
+ * @param $html
2965
+ * @param $section_fields
2966
+ */
2967
+ function settings_install_info_tab( $html, $section_fields ) {
2968
+ global $wpdb;
2969
+
2970
+ if ( ! class_exists( '\Browser' ) )
2971
+ require_once um_path . 'includes/lib/browser.php';
2972
+
2973
+ // Detect browser
2974
+ $browser = new \Browser();
2975
+
2976
+ // Get theme info
2977
+ $theme_data = wp_get_theme();
2978
+ $theme = $theme_data->Name . ' ' . $theme_data->Version;
2979
+
2980
+ // Identify Hosting Provider
2981
+ $host = um_get_host();
2982
+
2983
+ um_fetch_user( get_current_user_id() );
2984
+
2985
+ if ( isset( $this->content ) ) {
2986
+ echo $this->content;
2987
+ } else { ?>
2988
+
2989
+ <h3>Install Info</h3>
2990
+
2991
+ <form action="" method="post" dir="ltr">
2992
+ <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' ); ?>">
2993
+ ### Begin Install Info ###
2994
+
2995
+ ## Please include this information when posting support requests ##
2996
+
2997
+ <?php
2998
+ /**
2999
+ * UM hook
3000
+ *
3001
+ * @type action
3002
+ * @title um_install_info_before
3003
+ * @description Before install info settings
3004
+ * @change_log
3005
+ * ["Since: 2.0"]
3006
+ * @usage add_action( 'um_install_info_before', 'function_name', 10 );
3007
+ * @example
3008
+ * <?php
3009
+ * add_action( 'um_install_info_before', 'my_install_info_before', 10 );
3010
+ * function my_install_info_before() {
3011
+ * // your code here
3012
+ * }
3013
+ * ?>
3014
+ */
3015
+ do_action( 'um_install_info_before' ); ?>
3016
+
3017
+ --- Site Info ---
3018
+
3019
+ Site URL: <?php echo site_url() . "\n"; ?>
3020
+ Home URL: <?php echo home_url() . "\n"; ?>
3021
+ Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
3022
+
3023
+ --- Hosting Provider ---
3024
+
3025
+ <?php if( $host ) : ?>
3026
+ Host: <?php echo $host . "\n"; ?>
3027
+ <?php endif; ?>
3028
+
3029
+ --- User Browser ---
3030
+
3031
+ <?php echo $browser ; ?>
3032
+
3033
+ ---- Current User Details --
3034
+
3035
+ <?php $user = wp_get_current_user(); ?>
3036
+ Role: <?php echo implode( ', ', um_user( 'roles' ) ). "\n"; ?>
3037
+
3038
+
3039
+ --- WordPress Configurations ---
3040
+
3041
+ Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
3042
+ Language: <?php echo get_locale()."\n"; ?>
3043
+ Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
3044
+ Active Theme: <?php echo $theme . "\n"; ?>
3045
+ <?php $show_on_front = get_option( 'show_on_front' ); ?>
3046
+ <?php if( $show_on_front == "posts" ): ?>
3047
+ Show On Front: <?php echo get_option( 'show_on_front' ) . "/static\n" ?>
3048
+ <?php elseif( $show_on_front == "page" ): ?>
3049
+ Page On Front: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
3050
+ Page For Posts: <?php $id = get_option( 'page_for_posts' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
3051
+ <?php endif; ?>
3052
+ ABSPATH: <?php echo ABSPATH."\n"; ?>
3053
+ <?php $wp_count_posts = wp_count_posts(); ?>
3054
+ All Posts/Pages: <?php echo array_sum((array)$wp_count_posts)."\n";?>
3055
+ <?php
3056
+ $request['cmd'] = '_notify-validate';
3057
+
3058
+ $params = array(
3059
+ 'sslverify' => false,
3060
+ 'timeout' => 60,
3061
+ 'user-agent' => 'UltimateMember/' . ultimatemember_version,
3062
+ 'body' => $request
3063
+ );
3064
+
3065
+ $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
3066
+
3067
+ if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
3068
+ $WP_REMOTE_POST = 'wp_remote_post() works' . "\n";
3069
+ } else {
3070
+ $WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n";
3071
+ }
3072
+ ?>
3073
+ WP Remote Post: <?php echo $WP_REMOTE_POST; ?>
3074
+ WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
3075
+ 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"; ?>
3076
+ Memory Limit: <?php echo ( um_let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>
3077
+
3078
+
3079
+ --- UM Configurations ---
3080
+
3081
+ Version: <?php echo ultimatemember_version . "\n"; ?>
3082
+ Upgraded From: <?php echo get_option( 'um_last_version_upgrade', 'None' ) . "\n"; ?>
3083
+ Current URL Method: <?php echo UM()->options()->get( 'current_url_method' ). "\n"; ?>
3084
+ Cache User Profile: <?php if( UM()->options()->get( 'um_profile_object_cache_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
3085
+ Generate Slugs on Directories: <?php if( UM()->options()->get( 'um_generate_slug_in_directory' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
3086
+ Force UTF-8 Encoding: <?php if( UM()->options()->get( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3087
+ JS/CSS Compression: <?php if ( defined('SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3088
+ <?php if( is_multisite() ): ?>
3089
+ Network Structure: <?php echo UM()->options()->get( 'network_permalink_structure' ). "\n"; ?>
3090
+ <?php endif; ?>
3091
+ Port Forwarding in URL: <?php if( UM()->options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3092
+ Exclude CSS/JS on Home: <?php if( UM()->options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3093
+
3094
+
3095
+ --- UM Pages Configuration ---
3096
+
3097
+ <?php
3098
+ /**
3099
+ * UM hook
3100
+ *
3101
+ * @type action
3102
+ * @title um_install_info_before_page_config
3103
+ * @description Before page config install info
3104
+ * @change_log
3105
+ * ["Since: 2.0"]
3106
+ * @usage add_action( 'um_install_info_before_page_config', 'function_name', 10 );
3107
+ * @example
3108
+ * <?php
3109
+ * add_action( 'um_install_info_before_page_config', 'my_install_info_before_page_config', 10 );
3110
+ * function my_install_info_before_page_config() {
3111
+ * // your code here
3112
+ * }
3113
+ * ?>
3114
+ */
3115
+ do_action( "um_install_info_before_page_config" ); ?>
3116
+ User: <?php echo get_permalink( UM()->options()->get('core_user') ) . "\n"; ?>
3117
+ Account: <?php echo get_permalink( UM()->options()->get('core_account') ) . "\n"; ?>
3118
+ Members: <?php echo get_permalink( UM()->options()->get('core_members') ) . "\n"; ?>
3119
+ Register: <?php echo get_permalink( UM()->options()->get('core_register') ) . "\n"; ?>
3120
+ Login: <?php echo get_permalink( UM()->options()->get('core_login') ) . "\n"; ?>
3121
+ Logout: <?php echo get_permalink( UM()->options()->get('core_logout') ) . "\n"; ?>
3122
+ Password Reset: <?php echo get_permalink( UM()->options()->get('core_password-reset') ) . "\n"; ?>
3123
+ <?php
3124
+ /**
3125
+ * UM hook
3126
+ *
3127
+ * @type action
3128
+ * @title um_install_info_after_page_config
3129
+ * @description After page config install info
3130
+ * @change_log
3131
+ * ["Since: 2.0"]
3132
+ * @usage add_action( 'um_install_info_after_page_config', 'function_name', 10 );
3133
+ * @example
3134
+ * <?php
3135
+ * add_action( 'um_install_info_after_page_config', 'my_install_info_after_page_config', 10 );
3136
+ * function my_install_info_after_page_config() {
3137
+ * // your code here
3138
+ * }
3139
+ * ?>
3140
+ */
3141
+ do_action( "um_install_info_after_page_config" ); ?>
3142
+
3143
+
3144
+ --- UM Users Configuration ---
3145
+
3146
+ Default New User Role: <?php echo UM()->options()->get('register_role') . "\n"; ?>
3147
+ Profile Permalink Base: <?php echo UM()->options()->get('permalink_base') . "\n"; ?>
3148
+ User Display Name: <?php echo UM()->options()->get('display_name') . "\n"; ?>
3149
+ Force Name to Uppercase: <?php echo $this->info_value( UM()->options()->get('force_display_name_capitlized'), 'yesno', true ); ?>
3150
+ Redirect author to profile: <?php echo $this->info_value( UM()->options()->get('author_redirect'), 'yesno', true ); ?>
3151
+ Enable Members Directory: <?php echo $this->info_value( UM()->options()->get('members_page'), 'yesno', true ); ?>
3152
+ Use Gravatars: <?php echo $this->info_value( UM()->options()->get('use_gravatars'), 'yesno', true ); ?>
3153
+ <?php if( UM()->options()->get('use_gravatars') ): ?>Gravatar builtin image: <?php echo UM()->options()->get('use_um_gravatar_default_builtin_image') . "\n"; ?>
3154
+ UM Avatar as blank Gravatar: <?php echo $this->info_value( UM()->options()->get('use_um_gravatar_default_image'), 'yesno', true ); ?><?php endif; ?>
3155
+ Require a strong password: <?php echo $this->info_value( UM()->options()->get('reset_require_strongpass'), 'onoff', true ); ?>
3156
+
3157
+
3158
+ --- UM Access Configuration ---
3159
+
3160
+ Panic Key: <?php echo UM()->options()->get('panic_key') . "\n"; ?>
3161
+ Global Site Access: <?php $arr = array('Site accessible to Everyone','','Site accessible to Logged In Users'); echo $arr[ (int) UM()->options()->get('accessible') ] . "\n"; ?>
3162
+ <?php if( UM()->options()->get('accessible') == 2 ) { ?>
3163
+ Custom Redirect URL: <?php echo UM()->options()->get('access_redirect')."\n";?>
3164
+ 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";?>
3165
+ <?php } ?>
3166
+ Backend Login Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_login'), 'yesno', true ); ?>
3167
+ <?php if( ! UM()->options()->get('wpadmin_login') ) { ?>
3168
+ 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"; }?>
3169
+ <?php } ?>
3170
+ Backend Register Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_register'), 'yesno', true ); ?>
3171
+ <?php if( ! UM()->options()->get('wpadmin_register') ) { ?>
3172
+ 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"; }?>
3173
+ <?php } ?>
3174
+ Access Control widget for Admins only: <?php echo $this->info_value( UM()->options()->get('access_widget_admin_only'), 'yesno', true ); ?>
3175
+ Enable the Reset Password Limit: <?php echo $this->info_value( UM()->options()->get('enable_reset_password_limit'), 'yesno', true ); ?>
3176
+ <?php if( UM()->options()->get('enable_reset_password_limit') ) { ?>
3177
+ Reset Password Limit: <?php echo UM()->options()->get('reset_password_limit_number') ?>
3178
+ Disable Reset Password Limit for Admins: <?php echo $this->info_value( UM()->options()->get('disable_admin_reset_password_limit'), 'yesno', true ) ?>
3179
+ <?php } ?>
3180
+ <?php $wpadmin_allow_ips = UM()->options()->get( 'wpadmin_allow_ips' ); if( ! empty( $wpadmin_allow_ips ) ) { ?>
3181
+ Whitelisted Backend IPs: <?php echo count( explode("\n",trim(UM()->options()->get('wpadmin_allow_ips') ) ) )."\n"; ?>
3182
+ <?php } ?>
3183
+ <?php $blocked_ips = UM()->options()->get('blocked_ips'); if( ! empty( $blocked_ips ) ){ ?>
3184
+ Blocked IP Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_ips') ) )."\n"; ?>
3185
+ <?php } ?>
3186
+ <?php $blocked_emails = UM()->options()->get('blocked_emails'); if( ! empty( $blocked_emails ) ){ ?>
3187
+ Blocked Email Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_emails') ) )."\n"; ?>
3188
+ <?php } ?>
3189
+ <?php $blocked_words = UM()->options()->get('blocked_words'); if( ! empty( $blocked_words ) ){ ?>
3190
+ Blacklist Words: <?php echo count( explode("\n",UM()->options()->get('blocked_words') ) )."\n"; ?>
3191
+ <?php } ?>
3192
+
3193
+
3194
+ --- UM Email Configurations ---
3195
+
3196
+ 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";?>
3197
+ 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";?>
3198
+ Use HTML for E-mails: <?php echo $this->info_value( UM()->options()->get('email_html'), 'yesno', true ); ?>
3199
+ Account Welcome Email: <?php echo $this->info_value( UM()->options()->get('welcome_email_on'), 'yesno', true ); ?>
3200
+ Account Activation Email: <?php echo $this->info_value( UM()->options()->get('checkmail_email_on'), 'yesno', true ); ?>
3201
+ Pending Review Email: <?php echo $this->info_value( UM()->options()->get('pending_email_on'), 'yesno', true ); ?>
3202
+ Account Approved Email: <?php echo $this->info_value( UM()->options()->get('approved_email_on'), 'yesno', true ); ?>
3203
+ Account Rejected Email: <?php echo $this->info_value( UM()->options()->get('rejected_email_on'), 'yesno', true ); ?>
3204
+ Account Deactivated Email: <?php echo $this->info_value( UM()->options()->get('inactive_email_on'), 'yesno', true ); ?>
3205
+ Account Deleted Email: <?php echo $this->info_value( UM()->options()->get('deletion_email_on'), 'yesno', true ); ?>
3206
+ Password Reset Email: <?php echo $this->info_value( UM()->options()->get('resetpw_email_on'), 'yesno', true ); ?>
3207
+ Password Changed Email: <?php echo $this->info_value( UM()->options()->get('changedpw_email_on'), 'yesno', true ); ?>
3208
+
3209
+
3210
+ --- UM Total Users ---
3211
+
3212
+ <?php $result = count_users();
3213
+ echo 'All Users('.$result['total_users'].")\n";
3214
+ foreach( $result['avail_roles'] as $role => $count ) {
3215
+ echo $role."(".$count.")\n";
3216
+ } ?>
3217
+
3218
+
3219
+ --- UM Roles ---
3220
+
3221
+ <?php foreach( UM()->roles()->get_roles() as $role_id => $role ) {
3222
+ echo $role." ({$role_id})\n";
3223
+ } ?>
3224
+
3225
+
3226
+ --- UM Custom Templates ---
3227
+
3228
+ <?php // Show templates that have been copied to the theme's edd_templates dir
3229
+ $dir = get_stylesheet_directory() . '/ultimate-member/templates/*.php';
3230
+ if ( ! empty( $dir ) ) {
3231
+ $found = glob( $dir );
3232
+ if ( ! empty( $found ) ) {
3233
+ foreach ( glob( $dir ) as $file ) {
3234
+ echo "File: " . $file . "\n";
3235
+ }
3236
+ } else {
3237
+ echo 'N/A'."\n";
3238
+ }
3239
+ } ?>
3240
+
3241
+
3242
+ --- UM Email HTML Templates ---
3243
+
3244
+ <?php $dir = get_stylesheet_directory() . '/ultimate-member/templates/emails/*.html';
3245
+
3246
+ if ( ! empty( $dir ) ) {
3247
+ $found = glob( $dir );
3248
+ if ( ! empty( $found ) ){
3249
+ foreach ( glob( $dir ) as $file ) {
3250
+ echo "File: ". $file . "\n";
3251
+ }
3252
+ } else {
3253
+ echo 'N/A'."\n";
3254
+ }
3255
+ } ?>
3256
+
3257
+
3258
+ --- Web Server Configurations ---
3259
+
3260
+ PHP Version: <?php echo PHP_VERSION . "\n"; ?>
3261
+ MySQL Version: <?php echo $wpdb->db_version() . "\n"; ?>
3262
+ Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
3263
+
3264
+
3265
+ --- PHP Configurations ---
3266
+
3267
+ PHP Memory Limit: <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
3268
+ PHP Upload Max Size: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
3269
+ PHP Post Max Size: <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
3270
+ PHP Upload Max Filesize: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
3271
+ PHP Time Limit: <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
3272
+ PHP Max Input Vars: <?php echo ini_get( 'max_input_vars' ) . "\n"; ?>
3273
+ PHP Arg Separator: <?php echo ini_get( 'arg_separator.output' ) . "\n"; ?>
3274
+ PHP Allow URL File Open: <?php echo ini_get( 'allow_url_fopen' ) ? "Yes\n" : "No\n"; ?>
3275
+
3276
+
3277
+ --- Web Server Extensions/Modules ---
3278
+
3279
+ DISPLAY ERRORS: <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
3280
+ FSOCKOPEN: <?php echo ( function_exists( 'fsockopen' ) ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; ?><?php echo "\n"; ?>
3281
+ cURL: <?php echo ( function_exists( 'curl_init' ) ) ? 'Your server supports cURL.' : 'Your server does not support cURL.'; ?><?php echo "\n"; ?>
3282
+ 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"; ?>
3283
+ SUHOSIN: <?php echo ( extension_loaded( 'suhosin' ) ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; ?><?php echo "\n"; ?>
3284
+ 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"; ?>
3285
+ 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"; ?>
3286
+ 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"; ?>
3287
+
3288
+
3289
+ --- Session Configurations ---
3290
+
3291
+ Session: <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; ?><?php echo "\n"; ?>
3292
+ Session Name: <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
3293
+ Cookie Path: <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
3294
+ Save Path: <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
3295
+ Use Cookies: <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
3296
+ Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
3297
+
3298
+
3299
+ --- WordPress Active Plugins ---
3300
+
3301
+ <?php $plugins = get_plugins();
3302
+ $active_plugins = get_option( 'active_plugins', array() );
3303
+
3304
+ foreach ( $plugins as $plugin_path => $plugin ) {
3305
+ // If the plugin isn't active, don't show it.
3306
+ if ( ! in_array( $plugin_path, $active_plugins ) )
3307
+ continue;
3308
+
3309
+ echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
3310
+ }
3311
+
3312
+ if ( is_multisite() ) { ?>
3313
+
3314
+ --- WordPress Network Active Plugins ---
3315
+
3316
+ <?php $plugins = wp_get_active_network_plugins();
3317
+ $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
3318
+
3319
+ foreach ( $plugins as $plugin_path ) {
3320
+ $plugin_base = plugin_basename( $plugin_path );
3321
+
3322
+ // If the plugin isn't active, don't show it.
3323
+ if ( ! array_key_exists( $plugin_base, $active_plugins ) )
3324
+ continue;
3325
+
3326
+ $plugin = get_plugin_data( $plugin_path );
3327
+
3328
+ echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n";
3329
+ }
3330
+
3331
+ }
3332
+
3333
+ /**
3334
+ * UM hook
3335
+ *
3336
+ * @type action
3337
+ * @title um_install_info_after
3338
+ * @description After install info
3339
+ * @change_log
3340
+ * ["Since: 2.0"]
3341
+ * @usage add_action( 'um_install_info_after', 'function_name', 10 );
3342
+ * @example
3343
+ * <?php
3344
+ * add_action( 'um_install_info_after', 'my_install_info_after', 10 );
3345
+ * function my_install_info_after() {
3346
+ * // your code here
3347
+ * }
3348
+ * ?>
3349
+ */
3350
+ do_action( 'um_install_info_after' ); ?>
3351
+
3352
+ ### End Install Info ###
3353
+ </textarea>
3354
+ <p class="submit">
3355
+ <input type="hidden" name="um-addon-hook" value="download_install_info" />
3356
+ <?php submit_button( 'Download Install Info File', 'primary', 'download_install_info', false ); ?>
3357
+ </p>
3358
+ </form>
3359
+
3360
+ <?php }
3361
+ }
3362
+
3363
+
3364
+ /**
3365
+ *
3366
+ */
3367
+ function um_download_install_info() {
3368
+ if ( ! empty( $_POST['download_install_info'] ) ) {
3369
+ nocache_headers();
3370
+
3371
+ header( "Content-type: text/plain" );
3372
+ header( 'Content-Disposition: attachment; filename="ultimatemember-install-info.txt"' );
3373
+
3374
+ echo wp_strip_all_tags( sanitize_textarea_field( $_POST['um-install-info'] ) );
3375
+ exit;
3376
+ }
3377
+ }
3378
+
3379
+
3380
+ /**
3381
+ * @param string $raw_value
3382
+ * @param string $type
3383
+ * @param string $default
3384
+ *
3385
+ * @return string
3386
+ */
3387
+ function info_value( $raw_value = '', $type = 'yesno', $default = '' ) {
3388
+
3389
+ if ( $type == 'yesno' ) {
3390
+ $raw_value = ( $default == $raw_value ) ? "Yes" : "No";
3391
+ } elseif( $type == 'onoff' ) {
3392
+ $raw_value = ( $default == $raw_value ) ? "On" : "Off";
3393
+ }
3394
+
3395
+ return $raw_value."\n";
3396
+ }
3397
+
3398
+
3399
+ /**
3400
+ * Render settings section
3401
+ *
3402
+ * @param array $section_fields
3403
+ * @param string $current_tab
3404
+ * @param string $current_subtab
3405
+ *
3406
+ * @return string
3407
+ */
3408
+ function render_settings_section( $section_fields, $current_tab, $current_subtab ) {
3409
+ ob_start();
3410
+
3411
+ UM()->admin_forms_settings( array(
3412
+ 'class' => 'um_options-' . $current_tab . '-' . $current_subtab . ' um-third-column',
3413
+ 'prefix_id' => 'um_options',
3414
+ 'fields' => $section_fields
3415
+ ) )->render_form(); ?>
3416
+
3417
+ <?php $section = ob_get_clean();
3418
+
3419
+ return $section;
3420
+ }
3421
+
3422
+
3423
+ /**
3424
+ * @param array $settings
3425
+ *
3426
+ * @return array
3427
+ */
3428
+ function save_email_templates( $settings ) {
3429
+
3430
+ if ( empty( $settings['um_email_template'] ) ) {
3431
+ return $settings;
3432
+ }
3433
+
3434
+ $template = $settings['um_email_template'];
3435
+ $content = wp_kses_post( stripslashes( $settings[ $template ] ) );
3436
+
3437
+ $theme_template_path = UM()->mail()->get_template_file( 'theme', $template );
3438
+
3439
+ if ( ! file_exists( $theme_template_path ) ) {
3440
+ UM()->mail()->copy_email_template( $template );
3441
+ }
3442
+
3443
+ $fp = fopen( $theme_template_path, "w" );
3444
+ $result = fputs( $fp, $content );
3445
+ fclose( $fp );
3446
+
3447
+ if ( $result !== false ) {
3448
+ unset( $settings['um_email_template'] );
3449
+ unset( $settings[ $template ] );
3450
+ }
3451
+
3452
+ return $settings;
3453
+ }
3454
+ }
3455
+ }
includes/admin/templates/access/restrict_content.php CHANGED
@@ -1,164 +1,164 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
- exit;
4
- }
5
- ?>
6
-
7
- <div class="um-admin-metabox">
8
- <?php
9
- if ( ! empty( $object->ID ) ) {
10
- $data = get_post_meta( $object->ID, 'um_content_restriction', true );
11
- } else {
12
- $data = array();
13
- }
14
-
15
- $_um_access_roles_value = array();
16
- if ( ! empty( $data['_um_access_roles'] ) ) {
17
- foreach ( $data['_um_access_roles'] as $key => $value ) {
18
- if ( $value ) {
19
- $_um_access_roles_value[] = $key;
20
- }
21
- }
22
- }
23
-
24
- if ( ! empty( $object->post_type ) ) {
25
- $post_type_object = get_post_type_object( $object->post_type );
26
- } else {
27
- $post_type_object = array();
28
- }
29
-
30
- /**
31
- * UM hook
32
- *
33
- * @type filter
34
- * @title um_admin_access_settings_fields
35
- * @description Extend Admin Access Settings Fields
36
- * @input_vars
37
- * [{"var":"$fields","type":"array","desc":"Access Settings Fields"},
38
- * {"var":"$data","type":"array","desc":"Form Data"}]
39
- * @change_log
40
- * ["Since: 2.0"]
41
- * @usage add_filter( 'um_admin_access_settings_fields', 'function_name', 10, 2 );
42
- * @example
43
- * <?php
44
- * add_filter( 'um_admin_access_settings_fields', 'my_admin_access_settings_fields', 10, 2 );
45
- * function my_admin_access_settings_fields( $fields, $data ) {
46
- * // your code here
47
- * return $fields;
48
- * }
49
- * ?>
50
- */
51
- $fields = apply_filters( 'um_admin_access_settings_fields', array(
52
- array(
53
- 'id' => '_um_custom_access_settings',
54
- 'type' => 'checkbox',
55
- 'label' => __( 'Restrict access to this post?', 'ultimate-member' ),
56
- 'tooltip' => __( 'Activate individual content restriction settings for this post. Then ignore all terms restriction content settings if they exists.', 'ultimate-member' ),
57
- 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
58
- ),
59
- array(
60
- 'id' => '_um_accessible',
61
- 'type' => 'select',
62
- 'label' => __( 'Who can access this post?', 'ultimate-member' ),
63
- 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0,
64
- 'options' => array(
65
- '0' => __( 'Everyone', 'ultimate-member' ),
66
- '1' => __( 'Logged out users', 'ultimate-member' ),
67
- '2' => __( 'Logged in users', 'ultimate-member' ),
68
- ),
69
- 'conditional' => array( '_um_custom_access_settings', '=', '1' ),
70
- ),
71
- array(
72
- 'id' => '_um_access_roles',
73
- 'type' => 'multi_checkbox',
74
- 'label' => __( 'Select which roles can access this post', 'ultimate-member' ),
75
- 'tooltip' => __( 'Leave empty if you want to display a post for all logged in users', 'ultimate-member' ),
76
- 'value' => $_um_access_roles_value,
77
- 'options' => UM()->roles()->get_roles( false ),
78
- 'columns' => 3,
79
- 'conditional' => array( '_um_accessible', '=', '2' ),
80
- ),
81
- array(
82
- 'id' => '_um_access_hide_from_queries',
83
- 'type' => 'checkbox',
84
- 'label' => __( 'Would you like to display 404 page when users haven\'t access?', 'ultimate-member' ),
85
- 'tooltip' => __( 'Recommended to be enabled. Restricted post will be hidden by exclusion from WP Query. The safest and most effective method that hides post and its comments from all requests, RSS feeds, etc. on your site', 'ultimate-member' ),
86
- 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
87
- 'conditional' => array( '_um_accessible', '!=', '0' ),
88
- ),
89
- array(
90
- 'id' => '_um_noaccess_action',
91
- 'type' => 'select',
92
- 'label' => __( 'What happens when users without access try to view the post?', 'ultimate-member' ),
93
- 'tooltip' => __( 'Action when users without access tries to view the post', 'ultimate-member' ),
94
- 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0,
95
- 'options' => array(
96
- '0' => __( 'Show access restricted message', 'ultimate-member' ),
97
- '1' => __( 'Redirect user', 'ultimate-member' ),
98
- ),
99
- 'conditional' => array( '_um_access_hide_from_queries', '=', '0' ),
100
- ),
101
- array(
102
- 'id' => '_um_restrict_by_custom_message',
103
- 'type' => 'select',
104
- 'label' => __( 'Restricted access message type', 'ultimate-member' ),
105
- 'tooltip' => __( 'Would you like to use the global default message or apply a custom message to this post?', 'ultimate-member' ),
106
- 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
107
- 'options' => array(
108
- '0' => __( 'Global default message', 'ultimate-member' ),
109
- '1' => __( 'Custom message', 'ultimate-member' ),
110
- ),
111
- 'conditional' => array( '_um_noaccess_action', '=', '0' ),
112
- ),
113
- array(
114
- 'id' => '_um_restrict_custom_message',
115
- 'type' => 'wp_editor',
116
- 'label' => __( 'Custom restricted access message', 'ultimate-member' ),
117
- 'tooltip' => __( 'You may replace global restricted access message here', 'ultimate-member' ),
118
- 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
119
- 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ),
120
- ),
121
- array(
122
- 'id' => '_um_access_redirect',
123
- 'type' => 'select',
124
- 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
125
- 'tooltip' => __( 'Select redirect to page when user hasn\'t access to post', 'ultimate-member' ),
126
- 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
127
- 'options' => array(
128
- '0' => __( 'Login page', 'ultimate-member' ),
129
- '1' => __( 'Custom URL', 'ultimate-member' ),
130
- ),
131
- 'conditional' => array( '_um_noaccess_action', '=', '1' ),
132
- ),
133
- array(
134
- 'id' => '_um_access_redirect_url',
135
- 'type' => 'text',
136
- 'label' => __( 'Redirect URL', 'ultimate-member' ),
137
- 'tooltip' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ),
138
- 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
139
- 'conditional' => array( '_um_access_redirect', '=', '1' ),
140
- ),
141
- ), $data, $object, $post_type_object );
142
-
143
- // Hierarchical
144
- // if ( $post_type_object->hierarchical ) {
145
- // $fields[] = array(
146
- // 'id' => '_um_access_hierarchical',
147
- // 'type' => 'checkbox',
148
- // 'label' => __( 'Hierarchical', 'ultimate-member' ),
149
- // 'tooltip' => __( 'Use parent page settings for the child pages that doesn\'t have own restriction settings.', 'ultimate-member' ),
150
- // 'value' => empty( $data['_um_access_hierarchical'] ) ? 0 : $data['_um_access_hierarchical'],
151
- // 'conditional' => array( '_um_custom_access_settings', '=', '1' )
152
- // );
153
- // }
154
-
155
- UM()->admin_forms(
156
- array(
157
- 'class' => 'um-restrict-content um-third-column',
158
- 'prefix_id' => 'um_content_restriction',
159
- 'fields' => $fields,
160
- )
161
- )->render_form();
162
- ?>
163
-
164
- </div>
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+ ?>
6
+
7
+ <div class="um-admin-metabox">
8
+ <?php
9
+ if ( ! empty( $object->ID ) ) {
10
+ $data = get_post_meta( $object->ID, 'um_content_restriction', true );
11
+ } else {
12
+ $data = array();
13
+ }
14
+
15
+ $_um_access_roles_value = array();
16
+ if ( ! empty( $data['_um_access_roles'] ) ) {
17
+ foreach ( $data['_um_access_roles'] as $key => $value ) {
18
+ if ( $value ) {
19
+ $_um_access_roles_value[] = $key;
20
+ }
21
+ }
22
+ }
23
+
24
+ if ( ! empty( $object->post_type ) ) {
25
+ $post_type_object = get_post_type_object( $object->post_type );
26
+ } else {
27
+ $post_type_object = array();
28
+ }
29
+
30
+ /**
31
+ * UM hook
32
+ *
33
+ * @type filter
34
+ * @title um_admin_access_settings_fields
35
+ * @description Extend Admin Access Settings Fields
36
+ * @input_vars
37
+ * [{"var":"$fields","type":"array","desc":"Access Settings Fields"},
38
+ * {"var":"$data","type":"array","desc":"Form Data"}]
39
+ * @change_log
40
+ * ["Since: 2.0"]
41
+ * @usage add_filter( 'um_admin_access_settings_fields', 'function_name', 10, 2 );
42
+ * @example
43
+ * <?php
44
+ * add_filter( 'um_admin_access_settings_fields', 'my_admin_access_settings_fields', 10, 2 );
45
+ * function my_admin_access_settings_fields( $fields, $data ) {
46
+ * // your code here
47
+ * return $fields;
48
+ * }
49
+ * ?>
50
+ */
51
+ $fields = apply_filters( 'um_admin_access_settings_fields', array(
52
+ array(
53
+ 'id' => '_um_custom_access_settings',
54
+ 'type' => 'checkbox',
55
+ 'label' => __( 'Restrict access to this post?', 'ultimate-member' ),
56
+ 'tooltip' => __( 'Activate individual content restriction settings for this post. Then ignore all terms restriction content settings if they exists.', 'ultimate-member' ),
57
+ 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
58
+ ),
59
+ array(
60
+ 'id' => '_um_accessible',
61
+ 'type' => 'select',
62
+ 'label' => __( 'Who can access this post?', 'ultimate-member' ),
63
+ 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0,
64
+ 'options' => array(
65
+ '0' => __( 'Everyone', 'ultimate-member' ),
66
+ '1' => __( 'Logged out users', 'ultimate-member' ),
67
+ '2' => __( 'Logged in users', 'ultimate-member' ),
68
+ ),
69
+ 'conditional' => array( '_um_custom_access_settings', '=', '1' ),
70
+ ),
71
+ array(
72
+ 'id' => '_um_access_roles',
73
+ 'type' => 'multi_checkbox',
74
+ 'label' => __( 'Select which roles can access this post', 'ultimate-member' ),
75
+ 'tooltip' => __( 'Leave empty if you want to display a post for all logged in users', 'ultimate-member' ),
76
+ 'value' => $_um_access_roles_value,
77
+ 'options' => UM()->roles()->get_roles( false ),
78
+ 'columns' => 3,
79
+ 'conditional' => array( '_um_accessible', '=', '2' ),
80
+ ),
81
+ array(
82
+ 'id' => '_um_access_hide_from_queries',
83
+ 'type' => 'checkbox',
84
+ 'label' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Hide from queries', 'ultimate-member' ) : __( 'Would you like to display 404 page when users haven\'t access?', 'ultimate-member' ),
85
+ 'tooltip' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Exclude only from WP queries results', 'ultimate-member' ) : __( 'Recommended to be enabled. Restricted post will be hidden by exclusion from WP Query. The safest and most effective method that hides post and its comments from all requests, RSS feeds, etc. on your site', 'ultimate-member' ),
86
+ 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
87
+ 'conditional' => array( '_um_accessible', '!=', '0' ),
88
+ ),
89
+ array(
90
+ 'id' => '_um_noaccess_action',
91
+ 'type' => 'select',
92
+ 'label' => __( 'What happens when users without access try to view the post?', 'ultimate-member' ),
93
+ 'tooltip' => __( 'Action when users without access tries to view the post', 'ultimate-member' ),
94
+ 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0,
95
+ 'options' => array(
96
+ '0' => __( 'Show access restricted message', 'ultimate-member' ),
97
+ '1' => __( 'Redirect user', 'ultimate-member' ),
98
+ ),
99
+ 'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? '' : array( '_um_access_hide_from_queries', '=', '0' ),
100
+ ),
101
+ array(
102
+ 'id' => '_um_restrict_by_custom_message',
103
+ 'type' => 'select',
104
+ 'label' => __( 'Restricted access message type', 'ultimate-member' ),
105
+ 'tooltip' => __( 'Would you like to use the global default message or apply a custom message to this post?', 'ultimate-member' ),
106
+ 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
107
+ 'options' => array(
108
+ '0' => __( 'Global default message', 'ultimate-member' ),
109
+ '1' => __( 'Custom message', 'ultimate-member' ),
110
+ ),
111
+ 'conditional' => array( '_um_noaccess_action', '=', '0' ),
112
+ ),
113
+ array(
114
+ 'id' => '_um_restrict_custom_message',
115
+ 'type' => 'wp_editor',
116
+ 'label' => __( 'Custom restricted access message', 'ultimate-member' ),
117
+ 'tooltip' => __( 'You may replace global restricted access message here', 'ultimate-member' ),
118
+ 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
119
+ 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ),
120
+ ),
121
+ array(
122
+ 'id' => '_um_access_redirect',
123
+ 'type' => 'select',
124
+ 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
125
+ 'tooltip' => __( 'Select redirect to page when user hasn\'t access to post', 'ultimate-member' ),
126
+ 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
127
+ 'options' => array(
128
+ '0' => __( 'Login page', 'ultimate-member' ),
129
+ '1' => __( 'Custom URL', 'ultimate-member' ),
130
+ ),
131
+ 'conditional' => array( '_um_noaccess_action', '=', '1' ),
132
+ ),
133
+ array(
134
+ 'id' => '_um_access_redirect_url',
135
+ 'type' => 'text',
136
+ 'label' => __( 'Redirect URL', 'ultimate-member' ),
137
+ 'tooltip' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ),
138
+ 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
139
+ 'conditional' => array( '_um_access_redirect', '=', '1' ),
140
+ ),
141
+ ), $data, $object, $post_type_object );
142
+
143
+ // Hierarchical
144
+ // if ( $post_type_object->hierarchical ) {
145
+ // $fields[] = array(
146
+ // 'id' => '_um_access_hierarchical',
147
+ // 'type' => 'checkbox',
148
+ // 'label' => __( 'Hierarchical', 'ultimate-member' ),
149
+ // 'tooltip' => __( 'Use parent page settings for the child pages that doesn\'t have own restriction settings.', 'ultimate-member' ),
150
+ // 'value' => empty( $data['_um_access_hierarchical'] ) ? 0 : $data['_um_access_hierarchical'],
151
+ // 'conditional' => array( '_um_custom_access_settings', '=', '1' )
152
+ // );
153
+ // }
154
+
155
+ UM()->admin_forms(
156
+ array(
157
+ 'class' => 'um-restrict-content um-third-column',
158
+ 'prefix_id' => 'um_content_restriction',
159
+ 'fields' => $fields,
160
+ )
161
+ )->render_form();
162
+ ?>
163
+
164
+ </div>
includes/class-config.php CHANGED
@@ -1,805 +1,807 @@
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
- 'uninstall_on_delete' => 0,
516
- 'permalink_base' => 'user_login',
517
- 'display_name' => 'full_name',
518
- 'display_name_field' => '',
519
- 'author_redirect' => 1,
520
- 'members_page' => 1,
521
- 'use_gravatars' => 0,
522
- 'use_um_gravatar_default_builtin_image' => 'default',
523
- 'use_um_gravatar_default_image' => 0,
524
- 'reset_require_strongpass' => 0,
525
- 'account_tab_password' => 1,
526
- 'account_tab_privacy' => 1,
527
- 'account_tab_notifications' => 1,
528
- 'account_tab_delete' => 1,
529
- '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' ),
530
- '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' ),
531
- 'account_name' => 1,
532
- 'account_name_disable' => 0,
533
- 'account_name_require' => 1,
534
- 'account_email' => 1,
535
- 'account_general_password' => 0,
536
- 'account_hide_in_directory' => 1,
537
- 'account_hide_in_directory_default' => 'No',
538
- 'account_require_strongpass' => 0,
539
- 'photo_thumb_sizes' => array( 40, 80, 190 ),
540
- 'cover_thumb_sizes' => array( 300, 600 ),
541
- 'accessible' => 0,
542
- 'access_redirect' => '',
543
- 'access_exclude_uris' => array(),
544
- 'home_page_accessible' => 1,
545
- 'category_page_accessible' => 1,
546
- 'restricted_access_post_title' => __( 'Restricted content', 'ultimate-member' ),
547
- 'restricted_access_message' => '',
548
- 'restricted_blocks' => 0,
549
- 'enable_blocks' => 0,
550
- 'restricted_block_message' => '',
551
- 'enable_reset_password_limit' => 1,
552
- 'reset_password_limit_number' => 3,
553
- 'blocked_emails' => '',
554
- 'blocked_words' => 'admin' . "\r\n" . 'administrator' . "\r\n" . 'webmaster' . "\r\n" . 'support' . "\r\n" . 'staff',
555
- 'default_avatar' => '',
556
- 'default_cover' => '',
557
- 'disable_profile_photo_upload' => 0,
558
- 'profile_show_metaicon' => 0,
559
- 'profile_menu' => 1,
560
- 'profile_menu_default_tab' => 'main',
561
- 'profile_menu_icons' => 1,
562
- 'form_asterisk' => 0,
563
- 'profile_title' => '{display_name} | {site_name}',
564
- 'profile_desc' => '{display_name} is on {site_name}. Join {site_name} to view {display_name}\'s profile',
565
- 'admin_email' => get_bloginfo('admin_email'),
566
- 'mail_from' => get_bloginfo('name'),
567
- 'mail_from_addr' => get_bloginfo('admin_email'),
568
- 'email_html' => 1,
569
- 'image_orientation_by_exif' => 0,
570
- 'image_compression' => 60,
571
- 'image_max_width' => 1000,
572
- 'cover_min_width' => 1000,
573
- 'profile_photo_max_size' => 999999999,
574
- 'cover_photo_max_size' => 999999999,
575
- 'custom_roles_increment' => 1,
576
- 'um_profile_object_cache_stop' => 0,
577
- 'rest_api_version' => '2.0',
578
- 'member_directory_own_table' => 0,
579
- 'profile_show_html_bio' => 0,
580
- 'profile_noindex' => 0,
581
- 'activation_link_expiry_time' => '',
582
- );
583
-
584
- add_filter( 'um_get_tabs_from_config', '__return_true' );
585
-
586
- $tabs = UM()->profile()->tabs();
587
-
588
- foreach ( $tabs as $id => $tab ) {
589
-
590
- if ( ! empty( $tab['hidden'] ) ) {
591
- continue;
592
- }
593
-
594
- $this->settings_defaults[ 'profile_tab_' . $id ] = 1;
595
-
596
- if ( ! isset( $tab['default_privacy'] ) ) {
597
- $this->settings_defaults[ 'profile_tab_' . $id . '_privacy' ] = 0;
598
- $this->settings_defaults[ 'profile_tab_' . $id . '_roles' ] = '';
599
- }
600
- }
601
-
602
- foreach ( $this->email_notifications as $key => $notification ) {
603
- $this->settings_defaults[ $key . '_on' ] = ! empty( $notification['default_active'] );
604
- $this->settings_defaults[ $key . '_sub' ] = $notification['subject'];
605
- $this->settings_defaults[ $key ] = $notification['body'];
606
- }
607
-
608
- foreach ( $this->core_pages as $page_s => $page ) {
609
- $page_id = UM()->options()->get_core_page_id( $page_s );
610
- $this->settings_defaults[ $page_id ] = '';
611
- }
612
-
613
- foreach( $this->core_form_meta_all as $key => $value ) {
614
- $this->settings_defaults[ str_replace( '_um_', '', $key ) ] = $value;
615
- }
616
-
617
-
618
- /**
619
- * UM hook
620
- *
621
- * @type filter
622
- * @title um_default_settings_values
623
- * @description Extend UM default settings
624
- * @input_vars
625
- * [{"var":"$settings","type":"array","desc":"UM default settings"}]
626
- * @change_log
627
- * ["Since: 2.0"]
628
- * @usage
629
- * <?php add_filter( 'um_default_settings_values', 'function_name', 10, 1 ); ?>
630
- * @example
631
- * <?php
632
- * add_filter( 'um_default_settings_values', 'my_default_settings_values', 10, 1 );
633
- * function my_default_settings_values( $settings ) {
634
- * // your code here
635
- * return $settings;
636
- * }
637
- * ?>
638
- */
639
- $this->settings_defaults = apply_filters( 'um_default_settings_values', $this->settings_defaults );
640
-
641
- $this->permalinks = $this->get_core_pages();
642
-
643
-
644
-
645
- $this->default_roles_metadata = array(
646
- /*
647
- * All caps map
648
- *
649
- * '_um_can_access_wpadmin' => 1,
650
- '_um_can_not_see_adminbar' => 0,
651
- '_um_can_edit_everyone' => 1,
652
- '_um_can_edit_roles' => '',
653
- '_um_can_delete_everyone' => 1,
654
- '_um_can_delete_roles' => '',
655
- '_um_after_delete' => '',
656
- '_um_delete_redirect_url' => '',
657
- '_um_can_edit_profile' => 1,
658
- '_um_can_delete_profile' => 1,
659
- '_um_default_homepage' => 1,
660
- '_um_redirect_homepage' => '',
661
- '_um_after_login' => 'redirect_admin',
662
- '_um_login_redirect_url' => '',
663
- '_um_after_logout' => 'redirect_home',
664
- '_um_logout_redirect_url' => '',
665
- '_um_can_view_all' => 1,
666
- '_um_can_view_roles' => '',
667
- '_um_can_make_private_profile' => 1,
668
- '_um_can_access_private_profile' => 1,
669
- '_um_status' => 'approved',
670
- '_um_auto_approve_act' => 'redirect_profile',
671
- '_um_auto_approve_url' => '',
672
- '_um_login_email_activate' => '',
673
- '_um_checkmail_action' => '',
674
- '_um_checkmail_message' => '',
675
- '_um_checkmail_url' => '',
676
- '_um_url_email_activate' => '',
677
- '_um_pending_action' => '',
678
- '_um_pending_message' => '',
679
- '_um_pending_url' => '',
680
- *
681
- * */
682
-
683
-
684
- 'subscriber' => array(
685
- '_um_can_access_wpadmin' => 0,
686
- '_um_can_not_see_adminbar' => 1,
687
- '_um_can_edit_everyone' => 0,
688
- '_um_can_delete_everyone' => 0,
689
- '_um_can_edit_profile' => 1,
690
- '_um_can_delete_profile' => 1,
691
- '_um_after_login' => 'redirect_profile',
692
- '_um_after_logout' => 'redirect_home',
693
- '_um_default_homepage' => 1,
694
- '_um_can_view_all' => 1,
695
- '_um_can_make_private_profile' => 0,
696
- '_um_can_access_private_profile' => 0,
697
- '_um_status' => 'approved',
698
- '_um_auto_approve_act' => 'redirect_profile',
699
- ),
700
- 'author' => array(
701
- '_um_can_access_wpadmin' => 0,
702
- '_um_can_not_see_adminbar' => 1,
703
- '_um_can_edit_everyone' => 0,
704
- '_um_can_delete_everyone' => 0,
705
- '_um_can_edit_profile' => 1,
706
- '_um_can_delete_profile' => 1,
707
- '_um_after_login' => 'redirect_profile',
708
- '_um_after_logout' => 'redirect_home',
709
- '_um_default_homepage' => 1,
710
- '_um_can_view_all' => 1,
711
- '_um_can_make_private_profile' => 0,
712
- '_um_can_access_private_profile' => 0,
713
- '_um_status' => 'approved',
714
- '_um_auto_approve_act' => 'redirect_profile',
715
- ),
716
- 'contributor' => array(
717
- '_um_can_access_wpadmin' => 0,
718
- '_um_can_not_see_adminbar' => 1,
719
- '_um_can_edit_everyone' => 0,
720
- '_um_can_delete_everyone' => 0,
721
- '_um_can_edit_profile' => 1,
722
- '_um_can_delete_profile' => 1,
723
- '_um_after_login' => 'redirect_profile',
724
- '_um_after_logout' => 'redirect_home',
725
- '_um_default_homepage' => 1,
726
- '_um_can_view_all' => 1,
727
- '_um_can_make_private_profile' => 0,
728
- '_um_can_access_private_profile' => 0,
729
- '_um_status' => 'approved',
730
- '_um_auto_approve_act' => 'redirect_profile',
731
- ),
732
- 'editor' => array(
733
- '_um_can_access_wpadmin' => 0,
734
- '_um_can_not_see_adminbar' => 1,
735
- '_um_can_edit_everyone' => 0,
736
- '_um_can_delete_everyone' => 0,
737
- '_um_can_edit_profile' => 1,
738
- '_um_can_delete_profile' => 1,
739
- '_um_after_login' => 'redirect_profile',
740
- '_um_after_logout' => 'redirect_home',
741
- '_um_default_homepage' => 1,
742
- '_um_can_view_all' => 1,
743
- '_um_can_make_private_profile' => 0,
744
- '_um_can_access_private_profile' => 0,
745
- '_um_status' => 'approved',
746
- '_um_auto_approve_act' => 'redirect_profile',
747
- ),
748
- 'administrator' => array(
749
- '_um_can_access_wpadmin' => 1,
750
- '_um_can_not_see_adminbar' => 0,
751
- '_um_can_edit_everyone' => 1,
752
- '_um_can_delete_everyone' => 1,
753
- '_um_can_edit_profile' => 1,
754
- '_um_can_delete_profile' => 1,
755
- '_um_default_homepage' => 1,
756
- '_um_after_login' => 'redirect_admin',
757
- '_um_after_logout' => 'redirect_home',
758
- '_um_can_view_all' => 1,
759
- '_um_can_make_private_profile' => 1,
760
- '_um_can_access_private_profile' => 1,
761
- '_um_status' => 'approved',
762
- '_um_auto_approve_act' => 'redirect_profile',
763
- ),
764
- );
765
- }
766
-
767
-
768
- /**
769
- * Get UM Pages
770
- *
771
- * @return array
772
- */
773
- function get_core_pages() {
774
- $permalink = array();
775
- $core_pages = array_keys( $this->core_pages );
776
- if ( empty( $core_pages ) ) {
777
- return $permalink;
778
- }
779
-
780
- foreach ( $core_pages as $page_key ) {
781
- $page_option_key = UM()->options()->get_core_page_id( $page_key );
782
- $permalink[ $page_key ] = UM()->options()->get( $page_option_key );
783
- }
784
-
785
- return $permalink;
786
- }
787
-
788
-
789
- /**
790
- * @todo make config class not cycled
791
- */
792
- function set_core_page() {
793
- $this->core_pages = apply_filters( 'um_core_pages', array(
794
- 'user' => array( 'title' => __( 'User', 'ultimate-member' ) ),
795
- 'login' => array( 'title' => __( 'Login', 'ultimate-member' ) ),
796
- 'register' => array( 'title' => __( 'Register', 'ultimate-member' ) ),
797
- 'members' => array( 'title' => __( 'Members', 'ultimate-member' ) ),
798
- 'logout' => array( 'title' => __( 'Logout', 'ultimate-member' ) ),
799
- 'account' => array( 'title' => __( 'Account', 'ultimate-member' ) ),
800
- 'password-reset' => array( 'title' => __( 'Password Reset', 'ultimate-member' ) ),
801
- ) );
802
- }
803
- //end class
804
- }
805
- }
 
 
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
+ 'sub