Version Description
Download this release
Release Info
Developer | nsinelnikov |
Plugin | 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 +8 -2
- assets/js/um-members.min.js +1 -1
- assets/js/um-modal.js +1 -0
- assets/js/um-modal.min.js +1 -1
- assets/js/um-scripts.js +7 -0
- assets/js/um-scripts.min.js +1 -1
- includes/admin/core/class-admin-dragdrop.php +249 -249
- includes/admin/core/class-admin-metabox.php +2427 -2427
- includes/admin/core/class-admin-notices.php +2 -1
- includes/admin/core/class-admin-settings.php +3455 -3437
- includes/admin/templates/access/restrict_content.php +164 -164
- includes/class-config.php +807 -805
- includes/core/class-access.php +1435 -1276
- includes/core/class-external-integrations.php +26 -1
- includes/core/class-fields.php +3042 -4779
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
|
|
|
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="' +
|
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),
|
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 =
|
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 & 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 |
-
<?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 & Drop Photo', 'ultimate-member' );
|
1989 |
-
}
|
1990 |
-
if ( $this->set_field_type == 'file' ) {
|
1991 |
-
$value = __( 'Drag & 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 & 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 |
+
<?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 & Drop Photo', 'ultimate-member' );
|
1989 |
+
}
|
1990 |
+
if ( $this->set_field_type == 'file' ) {
|
1991 |
+
$value = __( 'Drag & 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 |
-
|
|
|
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' => '
|
507 |
-
'type' => '
|
508 |
-
'label' => __( '
|
509 |
-
'tooltip' => __( '
|
510 |
-
),
|
511 |
-
array(
|
512 |
-
'id'
|
513 |
-
'type'
|
514 |
-
'label'
|
515 |
-
'tooltip'
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
'
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
array(
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
array(
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
array(
|
588 |
-
'id'
|
589 |
-
'type'
|
590 |
-
'
|
591 |
-
|
592 |
-
|
593 |
-
'
|
594 |
-
'
|
595 |
-
'
|
596 |
-
),
|
597 |
-
array(
|
598 |
-
'id' => '
|
599 |
-
'type' => 'multi_checkbox',
|
600 |
-
'label' => __( 'Enable the "Content Restriction" settings for
|
601 |
-
'tooltip' => __( 'Check
|
602 |
-
'options' => $
|
603 |
-
'columns' => 3,
|
604 |
-
'value' => $
|
605 |
-
'default' => UM()->options()->get_default( '
|
606 |
-
),
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
'
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
);
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
*
|
929 |
-
*
|
930 |
-
*
|
931 |
-
*
|
932 |
-
*
|
933 |
-
*
|
934 |
-
* }
|
935 |
-
*
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
'
|
965 |
-
|
966 |
-
|
967 |
-
'
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
'
|
994 |
-
|
995 |
-
|
996 |
-
'
|
997 |
-
|
998 |
-
|
999 |
-
'
|
1000 |
-
'
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
'
|
1006 |
-
'
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
'
|
1012 |
-
'
|
1013 |
-
|
1014 |
-
|
1015 |
-
'
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
),
|
1025 |
-
'
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
'
|
1037 |
-
|
1038 |
-
|
1039 |
-
'
|
1040 |
-
|
1041 |
-
|
1042 |
-
'
|
1043 |
-
'
|
1044 |
-
|
1045 |
-
|
1046 |
-
'
|
1047 |
-
'
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
'
|
1054 |
-
'
|
1055 |
-
'label' => __( '
|
1056 |
-
'tooltip' => __( '
|
1057 |
-
'
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
'
|
1066 |
-
'
|
1067 |
-
'
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
'
|
1078 |
-
'
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
'
|
1084 |
-
'
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
'
|
1090 |
-
'
|
1091 |
-
|
1092 |
-
|
1093 |
-
'
|
1094 |
-
|
1095 |
-
),
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
'
|
1100 |
-
'
|
1101 |
-
'
|
1102 |
-
'
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
'
|
1109 |
-
'
|
1110 |
-
'
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
'
|
1118 |
-
|
1119 |
-
|
1120 |
-
'
|
1121 |
-
|
1122 |
-
|
1123 |
-
'
|
1124 |
-
'
|
1125 |
-
|
1126 |
-
|
1127 |
-
'
|
1128 |
-
|
1129 |
-
|
1130 |
-
'
|
1131 |
-
|
1132 |
-
|
1133 |
-
'
|
1134 |
-
'
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
'
|
1140 |
-
'
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
'
|
1146 |
-
'
|
1147 |
-
|
1148 |
-
|
1149 |
-
'
|
1150 |
-
|
1151 |
-
|
1152 |
-
'
|
1153 |
-
|
1154 |
-
|
1155 |
-
'
|
1156 |
-
'
|
1157 |
-
|
1158 |
-
|
1159 |
-
),
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
'
|
1171 |
-
'
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
'
|
1180 |
-
'
|
1181 |
-
|
1182 |
-
|
1183 |
-
'
|
1184 |
-
|
1185 |
-
|
1186 |
-
'
|
1187 |
-
'
|
1188 |
-
'
|
1189 |
-
'
|
1190 |
-
'
|
1191 |
-
),
|
1192 |
-
array(
|
1193 |
-
'id' => '
|
1194 |
-
'type' => 'multi_text',
|
1195 |
-
'size' => 'small',
|
1196 |
-
'label' => __( '
|
1197 |
-
'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each
|
1198 |
-
'validate' => 'numeric',
|
1199 |
-
'add_text' => __( 'Add New Size', 'ultimate-member' ),
|
1200 |
-
'show_default_number' => 1,
|
1201 |
-
),
|
1202 |
-
array(
|
1203 |
-
'id'
|
1204 |
-
'type'
|
1205 |
-
'
|
1206 |
-
'
|
1207 |
-
|
1208 |
-
|
1209 |
-
'
|
1210 |
-
'
|
1211 |
-
|
1212 |
-
|
1213 |
-
'
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
'
|
1220 |
-
'
|
1221 |
-
'
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
'
|
1228 |
-
'
|
1229 |
-
'
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
'
|
1257 |
-
'
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
'
|
1262 |
-
'
|
1263 |
-
'
|
1264 |
-
|
1265 |
-
|
1266 |
-
'
|
1267 |
-
'
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
'
|
1292 |
-
'
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
'
|
1298 |
-
'
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
'
|
1309 |
-
'
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
'
|
1322 |
-
'
|
1323 |
-
'
|
1324 |
-
'tooltip' => __( '
|
1325 |
-
'
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
'
|
1331 |
-
'
|
1332 |
-
'
|
1333 |
-
'
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
'
|
1339 |
-
'
|
1340 |
-
'
|
1341 |
-
'
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
'
|
1347 |
-
|
1348 |
-
|
1349 |
-
'
|
1350 |
-
'
|
1351 |
-
'
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
'
|
1360 |
-
'
|
1361 |
-
'
|
1362 |
-
|
1363 |
-
|
1364 |
-
'
|
1365 |
-
|
1366 |
-
|
1367 |
-
'
|
1368 |
-
'
|
1369 |
-
'
|
1370 |
-
'
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
'
|
1375 |
-
'
|
1376 |
-
'
|
1377 |
-
'
|
1378 |
-
'
|
1379 |
-
|
1380 |
-
|
1381 |
-
),
|
1382 |
-
array(
|
1383 |
-
'id' => '
|
1384 |
-
'type' => 'media',
|
1385 |
-
'
|
1386 |
-
'
|
1387 |
-
'
|
1388 |
-
'
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
'
|
1394 |
-
'
|
1395 |
-
'
|
1396 |
-
'
|
1397 |
-
|
1398 |
-
|
1399 |
-
'
|
1400 |
-
|
1401 |
-
|
1402 |
-
'
|
1403 |
-
'
|
1404 |
-
'
|
1405 |
-
'
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
'
|
1410 |
-
'
|
1411 |
-
'
|
1412 |
-
'
|
1413 |
-
|
1414 |
-
|
1415 |
-
'
|
1416 |
-
|
1417 |
-
|
1418 |
-
'
|
1419 |
-
'
|
1420 |
-
'
|
1421 |
-
'
|
1422 |
-
'
|
1423 |
-
),
|
1424 |
-
array(
|
1425 |
-
'id' => '
|
1426 |
-
'type' => 'select',
|
1427 |
-
'label' => __( 'Profile Cover
|
1428 |
-
'
|
1429 |
-
'
|
1430 |
-
'
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
'
|
1437 |
-
'
|
1438 |
-
|
1439 |
-
|
1440 |
-
'
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
'
|
1448 |
-
|
1449 |
-
|
1450 |
-
'
|
1451 |
-
'
|
1452 |
-
|
1453 |
-
|
1454 |
-
'
|
1455 |
-
|
1456 |
-
|
1457 |
-
'
|
1458 |
-
'
|
1459 |
-
|
1460 |
-
|
1461 |
-
'
|
1462 |
-
|
1463 |
-
|
1464 |
-
'
|
1465 |
-
'
|
1466 |
-
|
1467 |
-
|
1468 |
-
'
|
1469 |
-
|
1470 |
-
|
1471 |
-
'
|
1472 |
-
|
1473 |
-
|
1474 |
-
'
|
1475 |
-
'
|
1476 |
-
|
1477 |
-
|
1478 |
-
'
|
1479 |
-
'
|
1480 |
-
'
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
'
|
1485 |
-
'
|
1486 |
-
'
|
1487 |
-
'
|
1488 |
-
'
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
'
|
1496 |
-
'
|
1497 |
-
'
|
1498 |
-
'
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
'
|
1503 |
-
|
1504 |
-
|
1505 |
-
'
|
1506 |
-
'
|
1507 |
-
'
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
'
|
1530 |
-
'
|
1531 |
-
'
|
1532 |
-
'tooltip' => __( '
|
1533 |
-
'
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
'
|
1539 |
-
'
|
1540 |
-
'
|
1541 |
-
'
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
'
|
1547 |
-
|
1548 |
-
|
1549 |
-
'
|
1550 |
-
'
|
1551 |
-
'
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
'
|
1560 |
-
|
1561 |
-
|
1562 |
-
'
|
1563 |
-
'
|
1564 |
-
'
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
'
|
1573 |
-
'
|
1574 |
-
'
|
1575 |
-
|
1576 |
-
|
1577 |
-
'
|
1578 |
-
|
1579 |
-
|
1580 |
-
'
|
1581 |
-
'
|
1582 |
-
'
|
1583 |
-
'
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
'
|
1588 |
-
'
|
1589 |
-
'
|
1590 |
-
'
|
1591 |
-
'
|
1592 |
-
'
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
'
|
1597 |
-
'
|
1598 |
-
'
|
1599 |
-
'default'
|
1600 |
-
'
|
1601 |
-
'
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
'
|
1610 |
-
'
|
1611 |
-
'
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
'
|
1620 |
-
'
|
1621 |
-
'
|
1622 |
-
'tooltip' => __( '
|
1623 |
-
'
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
'
|
1629 |
-
'
|
1630 |
-
'
|
1631 |
-
'
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
'
|
1637 |
-
|
1638 |
-
|
1639 |
-
'
|
1640 |
-
'
|
1641 |
-
'
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
'
|
1650 |
-
|
1651 |
-
|
1652 |
-
'
|
1653 |
-
'
|
1654 |
-
'
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
'
|
1663 |
-
'
|
1664 |
-
'
|
1665 |
-
|
1666 |
-
|
1667 |
-
'
|
1668 |
-
|
1669 |
-
|
1670 |
-
'
|
1671 |
-
'
|
1672 |
-
'
|
1673 |
-
'
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
'
|
1678 |
-
'
|
1679 |
-
'
|
1680 |
-
'
|
1681 |
-
'
|
1682 |
-
'
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
'
|
1687 |
-
'
|
1688 |
-
'
|
1689 |
-
'
|
1690 |
-
|
1691 |
-
|
1692 |
-
'
|
1693 |
-
|
1694 |
-
|
1695 |
-
'
|
1696 |
-
'
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
'
|
1725 |
-
|
1726 |
-
|
1727 |
-
'
|
1728 |
-
'
|
1729 |
-
|
1730 |
-
),
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
'
|
1735 |
-
'
|
1736 |
-
'
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
'
|
1746 |
-
'
|
1747 |
-
|
1748 |
-
|
1749 |
-
'
|
1750 |
-
|
1751 |
-
|
1752 |
-
),
|
1753 |
-
),
|
1754 |
-
|
1755 |
-
|
1756 |
-
'
|
1757 |
-
'
|
1758 |
-
'
|
1759 |
-
'
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
array(
|
1767 |
-
'
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
$
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
}
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
*
|
1931 |
-
*
|
1932 |
-
*
|
1933 |
-
* @
|
1934 |
-
*
|
1935 |
-
*
|
1936 |
-
*
|
1937 |
-
*
|
1938 |
-
*
|
1939 |
-
*
|
1940 |
-
*
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
*
|
1949 |
-
*
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
*
|
1986 |
-
*
|
1987 |
-
*
|
1988 |
-
* @
|
1989 |
-
* @
|
1990 |
-
*
|
1991 |
-
*
|
1992 |
-
* {
|
1993 |
-
*
|
1994 |
-
*
|
1995 |
-
*
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
*
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
$
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
*
|
2154 |
-
*
|
2155 |
-
* @
|
2156 |
-
* @
|
2157 |
-
* @
|
2158 |
-
*
|
2159 |
-
*
|
2160 |
-
* @
|
2161 |
-
*
|
2162 |
-
*
|
2163 |
-
*
|
2164 |
-
*
|
2165 |
-
*
|
2166 |
-
*
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
*
|
2182 |
-
*
|
2183 |
-
*
|
2184 |
-
*
|
2185 |
-
*
|
2186 |
-
*
|
2187 |
-
*
|
2188 |
-
*
|
2189 |
-
|
2190 |
-
|
2191 |
-
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
|
2197 |
-
|
2198 |
-
|
2199 |
-
|
2200 |
-
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
-
|
2208 |
-
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
|
2247 |
-
if (
|
2248 |
-
|
2249 |
-
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
2257 |
-
|
2258 |
-
|
2259 |
-
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
|
2294 |
-
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
-
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
-
|
2323 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
|
2329 |
-
|
2330 |
-
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
)
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
|
2433 |
-
|
2434 |
-
|
2435 |
-
|
2436 |
-
|
2437 |
-
|
2438 |
-
|
2439 |
-
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
-
|
2445 |
-
|
2446 |
-
|
2447 |
-
|
2448 |
-
|
2449 |
-
|
2450 |
-
|
2451 |
-
|
2452 |
-
|
2453 |
-
|
2454 |
-
|
2455 |
-
|
2456 |
-
|
2457 |
-
|
2458 |
-
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
-
|
2465 |
-
|
2466 |
-
|
2467 |
-
|
2468 |
-
|
2469 |
-
|
2470 |
-
|
2471 |
-
$
|
2472 |
-
|
2473 |
-
|
2474 |
-
|
2475 |
-
|
2476 |
-
|
2477 |
-
|
2478 |
-
|
2479 |
-
|
2480 |
-
|
2481 |
-
|
2482 |
-
|
2483 |
-
|
2484 |
-
|
2485 |
-
|
2486 |
-
|
2487 |
-
|
2488 |
-
$
|
2489 |
-
$
|
2490 |
-
|
2491 |
-
|
2492 |
-
|
2493 |
-
|
2494 |
-
|
2495 |
-
|
2496 |
-
}
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
|
2502 |
-
|
2503 |
-
|
2504 |
-
|
2505 |
-
|
2506 |
-
|
2507 |
-
$
|
2508 |
-
|
2509 |
-
|
2510 |
-
'
|
2511 |
-
'
|
2512 |
-
'
|
2513 |
-
|
2514 |
-
|
2515 |
-
|
2516 |
-
|
2517 |
-
|
2518 |
-
|
2519 |
-
$
|
2520 |
-
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
)
|
2527 |
-
|
2528 |
-
|
2529 |
-
|
2530 |
-
|
2531 |
-
|
2532 |
-
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
|
2544 |
-
|
2545 |
-
|
2546 |
-
|
2547 |
-
|
2548 |
-
|
2549 |
-
|
2550 |
-
|
2551 |
-
|
2552 |
-
|
2553 |
-
|
2554 |
-
|
2555 |
-
|
2556 |
-
|
2557 |
-
|
2558 |
-
|
2559 |
-
|
2560 |
-
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
|
2577 |
-
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
|
2589 |
-
|
2590 |
-
|
2591 |
-
|
2592 |
-
*
|
2593 |
-
|
2594 |
-
|
2595 |
-
|
2596 |
-
|
2597 |
-
|
2598 |
-
|
2599 |
-
|
2600 |
-
|
2601 |
-
|
2602 |
-
|
2603 |
-
|
2604 |
-
|
2605 |
-
|
2606 |
-
|
2607 |
-
|
2608 |
-
|
2609 |
-
|
2610 |
-
|
2611 |
-
|
2612 |
-
|
2613 |
-
array(
|
2614 |
-
'id'
|
2615 |
-
'type'
|
2616 |
-
'
|
2617 |
-
|
2618 |
-
|
2619 |
-
'
|
2620 |
-
'
|
2621 |
-
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
-
|
2626 |
-
|
2627 |
-
|
2628 |
-
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
|
2635 |
-
|
2636 |
-
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
2641 |
-
|
2642 |
-
|
2643 |
-
|
2644 |
-
|
2645 |
-
|
2646 |
-
|
2647 |
-
|
2648 |
-
|
2649 |
-
|
2650 |
-
|
2651 |
-
|
2652 |
-
|
2653 |
-
|
2654 |
-
|
2655 |
-
|
2656 |
-
|
2657 |
-
|
2658 |
-
|
2659 |
-
|
2660 |
-
|
2661 |
-
|
2662 |
-
|
2663 |
-
|
2664 |
-
|
2665 |
-
|
2666 |
-
|
2667 |
-
|
2668 |
-
|
2669 |
-
|
2670 |
-
|
2671 |
-
|
2672 |
-
|
2673 |
-
|
2674 |
-
|
2675 |
-
|
2676 |
-
|
2677 |
-
|
2678 |
-
|
2679 |
-
|
2680 |
-
|
2681 |
-
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
$
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
$
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
$
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
|
2711 |
-
|
2712 |
-
|
2713 |
-
|
2714 |
-
|
2715 |
-
|
2716 |
-
|
2717 |
-
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
|
2722 |
-
|
2723 |
-
|
2724 |
-
|
2725 |
-
|
2726 |
-
|
2727 |
-
|
2728 |
-
|
2729 |
-
$license_status = 'license-' . $class . '-notice';
|
2730 |
-
|
2731 |
-
break;
|
2732 |
-
|
2733 |
-
case '
|
2734 |
-
|
2735 |
-
$class = 'error';
|
2736 |
-
$messages[] = __( '
|
2737 |
-
|
2738 |
-
$license_status = 'license-' . $class . '-notice';
|
2739 |
-
|
2740 |
-
|
2741 |
-
|
2742 |
-
|
2743 |
-
|
2744 |
-
$
|
2745 |
-
$messages[] = sprintf( __( '
|
2746 |
-
|
2747 |
-
$license_status = 'license-' . $class . '-notice';
|
2748 |
-
|
2749 |
-
|
2750 |
-
|
2751 |
-
|
2752 |
-
|
2753 |
-
|
2754 |
-
|
2755 |
-
|
2756 |
-
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
|
2762 |
-
|
2763 |
-
|
2764 |
-
|
2765 |
-
|
2766 |
-
|
2767 |
-
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
-
|
2772 |
-
|
2773 |
-
|
2774 |
-
|
2775 |
-
|
2776 |
-
|
2777 |
-
|
2778 |
-
|
2779 |
-
|
2780 |
-
|
2781 |
-
|
2782 |
-
|
2783 |
-
|
2784 |
-
|
2785 |
-
|
2786 |
-
|
2787 |
-
|
2788 |
-
|
2789 |
-
|
2790 |
-
|
2791 |
-
|
2792 |
-
|
2793 |
-
|
2794 |
-
|
2795 |
-
$
|
2796 |
-
|
2797 |
-
|
2798 |
-
|
2799 |
-
|
2800 |
-
|
2801 |
-
$
|
2802 |
-
|
2803 |
-
|
2804 |
-
|
2805 |
-
|
2806 |
-
|
2807 |
-
$
|
2808 |
-
|
2809 |
-
|
2810 |
-
|
2811 |
-
|
2812 |
-
|
2813 |
-
|
2814 |
-
|
2815 |
-
|
2816 |
-
|
2817 |
-
|
2818 |
-
|
2819 |
-
|
2820 |
-
|
2821 |
-
|
2822 |
-
|
2823 |
-
|
2824 |
-
|
2825 |
-
|
2826 |
-
|
2827 |
-
|
2828 |
-
|
2829 |
-
|
2830 |
-
|
2831 |
-
|
2832 |
-
|
2833 |
-
|
2834 |
-
|
2835 |
-
|
2836 |
-
|
2837 |
-
|
2838 |
-
|
2839 |
-
$license_status = 'license-' . $class . '-notice';
|
2840 |
-
|
2841 |
-
break;
|
2842 |
-
|
2843 |
-
case '
|
2844 |
-
|
2845 |
-
$class = 'error';
|
2846 |
-
$messages[] = __( '
|
2847 |
-
|
2848 |
-
$license_status = 'license-' . $class . '-notice';
|
2849 |
-
|
2850 |
-
|
2851 |
-
|
2852 |
-
|
2853 |
-
|
2854 |
-
$class = '
|
2855 |
-
|
2856 |
-
|
2857 |
-
$
|
2858 |
-
|
2859 |
-
|
2860 |
-
|
2861 |
-
|
2862 |
-
|
2863 |
-
|
2864 |
-
|
2865 |
-
|
2866 |
-
|
2867 |
-
|
2868 |
-
|
2869 |
-
|
2870 |
-
|
2871 |
-
|
2872 |
-
|
2873 |
-
|
2874 |
-
|
2875 |
-
|
2876 |
-
|
2877 |
-
|
2878 |
-
|
2879 |
-
|
2880 |
-
|
2881 |
-
|
2882 |
-
|
2883 |
-
|
2884 |
-
|
2885 |
-
|
2886 |
-
|
2887 |
-
|
2888 |
-
|
2889 |
-
|
2890 |
-
|
2891 |
-
|
2892 |
-
|
2893 |
-
|
2894 |
-
|
2895 |
-
|
2896 |
-
|
2897 |
-
|
2898 |
-
|
2899 |
-
|
2900 |
-
|
2901 |
-
|
2902 |
-
|
2903 |
-
|
2904 |
-
|
2905 |
-
|
2906 |
-
|
2907 |
-
|
2908 |
-
|
2909 |
-
|
2910 |
-
|
2911 |
-
|
2912 |
-
|
2913 |
-
|
2914 |
-
|
2915 |
-
|
2916 |
-
|
2917 |
-
|
2918 |
-
|
2919 |
-
|
2920 |
-
|
2921 |
-
|
2922 |
-
|
2923 |
-
|
2924 |
-
|
2925 |
-
|
2926 |
-
|
2927 |
-
|
2928 |
-
|
2929 |
-
|
2930 |
-
|
2931 |
-
|
2932 |
-
|
2933 |
-
|
2934 |
-
|
2935 |
-
|
2936 |
-
|
2937 |
-
|
2938 |
-
|
2939 |
-
|
2940 |
-
|
2941 |
-
|
2942 |
-
|
2943 |
-
|
2944 |
-
|
2945 |
-
|
2946 |
-
|
2947 |
-
|
2948 |
-
|
2949 |
-
|
2950 |
-
|
2951 |
-
|
2952 |
-
|
2953 |
-
|
2954 |
-
|
2955 |
-
|
2956 |
-
|
2957 |
-
|
2958 |
-
|
2959 |
-
$
|
2960 |
-
|
2961 |
-
|
2962 |
-
|
2963 |
-
|
2964 |
-
|
2965 |
-
|
2966 |
-
|
2967 |
-
|
2968 |
-
|
2969 |
-
|
2970 |
-
|
2971 |
-
|
2972 |
-
|
2973 |
-
|
2974 |
-
|
2975 |
-
|
2976 |
-
|
2977 |
-
|
2978 |
-
|
2979 |
-
|
2980 |
-
|
2981 |
-
|
2982 |
-
|
2983 |
-
|
2984 |
-
|
2985 |
-
|
2986 |
-
|
2987 |
-
|
2988 |
-
|
2989 |
-
|
2990 |
-
|
2991 |
-
|
2992 |
-
|
2993 |
-
|
2994 |
-
|
2995 |
-
|
2996 |
-
|
2997 |
-
|
2998 |
-
|
2999 |
-
|
3000 |
-
|
3001 |
-
|
3002 |
-
|
3003 |
-
|
3004 |
-
|
3005 |
-
|
3006 |
-
|
3007 |
-
|
3008 |
-
|
3009 |
-
|
3010 |
-
|
3011 |
-
|
3012 |
-
|
3013 |
-
|
3014 |
-
|
3015 |
-
|
3016 |
-
|
3017 |
-
|
3018 |
-
|
3019 |
-
|
3020 |
-
|
3021 |
-
|
3022 |
-
|
3023 |
-
|
3024 |
-
|
3025 |
-
|
3026 |
-
|
3027 |
-
<?php
|
3028 |
-
|
3029 |
-
|
3030 |
-
|
3031 |
-
|
3032 |
-
|
3033 |
-
|
3034 |
-
|
3035 |
-
<?php $
|
3036 |
-
|
3037 |
-
|
3038 |
-
|
3039 |
-
|
3040 |
-
|
3041 |
-
'
|
3042 |
-
|
3043 |
-
|
3044 |
-
|
3045 |
-
);
|
3046 |
-
|
3047 |
-
|
3048 |
-
|
3049 |
-
|
3050 |
-
$
|
3051 |
-
|
3052 |
-
|
3053 |
-
|
3054 |
-
|
3055 |
-
|
3056 |
-
|
3057 |
-
|
3058 |
-
|
3059 |
-
|
3060 |
-
|
3061 |
-
|
3062 |
-
|
3063 |
-
|
3064 |
-
|
3065 |
-
|
3066 |
-
|
3067 |
-
|
3068 |
-
|
3069 |
-
|
3070 |
-
|
3071 |
-
|
3072 |
-
|
3073 |
-
|
3074 |
-
|
3075 |
-
|
3076 |
-
|
3077 |
-
|
3078 |
-
|
3079 |
-
|
3080 |
-
|
3081 |
-
|
3082 |
-
|
3083 |
-
|
3084 |
-
|
3085 |
-
|
3086 |
-
|
3087 |
-
|
3088 |
-
|
3089 |
-
|
3090 |
-
|
3091 |
-
|
3092 |
-
|
3093 |
-
|
3094 |
-
|
3095 |
-
|
3096 |
-
|
3097 |
-
|
3098 |
-
|
3099 |
-
|
3100 |
-
|
3101 |
-
|
3102 |
-
|
3103 |
-
|
3104 |
-
|
3105 |
-
|
3106 |
-
|
3107 |
-
*
|
3108 |
-
*
|
3109 |
-
*
|
3110 |
-
*
|
3111 |
-
*
|
3112 |
-
*
|
3113 |
-
*
|
3114 |
-
|
3115 |
-
|
3116 |
-
|
3117 |
-
|
3118 |
-
|
3119 |
-
|
3120 |
-
|
3121 |
-
|
3122 |
-
|
3123 |
-
|
3124 |
-
|
3125 |
-
|
3126 |
-
|
3127 |
-
|
3128 |
-
|
3129 |
-
|
3130 |
-
|
3131 |
-
|
3132 |
-
|
3133 |
-
|
3134 |
-
|
3135 |
-
|
3136 |
-
|
3137 |
-
|
3138 |
-
|
3139 |
-
|
3140 |
-
|
3141 |
-
|
3142 |
-
|
3143 |
-
|
3144 |
-
|
3145 |
-
|
3146 |
-
|
3147 |
-
<?php
|
3148 |
-
|
3149 |
-
<?php
|
3150 |
-
Redirect to
|
3151 |
-
<?php
|
3152 |
-
|
3153 |
-
<?php if(
|
3154 |
-
|
3155 |
-
<?php
|
3156 |
-
|
3157 |
-
|
3158 |
-
|
3159 |
-
|
3160 |
-
|
3161 |
-
<?php
|
3162 |
-
<?php
|
3163 |
-
|
3164 |
-
|
3165 |
-
<?php
|
3166 |
-
|
3167 |
-
<?php
|
3168 |
-
<?php
|
3169 |
-
|
3170 |
-
<?php
|
3171 |
-
<?php
|
3172 |
-
|
3173 |
-
<?php } ?>
|
3174 |
-
|
3175 |
-
|
3176 |
-
|
3177 |
-
|
3178 |
-
|
3179 |
-
|
3180 |
-
|
3181 |
-
|
3182 |
-
|
3183 |
-
|
3184 |
-
|
3185 |
-
|
3186 |
-
|
3187 |
-
|
3188 |
-
|
3189 |
-
|
3190 |
-
|
3191 |
-
|
3192 |
-
|
3193 |
-
|
3194 |
-
|
3195 |
-
|
3196 |
-
|
3197 |
-
|
3198 |
-
|
3199 |
-
|
3200 |
-
|
3201 |
-
|
3202 |
-
|
3203 |
-
|
3204 |
-
|
3205 |
-
|
3206 |
-
|
3207 |
-
|
3208 |
-
|
3209 |
-
|
3210 |
-
|
3211 |
-
|
3212 |
-
|
3213 |
-
|
3214 |
-
|
3215 |
-
|
3216 |
-
|
3217 |
-
|
3218 |
-
|
3219 |
-
|
3220 |
-
|
3221 |
-
|
3222 |
-
|
3223 |
-
|
3224 |
-
|
3225 |
-
|
3226 |
-
|
3227 |
-
|
3228 |
-
|
3229 |
-
|
3230 |
-
|
3231 |
-
|
3232 |
-
|
3233 |
-
|
3234 |
-
|
3235 |
-
|
3236 |
-
}
|
3237 |
-
|
3238 |
-
|
3239 |
-
|
3240 |
-
|
3241 |
-
|
3242 |
-
|
3243 |
-
|
3244 |
-
|
3245 |
-
|
3246 |
-
|
3247 |
-
|
3248 |
-
|
3249 |
-
|
3250 |
-
|
3251 |
-
|
3252 |
-
|
3253 |
-
|
3254 |
-
|
3255 |
-
|
3256 |
-
|
3257 |
-
|
3258 |
-
|
3259 |
-
|
3260 |
-
|
3261 |
-
|
3262 |
-
|
3263 |
-
|
3264 |
-
|
3265 |
-
|
3266 |
-
|
3267 |
-
|
3268 |
-
|
3269 |
-
|
3270 |
-
|
3271 |
-
|
3272 |
-
|
3273 |
-
|
3274 |
-
|
3275 |
-
|
3276 |
-
|
3277 |
-
|
3278 |
-
|
3279 |
-
|
3280 |
-
|
3281 |
-
|
3282 |
-
|
3283 |
-
|
3284 |
-
|
3285 |
-
|
3286 |
-
|
3287 |
-
|
3288 |
-
|
3289 |
-
|
3290 |
-
|
3291 |
-
|
3292 |
-
|
3293 |
-
|
3294 |
-
|
3295 |
-
|
3296 |
-
|
3297 |
-
|
3298 |
-
|
3299 |
-
|
3300 |
-
|
3301 |
-
|
3302 |
-
|
3303 |
-
|
3304 |
-
|
3305 |
-
|
3306 |
-
|
3307 |
-
|
3308 |
-
|
3309 |
-
|
3310 |
-
|
3311 |
-
|
3312 |
-
|
3313 |
-
|
3314 |
-
|
3315 |
-
|
3316 |
-
|
3317 |
-
|
3318 |
-
|
3319 |
-
|
3320 |
-
|
3321 |
-
|
3322 |
-
|
3323 |
-
|
3324 |
-
|
3325 |
-
|
3326 |
-
|
3327 |
-
|
3328 |
-
|
3329 |
-
|
3330 |
-
|
3331 |
-
|
3332 |
-
|
3333 |
-
|
3334 |
-
|
3335 |
-
|
3336 |
-
|
3337 |
-
|
3338 |
-
|
3339 |
-
|
3340 |
-
|
3341 |
-
|
3342 |
-
|
3343 |
-
|
3344 |
-
|
3345 |
-
|
3346 |
-
|
3347 |
-
|
3348 |
-
|
3349 |
-
|
3350 |
-
|
3351 |
-
|
3352 |
-
|
3353 |
-
|
3354 |
-
|
3355 |
-
|
3356 |
-
|
3357 |
-
|
3358 |
-
|
3359 |
-
|
3360 |
-
|
3361 |
-
|
3362 |
-
|
3363 |
-
|
3364 |
-
|
3365 |
-
*
|
3366 |
-
|
3367 |
-
|
3368 |
-
|
3369 |
-
|
3370 |
-
|
3371 |
-
|
3372 |
-
|
3373 |
-
|
3374 |
-
|
3375 |
-
|
3376 |
-
|
3377 |
-
|
3378 |
-
|
3379 |
-
|
3380 |
-
|
3381 |
-
|
3382 |
-
*
|
3383 |
-
*
|
3384 |
-
*
|
3385 |
-
* @
|
3386 |
-
|
3387 |
-
|
3388 |
-
|
3389 |
-
|
3390 |
-
|
3391 |
-
|
3392 |
-
|
3393 |
-
|
3394 |
-
|
3395 |
-
|
3396 |
-
|
3397 |
-
|
3398 |
-
|
3399 |
-
|
3400 |
-
|
3401 |
-
|
3402 |
-
|
3403 |
-
|
3404 |
-
|
3405 |
-
|
3406 |
-
* @
|
3407 |
-
|
3408 |
-
|
3409 |
-
|
3410 |
-
|
3411 |
-
|
3412 |
-
|
3413 |
-
|
3414 |
-
|
3415 |
-
|
3416 |
-
|
3417 |
-
$
|
3418 |
-
|
3419 |
-
|
3420 |
-
|
3421 |
-
|
3422 |
-
|
3423 |
-
|
3424 |
-
|
3425 |
-
|
3426 |
-
|
3427 |
-
|
3428 |
-
|
3429 |
-
|
3430 |
-
|
3431 |
-
|
3432 |
-
}
|
3433 |
-
|
3434 |
-
|
3435 |
-
|
3436 |
-
|
3437 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ) ? '' : '§ion=' . $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 |
-
'
|
516 |
-
'
|
517 |
-
'
|
518 |
-
'
|
519 |
-
'
|
520 |
-
'
|
521 |
-
'
|
522 |
-
'
|
523 |
-
'
|
524 |
-
'
|
525 |
-
'
|
526 |
-
'
|
527 |
-
'
|
528 |
-
'
|
529 |
-
'
|
530 |
-
'
|
531 |
-
'
|
532 |
-
'
|
533 |
-
'
|
534 |
-
'
|
535 |
-
'
|
536 |
-
'
|
537 |
-
'
|
538 |
-
'
|
539 |
-
'
|
540 |
-
'
|
541 |
-
'
|
542 |
-
'
|
543 |
-
'
|
544 |
-
'
|
545 |
-
'
|
546 |
-
'
|
547 |
-
'
|
548 |
-
'
|
549 |
-
'
|
550 |
-
'
|
551 |
-
'
|
552 |
-
'
|
553 |
-
'
|
554 |
-
'
|
555 |
-
'
|
556 |
-
'
|
557 |
-
'
|
558 |
-
'
|
559 |
-
'
|
560 |
-
'
|
561 |
-
'
|
562 |
-
'
|
563 |
-
'
|
564 |
-
'
|
565 |
-
'
|
566 |
-
'
|
567 |
-
'
|
568 |
-
'
|
569 |
-
'
|
570 |
-
'
|
571 |
-
'
|
572 |
-
'
|
573 |
-
'
|
574 |
-
'
|
575 |
-
'
|
576 |
-
'
|
577 |
-
'
|
578 |
-
'
|
579 |
-
'
|
580 |
-
'
|
581 |
-
'
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
$this->settings_defaults[ $key ] = $notification['
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
*
|
622 |
-
*
|
623 |
-
* @
|
624 |
-
* @
|
625 |
-
*
|
626 |
-
* @
|
627 |
-
* ["
|
628 |
-
* @
|
629 |
-
*
|
630 |
-
* @
|
631 |
-
* <?php
|
632 |
-
*
|
633 |
-
*
|
634 |
-
*
|
635 |
-
*
|
636 |
-
*
|
637 |
-
*
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
$this->
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
*
|
650 |
-
|
651 |
-
|
652 |
-
'
|
653 |
-
'
|
654 |
-
'
|
655 |
-
'
|
656 |
-
'
|
657 |
-
'
|
658 |
-
'
|
659 |
-
'
|
660 |
-
'
|
661 |
-
'
|
662 |
-
'
|
663 |
-
'
|
664 |
-
'
|
665 |
-
'
|
666 |
-
'
|
667 |
-
'
|
668 |
-
'
|
669 |
-
'
|
670 |
-
'
|
671 |
-
'
|
672 |
-
'
|
673 |
-
'
|
674 |
-
'
|
675 |
-
'
|
676 |
-
'
|
677 |
-
'
|
678 |
-
'
|
679 |
-
'
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
'
|
688 |
-
'
|
689 |
-
'
|
690 |
-
'
|
691 |
-
'
|
692 |
-
'
|
693 |
-
'
|
694 |
-
'
|
695 |
-
'
|
696 |
-
'
|
697 |
-
'
|
698 |
-
'
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
'
|
704 |
-
'
|
705 |
-
'
|
706 |
-
'
|
707 |
-
'
|
708 |
-
'
|
709 |
-
'
|
710 |
-
'
|
711 |
-
'
|
712 |
-
'
|
713 |
-
'
|
714 |
-
'
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
'
|
720 |
-
'
|
721 |
-
'
|
722 |
-
'
|
723 |
-
'
|
724 |
-
'
|
725 |
-
'
|
726 |
-
'
|
727 |
-
'
|
728 |
-
'
|
729 |
-
'
|
730 |
-
'
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
'
|
736 |
-
'
|
737 |
-
'
|
738 |
-
'
|
739 |
-
'
|
740 |
-
'
|
741 |
-
'
|
742 |
-
'
|
743 |
-
'
|
744 |
-
'
|
745 |
-
'
|
746 |
-
'
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
'
|
752 |
-
'
|
753 |
-
'
|
754 |
-
'
|
755 |
-
'
|
756 |
-
'
|
757 |
-
'
|
758 |
-
'
|
759 |
-
'
|
760 |
-
'
|
761 |
-
'
|
762 |
-
'
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
*
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
'
|
797 |
-
'
|
798 |
-
'
|
799 |
-
'
|
800 |
-
'
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace um;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\Config' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Config
|
13 |
+
*
|
14 |
+
* Class with global variables for UM
|
15 |
+
*
|
16 |
+
* @package um
|
17 |
+
*/
|
18 |
+
class Config {
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @var array
|
23 |
+
*/
|
24 |
+
var $core_forms;
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
var $core_directories;
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @var mixed|void
|
35 |
+
*/
|
36 |
+
var $core_pages;
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @var array
|
41 |
+
*/
|
42 |
+
var $core_directory_meta = array();
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @var array
|
47 |
+
*/
|
48 |
+
var $core_global_meta_all;
|
49 |
+
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @var mixed|void
|
53 |
+
*/
|
54 |
+
var $core_form_meta_all;
|
55 |
+
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @var array
|
59 |
+
*/
|
60 |
+
var $core_form_meta = array();
|
61 |
+
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @var
|
65 |
+
*/
|
66 |
+
var $perms;
|
67 |
+
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @var
|
71 |
+
*/
|
72 |
+
var $nonadmin_perms;
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @var mixed|void
|
77 |
+
*/
|
78 |
+
var $email_notifications;
|
79 |
+
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @var mixed|void
|
83 |
+
*/
|
84 |
+
var $settings_defaults;
|
85 |
+
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @var array
|
89 |
+
*/
|
90 |
+
var $permalinks;
|
91 |
+
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Config constructor.
|
95 |
+
*/
|
96 |
+
function __construct() {
|
97 |
+
$this->core_forms = array(
|
98 |
+
'register',
|
99 |
+
'login',
|
100 |
+
'profile',
|
101 |
+
);
|
102 |
+
|
103 |
+
$this->core_directories = array(
|
104 |
+
'members',
|
105 |
+
);
|
106 |
+
|
107 |
+
|
108 |
+
/**
|
109 |
+
* UM hook
|
110 |
+
*
|
111 |
+
* @type filter
|
112 |
+
* @title um_core_pages
|
113 |
+
* @description Extend UM core pages
|
114 |
+
* @input_vars
|
115 |
+
* [{"var":"$pages","type":"array","desc":"UM core pages"}]
|
116 |
+
* @change_log
|
117 |
+
* ["Since: 2.0"]
|
118 |
+
* @usage
|
119 |
+
* <?php add_filter( 'um_core_pages', 'function_name', 10, 1 ); ?>
|
120 |
+
* @example
|
121 |
+
* <?php
|
122 |
+
* add_filter( 'um_core_pages', 'my_core_pages', 10, 1 );
|
123 |
+
* function my_core_pages( $pages ) {
|
124 |
+
* // your code here
|
125 |
+
* $pages['my_page_key'] = array( 'title' => __( 'My Page Title', 'my-translate-key' ) );
|
126 |
+
* return $pages;
|
127 |
+
* }
|
128 |
+
* ?>
|
129 |
+
*/
|
130 |
+
$this->core_pages = apply_filters( 'um_core_pages', array(
|
131 |
+
'user' => array( 'title' => __( 'User', 'ultimate-member' ) ),
|
132 |
+
'login' => array( 'title' => __( 'Login', 'ultimate-member' ) ),
|
133 |
+
'register' => array( 'title' => __( 'Register', 'ultimate-member' ) ),
|
134 |
+
'members' => array( 'title' => __( 'Members', 'ultimate-member' ) ),
|
135 |
+
'logout' => array( 'title' => __( 'Logout', 'ultimate-member' ) ),
|
136 |
+
'account' => array( 'title' => __( 'Account', 'ultimate-member' ) ),
|
137 |
+
'password-reset' => array( 'title' => __( 'Password Reset', 'ultimate-member' ) ),
|
138 |
+
) );
|
139 |
+
|
140 |
+
$this->core_directory_meta['members'] = array(
|
141 |
+
'_um_core' => 'members',
|
142 |
+
'_um_template' => 'members',
|
143 |
+
'_um_mode' => 'directory',
|
144 |
+
'_um_view_types' => array( 'grid' ),
|
145 |
+
'_um_default_view' => 'grid',
|
146 |
+
'_um_roles' => array(),
|
147 |
+
'_um_has_profile_photo' => 0,
|
148 |
+
'_um_has_cover_photo' => 0,
|
149 |
+
'_um_show_these_users' => '',
|
150 |
+
'_um_exclude_these_users' => '',
|
151 |
+
|
152 |
+
'_um_sortby' => 'user_registered_desc',
|
153 |
+
'_um_sortby_custom' => '',
|
154 |
+
'_um_sortby_custom_label' => '',
|
155 |
+
'_um_enable_sorting' => 0,
|
156 |
+
'_um_sorting_fields' => array(),
|
157 |
+
|
158 |
+
'_um_profile_photo' => '1',
|
159 |
+
'_um_cover_photos' => '1',
|
160 |
+
'_um_show_name' => '1',
|
161 |
+
'_um_show_tagline' => 0,
|
162 |
+
'_um_tagline_fields' => array(),
|
163 |
+
'_um_show_userinfo' => 0,
|
164 |
+
'_um_reveal_fields' => array(),
|
165 |
+
'_um_show_social' => 0,
|
166 |
+
'_um_userinfo_animate' => '1',
|
167 |
+
|
168 |
+
'_um_search' => 0,
|
169 |
+
'_um_roles_can_search' => array(),
|
170 |
+
'_um_filters' => 0,
|
171 |
+
'_um_roles_can_filter' => array(),
|
172 |
+
'_um_search_fields' => array(),
|
173 |
+
'_um_filters_expanded' => 0,
|
174 |
+
'_um_filters_is_collapsible' => 1,
|
175 |
+
'_um_search_filters' => array(),
|
176 |
+
|
177 |
+
'_um_must_search' => 0,
|
178 |
+
'_um_max_users' => '',
|
179 |
+
'_um_profiles_per_page' => 12,
|
180 |
+
'_um_profiles_per_page_mobile' => 6,
|
181 |
+
'_um_directory_header' => __( '{total_users} Members', 'ultimate-member' ),
|
182 |
+
'_um_directory_header_single' => __( '{total_users} Member', 'ultimate-member' ),
|
183 |
+
'_um_directory_no_users' => __( 'We are sorry. We cannot find any users who match your search criteria.', 'ultimate-member' ),
|
184 |
+
);
|
185 |
+
|
186 |
+
$this->core_global_meta_all = array(
|
187 |
+
'_um_primary_btn_color',
|
188 |
+
'_um_primary_btn_hover',
|
189 |
+
'_um_primary_btn_text',
|
190 |
+
'_um_secondary_btn_color',
|
191 |
+
'_um_secondary_btn_hover',
|
192 |
+
'_um_secondary_btn_text',
|
193 |
+
'_um_form_border',
|
194 |
+
'_um_form_border_hover',
|
195 |
+
'_um_form_bg_color',
|
196 |
+
'_um_form_bg_color_focus',
|
197 |
+
'_um_form_placeholder',
|
198 |
+
'_um_form_icon_color',
|
199 |
+
'_um_form_asterisk_color',
|
200 |
+
'_um_form_field_label',
|
201 |
+
'_um_form_text_color',
|
202 |
+
'_um_active_color',
|
203 |
+
'_um_help_tip_color',
|
204 |
+
'_um_secondary_color',
|
205 |
+
);
|
206 |
+
|
207 |
+
|
208 |
+
/**
|
209 |
+
* UM hook
|
210 |
+
*
|
211 |
+
* @type filter
|
212 |
+
* @title um_core_form_meta_all
|
213 |
+
* @description Extend UM forms meta keys
|
214 |
+
* @input_vars
|
215 |
+
* [{"var":"$meta","type":"array","desc":"UM forms meta"}]
|
216 |
+
* @change_log
|
217 |
+
* ["Since: 2.0"]
|
218 |
+
* @usage
|
219 |
+
* <?php add_filter( 'um_core_form_meta_all', 'function_name', 10, 1 ); ?>
|
220 |
+
* @example
|
221 |
+
* <?php
|
222 |
+
* add_filter( 'um_core_form_meta_all', 'my_core_form_meta', 10, 1 );
|
223 |
+
* function my_core_form_meta( $meta ) {
|
224 |
+
* // your code here
|
225 |
+
* $meta['my_meta_key'] = 'my_meta_value';
|
226 |
+
* return $meta;
|
227 |
+
* }
|
228 |
+
* ?>
|
229 |
+
*/
|
230 |
+
$this->core_form_meta_all = apply_filters( 'um_core_form_meta_all', array(
|
231 |
+
/*Profile Form*/
|
232 |
+
'_um_profile_show_name' => 1,
|
233 |
+
'_um_profile_show_social_links' => 0,
|
234 |
+
'_um_profile_show_bio' => 1,
|
235 |
+
'_um_profile_bio_maxchars' => 180,
|
236 |
+
'_um_profile_header_menu' => 'bc',
|
237 |
+
'_um_profile_empty_text' => 1,
|
238 |
+
'_um_profile_empty_text_emo' => 1,
|
239 |
+
'_um_profile_role' => array(),
|
240 |
+
'_um_profile_template' => 'profile',
|
241 |
+
'_um_profile_max_width' => '1000px',
|
242 |
+
'_um_profile_area_max_width' => '600px',
|
243 |
+
'_um_profile_align' => 'center',
|
244 |
+
'_um_profile_icons' => 'label',
|
245 |
+
'_um_profile_disable_photo_upload' => 0,
|
246 |
+
'_um_profile_photosize' => '190',
|
247 |
+
'_um_profile_cover_enabled' => 1,
|
248 |
+
'_um_profile_coversize' => 'original',
|
249 |
+
'_um_profile_cover_ratio' => '2.7:1',
|
250 |
+
'_um_profile_photocorner' => '1',
|
251 |
+
'_um_profile_header_bg' => '',
|
252 |
+
'_um_profile_primary_btn_word' => __( 'Update Profile', 'ultimate-member' ),
|
253 |
+
'_um_profile_secondary_btn' => '1',
|
254 |
+
'_um_profile_secondary_btn_word' => __( 'Cancel', 'ultimate-member' ),
|
255 |
+
|
256 |
+
/*Registration Form*/
|
257 |
+
'_um_register_role' => '0',
|
258 |
+
'_um_register_template' => 'register',
|
259 |
+
'_um_register_max_width' => '450px',
|
260 |
+
'_um_register_align' => 'center',
|
261 |
+
'_um_register_icons' => 'label',
|
262 |
+
'_um_register_primary_btn_word' => __( 'Register', 'ultimate-member' ),
|
263 |
+
'_um_register_secondary_btn' => 1,
|
264 |
+
'_um_register_secondary_btn_word' => __( 'Login', 'ultimate-member' ),
|
265 |
+
'_um_register_secondary_btn_url' => '',
|
266 |
+
|
267 |
+
/*Login Form*/
|
268 |
+
'_um_login_template' => 'login',
|
269 |
+
'_um_login_max_width' => '450px',
|
270 |
+
'_um_login_align' => 'center',
|
271 |
+
'_um_login_icons' => 'label',
|
272 |
+
'_um_login_primary_btn_word' => __( 'Login', 'ultimate-member' ),
|
273 |
+
'_um_login_forgot_pass_link' => 1,
|
274 |
+
'_um_login_show_rememberme' => 1,
|
275 |
+
'_um_login_secondary_btn' => 1,
|
276 |
+
'_um_login_secondary_btn_word' => __( 'Register', 'ultimate-member' ),
|
277 |
+
'_um_login_secondary_btn_url' => '',
|
278 |
+
|
279 |
+
/*Member Directory*/
|
280 |
+
'_um_directory_template' => 'members',
|
281 |
+
'_um_directory_header' => __( '{total_users} Members', 'ultimate-member' ),
|
282 |
+
'_um_directory_header_single' => __( '{total_users} Member', 'ultimate-member' ),
|
283 |
+
) );
|
284 |
+
|
285 |
+
$this->core_form_meta['register'] = array(
|
286 |
+
'_um_custom_fields' => 'a:6:{s:10:"user_login";a:15:{s:5:"title";s:8:"Username";s:7:"metakey";s:10:"user_login";s:4:"type";s:4:"text";s:5:"label";s:8:"Username";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:0;s:8:"validate";s:15:"unique_username";s:9:"min_chars";i:3;s:9:"max_chars";i:24;s:8:"position";s:1:"1";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:10:"user_email";a:13:{s:5:"title";s:14:"E-mail Address";s:7:"metakey";s:10:"user_email";s:4:"type";s:4:"text";s:5:"label";s:14:"E-mail Address";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"validate";s:12:"unique_email";s:8:"position";s:1:"4";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:13:"user_password";a:16:{s:5:"title";s:8:"Password";s:7:"metakey";s:13:"user_password";s:4:"type";s:8:"password";s:5:"label";s:8:"Password";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:1;s:9:"min_chars";i:8;s:9:"max_chars";i:30;s:15:"force_good_pass";i:1;s:18:"force_confirm_pass";i:1;s:8:"position";s:1:"5";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:10:"first_name";a:12:{s:5:"title";s:10:"First Name";s:7:"metakey";s:10:"first_name";s:4:"type";s:4:"text";s:5:"label";s:10:"First Name";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"position";s:1:"2";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"last_name";a:12:{s:5:"title";s:9:"Last Name";s:7:"metakey";s:9:"last_name";s:4:"type";s:4:"text";s:5:"label";s:9:"Last Name";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";i:1;s:8:"position";s:1:"3";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
287 |
+
'_um_mode' => 'register',
|
288 |
+
'_um_core' => 'register',
|
289 |
+
'_um_register_use_custom_settings' => 0,
|
290 |
+
);
|
291 |
+
|
292 |
+
$this->core_form_meta['login'] = array(
|
293 |
+
'_um_custom_fields' => 'a:3:{s:8:"username";a:13:{s:5:"title";s:18:"Username or E-mail";s:7:"metakey";s:8:"username";s:4:"type";s:4:"text";s:5:"label";s:18:"Username or E-mail";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:0;s:8:"validate";s:24:"unique_username_or_email";s:8:"position";s:1:"1";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:13:"user_password";a:16:{s:5:"title";s:8:"Password";s:7:"metakey";s:13:"user_password";s:4:"type";s:8:"password";s:5:"label";s:8:"Password";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";i:1;s:9:"min_chars";i:8;s:9:"max_chars";i:30;s:15:"force_good_pass";i:1;s:18:"force_confirm_pass";i:1;s:8:"position";s:1:"2";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
294 |
+
'_um_mode' => 'login',
|
295 |
+
'_um_core' => 'login',
|
296 |
+
'_um_login_use_custom_settings' => 0,
|
297 |
+
);
|
298 |
+
|
299 |
+
$this->core_form_meta['profile'] = array(
|
300 |
+
'_um_custom_fields' => 'a:1:{s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
|
301 |
+
'_um_mode' => 'profile',
|
302 |
+
'_um_core' => 'profile',
|
303 |
+
'_um_profile_use_custom_settings' => 0,
|
304 |
+
);
|
305 |
+
|
306 |
+
|
307 |
+
/**
|
308 |
+
* UM hook
|
309 |
+
*
|
310 |
+
* @type filter
|
311 |
+
* @title um_email_notifications
|
312 |
+
* @description Extend UM email notifications
|
313 |
+
* @input_vars
|
314 |
+
* [{"var":"$emails","type":"array","desc":"UM email notifications"}]
|
315 |
+
* @change_log
|
316 |
+
* ["Since: 2.0"]
|
317 |
+
* @usage
|
318 |
+
* <?php add_filter( 'um_email_notifications', 'function_name', 10, 1 ); ?>
|
319 |
+
* @example
|
320 |
+
* <?php
|
321 |
+
* add_filter( 'um_email_notifications', 'my_email_notifications', 10, 1 );
|
322 |
+
* function my_email_notifications( $emails ) {
|
323 |
+
* // your code here
|
324 |
+
* $emails['my_email'] = array(
|
325 |
+
* 'key' => 'my_email',
|
326 |
+
* 'title' => __( 'my_email_title','ultimate-member' ),
|
327 |
+
* 'subject' => 'my_email_subject',
|
328 |
+
* 'body' => 'my_email_body',
|
329 |
+
* 'description' => 'my_email_description',
|
330 |
+
* 'recipient' => 'user', // set 'admin' for make administrator as recipient
|
331 |
+
* 'default_active' => true // can be false for make disabled by default
|
332 |
+
* );
|
333 |
+
*
|
334 |
+
* return $emails;
|
335 |
+
* }
|
336 |
+
* ?>
|
337 |
+
*/
|
338 |
+
$this->email_notifications = apply_filters( 'um_email_notifications', array(
|
339 |
+
'welcome_email' => array(
|
340 |
+
'key' => 'welcome_email',
|
341 |
+
'title' => __( 'Account Welcome Email','ultimate-member' ),
|
342 |
+
'subject' => 'Welcome to {site_name}!',
|
343 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
344 |
+
'Thank you for signing up with {site_name}! Your account is now active.<br /><br />' .
|
345 |
+
'To login please visit the following url:<br /><br />' .
|
346 |
+
'{login_url} <br /><br />' .
|
347 |
+
'Your account e-mail: {email} <br />' .
|
348 |
+
'Your account username: {username} <br /><br />' .
|
349 |
+
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
350 |
+
'Thanks,<br />' .
|
351 |
+
'{site_name}',
|
352 |
+
'description' => __('Whether to send the user an email when his account is automatically approved','ultimate-member'),
|
353 |
+
'recipient' => 'user',
|
354 |
+
'default_active' => true
|
355 |
+
),
|
356 |
+
'checkmail_email' => array(
|
357 |
+
'key' => 'checkmail_email',
|
358 |
+
'title' => __( 'Account Activation Email','ultimate-member' ),
|
359 |
+
'subject' => 'Please activate your account',
|
360 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
361 |
+
'Thank you for signing up with {site_name}! To activate your account, please click the link below to confirm your email address:<br /><br />' .
|
362 |
+
'{account_activation_link} <br /><br />' .
|
363 |
+
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
364 |
+
'Thanks, <br />' .
|
365 |
+
'{site_name}',
|
366 |
+
'description' => __('Whether to send the user an email when his account needs e-mail activation','ultimate-member'),
|
367 |
+
'recipient' => 'user'
|
368 |
+
),
|
369 |
+
'pending_email' => array(
|
370 |
+
'key' => 'pending_email',
|
371 |
+
'title' => __( 'Your account is pending review','ultimate-member' ),
|
372 |
+
'subject' => '[{site_name}] New user account',
|
373 |
+
'body' => 'Hi {display_name}, <br /><br />' .
|
374 |
+
'Thank you for signing up with {site_name}! Your account is currently being reviewed by a member of our team.<br /><br />' .
|
375 |
+
'Please allow us some time to process your request.<br /><br />' .
|
376 |
+
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
377 |
+
'Thanks,<br />' .
|
378 |
+
'{site_name}',
|
379 |
+
'description' => __('Whether to send the user an email when his account needs admin review','ultimate-member'),
|
380 |
+
'recipient' => 'user'
|
381 |
+
),
|
382 |
+
'approved_email' => array(
|
383 |
+
'key' => 'approved_email',
|
384 |
+
'title' => __( 'Account Approved Email','ultimate-member' ),
|
385 |
+
'subject' => 'Your account at {site_name} is now active',
|
386 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
387 |
+
'Thank you for signing up with {site_name}! Your account has been approved and is now active.<br /><br />' .
|
388 |
+
'To login please visit the following url:<br /><br />' .
|
389 |
+
'{login_url}<br /><br />' .
|
390 |
+
'Your account e-mail: {email}<br />' .
|
391 |
+
'Your account username: {username}<br />' .
|
392 |
+
'Set your account password: {password_reset_link}<br /><br />' .
|
393 |
+
'If you have any problems, please contact us at {admin_email}<br /><br />' .
|
394 |
+
'Thanks,<br />' .
|
395 |
+
'{site_name}',
|
396 |
+
'description' => __('Whether to send the user an email when his account is approved','ultimate-member'),
|
397 |
+
'recipient' => 'user'
|
398 |
+
),
|
399 |
+
'rejected_email' => array(
|
400 |
+
'key' => 'rejected_email',
|
401 |
+
'title' => __( 'Account Rejected Email','ultimate-member' ),
|
402 |
+
'subject' => 'Your account has been rejected',
|
403 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
404 |
+
'Thank you for applying for membership to {site_name}! We have reviewed your information and unfortunately we are unable to accept you as a member at this moment.<br /><br />' .
|
405 |
+
'Please feel free to apply again at a future date.<br /><br />' .
|
406 |
+
'Thanks,<br />' .
|
407 |
+
'{site_name}',
|
408 |
+
'description' => __('Whether to send the user an email when his account is rejected','ultimate-member'),
|
409 |
+
'recipient' => 'user'
|
410 |
+
),
|
411 |
+
'inactive_email' => array(
|
412 |
+
'key' => 'inactive_email',
|
413 |
+
'title' => __( 'Account Deactivated Email','ultimate-member' ),
|
414 |
+
'subject' => 'Your account has been deactivated',
|
415 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
416 |
+
'This is an automated email to let you know your {site_name} account has been deactivated.<br /><br />' .
|
417 |
+
'If you would like your account to be reactivated please contact us at {admin_email}<br /><br />' .
|
418 |
+
'Thanks,<br />' .
|
419 |
+
'{site_name}',
|
420 |
+
'description' => __('Whether to send the user an email when his account is deactivated','ultimate-member'),
|
421 |
+
'recipient' => 'user',
|
422 |
+
'default_active' => true
|
423 |
+
),
|
424 |
+
'deletion_email' => array(
|
425 |
+
'key' => 'deletion_email',
|
426 |
+
'title' => __( 'Account Deleted Email','ultimate-member' ),
|
427 |
+
'subject' => 'Your account has been deleted',
|
428 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
429 |
+
'This is an automated email to let you know your {site_name} account has been deleted. All of your personal information has been permanently deleted and you will no longer be able to login to {site_name}.<br /><br />' .
|
430 |
+
'If your account has been deleted by accident please contact us at {admin_email} <br />' .
|
431 |
+
'Thanks,<br />' .
|
432 |
+
'{site_name}',
|
433 |
+
'description' => __('Whether to send the user an email when his account is deleted','ultimate-member'),
|
434 |
+
'recipient' => 'user',
|
435 |
+
'default_active' => true
|
436 |
+
),
|
437 |
+
'resetpw_email' => array(
|
438 |
+
'key' => 'resetpw_email',
|
439 |
+
'title' => __( 'Password Reset Email','ultimate-member' ),
|
440 |
+
'subject' => 'Reset your password',
|
441 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
442 |
+
'We received a request to reset the password for your account. If you made this request, click the link below to change your password:<br /><br />' .
|
443 |
+
'{password_reset_link}<br /><br />' .
|
444 |
+
'If you didn\'t make this request, you can ignore this email <br /><br />' .
|
445 |
+
'Thanks,<br />' .
|
446 |
+
'{site_name}',
|
447 |
+
'description' => __('Whether to send an email when users changed their password (Recommended, please keep on)','ultimate-member'),
|
448 |
+
'recipient' => 'user',
|
449 |
+
'default_active' => true
|
450 |
+
),
|
451 |
+
'changedpw_email' => array(
|
452 |
+
'key' => 'changedpw_email',
|
453 |
+
'title' => __( 'Password Changed Email','ultimate-member' ),
|
454 |
+
'subject' => 'Your {site_name} password has been changed',
|
455 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
456 |
+
'You recently changed the password associated with your {site_name} account.<br /><br />' .
|
457 |
+
'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}<br /><br />' .
|
458 |
+
'Thanks,<br />' .
|
459 |
+
'{site_name}',
|
460 |
+
'description' => __('Whether to send the user an email when he request to reset password (Recommended, please keep on)','ultimate-member'),
|
461 |
+
'recipient' => 'user',
|
462 |
+
'default_active' => true
|
463 |
+
),
|
464 |
+
'changedaccount_email' => array(
|
465 |
+
'key' => 'changedaccount_email',
|
466 |
+
'title' => __( 'Account Updated Email','ultimate-member' ),
|
467 |
+
'subject' => 'Your account at {site_name} was updated',
|
468 |
+
'body' => 'Hi {display_name},<br /><br />' .
|
469 |
+
'You recently updated your {site_name} account.<br /><br />' .
|
470 |
+
'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}<br /><br />' .
|
471 |
+
'Thanks,<br />' .
|
472 |
+
'{site_name}',
|
473 |
+
'description' => __('Whether to send the user an email when he updated their account','ultimate-member'),
|
474 |
+
'recipient' => 'user',
|
475 |
+
'default_active'=> true
|
476 |
+
),
|
477 |
+
'notification_new_user' => array(
|
478 |
+
'key' => 'notification_new_user',
|
479 |
+
'title' => __( 'New User Notification','ultimate-member' ),
|
480 |
+
'subject' => '[{site_name}] New user account',
|
481 |
+
'body' => '{display_name} has just created an account on {site_name}. To view their profile click here:<br /><br />' .
|
482 |
+
'{user_profile_link}<br /><br />' .
|
483 |
+
'Here is the submitted registration form:<br /><br />' .
|
484 |
+
'{submitted_registration}',
|
485 |
+
'description' => __('Whether to receive notification when a new user account is approved','ultimate-member'),
|
486 |
+
'recipient' => 'admin',
|
487 |
+
'default_active' => true
|
488 |
+
),
|
489 |
+
'notification_review' => array(
|
490 |
+
'key' => 'notification_review',
|
491 |
+
'title' => __( 'Account Needs Review Notification','ultimate-member' ),
|
492 |
+
'subject' => '[{site_name}] New user awaiting review',
|
493 |
+
'body' => '{display_name} has just applied for membership to {site_name} and is waiting to be reviewed.<br /><br />' .
|
494 |
+
'To review this member please click the following link:<br /><br />' .
|
495 |
+
'{user_profile_link}<br /><br />' .
|
496 |
+
'Here is the submitted registration form:<br /><br />' .
|
497 |
+
'{submitted_registration}',
|
498 |
+
'description' => __('Whether to receive notification when an account needs admin review','ultimate-member'),
|
499 |
+
'recipient' => 'admin'
|
500 |
+
),
|
501 |
+
'notification_deletion' => array(
|
502 |
+
'key' => 'notification_deletion',
|
503 |
+
'title' => __( 'Account Deletion Notification','ultimate-member' ),
|
504 |
+
'subject' => '[{site_name}] Account deleted',
|
505 |
+
'body' => '{display_name} has just deleted their {site_name} account.',
|
506 |
+
'description' => __('Whether to receive notification when an account is deleted','ultimate-member'),
|
507 |
+
'recipient' => 'admin'
|
508 |
+
)
|
509 |
+
) );
|
510 |
+
|
511 |
+
|
512 |
+
//settings defaults
|
513 |
+
$this->settings_defaults = array(
|
514 |
+
'restricted_access_post_metabox' => array( 'post' => 1, 'page' => 1 ),
|
515 |
+
'disable_restriction_pre_queries' => 0,
|
516 |
+
'uninstall_on_delete' => 0,
|
517 |
+
'permalink_base' => 'user_login',
|
518 |
+
'display_name' => 'full_name',
|
519 |
+
'display_name_field' => '',
|
520 |
+
'author_redirect' => 1,
|
521 |
+
'members_page' => 1,
|
522 |
+
'use_gravatars' => 0,
|
523 |
+
'use_um_gravatar_default_builtin_image' => 'default',
|
524 |
+
'use_um_gravatar_default_image' => 0,
|
525 |
+
'reset_require_strongpass' => 0,
|
526 |
+
'account_tab_password' => 1,
|
527 |
+
'account_tab_privacy' => 1,
|
528 |
+
'account_tab_notifications' => 1,
|
529 |
+
'account_tab_delete' => 1,
|
530 |
+
'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' ),
|
531 |
+
'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' ),
|
532 |
+
'account_name' => 1,
|
533 |
+
'account_name_disable' => 0,
|
534 |
+
'account_name_require' => 1,
|
535 |
+
'account_email' => 1,
|
536 |
+
'account_general_password' => 0,
|
537 |
+
'account_hide_in_directory' => 1,
|
538 |
+
'account_hide_in_directory_default' => 'No',
|
539 |
+
'account_require_strongpass' => 0,
|
540 |
+
'photo_thumb_sizes' => array( 40, 80, 190 ),
|
541 |
+
'cover_thumb_sizes' => array( 300, 600 ),
|
542 |
+
'accessible' => 0,
|
543 |
+
'access_redirect' => '',
|
544 |
+
'access_exclude_uris' => array(),
|
545 |
+
'home_page_accessible' => 1,
|
546 |
+
'category_page_accessible' => 1,
|
547 |
+
'restricted_post_title_replace' => 1,
|
548 |
+
'restricted_access_post_title' => __( 'Restricted content', 'ultimate-member' ),
|
549 |
+
'restricted_access_message' => '',
|
550 |
+
'restricted_blocks' => 0,
|
551 |
+
'enable_blocks' => 0,
|
552 |
+
'restricted_block_message' => '',
|
553 |
+
'enable_reset_password_limit' => 1,
|
554 |
+
'reset_password_limit_number' => 3,
|
555 |
+
'blocked_emails' => '',
|
556 |
+
'blocked_words' => 'admin' . "\r\n" . 'administrator' . "\r\n" . 'webmaster' . "\r\n" . 'support' . "\r\n" . 'staff',
|
557 |
+
'default_avatar' => '',
|
558 |
+
'default_cover' => '',
|
559 |
+
'disable_profile_photo_upload' => 0,
|
560 |
+
'profile_show_metaicon' => 0,
|
561 |
+
'profile_menu' => 1,
|
562 |
+
'profile_menu_default_tab' => 'main',
|
563 |
+
'profile_menu_icons' => 1,
|
564 |
+
'form_asterisk' => 0,
|
565 |
+
'profile_title' => '{display_name} | {site_name}',
|
566 |
+
'profile_desc' => '{display_name} is on {site_name}. Join {site_name} to view {display_name}\'s profile',
|
567 |
+
'admin_email' => get_bloginfo('admin_email'),
|
568 |
+
'mail_from' => get_bloginfo('name'),
|
569 |
+
'mail_from_addr' => get_bloginfo('admin_email'),
|
570 |
+
'email_html' => 1,
|
571 |
+
'image_orientation_by_exif' => 0,
|
572 |
+
'image_compression' => 60,
|
573 |
+
'image_max_width' => 1000,
|
574 |
+
'cover_min_width' => 1000,
|
575 |
+
'profile_photo_max_size' => 999999999,
|
576 |
+
'cover_photo_max_size' => 999999999,
|
577 |
+
'custom_roles_increment' => 1,
|
578 |
+
'um_profile_object_cache_stop' => 0,
|
579 |
+
'rest_api_version' => '2.0',
|
580 |
+
'member_directory_own_table' => 0,
|
581 |
+
'profile_show_html_bio' => 0,
|
582 |
+
'profile_noindex' => 0,
|
583 |
+
'activation_link_expiry_time' => '',
|
584 |
+
);
|
585 |
+
|
586 |
+
add_filter( 'um_get_tabs_from_config', '__return_true' );
|
587 |
+
|
588 |
+
$tabs = UM()->profile()->tabs();
|
589 |
+
|
590 |
+
foreach ( $tabs as $id => $tab ) {
|
591 |
+
|
592 |
+
if ( ! empty( $tab['hidden'] ) ) {
|
593 |
+
continue;
|
594 |
+
}
|
595 |
+
|
596 |
+
$this->settings_defaults[ 'profile_tab_' . $id ] = 1;
|
597 |
+
|
598 |
+
if ( ! isset( $tab['default_privacy'] ) ) {
|
599 |
+
$this->settings_defaults[ 'profile_tab_' . $id . '_privacy' ] = 0;
|
600 |
+
$this->settings_defaults[ 'profile_tab_' . $id . '_roles' ] = '';
|
601 |
+
}
|
602 |
+
}
|
603 |
+
|
604 |
+
foreach ( $this->email_notifications as $key => $notification ) {
|
605 |
+
$this->settings_defaults[ $key . '_on' ] = ! empty( $notification['default_active'] );
|
606 |
+
$this->settings_defaults[ $key . '_sub' ] = $notification['subject'];
|
607 |
+
$this->settings_defaults[ $key ] = $notification['body'];
|
608 |
+
}
|
609 |
+
|
610 |
+
foreach ( $this->core_pages as $page_s => $page ) {
|
611 |
+
$page_id = UM()->options()->get_core_page_id( $page_s );
|
612 |
+
$this->settings_defaults[ $page_id ] = '';
|
613 |
+
}
|
614 |
+
|
615 |
+
foreach( $this->core_form_meta_all as $key => $value ) {
|
616 |
+
$this->settings_defaults[ str_replace( '_um_', '', $key ) ] = $value;
|
617 |
+
}
|
618 |
+
|
619 |
+
|
620 |
+
/**
|
621 |
+
* UM hook
|
622 |
+
*
|
623 |
+
* @type filter
|
624 |
+
* @title um_default_settings_values
|
625 |
+
* @description Extend UM default settings
|
626 |
+
* @input_vars
|
627 |
+
* [{"var":"$settings","type":"array","desc":"UM default settings"}]
|
628 |
+
* @change_log
|
629 |
+
* ["Since: 2.0"]
|
630 |
+
* @usage
|
631 |
+
* <?php add_filter( 'um_default_settings_values', 'function_name', 10, 1 ); ?>
|
632 |
+
* @example
|
633 |
+
* <?php
|
634 |
+
* add_filter( 'um_default_settings_values', 'my_default_settings_values', 10, 1 );
|
635 |
+
* function my_default_settings_values( $settings ) {
|
636 |
+
* // your code here
|
637 |
+
* return $settings;
|
638 |
+
* }
|
639 |
+
* ?>
|
640 |
+
*/
|
641 |
+
$this->settings_defaults = apply_filters( 'um_default_settings_values', $this->settings_defaults );
|
642 |
+
|
643 |
+
$this->permalinks = $this->get_core_pages();
|
644 |
+
|
645 |
+
|
646 |
+
|
647 |
+
$this->default_roles_metadata = array(
|
648 |
+
/*
|
649 |
+
* All caps map
|
650 |
+
*
|
651 |
+
* '_um_can_access_wpadmin' => 1,
|
652 |
+
'_um_can_not_see_adminbar' => 0,
|
653 |
+
'_um_can_edit_everyone' => 1,
|
654 |
+
'_um_can_edit_roles' => '',
|
655 |
+
'_um_can_delete_everyone' => 1,
|
656 |
+
'_um_can_delete_roles' => '',
|
657 |
+
'_um_after_delete' => '',
|
658 |
+
'_um_delete_redirect_url' => '',
|
659 |
+
'_um_can_edit_profile' => 1,
|
660 |
+
'_um_can_delete_profile' => 1,
|
661 |
+
'_um_default_homepage' => 1,
|
662 |
+
'_um_redirect_homepage' => '',
|
663 |
+
'_um_after_login' => 'redirect_admin',
|
664 |
+
'_um_login_redirect_url' => '',
|
665 |
+
'_um_after_logout' => 'redirect_home',
|
666 |
+
'_um_logout_redirect_url' => '',
|
667 |
+
'_um_can_view_all' => 1,
|
668 |
+
'_um_can_view_roles' => '',
|
669 |
+
'_um_can_make_private_profile' => 1,
|
670 |
+
'_um_can_access_private_profile' => 1,
|
671 |
+
'_um_status' => 'approved',
|
672 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
673 |
+
'_um_auto_approve_url' => '',
|
674 |
+
'_um_login_email_activate' => '',
|
675 |
+
'_um_checkmail_action' => '',
|
676 |
+
'_um_checkmail_message' => '',
|
677 |
+
'_um_checkmail_url' => '',
|
678 |
+
'_um_url_email_activate' => '',
|
679 |
+
'_um_pending_action' => '',
|
680 |
+
'_um_pending_message' => '',
|
681 |
+
'_um_pending_url' => '',
|
682 |
+
*
|
683 |
+
* */
|
684 |
+
|
685 |
+
|
686 |
+
'subscriber' => array(
|
687 |
+
'_um_can_access_wpadmin' => 0,
|
688 |
+
'_um_can_not_see_adminbar' => 1,
|
689 |
+
'_um_can_edit_everyone' => 0,
|
690 |
+
'_um_can_delete_everyone' => 0,
|
691 |
+
'_um_can_edit_profile' => 1,
|
692 |
+
'_um_can_delete_profile' => 1,
|
693 |
+
'_um_after_login' => 'redirect_profile',
|
694 |
+
'_um_after_logout' => 'redirect_home',
|
695 |
+
'_um_default_homepage' => 1,
|
696 |
+
'_um_can_view_all' => 1,
|
697 |
+
'_um_can_make_private_profile' => 0,
|
698 |
+
'_um_can_access_private_profile' => 0,
|
699 |
+
'_um_status' => 'approved',
|
700 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
701 |
+
),
|
702 |
+
'author' => array(
|
703 |
+
'_um_can_access_wpadmin' => 0,
|
704 |
+
'_um_can_not_see_adminbar' => 1,
|
705 |
+
'_um_can_edit_everyone' => 0,
|
706 |
+
'_um_can_delete_everyone' => 0,
|
707 |
+
'_um_can_edit_profile' => 1,
|
708 |
+
'_um_can_delete_profile' => 1,
|
709 |
+
'_um_after_login' => 'redirect_profile',
|
710 |
+
'_um_after_logout' => 'redirect_home',
|
711 |
+
'_um_default_homepage' => 1,
|
712 |
+
'_um_can_view_all' => 1,
|
713 |
+
'_um_can_make_private_profile' => 0,
|
714 |
+
'_um_can_access_private_profile' => 0,
|
715 |
+
'_um_status' => 'approved',
|
716 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
717 |
+
),
|
718 |
+
'contributor' => array(
|
719 |
+
'_um_can_access_wpadmin' => 0,
|
720 |
+
'_um_can_not_see_adminbar' => 1,
|
721 |
+
'_um_can_edit_everyone' => 0,
|
722 |
+
'_um_can_delete_everyone' => 0,
|
723 |
+
'_um_can_edit_profile' => 1,
|
724 |
+
'_um_can_delete_profile' => 1,
|
725 |
+
'_um_after_login' => 'redirect_profile',
|
726 |
+
'_um_after_logout' => 'redirect_home',
|
727 |
+
'_um_default_homepage' => 1,
|
728 |
+
'_um_can_view_all' => 1,
|
729 |
+
'_um_can_make_private_profile' => 0,
|
730 |
+
'_um_can_access_private_profile' => 0,
|
731 |
+
'_um_status' => 'approved',
|
732 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
733 |
+
),
|
734 |
+
'editor' => array(
|
735 |
+
'_um_can_access_wpadmin' => 0,
|
736 |
+
'_um_can_not_see_adminbar' => 1,
|
737 |
+
'_um_can_edit_everyone' => 0,
|
738 |
+
'_um_can_delete_everyone' => 0,
|
739 |
+
'_um_can_edit_profile' => 1,
|
740 |
+
'_um_can_delete_profile' => 1,
|
741 |
+
'_um_after_login' => 'redirect_profile',
|
742 |
+
'_um_after_logout' => 'redirect_home',
|
743 |
+
'_um_default_homepage' => 1,
|
744 |
+
'_um_can_view_all' => 1,
|
745 |
+
'_um_can_make_private_profile' => 0,
|
746 |
+
'_um_can_access_private_profile' => 0,
|
747 |
+
'_um_status' => 'approved',
|
748 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
749 |
+
),
|
750 |
+
'administrator' => array(
|
751 |
+
'_um_can_access_wpadmin' => 1,
|
752 |
+
'_um_can_not_see_adminbar' => 0,
|
753 |
+
'_um_can_edit_everyone' => 1,
|
754 |
+
'_um_can_delete_everyone' => 1,
|
755 |
+
'_um_can_edit_profile' => 1,
|
756 |
+
'_um_can_delete_profile' => 1,
|
757 |
+
'_um_default_homepage' => 1,
|
758 |
+
'_um_after_login' => 'redirect_admin',
|
759 |
+
'_um_after_logout' => 'redirect_home',
|
760 |
+
'_um_can_view_all' => 1,
|
761 |
+
'_um_can_make_private_profile' => 1,
|
762 |
+
'_um_can_access_private_profile' => 1,
|
763 |
+
'_um_status' => 'approved',
|
764 |
+
'_um_auto_approve_act' => 'redirect_profile',
|
765 |
+
),
|
766 |
+
);
|
767 |
+
}
|
768 |
+
|
769 |
+
|
770 |
+
/**
|
771 |
+
* Get UM Pages
|
772 |
+
*
|
773 |
+
* @return array
|
774 |
+
*/
|
775 |
+
function get_core_pages() {
|
776 |
+
$permalink = array();
|
777 |
+
$core_pages = array_keys( $this->core_pages );
|
778 |
+
if ( empty( $core_pages ) ) {
|
779 |
+
return $permalink;
|
780 |
+
}
|
781 |
+
|
782 |
+
foreach ( $core_pages as $page_key ) {
|
783 |
+
$page_option_key = UM()->options()->get_core_page_id( $page_key );
|
784 |
+
$permalink[ $page_key ] = UM()->options()->get( $page_option_key );
|
785 |
+
}
|
786 |
+
|
787 |
+
return $permalink;
|
788 |
+
}
|
789 |
+
|
790 |
+
|
791 |
+
/**
|
792 |
+
* @todo make config class not cycled
|
793 |
+
*/
|
794 |
+
function set_core_page() {
|
795 |
+
$this->core_pages = apply_filters( 'um_core_pages', array(
|
796 |
+
'user' => array( 'title' => __( 'User', 'ultimate-member' ) ),
|
797 |
+
'login' => array( 'title' => __( 'Login', 'ultimate-member' ) ),
|
798 |
+
'register' => array( 'title' => __( 'Register', 'ultimate-member' ) ),
|
799 |
+
'members' => array( 'title' => __( 'Members', 'ultimate-member' ) ),
|
800 |
+
'logout' => array( 'title' => __( 'Logout', 'ultimate-member' ) ),
|
801 |
+
'account' => array( 'title' => __( 'Account', 'ultimate-member' ) ),
|
802 |
+
'password-reset' => array( 'title' => __( 'Password Reset', 'ultimate-member' ) ),
|
803 |
+
) );
|
804 |
+
}
|
805 |
+
//end class
|
806 |
+
}
|
807 |
+
}
|
includes/core/class-access.php
CHANGED
@@ -35,14 +35,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
35 |
private $allow_access;
|
36 |
|
37 |
|
38 |
-
/**
|
39 |
-
* @var \WP_Post
|
40 |
-
*/
|
41 |
-
private $current_single_post;
|
42 |
-
|
43 |
-
|
44 |
-
private $ignore_terms_exclude = false;
|
45 |
-
|
46 |
private $ignore_exclude = false;
|
47 |
|
48 |
|
@@ -55,124 +47,492 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
55 |
$this->redirect_handler = false;
|
56 |
$this->allow_access = false;
|
57 |
|
58 |
-
//
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
add_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 );
|
61 |
add_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 );
|
62 |
-
add_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99, 1 );
|
63 |
|
|
|
|
|
|
|
64 |
add_filter( 'wp_count_posts', array( &$this, 'custom_count_posts_handler' ), 99, 3 );
|
65 |
-
add_filter( 'getarchives_where', array( &$this, 'exclude_restricted_posts_archives_widget' ), 99, 2 );
|
66 |
|
67 |
-
//
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
//
|
71 |
add_action( 'pre_get_comments', array( &$this, 'exclude_posts_comments' ), 99, 1 );
|
72 |
-
add_filter( 'comment_feed_where', array( &$this, 'exclude_posts_comments_feed' ), 99, 2 );
|
73 |
add_filter( 'wp_count_comments', array( &$this, 'custom_comments_count_handler' ), 99, 2 );
|
74 |
-
|
|
|
|
|
75 |
add_filter( 'comments_open', array( $this, 'disable_comments_open' ), 99, 2 );
|
76 |
add_filter( 'get_comments_number', array( $this, 'disable_comments_open_number' ), 99, 2 );
|
77 |
|
78 |
-
//
|
79 |
-
//there also will be redirects if they need
|
80 |
-
//protect posts types
|
81 |
-
add_filter( 'the_posts', array( &$this, 'filter_protected_posts' ), 99, 2 );
|
82 |
-
//protect pages for wp_list_pages func
|
83 |
-
add_filter( 'get_pages', array( &$this, 'filter_protected_posts' ), 99, 2 );
|
84 |
-
|
85 |
-
add_filter( 'the_title', array( &$this, 'filter_restricted_post_title' ), 10, 2 );
|
86 |
-
|
87 |
-
//filter menu items
|
88 |
add_filter( 'wp_nav_menu_objects', array( &$this, 'filter_menu' ), 99, 2 );
|
89 |
-
// blocks restrictions
|
90 |
-
add_filter( 'render_block', array( $this, 'restrict_blocks' ), 10, 2 );
|
91 |
|
92 |
-
//
|
93 |
-
add_filter( '
|
94 |
-
add_filter( 'has_post_thumbnail', array( &$this, 'filter_post_thumbnail' ), 99, 3 );
|
95 |
|
96 |
-
//
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
add_action( 'avada_after_main_content', array( &$this, 'replace_post_content_off' ), 8 );
|
103 |
|
104 |
-
//check the site's accessible more priority have Individual Post/Term Restriction settings
|
105 |
add_action( 'template_redirect', array( &$this, 'template_redirect' ), 1000 );
|
106 |
add_action( 'um_access_check_individual_term_settings', array( &$this, 'um_access_check_individual_term_settings' ) );
|
107 |
add_action( 'um_access_check_global_settings', array( &$this, 'um_access_check_global_settings' ) );
|
|
|
|
|
|
|
108 |
}
|
109 |
|
|
|
110 |
/**
|
111 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
*
|
113 |
* @return array
|
114 |
*/
|
115 |
-
function
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
}
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
if ( empty( $restricted_taxonomies ) ) {
|
124 |
-
$
|
125 |
-
return array();
|
126 |
}
|
127 |
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
);
|
136 |
|
137 |
-
if ( empty( $term_ids ) ) {
|
138 |
-
$cache =
|
139 |
-
return
|
140 |
}
|
141 |
|
142 |
-
$exclude = array();
|
143 |
foreach ( $term_ids as $term_id ) {
|
144 |
if ( $this->is_restricted_term( $term_id ) ) {
|
145 |
$exclude[] = $term_id;
|
146 |
}
|
147 |
}
|
148 |
|
149 |
-
$
|
|
|
150 |
return $exclude;
|
151 |
}
|
152 |
|
153 |
|
|
|
|
|
|
|
154 |
function exclude_hidden_terms_query( $query ) {
|
155 |
-
if ( current_user_can( 'administrator' ) || $
|
156 |
return;
|
157 |
}
|
158 |
|
159 |
-
$exclude = $this->exclude_terms_array();
|
160 |
if ( ! empty( $exclude ) ) {
|
161 |
$query->query_vars['exclude'] = ! empty( $query->query_vars['exclude'] ) ? wp_parse_id_list( $query->query_vars['exclude'] ) : $exclude;
|
162 |
}
|
163 |
}
|
164 |
|
165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
function custom_count_posts_handler( $counts, $type, $perm ) {
|
|
|
|
|
|
|
|
|
167 |
global $wpdb;
|
168 |
|
169 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
if ( empty( $exclude_posts ) ) {
|
|
|
171 |
return $counts;
|
172 |
}
|
173 |
|
174 |
-
$cache_key = _count_posts_cache_key( $type, $perm );
|
175 |
-
|
176 |
$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
|
177 |
|
178 |
if ( 'readable' === $perm && is_user_logged_in() ) {
|
@@ -197,893 +557,738 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
197 |
}
|
198 |
|
199 |
$counts = (object) $counts;
|
200 |
-
wp_cache_set( $cache_key, $counts, 'counts' );
|
201 |
|
|
|
202 |
return $counts;
|
203 |
}
|
204 |
|
205 |
|
206 |
-
|
207 |
-
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
}
|
210 |
|
211 |
-
$exclude_posts = $this->exclude_posts_array(
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
}
|
216 |
|
217 |
-
|
218 |
-
$stats['moderated'] = $stats['awaiting_moderation'];
|
219 |
-
unset( $stats['awaiting_moderation'] );
|
220 |
-
|
221 |
-
$stats_object = (object) $stats;
|
222 |
-
|
223 |
-
return $stats_object;
|
224 |
}
|
225 |
|
226 |
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
$where = 'WHERE 1=1';
|
239 |
-
if ( $post_id > 0 ) {
|
240 |
-
$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
|
241 |
}
|
242 |
|
|
|
243 |
if ( ! empty( $exclude_posts ) ) {
|
244 |
-
$
|
245 |
-
$where .= ' AND comment_post_ID NOT IN ( ' . $exclude_string . ' )';
|
246 |
}
|
247 |
|
248 |
-
$
|
249 |
-
|
250 |
-
SELECT comment_approved, COUNT( * ) AS total
|
251 |
-
FROM {$wpdb->comments}
|
252 |
-
{$where}
|
253 |
-
GROUP BY comment_approved
|
254 |
-
",
|
255 |
-
ARRAY_A
|
256 |
-
);
|
257 |
|
258 |
-
$comment_count = array(
|
259 |
-
'approved' => 0,
|
260 |
-
'awaiting_moderation' => 0,
|
261 |
-
'spam' => 0,
|
262 |
-
'trash' => 0,
|
263 |
-
'post-trashed' => 0,
|
264 |
-
'total_comments' => 0,
|
265 |
-
'all' => 0,
|
266 |
-
);
|
267 |
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
break;
|
280 |
-
case '1':
|
281 |
-
$comment_count['approved'] = $row['total'];
|
282 |
-
$comment_count['total_comments'] += $row['total'];
|
283 |
-
$comment_count['all'] += $row['total'];
|
284 |
-
break;
|
285 |
-
case '0':
|
286 |
-
$comment_count['awaiting_moderation'] = $row['total'];
|
287 |
-
$comment_count['total_comments'] += $row['total'];
|
288 |
-
$comment_count['all'] += $row['total'];
|
289 |
-
break;
|
290 |
-
default:
|
291 |
-
break;
|
292 |
-
}
|
293 |
}
|
294 |
|
295 |
-
$
|
296 |
-
|
|
|
|
|
|
|
297 |
|
298 |
-
return $
|
299 |
}
|
300 |
|
301 |
|
302 |
/**
|
303 |
-
*
|
304 |
*
|
305 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
*/
|
307 |
-
function
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
* @usage add_filter( 'um_custom_restriction', 'function_name', 10, 2 );
|
320 |
-
* @example
|
321 |
-
* <?php
|
322 |
-
* add_filter( 'um_custom_restriction', 'my_custom_restriction', 10, 2 );
|
323 |
-
* function my_directory_sort_users_select( $custom_restriction, $restriction ) {
|
324 |
-
* // your code here
|
325 |
-
* return $custom_restriction;
|
326 |
-
* }
|
327 |
-
* ?>
|
328 |
-
*/
|
329 |
-
return apply_filters( 'um_custom_restriction', true, $restriction );
|
330 |
}
|
331 |
|
332 |
|
333 |
/**
|
334 |
-
*
|
|
|
|
|
|
|
|
|
|
|
335 |
*/
|
336 |
-
function
|
337 |
-
|
338 |
-
|
339 |
-
return;
|
340 |
}
|
341 |
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
} elseif ( is_category() ) {
|
346 |
-
$term_id = get_query_var( 'cat' );
|
347 |
-
} elseif ( is_tax() ) {
|
348 |
-
$tax_name = get_query_var( 'taxonomy' );
|
349 |
|
350 |
-
|
351 |
-
|
|
|
352 |
|
353 |
-
|
|
|
354 |
}
|
355 |
|
356 |
-
|
357 |
-
|
|
|
358 |
}
|
359 |
|
360 |
-
if ( $this->
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
add_filter( 'taxonomy_template', array( &$this, 'taxonomy_message' ), 10, 3 );
|
365 |
|
366 |
-
|
367 |
-
|
368 |
-
$curr = UM()->permalinks()->get_current_url();
|
369 |
|
370 |
-
if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) {
|
371 |
|
372 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
|
374 |
-
|
|
|
|
|
|
|
375 |
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
}
|
381 |
|
382 |
-
|
|
|
383 |
|
384 |
-
|
|
|
|
|
|
|
385 |
}
|
386 |
}
|
|
|
|
|
387 |
}
|
388 |
|
389 |
|
390 |
/**
|
391 |
-
*
|
392 |
-
*
|
393 |
-
* @param $
|
|
|
394 |
*
|
395 |
* @return string
|
396 |
*/
|
397 |
-
function
|
398 |
-
|
399 |
-
|
|
|
400 |
|
|
|
|
|
|
|
401 |
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
global $post;
|
407 |
|
408 |
-
|
409 |
-
|
|
|
410 |
|
411 |
-
|
412 |
-
|
413 |
|
414 |
-
$user_default_homepage = um_user( 'default_homepage' );
|
415 |
-
if ( ! empty( $user_default_homepage ) ) {
|
416 |
-
return;
|
417 |
-
}
|
418 |
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
* @usage
|
432 |
-
* <?php add_filter( 'um_custom_homepage_redirect_url', 'function_name', 10, 2 ); ?>
|
433 |
-
* @example
|
434 |
-
* <?php
|
435 |
-
* add_filter( 'um_custom_homepage_redirect_url', 'my_custom_homepage_redirect_url', 10, 2 );
|
436 |
-
* function my_custom_homepage_redirect_url( $url, $id ) {
|
437 |
-
* // your code here
|
438 |
-
* return $url;
|
439 |
-
* }
|
440 |
-
* ?>
|
441 |
-
*/
|
442 |
-
$redirect_homepage = apply_filters( 'um_custom_homepage_redirect_url', $redirect_homepage, um_user( 'ID' ) );
|
443 |
-
$redirect_to = ! empty( $redirect_homepage ) ? $redirect_homepage : um_get_core_page( 'user' );
|
444 |
-
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect_to ) ), "custom_homepage" );
|
445 |
|
446 |
-
|
447 |
-
|
448 |
|
449 |
-
if ( $access == 2 ) {
|
450 |
-
//global settings for accessible home page
|
451 |
-
$home_page_accessible = UM()->options()->get( 'home_page_accessible' );
|
452 |
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
}
|
466 |
}
|
467 |
-
}
|
468 |
-
|
469 |
-
|
470 |
-
$
|
471 |
-
|
472 |
-
if ( $access == 2 ) {
|
473 |
-
//global settings for accessible home page
|
474 |
-
$category_page_accessible = UM()->options()->get( 'category_page_accessible' );
|
475 |
-
if ( $category_page_accessible == 0 ) {
|
476 |
-
//get redirect URL if not set get login page by default
|
477 |
-
$redirect = UM()->options()->get( 'access_redirect' );
|
478 |
-
if ( ! $redirect ) {
|
479 |
-
$redirect = um_get_core_page( 'login' );
|
480 |
-
}
|
481 |
-
|
482 |
-
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect ) ), 'global' );
|
483 |
-
} else {
|
484 |
-
$this->allow_access = true;
|
485 |
-
return;
|
486 |
-
}
|
487 |
-
}
|
488 |
}
|
489 |
}
|
490 |
|
491 |
-
$
|
492 |
-
|
493 |
-
if ( $access == 2 && ( ! is_user_logged_in() || $ms_empty_role_access ) ) {
|
494 |
-
|
495 |
-
//build exclude URLs pages
|
496 |
-
$redirects = array();
|
497 |
-
$redirects[] = trim( untrailingslashit( UM()->options()->get( 'access_redirect' ) ) );
|
498 |
-
|
499 |
-
$exclude_uris = UM()->options()->get( 'access_exclude_uris' );
|
500 |
-
if ( ! empty( $exclude_uris ) ) {
|
501 |
-
$exclude_uris = array_map( 'trim', $exclude_uris );
|
502 |
-
$redirects = array_merge( $redirects, $exclude_uris );
|
503 |
-
}
|
504 |
-
|
505 |
-
$redirects = array_unique( $redirects );
|
506 |
-
|
507 |
-
$current_url = UM()->permalinks()->get_current_url( get_option( 'permalink_structure' ) );
|
508 |
-
$current_url = untrailingslashit( $current_url );
|
509 |
-
$current_url_slash = trailingslashit( $current_url );
|
510 |
-
|
511 |
-
if ( ! ( isset( $post->ID ) && ( in_array( $current_url, $redirects ) || in_array( $current_url_slash, $redirects ) ) ) ) {
|
512 |
-
//if current page not in exclude URLs
|
513 |
-
//get redirect URL if not set get login page by default
|
514 |
-
$redirect = UM()->options()->get( 'access_redirect' );
|
515 |
-
if ( ! $redirect ) {
|
516 |
-
$redirect = um_get_core_page( 'login' );
|
517 |
-
}
|
518 |
|
519 |
-
|
520 |
-
} else {
|
521 |
-
$this->redirect_handler = false;
|
522 |
-
$this->allow_access = true;
|
523 |
-
}
|
524 |
-
}
|
525 |
}
|
526 |
|
527 |
|
|
|
528 |
/**
|
529 |
-
*
|
530 |
*
|
531 |
-
*
|
532 |
*/
|
533 |
-
function
|
534 |
-
global $post, $wp_query;
|
535 |
-
|
536 |
-
//if we logged by administrator it can access to all content
|
537 |
if ( current_user_can( 'administrator' ) ) {
|
538 |
return;
|
539 |
}
|
540 |
|
541 |
-
if (
|
542 |
-
$
|
|
|
|
|
|
|
543 |
} else {
|
544 |
-
$
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
if ( $is_singular && $this->singular_page ) {
|
549 |
-
return;
|
550 |
-
}
|
551 |
-
|
552 |
-
//also skip if we currently at wp-admin or 404 page
|
553 |
-
if ( is_admin() || is_404() ) {
|
554 |
-
return;
|
555 |
-
}
|
556 |
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
|
|
562 |
}
|
563 |
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
* @type action
|
568 |
-
* @title um_roles_add_meta_boxes_um_role_meta
|
569 |
-
* @description Check terms individual restrict options
|
570 |
-
* @change_log
|
571 |
-
* ["Since: 2.0"]
|
572 |
-
* @usage add_action( 'um_access_check_individual_term_settings', 'function_name', 10 );
|
573 |
-
* @example
|
574 |
-
* <?php
|
575 |
-
* add_action( 'um_access_check_individual_term_settings', 'my_access_check_individual_term_settings', 10 );
|
576 |
-
* function my_access_check_individual_term_settings() {
|
577 |
-
* // your code here
|
578 |
-
* }
|
579 |
-
* ?>
|
580 |
-
*/
|
581 |
-
do_action( 'um_access_check_individual_term_settings' );
|
582 |
-
//exit from function if term page is accessible
|
583 |
-
if ( $this->check_access() ) {
|
584 |
-
return;
|
585 |
}
|
586 |
-
|
587 |
-
/**
|
588 |
-
* UM hook
|
589 |
-
*
|
590 |
-
* @type action
|
591 |
-
* @title um_access_check_global_settings
|
592 |
-
* @description Check global restrict content options
|
593 |
-
* @change_log
|
594 |
-
* ["Since: 2.0"]
|
595 |
-
* @usage add_action( 'um_access_check_global_settings', 'function_name', 10 );
|
596 |
-
* @example
|
597 |
-
* <?php
|
598 |
-
* add_action( 'um_access_check_global_settings', 'my_access_check_global_settings', 10 );
|
599 |
-
* function my_access_check_global_settings() {
|
600 |
-
* // your code here
|
601 |
-
* }
|
602 |
-
* ?>
|
603 |
-
*/
|
604 |
-
do_action( 'um_access_check_global_settings' );
|
605 |
-
|
606 |
-
$this->check_access();
|
607 |
}
|
608 |
|
609 |
|
610 |
/**
|
611 |
-
*
|
612 |
-
*
|
613 |
-
* @return bool
|
614 |
*/
|
615 |
-
function
|
616 |
-
|
617 |
-
|
|
|
|
|
|
|
618 |
}
|
|
|
619 |
|
620 |
-
|
621 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
622 |
}
|
623 |
|
624 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
625 |
}
|
626 |
|
627 |
|
628 |
/**
|
629 |
-
*
|
630 |
*
|
631 |
-
* @param string $
|
632 |
-
* @param
|
633 |
*
|
634 |
* @return string
|
635 |
*/
|
636 |
-
function
|
|
|
|
|
|
|
637 |
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
* @title um_access_enable_referer
|
643 |
-
* @description Access Referrer Enable/Disable
|
644 |
-
* @input_vars
|
645 |
-
* [{"var":"$referrer","type":"bool","desc":"Access referrer"}]
|
646 |
-
* @change_log
|
647 |
-
* ["Since: 2.0"]
|
648 |
-
* @usage add_filter( 'um_access_enable_referer', 'function_name', 10, 1 );
|
649 |
-
* @example
|
650 |
-
* <?php
|
651 |
-
* add_filter( 'um_access_enable_referer', 'my_access_enable_referer', 10, 1 );
|
652 |
-
* function my_access_enable_referer( $referrer ) {
|
653 |
-
* // your code here
|
654 |
-
* return $referrer;
|
655 |
-
* }
|
656 |
-
* ?>
|
657 |
-
*/
|
658 |
-
$enable_referer = apply_filters( 'um_access_enable_referer', false );
|
659 |
-
if ( ! $enable_referer ) {
|
660 |
-
return $url;
|
661 |
}
|
662 |
|
663 |
-
|
664 |
-
return $url;
|
665 |
}
|
666 |
|
667 |
|
668 |
/**
|
669 |
-
*
|
670 |
-
*
|
671 |
*
|
672 |
-
* @
|
673 |
-
* @param $roles
|
674 |
-
* @return bool
|
675 |
*/
|
676 |
-
function
|
677 |
-
$
|
|
|
|
|
678 |
|
679 |
-
if (
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
|
|
|
|
|
|
685 |
}
|
686 |
}
|
687 |
|
688 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
689 |
}
|
690 |
|
691 |
|
692 |
/**
|
693 |
-
*
|
694 |
-
*
|
695 |
-
* Restrict content new logic
|
696 |
*
|
697 |
-
* @
|
698 |
-
* @return bool|array
|
699 |
*/
|
700 |
-
function
|
701 |
static $cache = array();
|
702 |
|
703 |
-
|
704 |
-
|
705 |
-
if ( isset( $cache[ $cache_key ] ) ) {
|
706 |
-
return $cache[ $cache_key ];
|
707 |
-
}
|
708 |
-
|
709 |
-
if ( is_numeric( $post ) ) {
|
710 |
-
$post = get_post( $post );
|
711 |
}
|
712 |
|
713 |
-
|
714 |
-
if ( current_user_can( 'administrator' ) ) {
|
715 |
-
$cache[ $cache_key ] = false;
|
716 |
-
return false;
|
717 |
-
}
|
718 |
|
719 |
-
$
|
720 |
-
//exclude from privacy UM default pages (except Members list and User(Profile) page)
|
721 |
-
if ( ! empty( $post->post_type ) && $post->post_type === 'page' ) {
|
722 |
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
$exclude = true;
|
727 |
}
|
728 |
|
729 |
-
|
730 |
-
|
731 |
-
$
|
732 |
-
return false;
|
733 |
}
|
734 |
|
735 |
-
$
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
//get all taxonomies for current post type
|
745 |
-
$taxonomies = get_object_taxonomies( $post );
|
746 |
-
|
747 |
-
//get all post terms
|
748 |
-
$terms = array();
|
749 |
-
if ( ! empty( $taxonomies ) ) {
|
750 |
-
foreach ( $taxonomies as $taxonomy ) {
|
751 |
-
if ( empty( $restricted_taxonomies[ $taxonomy ] ) ) {
|
752 |
-
continue;
|
753 |
-
}
|
754 |
-
|
755 |
-
$this->ignore_terms_exclude = true;
|
756 |
-
$terms = array_merge( $terms, wp_get_post_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ) );
|
757 |
-
$this->ignore_terms_exclude = false;
|
758 |
-
}
|
759 |
-
}
|
760 |
-
|
761 |
-
//get restriction options for first term with privacy settigns
|
762 |
-
foreach ( $terms as $term_id ) {
|
763 |
-
$restriction = get_term_meta( $term_id, 'um_content_restriction', true );
|
764 |
-
|
765 |
-
if ( ! empty( $restriction['_um_custom_access_settings'] ) ) {
|
766 |
-
if ( ! isset( $restriction['_um_accessible'] ) ) {
|
767 |
-
continue;
|
768 |
-
} else {
|
769 |
-
$cache[ $cache_key ] = $restriction;
|
770 |
-
return $restriction;
|
771 |
-
}
|
772 |
-
}
|
773 |
-
}
|
774 |
-
|
775 |
-
$cache[ $cache_key ] = false;
|
776 |
-
return false;
|
777 |
-
} else {
|
778 |
-
|
779 |
-
// set default redirect if Profile page is restricted for not-logged in users and showing message instead of redirect
|
780 |
-
// this snippet was added to make the same action for {site_url}/user and {site_url}/user/{user_slug} URLs
|
781 |
-
// by default {site_url}/user is redirected to Homepage in rewrite rules because hasn't found username in query when user is not logged in
|
782 |
-
if ( ! is_user_logged_in() && um_is_core_post( $post, 'user' ) && $restriction['_um_accessible'] == '2' && $restriction['_um_noaccess_action'] == '0' ) {
|
783 |
-
if ( isset( $restriction['_um_access_roles'] ) ) {
|
784 |
-
$restriction = array(
|
785 |
-
'_um_accessible' => '2',
|
786 |
-
'_um_access_roles' => $restriction['_um_access_roles'],
|
787 |
-
'_um_noaccess_action' => '1',
|
788 |
-
'_um_access_redirect' => '1',
|
789 |
-
'_um_access_redirect_url' => get_home_url( get_current_blog_id() )
|
790 |
-
);
|
791 |
-
} else {
|
792 |
-
$restriction = array(
|
793 |
-
'_um_accessible' => '2',
|
794 |
-
'_um_noaccess_action' => '1',
|
795 |
-
'_um_access_redirect' => '1',
|
796 |
-
'_um_access_redirect_url' => get_home_url( get_current_blog_id() )
|
797 |
-
);
|
798 |
-
}
|
799 |
-
}
|
800 |
|
801 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
802 |
|
803 |
-
|
804 |
-
|
805 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
806 |
}
|
807 |
}
|
808 |
|
809 |
-
|
810 |
-
$
|
811 |
|
812 |
-
|
813 |
-
|
814 |
|
815 |
-
//get all post terms
|
816 |
-
$terms = array();
|
817 |
-
if ( ! empty( $taxonomies ) ) {
|
818 |
-
foreach ( $taxonomies as $taxonomy ) {
|
819 |
-
if ( empty( $restricted_taxonomies[ $taxonomy ] ) ) {
|
820 |
-
continue;
|
821 |
-
}
|
822 |
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
827 |
}
|
828 |
|
829 |
-
|
830 |
-
foreach ( $terms as $term_id ) {
|
831 |
-
$restriction = get_term_meta( $term_id, 'um_content_restriction', true );
|
832 |
|
833 |
-
|
834 |
-
|
835 |
-
continue;
|
836 |
-
} else {
|
837 |
-
$cache[ $cache_key ] = $restriction;
|
838 |
-
return $restriction;
|
839 |
-
}
|
840 |
-
}
|
841 |
}
|
842 |
|
843 |
-
$
|
844 |
-
|
845 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
846 |
}
|
847 |
|
848 |
|
849 |
/**
|
850 |
-
*
|
851 |
-
*
|
852 |
-
* @param string $title
|
853 |
-
* @param int|null $id
|
854 |
*
|
855 |
-
* @
|
|
|
|
|
856 |
*/
|
857 |
-
function
|
858 |
-
if (
|
859 |
-
return $
|
860 |
}
|
861 |
|
862 |
-
|
863 |
-
|
|
|
|
|
864 |
}
|
865 |
|
866 |
-
if ( $this->is_restricted( $
|
867 |
-
$
|
868 |
-
|
869 |
}
|
870 |
|
871 |
-
|
|
|
|
|
|
|
872 |
}
|
873 |
|
874 |
|
875 |
/**
|
876 |
-
* Protect Post Types in query
|
877 |
* Restrict content new logic
|
878 |
-
*
|
879 |
-
* @param $
|
880 |
-
* @param \WP_Query $query
|
881 |
* @return array
|
882 |
*/
|
883 |
-
function
|
884 |
-
$filtered_posts = array();
|
885 |
-
|
886 |
//if empty
|
887 |
-
if ( empty( $
|
888 |
-
return $
|
889 |
}
|
890 |
|
891 |
if ( current_user_can( 'administrator' ) ) {
|
892 |
-
return $
|
893 |
}
|
894 |
|
895 |
-
$
|
896 |
-
$restricted_global_title = UM()->options()->get( 'restricted_access_post_title' );
|
897 |
-
|
898 |
-
if ( is_object( $query ) ) {
|
899 |
-
$is_singular = $query->is_singular();
|
900 |
-
} else {
|
901 |
-
$is_singular = ! empty( $query->is_singular ) ? true : false;
|
902 |
-
}
|
903 |
|
904 |
//other filter
|
905 |
-
foreach ( $
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
}
|
921 |
-
|
922 |
-
//post is private
|
923 |
-
if ( '0' == $restriction['_um_accessible'] ) {
|
924 |
-
$this->singular_page = true;
|
925 |
-
$filtered_posts[] = $post;
|
926 |
-
continue;
|
927 |
-
} elseif ( '1' == $restriction['_um_accessible'] ) {
|
928 |
-
//if post for not logged in users and user is not logged in
|
929 |
-
if ( ! is_user_logged_in() ) {
|
930 |
-
$this->singular_page = true;
|
931 |
-
|
932 |
-
$filtered_posts[] = $post;
|
933 |
-
continue;
|
934 |
-
} else {
|
935 |
-
|
936 |
-
if ( empty( $is_singular ) ) {
|
937 |
-
//if not single query when exclude if set _um_access_hide_from_queries
|
938 |
-
if ( empty( $restriction['_um_access_hide_from_queries'] ) ) {
|
939 |
-
|
940 |
-
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
941 |
-
$post->post_content = stripslashes( $restricted_global_message );
|
942 |
-
$post->post_title = stripslashes( $restricted_global_title );
|
943 |
-
$post->post_excerpt = '';
|
944 |
-
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
945 |
-
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
946 |
-
$post->post_title = stripslashes( $restricted_global_title );
|
947 |
-
$post->post_excerpt = '';
|
948 |
-
}
|
949 |
-
|
950 |
-
$post = apply_filters( 'um_restricted_archive_post', $post, $restriction, $original_post );
|
951 |
-
$filtered_posts[] = $post;
|
952 |
continue;
|
953 |
}
|
954 |
-
}
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
959 |
|
960 |
-
|
961 |
-
|
962 |
-
$post->post_title = stripslashes( $restricted_global_title );
|
963 |
-
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
964 |
-
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
965 |
-
$post->post_title = stripslashes( $restricted_global_title );
|
966 |
-
}
|
967 |
|
968 |
-
$post = apply_filters( 'um_restricted_singular_post', $post, $restriction, $original_post );
|
969 |
|
970 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
971 |
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
* @title um_access_fix_external_post_content
|
977 |
-
* @description Hook for 3-d party content filtration
|
978 |
-
* @change_log
|
979 |
-
* ["Since: 2.0"]
|
980 |
-
* @usage add_action( 'um_access_fix_external_post_content', 'function_name', 10 );
|
981 |
-
* @example
|
982 |
-
* <?php
|
983 |
-
* add_action( 'um_access_fix_external_post_content', 'my_access_fix_external_post_content', 10 );
|
984 |
-
* function my_access_fix_external_post_content() {
|
985 |
-
* // your code here
|
986 |
-
* }
|
987 |
-
* ?>
|
988 |
-
*/
|
989 |
-
do_action( 'um_access_fix_external_post_content' );
|
990 |
|
991 |
-
|
|
|
|
|
992 |
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
$curr = UM()->permalinks()->get_current_url();
|
997 |
|
998 |
-
|
|
|
|
|
999 |
|
1000 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1001 |
|
1002 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1003 |
|
1004 |
-
|
1005 |
-
$redirect = $restriction['_um_access_redirect_url'];
|
1006 |
-
} else {
|
1007 |
-
$redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) );
|
1008 |
-
}
|
1009 |
|
1010 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1011 |
}
|
1012 |
-
|
1013 |
}
|
1014 |
}
|
1015 |
}
|
1016 |
-
|
1017 |
-
|
|
|
1018 |
if ( is_user_logged_in() ) {
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
$
|
1025 |
-
|
1026 |
-
$filtered_posts[] = $post;
|
1027 |
-
continue;
|
1028 |
-
}
|
1029 |
-
} else {
|
1030 |
-
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
|
1031 |
-
|
1032 |
-
if ( isset( $user_can ) && $user_can && $custom_restrict ) {
|
1033 |
-
$this->singular_page = true;
|
1034 |
-
|
1035 |
-
$filtered_posts[] = $post;
|
1036 |
-
continue;
|
1037 |
}
|
1038 |
}
|
|
|
|
|
|
|
|
|
1039 |
|
1040 |
-
|
1041 |
-
|
1042 |
-
if ( empty( $restriction['_um_access_hide_from_queries'] ) ) {
|
1043 |
-
|
1044 |
-
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
1045 |
-
$post->post_content = stripslashes( $restricted_global_message );
|
1046 |
-
$post->post_title = stripslashes( $restricted_global_title );
|
1047 |
-
$post->post_excerpt = '';
|
1048 |
-
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
1049 |
-
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
1050 |
-
$post->post_title = stripslashes( $restricted_global_title );
|
1051 |
-
$post->post_excerpt = '';
|
1052 |
-
}
|
1053 |
|
1054 |
-
$post = apply_filters( 'um_restricted_archive_post', $post, $restriction, $original_post );
|
1055 |
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1061 |
|
1062 |
-
|
1063 |
-
|
|
|
|
|
1064 |
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
|
|
1068 |
|
1069 |
-
|
|
|
|
|
|
|
|
|
1070 |
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1077 |
|
1078 |
-
|
1079 |
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1084 |
|
1085 |
-
|
|
|
|
|
1086 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1087 |
/**
|
1088 |
* UM hook
|
1089 |
*
|
@@ -1103,485 +1308,587 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
1103 |
*/
|
1104 |
do_action( 'um_access_fix_external_post_content' );
|
1105 |
|
1106 |
-
add_filter( 'single_template', array( &$this, 'woocommerce_template' ), 9999999, 1 );
|
1107 |
-
|
1108 |
$filtered_posts[] = $post;
|
1109 |
continue;
|
1110 |
-
}
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) {
|
1115 |
|
1116 |
-
|
1117 |
|
1118 |
-
|
1119 |
|
1120 |
-
|
1121 |
-
$redirect = $restriction['_um_access_redirect_url'];
|
1122 |
-
} else {
|
1123 |
-
$redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) );
|
1124 |
-
}
|
1125 |
|
1126 |
-
|
|
|
|
|
|
|
1127 |
}
|
1128 |
|
|
|
1129 |
}
|
1130 |
}
|
1131 |
-
|
1132 |
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1133 |
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
1138 |
-
$post->post_content = stripslashes( $restricted_global_message );
|
1139 |
-
$post->post_title = stripslashes( $restricted_global_title );
|
1140 |
-
$post->post_excerpt = '';
|
1141 |
-
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
1142 |
-
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
1143 |
-
$post->post_title = stripslashes( $restricted_global_title );
|
1144 |
-
$post->post_excerpt = '';
|
1145 |
-
}
|
1146 |
|
1147 |
-
$post = apply_filters( 'um_restricted_archive_post', $post, $restriction, $original_post );
|
1148 |
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
|
|
|
|
1154 |
|
1155 |
-
|
1156 |
-
|
|
|
|
|
1157 |
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
|
|
|
|
1161 |
|
1162 |
-
|
|
|
|
|
|
|
1163 |
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
|
|
|
|
|
|
|
|
|
|
1170 |
|
1171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1172 |
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1177 |
|
1178 |
-
|
|
|
1179 |
|
1180 |
-
/**
|
1181 |
-
* UM hook
|
1182 |
-
*
|
1183 |
-
* @type action
|
1184 |
-
* @title um_access_fix_external_post_content
|
1185 |
-
* @description Hook for 3-d party content filtration
|
1186 |
-
* @change_log
|
1187 |
-
* ["Since: 2.0"]
|
1188 |
-
* @usage add_action( 'um_access_fix_external_post_content', 'function_name', 10 );
|
1189 |
-
* @example
|
1190 |
-
* <?php
|
1191 |
-
* add_action( 'um_access_fix_external_post_content', 'my_access_fix_external_post_content', 10 );
|
1192 |
-
* function my_access_fix_external_post_content() {
|
1193 |
-
* // your code here
|
1194 |
-
* }
|
1195 |
-
* ?>
|
1196 |
-
*/
|
1197 |
-
do_action( 'um_access_fix_external_post_content' );
|
1198 |
|
1199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1200 |
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
|
|
|
|
|
|
|
|
1204 |
|
1205 |
-
|
|
|
1206 |
|
1207 |
-
|
|
|
1208 |
|
1209 |
-
|
|
|
|
|
1210 |
|
1211 |
-
|
|
|
|
|
|
|
1212 |
|
1213 |
-
|
1214 |
-
$redirect = $restriction['_um_access_redirect_url'];
|
1215 |
-
} else {
|
1216 |
-
$redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) );
|
1217 |
-
}
|
1218 |
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
|
|
|
|
|
|
|
|
|
|
1222 |
}
|
|
|
|
|
|
|
1223 |
}
|
|
|
|
|
|
|
|
|
|
|
1224 |
}
|
1225 |
}
|
1226 |
-
|
1227 |
-
return $filtered_posts;
|
1228 |
}
|
1229 |
|
1230 |
|
1231 |
/**
|
1232 |
-
*
|
1233 |
-
*
|
1234 |
-
* @param
|
1235 |
*
|
1236 |
-
* @return
|
1237 |
*/
|
1238 |
-
function
|
1239 |
-
|
1240 |
-
|
1241 |
-
'default' => false,
|
1242 |
-
);
|
1243 |
-
|
1244 |
-
$cache_key = $force ? 'force' : 'default';
|
1245 |
-
|
1246 |
-
if ( false !== $cache[ $cache_key ] ) {
|
1247 |
-
return $cache[ $cache_key ];
|
1248 |
-
}
|
1249 |
-
|
1250 |
-
$exclude_posts = array();
|
1251 |
-
if ( current_user_can( 'administrator' ) || $this->ignore_exclude ) {
|
1252 |
-
$cache[ $cache_key ] = $exclude_posts;
|
1253 |
-
return $exclude_posts;
|
1254 |
-
}
|
1255 |
|
1256 |
-
// @todo using Object Cache `wp_cache_get()` `wp_cache_set()` functions
|
1257 |
|
1258 |
-
|
|
|
|
|
|
|
|
|
1259 |
|
1260 |
-
$
|
1261 |
-
|
1262 |
-
$this->ignore_exclude = true;
|
1263 |
-
// exclude all posts assigned to current term without individual restriction settings
|
1264 |
-
$post_ids = get_posts(
|
1265 |
-
array(
|
1266 |
-
'fields' => 'ids',
|
1267 |
-
'post_status' => 'any',
|
1268 |
-
'post_type' => array_keys( $restricted_posts ),
|
1269 |
-
'numberposts' => -1,
|
1270 |
-
'meta_query' => array(
|
1271 |
-
array(
|
1272 |
-
'key' => 'um_content_restriction',
|
1273 |
-
'compare' => 'EXISTS',
|
1274 |
-
),
|
1275 |
-
),
|
1276 |
-
)
|
1277 |
-
);
|
1278 |
|
1279 |
-
|
1280 |
-
|
1281 |
|
1282 |
-
|
|
|
|
|
|
|
1283 |
|
1284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1285 |
|
1286 |
-
|
1287 |
-
|
1288 |
-
"SELECT tm.term_id AS term_id,
|
1289 |
-
tt.taxonomy AS taxonomy
|
1290 |
-
FROM {$wpdb->termmeta} tm
|
1291 |
-
LEFT JOIN {$wpdb->term_taxonomy} tt ON tt.term_id = tm.term_id
|
1292 |
-
WHERE tm.meta_key = 'um_content_restriction' AND
|
1293 |
-
tt.taxonomy IN('" . implode( "','", array_keys( $restricted_taxonomies ) ) . "')",
|
1294 |
-
ARRAY_A
|
1295 |
-
);
|
1296 |
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
continue;
|
1301 |
-
}
|
1302 |
|
1303 |
-
$
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
'
|
1308 |
-
|
1309 |
-
'numberposts' => -1,
|
1310 |
-
'tax_query' => array(
|
1311 |
-
array(
|
1312 |
-
'taxonomy' => $term['taxonomy'],
|
1313 |
-
'field' => 'id',
|
1314 |
-
'terms' => $term['term_id'],
|
1315 |
-
),
|
1316 |
-
),
|
1317 |
-
'meta_query' => array(
|
1318 |
-
'relation' => 'OR',
|
1319 |
-
array(
|
1320 |
-
'relation' => 'AND',
|
1321 |
-
array(
|
1322 |
-
'key' => 'um_content_restriction',
|
1323 |
-
'value' => 's:26:"_um_custom_access_settings";s:1:"1"',
|
1324 |
-
'compare' => 'NOT LIKE',
|
1325 |
-
),
|
1326 |
-
array(
|
1327 |
-
'key' => 'um_content_restriction',
|
1328 |
-
'value' => 's:26:"_um_custom_access_settings";b:1',
|
1329 |
-
'compare' => 'NOT LIKE',
|
1330 |
-
),
|
1331 |
-
),
|
1332 |
-
array(
|
1333 |
-
'key' => 'um_content_restriction',
|
1334 |
-
'compare' => 'NOT EXISTS',
|
1335 |
-
),
|
1336 |
-
),
|
1337 |
-
)
|
1338 |
-
);
|
1339 |
-
$this->ignore_exclude = false;
|
1340 |
|
1341 |
-
|
1342 |
-
|
|
|
|
|
1343 |
}
|
1344 |
-
|
1345 |
-
$post_ids = array_merge( $post_ids, $posts );
|
1346 |
}
|
1347 |
}
|
1348 |
-
}
|
|
|
1349 |
|
1350 |
-
|
1351 |
-
$post_ids = array_unique( $post_ids );
|
1352 |
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) {
|
1362 |
-
array_push( $exclude_posts, $post_id );
|
1363 |
}
|
|
|
|
|
|
|
|
|
|
|
1364 |
}
|
1365 |
}
|
1366 |
}
|
1367 |
}
|
1368 |
|
1369 |
-
$
|
1370 |
-
|
1371 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1373 |
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
*/
|
1379 |
-
function exclude_posts( $query ) {
|
1380 |
-
if ( $query->is_main_query() ) {
|
1381 |
-
$exclude_posts = $this->exclude_posts_array( is_admin() );
|
1382 |
-
if ( ! empty( $exclude_posts ) ) {
|
1383 |
-
$post__not_in = $query->get( 'post__not_in', array() );
|
1384 |
-
$query->set( 'post__not_in', array_merge( wp_parse_id_list( $post__not_in ), $exclude_posts ) );
|
1385 |
}
|
1386 |
}
|
1387 |
}
|
1388 |
|
1389 |
|
1390 |
/**
|
1391 |
-
*
|
1392 |
*
|
1393 |
-
* @
|
1394 |
*/
|
1395 |
-
function
|
1396 |
-
|
1397 |
-
|
1398 |
-
$post__not_in = ! empty( $query->query_vars['post__not_in'] ) ? $query->query_vars['post__not_in'] : array();
|
1399 |
-
$query->query_vars['post__not_in'] = array_merge( wp_parse_id_list( $post__not_in ), $exclude_posts );
|
1400 |
}
|
1401 |
-
}
|
1402 |
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
*
|
1407 |
-
* @param string $where
|
1408 |
-
* @param \WP_Query $query
|
1409 |
-
*
|
1410 |
-
* @return string
|
1411 |
-
*/
|
1412 |
-
function exclude_posts_comments_feed( $where, $query ) {
|
1413 |
-
$exclude_posts = $this->exclude_posts_array( true );
|
1414 |
-
if ( ! empty( $exclude_posts ) ) {
|
1415 |
-
$exclude_string = implode( ',', $exclude_posts );
|
1416 |
-
$where .= ' AND comment_post_ID NOT IN ( ' . $exclude_string . ' )';
|
1417 |
}
|
1418 |
|
1419 |
-
return
|
1420 |
}
|
1421 |
|
1422 |
|
1423 |
/**
|
1424 |
-
*
|
1425 |
*
|
1426 |
-
* @param string
|
1427 |
-
* @param
|
1428 |
-
* @param array $excluded_terms
|
1429 |
-
* @param string $taxonomy.
|
1430 |
-
* @param \WP_Post $post
|
1431 |
*
|
1432 |
* @return string
|
1433 |
*/
|
1434 |
-
function
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1439 |
}
|
1440 |
|
1441 |
-
|
|
|
1442 |
}
|
1443 |
|
1444 |
|
1445 |
/**
|
1446 |
-
*
|
1447 |
-
*
|
1448 |
-
*
|
1449 |
*
|
1450 |
-
* @
|
|
|
1451 |
*/
|
1452 |
-
function
|
1453 |
-
|
1454 |
-
if (
|
1455 |
-
|
1456 |
-
$array['post__not_in'] = array_merge( wp_parse_id_list( $post__not_in ), $exclude_posts );
|
1457 |
}
|
1458 |
|
1459 |
-
|
1460 |
-
}
|
1461 |
|
|
|
1462 |
|
1463 |
-
|
1464 |
-
|
1465 |
-
*
|
1466 |
-
* @param string $sql_where
|
1467 |
-
* @param array $parsed_args
|
1468 |
-
*
|
1469 |
-
* @return string
|
1470 |
-
*/
|
1471 |
-
function exclude_restricted_posts_archives_widget( $sql_where, $parsed_args ) {
|
1472 |
-
$exclude_posts = $this->exclude_posts_array();
|
1473 |
-
if ( ! empty( $exclude_posts ) ) {
|
1474 |
-
$exclude_string = implode( ',', $exclude_posts );
|
1475 |
-
$sql_where .= ' AND ID NOT IN ( ' . $exclude_string . ' )';
|
1476 |
}
|
1477 |
|
1478 |
-
|
1479 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1480 |
|
|
|
|
|
|
|
1481 |
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
*/
|
1487 |
-
function woocommerce_template( $single_template ) {
|
1488 |
-
if ( ! UM()->dependencies()->woocommerce_active_check() ) {
|
1489 |
-
return $single_template;
|
1490 |
}
|
1491 |
|
1492 |
-
|
1493 |
-
|
|
|
|
|
1494 |
}
|
1495 |
|
1496 |
-
|
1497 |
-
}
|
1498 |
|
|
|
|
|
1499 |
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
* @param $content
|
1504 |
-
* @return string
|
1505 |
-
*/
|
1506 |
-
function replace_post_content( $content ) {
|
1507 |
-
if ( ! empty( $this->current_single_post ) ) {
|
1508 |
-
$content = $this->current_single_post->post_content;
|
1509 |
-
}
|
1510 |
-
return $content;
|
1511 |
-
}
|
1512 |
|
|
|
|
|
1513 |
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
add_filter( 'the_content', array( $this, 'replace_post_content' ), 9999, 1 );
|
1522 |
-
}
|
1523 |
|
|
|
|
|
|
|
1524 |
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
* @hooked get_footer
|
1529 |
-
* @since 2.1.17
|
1530 |
-
*/
|
1531 |
-
public function replace_post_content_off() {
|
1532 |
-
remove_filter( 'the_content', array( $this, 'replace_post_content' ), 9999 );
|
1533 |
-
}
|
1534 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1535 |
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
* @param mixed $open
|
1540 |
-
* @param int $post_id
|
1541 |
-
* @return boolean
|
1542 |
-
*/
|
1543 |
-
function disable_comments_open( $open, $post_id ) {
|
1544 |
-
static $cache = array();
|
1545 |
|
1546 |
-
|
1547 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1548 |
}
|
1549 |
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1553 |
}
|
1554 |
|
1555 |
-
$
|
1556 |
-
|
1557 |
-
|
1558 |
-
return $open;
|
1559 |
}
|
1560 |
|
1561 |
|
1562 |
/**
|
1563 |
-
*
|
1564 |
*
|
1565 |
-
* @param
|
1566 |
-
* @param
|
1567 |
-
* @return
|
1568 |
*/
|
1569 |
-
function
|
1570 |
-
|
1571 |
|
1572 |
-
if (
|
1573 |
-
|
|
|
|
|
|
|
|
|
|
|
1574 |
}
|
1575 |
|
1576 |
-
|
1577 |
-
|
1578 |
-
return $count;
|
1579 |
-
}
|
1580 |
|
1581 |
-
$count = 0;
|
1582 |
|
1583 |
-
|
1584 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1585 |
}
|
1586 |
|
1587 |
|
@@ -1592,6 +1899,11 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
1592 |
* @return bool
|
1593 |
*/
|
1594 |
function is_restricted( $post_id ) {
|
|
|
|
|
|
|
|
|
|
|
1595 |
static $cache = array();
|
1596 |
|
1597 |
if ( isset( $cache[ $post_id ] ) ) {
|
@@ -1603,6 +1915,12 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
1603 |
return false;
|
1604 |
}
|
1605 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1606 |
$restricted = true;
|
1607 |
|
1608 |
$restriction = $this->get_post_privacy_settings( $post_id );
|
@@ -1637,6 +1955,8 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
1637 |
}
|
1638 |
}
|
1639 |
|
|
|
|
|
1640 |
$cache[ $post_id ] = $restricted;
|
1641 |
|
1642 |
return $restricted;
|
@@ -1647,9 +1967,10 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
1647 |
* Is term restricted?
|
1648 |
*
|
1649 |
* @param int $term_id
|
|
|
1650 |
* @return bool
|
1651 |
*/
|
1652 |
-
function is_restricted_term( $term_id ) {
|
1653 |
static $cache = array();
|
1654 |
|
1655 |
if ( isset( $cache[ $term_id ] ) ) {
|
@@ -1687,12 +2008,16 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
1687 |
if ( '0' == $restriction['_um_accessible'] ) {
|
1688 |
//term is private
|
1689 |
$restricted = false;
|
1690 |
-
$
|
|
|
|
|
1691 |
} elseif ( '1' == $restriction['_um_accessible'] ) {
|
1692 |
//if term for not logged in users and user is not logged in
|
1693 |
if ( ! is_user_logged_in() ) {
|
1694 |
$restricted = false;
|
1695 |
-
$
|
|
|
|
|
1696 |
}
|
1697 |
} elseif ( '2' == $restriction['_um_accessible'] ) {
|
1698 |
//if term for logged in users and user is not logged in
|
@@ -1702,14 +2027,18 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
1702 |
if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) {
|
1703 |
if ( $custom_restrict ) {
|
1704 |
$restricted = false;
|
1705 |
-
$
|
|
|
|
|
1706 |
}
|
1707 |
} else {
|
1708 |
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
|
1709 |
|
1710 |
if ( $user_can && $custom_restrict ) {
|
1711 |
$restricted = false;
|
1712 |
-
$
|
|
|
|
|
1713 |
}
|
1714 |
}
|
1715 |
}
|
@@ -1717,180 +2046,10 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
|
1717 |
}
|
1718 |
}
|
1719 |
|
|
|
|
|
1720 |
$cache[ $term_id ] = $restricted;
|
1721 |
return $restricted;
|
1722 |
}
|
1723 |
-
|
1724 |
-
|
1725 |
-
/**
|
1726 |
-
* Hide attachment if the post is restricted
|
1727 |
-
*
|
1728 |
-
* @param string $url
|
1729 |
-
* @param int $attachment_id
|
1730 |
-
*
|
1731 |
-
* @return boolean|string
|
1732 |
-
*/
|
1733 |
-
function filter_attachment( $url, $attachment_id ) {
|
1734 |
-
return ( $attachment_id && $this->is_restricted( $attachment_id ) ) ? false : $url;
|
1735 |
-
}
|
1736 |
-
|
1737 |
-
|
1738 |
-
/**
|
1739 |
-
* Hide attachment if the post is restricted
|
1740 |
-
*
|
1741 |
-
* @param $has_thumbnail
|
1742 |
-
* @param $post
|
1743 |
-
* @param $thumbnail_id
|
1744 |
-
*
|
1745 |
-
* @return bool
|
1746 |
-
*/
|
1747 |
-
function filter_post_thumbnail( $has_thumbnail, $post, $thumbnail_id ) {
|
1748 |
-
if ( $this->is_restricted( $thumbnail_id ) ) {
|
1749 |
-
$has_thumbnail = false;
|
1750 |
-
} elseif ( ! empty( $post ) && ! empty( $post->ID ) ) {
|
1751 |
-
if ( $this->is_restricted( $post->ID ) ) {
|
1752 |
-
$has_thumbnail = false;
|
1753 |
-
}
|
1754 |
-
} else {
|
1755 |
-
$post_id = get_the_ID();
|
1756 |
-
if ( $this->is_restricted( $post_id ) ) {
|
1757 |
-
$has_thumbnail = false;
|
1758 |
-
}
|
1759 |
-
}
|
1760 |
-
|
1761 |
-
$has_thumbnail = apply_filters( 'um_restrict_post_thumbnail', $has_thumbnail, $post, $thumbnail_id );
|
1762 |
-
|
1763 |
-
return $has_thumbnail;
|
1764 |
-
}
|
1765 |
-
|
1766 |
-
|
1767 |
-
/**
|
1768 |
-
* Protect Post Types in menu query
|
1769 |
-
* Restrict content new logic
|
1770 |
-
* @param $menu_items
|
1771 |
-
* @param $args
|
1772 |
-
* @return array
|
1773 |
-
*/
|
1774 |
-
function filter_menu( $menu_items, $args ) {
|
1775 |
-
//if empty
|
1776 |
-
if ( empty( $menu_items ) ) {
|
1777 |
-
return $menu_items;
|
1778 |
-
}
|
1779 |
-
|
1780 |
-
if ( current_user_can( 'administrator' ) ) {
|
1781 |
-
return $menu_items;
|
1782 |
-
}
|
1783 |
-
|
1784 |
-
$filtered_items = array();
|
1785 |
-
|
1786 |
-
//other filter
|
1787 |
-
foreach ( $menu_items as $menu_item ) {
|
1788 |
-
if ( ! empty( $menu_item->object_id ) && ! empty( $menu_item->object ) ) {
|
1789 |
-
if ( ! $this->is_restricted( $menu_item->object_id ) ) {
|
1790 |
-
$filtered_items[] = $menu_item;
|
1791 |
-
continue;
|
1792 |
-
} else {
|
1793 |
-
$restriction_settings = $this->get_post_privacy_settings( $menu_item->object_id );
|
1794 |
-
if ( empty( $restriction_settings['_um_access_hide_from_queries'] ) ) {
|
1795 |
-
$filtered_items[] = $menu_item;
|
1796 |
-
continue;
|
1797 |
-
}
|
1798 |
-
}
|
1799 |
-
} else {
|
1800 |
-
//add all other posts
|
1801 |
-
$filtered_items[] = $menu_item;
|
1802 |
-
}
|
1803 |
-
}
|
1804 |
-
|
1805 |
-
return $filtered_items;
|
1806 |
-
}
|
1807 |
-
|
1808 |
-
|
1809 |
-
/**
|
1810 |
-
* @param $block_content
|
1811 |
-
* @param $block
|
1812 |
-
*
|
1813 |
-
* @return string
|
1814 |
-
*/
|
1815 |
-
function restrict_blocks( $block_content, $block ) {
|
1816 |
-
if ( is_admin() ) {
|
1817 |
-
return $block_content;
|
1818 |
-
}
|
1819 |
-
|
1820 |
-
$restricted_blocks = UM()->options()->get( 'restricted_blocks' );
|
1821 |
-
if ( empty( $restricted_blocks ) ) {
|
1822 |
-
return $block_content;
|
1823 |
-
}
|
1824 |
-
|
1825 |
-
if ( is_user_logged_in() && current_user_can( 'administrator' ) ) {
|
1826 |
-
return $block_content;
|
1827 |
-
}
|
1828 |
-
|
1829 |
-
if ( ! isset( $block['attrs']['um_is_restrict'] ) || $block['attrs']['um_is_restrict'] !== true ) {
|
1830 |
-
return $block_content;
|
1831 |
-
}
|
1832 |
-
|
1833 |
-
if ( empty( $block['attrs']['um_who_access'] ) ) {
|
1834 |
-
return $block_content;
|
1835 |
-
}
|
1836 |
-
|
1837 |
-
$default_message = UM()->options()->get( 'restricted_block_message' );
|
1838 |
-
switch ( $block['attrs']['um_who_access'] ) {
|
1839 |
-
case '1': {
|
1840 |
-
if ( ! is_user_logged_in() ) {
|
1841 |
-
$block_content = '';
|
1842 |
-
if ( isset( $block['attrs']['um_message_type'] ) ) {
|
1843 |
-
if ( $block['attrs']['um_message_type'] == '1' ) {
|
1844 |
-
$block_content = $default_message;
|
1845 |
-
} elseif ( $block['attrs']['um_message_type'] == '2' ) {
|
1846 |
-
$block_content = $block['attrs']['um_message_content'];
|
1847 |
-
}
|
1848 |
-
}
|
1849 |
-
} else {
|
1850 |
-
$display = true;
|
1851 |
-
|
1852 |
-
// What roles can access this content?
|
1853 |
-
if ( ! empty( $block['attrs']['um_roles_access'] ) ) {
|
1854 |
-
$display = false;
|
1855 |
-
foreach ( $block['attrs']['um_roles_access'] as $role ) {
|
1856 |
-
if ( current_user_can( $role ) ) {
|
1857 |
-
$display = true;
|
1858 |
-
}
|
1859 |
-
}
|
1860 |
-
}
|
1861 |
-
|
1862 |
-
$display = apply_filters( 'um_loggedin_block_restriction', $display, $block );
|
1863 |
-
|
1864 |
-
if ( ! $display ) {
|
1865 |
-
$block_content = '';
|
1866 |
-
if ( isset( $block['attrs']['um_message_type'] ) ) {
|
1867 |
-
if ( $block['attrs']['um_message_type'] == '1' ) {
|
1868 |
-
$block_content = $default_message;
|
1869 |
-
} elseif ( $block['attrs']['um_message_type'] == '2' ) {
|
1870 |
-
$block_content = $block['attrs']['um_message_content'];
|
1871 |
-
}
|
1872 |
-
}
|
1873 |
-
}
|
1874 |
-
}
|
1875 |
-
break;
|
1876 |
-
}
|
1877 |
-
case '2': {
|
1878 |
-
if ( is_user_logged_in() ) {
|
1879 |
-
$block_content = '';
|
1880 |
-
if ( isset( $block['attrs']['um_message_type'] ) ) {
|
1881 |
-
if ( $block['attrs']['um_message_type'] == '1' ) {
|
1882 |
-
$block_content = $default_message;
|
1883 |
-
} elseif ( $block['attrs']['um_message_type'] == '2' ) {
|
1884 |
-
$block_content = $block['attrs']['um_message_content'];
|
1885 |
-
}
|
1886 |
-
}
|
1887 |
-
}
|
1888 |
-
break;
|
1889 |
-
}
|
1890 |
-
}
|
1891 |
-
|
1892 |
-
return $block_content;
|
1893 |
-
}
|
1894 |
-
|
1895 |
}
|
1896 |
}
|
35 |
private $allow_access;
|
36 |
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
private $ignore_exclude = false;
|
39 |
|
40 |
|
47 |
$this->redirect_handler = false;
|
48 |
$this->allow_access = false;
|
49 |
|
50 |
+
// NEW HOOKS
|
51 |
+
|
52 |
+
// callbacks for changing terms query
|
53 |
+
add_action( 'pre_get_terms', array( &$this, 'exclude_hidden_terms_query' ), 99, 1 );
|
54 |
+
|
55 |
+
// Change recent posts widget query
|
56 |
+
add_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99, 1 );
|
57 |
+
// Exclude pages displayed by wp_list_pages function
|
58 |
+
add_filter( 'wp_list_pages_excludes', array( &$this, 'exclude_restricted_pages' ), 10, 1 );
|
59 |
+
// Archives list change where based on restricted posts
|
60 |
+
add_filter( 'getarchives_where', array( &$this, 'exclude_restricted_posts_archives_widget' ), 99, 2 );
|
61 |
+
|
62 |
+
// Navigation line below the post content, change query to exclude restricted
|
63 |
add_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 );
|
64 |
add_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 );
|
|
|
65 |
|
66 |
+
// callbacks for changing posts query
|
67 |
+
add_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 );
|
68 |
+
add_filter( 'posts_where', array( &$this, 'exclude_posts_where' ), 10, 2 );
|
69 |
add_filter( 'wp_count_posts', array( &$this, 'custom_count_posts_handler' ), 99, 3 );
|
|
|
70 |
|
71 |
+
// change the title of the post
|
72 |
+
add_filter( 'the_title', array( &$this, 'filter_restricted_post_title' ), 10, 2 );
|
73 |
+
// change the content of the restricted post
|
74 |
+
add_filter( 'the_content', array( &$this, 'filter_restricted_post_content' ), 999999, 1 );
|
75 |
+
// change the excerpt of the restricted post
|
76 |
+
add_filter( 'get_the_excerpt', array( &$this, 'filter_restricted_post_excerpt' ), 999999, 2 );
|
77 |
+
|
78 |
+
// filter attachment
|
79 |
+
add_filter( 'wp_get_attachment_url', array( &$this, 'filter_attachment' ), 99, 2 );
|
80 |
+
add_filter( 'has_post_thumbnail', array( &$this, 'filter_post_thumbnail' ), 99, 3 );
|
81 |
|
82 |
+
// comments queries
|
83 |
add_action( 'pre_get_comments', array( &$this, 'exclude_posts_comments' ), 99, 1 );
|
|
|
84 |
add_filter( 'wp_count_comments', array( &$this, 'custom_comments_count_handler' ), 99, 2 );
|
85 |
+
// comments RSS
|
86 |
+
add_filter( 'comment_feed_where', array( &$this, 'exclude_posts_comments_feed' ), 99, 2 );
|
87 |
+
// Disable comments if user has not permission to access current post
|
88 |
add_filter( 'comments_open', array( $this, 'disable_comments_open' ), 99, 2 );
|
89 |
add_filter( 'get_comments_number', array( $this, 'disable_comments_open_number' ), 99, 2 );
|
90 |
|
91 |
+
// filter menu items
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
add_filter( 'wp_nav_menu_objects', array( &$this, 'filter_menu' ), 99, 2 );
|
|
|
|
|
93 |
|
94 |
+
// Gutenberg blocks restrictions
|
95 |
+
add_filter( 'render_block', array( $this, 'restrict_blocks' ), 10, 2 );
|
|
|
96 |
|
97 |
+
// there is posts (Posts/Page/CPT) filtration if site is accessible
|
98 |
+
// there also will be redirects if they need
|
99 |
+
// protect posts types
|
100 |
+
add_filter( 'the_posts', array( &$this, 'filter_protected_posts' ), 99, 2 );
|
101 |
+
// protect pages for wp_list_pages func
|
102 |
+
add_filter( 'get_pages', array( &$this, 'filter_protected_posts' ), 99, 2 );
|
|
|
103 |
|
104 |
+
// check the site's accessible more priority have Individual Post/Term Restriction settings
|
105 |
add_action( 'template_redirect', array( &$this, 'template_redirect' ), 1000 );
|
106 |
add_action( 'um_access_check_individual_term_settings', array( &$this, 'um_access_check_individual_term_settings' ) );
|
107 |
add_action( 'um_access_check_global_settings', array( &$this, 'um_access_check_global_settings' ) );
|
108 |
+
|
109 |
+
|
110 |
+
add_action( 'plugins_loaded', array( &$this, 'disable_restriction_pre_queries' ), 1 );
|
111 |
}
|
112 |
|
113 |
+
|
114 |
/**
|
115 |
+
* Rollback function for old business logic to avoid security enhancements with 404 errors
|
116 |
+
*/
|
117 |
+
function disable_restriction_pre_queries() {
|
118 |
+
if ( ! UM()->options()->get( 'disable_restriction_pre_queries' ) ) {
|
119 |
+
return;
|
120 |
+
}
|
121 |
+
|
122 |
+
remove_action( 'pre_get_terms', array( &$this, 'exclude_hidden_terms_query' ), 99 );
|
123 |
+
remove_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99 );
|
124 |
+
remove_filter( 'wp_list_pages_excludes', array( &$this, 'exclude_restricted_pages' ), 10 );
|
125 |
+
remove_filter( 'getarchives_where', array( &$this, 'exclude_restricted_posts_archives_widget' ), 99 );
|
126 |
+
remove_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99 );
|
127 |
+
remove_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99 );
|
128 |
+
remove_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99 );
|
129 |
+
remove_filter( 'posts_where', array( &$this, 'exclude_posts_where' ), 10 );
|
130 |
+
remove_filter( 'wp_count_posts', array( &$this, 'custom_count_posts_handler' ), 99 );
|
131 |
+
remove_filter( 'the_title', array( &$this, 'filter_restricted_post_title' ), 10 );
|
132 |
+
}
|
133 |
+
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Get array with restricted posts
|
137 |
+
*
|
138 |
+
* @param bool $force
|
139 |
+
* @param bool|array|string $post_types
|
140 |
*
|
141 |
* @return array
|
142 |
*/
|
143 |
+
function exclude_posts_array( $force = false, $post_types = false ) {
|
144 |
+
if ( $this->ignore_exclude ) {
|
145 |
+
return array();
|
146 |
+
}
|
147 |
+
|
148 |
+
static $cache = array();
|
149 |
+
|
150 |
+
$cache_key = $force ? 'force' : 'default';
|
151 |
+
|
152 |
+
// `force` cache contains all restricted post IDs we can get them all from cache instead new queries
|
153 |
+
$force_cache_key = '';
|
154 |
+
if ( 'default' === $cache_key ) {
|
155 |
+
$force_cache_key = 'force';
|
156 |
+
}
|
157 |
+
|
158 |
+
// make $post_types as array if string
|
159 |
+
if ( ! empty( $post_types ) ) {
|
160 |
+
$post_types = is_array( $post_types ) ? $post_types : array( $post_types );
|
161 |
+
$cache_key .= md5( serialize( $post_types ) );
|
162 |
+
if ( ! empty( $force_cache_key ) ) {
|
163 |
+
$force_cache_key .= md5( serialize( $post_types ) );
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
if ( array_key_exists( $cache_key, $cache ) ) {
|
168 |
+
return $cache[ $cache_key ];
|
169 |
+
}
|
170 |
+
|
171 |
+
$exclude_posts = array();
|
172 |
+
if ( current_user_can( 'administrator' ) ) {
|
173 |
+
$cache[ $cache_key ] = $exclude_posts;
|
174 |
+
return $exclude_posts;
|
175 |
+
}
|
176 |
+
|
177 |
+
// @todo using Object Cache `wp_cache_get()` `wp_cache_set()` functions
|
178 |
+
|
179 |
+
// `force` cache contains all restricted post IDs we can get them all from cache instead new queries
|
180 |
+
if ( ! empty( $force_cache_key ) && array_key_exists( $force_cache_key, $cache ) ) {
|
181 |
+
$post_ids = $cache[ $force_cache_key ];
|
182 |
+
|
183 |
+
if ( ! empty( $post_ids ) ) {
|
184 |
+
foreach ( $post_ids as $post_id ) {
|
185 |
+
$content_restriction = $this->get_post_privacy_settings( $post_id );
|
186 |
+
if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) {
|
187 |
+
array_push( $exclude_posts, $post_id );
|
188 |
+
}
|
189 |
+
}
|
190 |
+
}
|
191 |
+
} else {
|
192 |
+
$restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' );
|
193 |
+
if ( ! empty( $restricted_posts ) ) {
|
194 |
+
$restricted_posts = array_keys( $restricted_posts );
|
195 |
+
if ( ! empty( $post_types ) ) {
|
196 |
+
$restricted_posts = array_intersect( $post_types, $restricted_posts );
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
if ( ! empty( $restricted_posts ) ) {
|
201 |
+
$this->ignore_exclude = true;
|
202 |
+
// exclude all posts assigned to current term without individual restriction settings
|
203 |
+
$post_ids = get_posts(
|
204 |
+
array(
|
205 |
+
'fields' => 'ids',
|
206 |
+
'post_status' => 'any',
|
207 |
+
'post_type' => $restricted_posts,
|
208 |
+
'numberposts' => -1,
|
209 |
+
'meta_query' => array(
|
210 |
+
array(
|
211 |
+
'key' => 'um_content_restriction',
|
212 |
+
'compare' => 'EXISTS',
|
213 |
+
),
|
214 |
+
),
|
215 |
+
)
|
216 |
+
);
|
217 |
+
|
218 |
+
$this->ignore_exclude = false;
|
219 |
+
}
|
220 |
+
|
221 |
+
$post_ids = empty( $post_ids ) ? array() : $post_ids;
|
222 |
+
|
223 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
224 |
+
|
225 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
226 |
+
$restricted_taxonomies = array_keys( $restricted_taxonomies );
|
227 |
+
foreach ( $restricted_taxonomies as $k => $taxonomy ) {
|
228 |
+
if ( ! taxonomy_exists( $taxonomy ) ) {
|
229 |
+
unset( $restricted_taxonomies[ $k ] );
|
230 |
+
}
|
231 |
+
}
|
232 |
+
$restricted_taxonomies = array_values( $restricted_taxonomies );
|
233 |
+
|
234 |
+
if ( ! empty( $post_types ) ) {
|
235 |
+
$taxonomies = array();
|
236 |
+
foreach ( $post_types as $p_t ) {
|
237 |
+
$taxonomies = array_merge( $taxonomies, get_object_taxonomies( $p_t ) );
|
238 |
+
}
|
239 |
+
$restricted_taxonomies = array_intersect( $taxonomies, $restricted_taxonomies );
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
244 |
+
global $wpdb;
|
245 |
+
|
246 |
+
$terms = $wpdb->get_results(
|
247 |
+
"SELECT tm.term_id AS term_id,
|
248 |
+
tt.taxonomy AS taxonomy
|
249 |
+
FROM {$wpdb->termmeta} tm
|
250 |
+
LEFT JOIN {$wpdb->term_taxonomy} tt ON tt.term_id = tm.term_id
|
251 |
+
WHERE tm.meta_key = 'um_content_restriction' AND
|
252 |
+
tt.taxonomy IN('" . implode( "','", $restricted_taxonomies ) . "')",
|
253 |
+
ARRAY_A
|
254 |
+
);
|
255 |
+
|
256 |
+
if ( ! empty( $terms ) ) {
|
257 |
+
foreach ( $terms as $term ) {
|
258 |
+
if ( ! $this->is_restricted_term( $term['term_id'] ) ) {
|
259 |
+
continue;
|
260 |
+
}
|
261 |
+
|
262 |
+
$this->ignore_exclude = true;
|
263 |
+
// exclude all posts assigned to current term without individual restriction settings
|
264 |
+
$posts = get_posts(
|
265 |
+
array(
|
266 |
+
'fields' => 'ids',
|
267 |
+
'post_status' => 'any',
|
268 |
+
'numberposts' => -1,
|
269 |
+
'tax_query' => array(
|
270 |
+
array(
|
271 |
+
'taxonomy' => $term['taxonomy'],
|
272 |
+
'field' => 'id',
|
273 |
+
'terms' => $term['term_id'],
|
274 |
+
),
|
275 |
+
),
|
276 |
+
'meta_query' => array(
|
277 |
+
'relation' => 'OR',
|
278 |
+
array(
|
279 |
+
'relation' => 'AND',
|
280 |
+
array(
|
281 |
+
'key' => 'um_content_restriction',
|
282 |
+
'value' => 's:26:"_um_custom_access_settings";s:1:"1"',
|
283 |
+
'compare' => 'NOT LIKE',
|
284 |
+
),
|
285 |
+
array(
|
286 |
+
'key' => 'um_content_restriction',
|
287 |
+
'value' => 's:26:"_um_custom_access_settings";b:1',
|
288 |
+
'compare' => 'NOT LIKE',
|
289 |
+
),
|
290 |
+
),
|
291 |
+
array(
|
292 |
+
'key' => 'um_content_restriction',
|
293 |
+
'compare' => 'NOT EXISTS',
|
294 |
+
),
|
295 |
+
),
|
296 |
+
)
|
297 |
+
);
|
298 |
+
$this->ignore_exclude = false;
|
299 |
+
|
300 |
+
if ( empty( $posts ) ) {
|
301 |
+
continue;
|
302 |
+
}
|
303 |
+
|
304 |
+
$post_ids = array_merge( $post_ids, $posts );
|
305 |
+
}
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
+
if ( ! empty( $post_ids ) ) {
|
310 |
+
$post_ids = array_unique( $post_ids );
|
311 |
|
312 |
+
foreach ( $post_ids as $post_id ) {
|
313 |
+
// handle every post privacy setting based on post type maybe it's inactive for now
|
314 |
+
// if individual restriction is enabled then get post terms restriction settings
|
315 |
+
if ( $this->is_restricted( $post_id ) ) {
|
316 |
+
if ( true === $force ) {
|
317 |
+
array_push( $exclude_posts, $post_id );
|
318 |
+
} else {
|
319 |
+
$content_restriction = $this->get_post_privacy_settings( $post_id );
|
320 |
+
if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) {
|
321 |
+
array_push( $exclude_posts, $post_id );
|
322 |
+
}
|
323 |
+
}
|
324 |
+
}
|
325 |
+
}
|
326 |
+
}
|
327 |
}
|
328 |
|
329 |
+
$exclude_posts = apply_filters( 'um_exclude_restricted_posts_ids', $exclude_posts, $force );
|
330 |
+
|
331 |
+
$cache[ $cache_key ] = $exclude_posts;
|
332 |
+
return $exclude_posts;
|
333 |
+
}
|
334 |
+
|
335 |
+
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Get array with restricted terms
|
339 |
+
*
|
340 |
+
* @param \WP_Term_Query $query
|
341 |
+
*
|
342 |
+
* @return array
|
343 |
+
*/
|
344 |
+
function exclude_terms_array( $query ) {
|
345 |
+
$exclude = array();
|
346 |
+
|
347 |
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
348 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
349 |
+
$restricted_taxonomies = array_keys( $restricted_taxonomies );
|
350 |
+
foreach ( $restricted_taxonomies as $k => $taxonomy ) {
|
351 |
+
if ( ! taxonomy_exists( $taxonomy ) ) {
|
352 |
+
unset( $restricted_taxonomies[ $k ] );
|
353 |
+
}
|
354 |
+
}
|
355 |
+
$restricted_taxonomies = array_values( $restricted_taxonomies );
|
356 |
+
|
357 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
358 |
+
if ( isset( $query->query_vars['taxonomy'] ) && is_array( $query->query_vars['taxonomy'] ) ) {
|
359 |
+
$restricted_taxonomies = array_intersect( $query->query_vars['taxonomy'], $restricted_taxonomies );
|
360 |
+
} elseif ( ! empty( $query->query_vars['term_taxonomy_id'] ) ) {
|
361 |
+
$term_taxonomy_ids = is_array( $query->query_vars['term_taxonomy_id'] ) ? $query->query_vars['term_taxonomy_id'] : array( $query->query_vars['term_taxonomy_id'] );
|
362 |
+
|
363 |
+
global $wpdb;
|
364 |
+
$tax_in_query = $wpdb->get_col( "SELECT DISTINCT taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN('" . implode( "','", $term_taxonomy_ids ) . "')" );
|
365 |
+
if ( ! empty( $tax_in_query ) ) {
|
366 |
+
$restricted_taxonomies = array_intersect( $tax_in_query, $restricted_taxonomies );
|
367 |
+
} else {
|
368 |
+
$restricted_taxonomies = array();
|
369 |
+
}
|
370 |
+
}
|
371 |
+
}
|
372 |
+
}
|
373 |
+
|
374 |
if ( empty( $restricted_taxonomies ) ) {
|
375 |
+
return $exclude;
|
|
|
376 |
}
|
377 |
|
378 |
+
$cache_key = md5( serialize( $restricted_taxonomies ) );
|
379 |
+
|
380 |
+
static $cache = array();
|
381 |
+
|
382 |
+
if ( array_key_exists( $cache_key, $cache ) ) {
|
383 |
+
return $cache[ $cache_key ];
|
384 |
+
}
|
385 |
+
|
386 |
+
$term_ids = get_terms(
|
387 |
+
array(
|
388 |
+
'taxonomy' => $restricted_taxonomies,
|
389 |
+
'hide_empty' => false,
|
390 |
+
'fields' => 'ids',
|
391 |
+
'meta_query' => array(
|
392 |
+
'key' => 'um_content_restriction',
|
393 |
+
'compare' => 'EXISTS',
|
394 |
+
),
|
395 |
+
'um_ignore_exclude' => true,
|
396 |
+
)
|
397 |
);
|
398 |
|
399 |
+
if ( empty( $term_ids ) || is_wp_error( $term_ids ) ) {
|
400 |
+
$cache[ $cache_key ] = $exclude;
|
401 |
+
return $exclude;
|
402 |
}
|
403 |
|
|
|
404 |
foreach ( $term_ids as $term_id ) {
|
405 |
if ( $this->is_restricted_term( $term_id ) ) {
|
406 |
$exclude[] = $term_id;
|
407 |
}
|
408 |
}
|
409 |
|
410 |
+
$exclude = apply_filters( 'um_exclude_restricted_terms_ids', $exclude );
|
411 |
+
$cache[ $cache_key ] = $exclude;
|
412 |
return $exclude;
|
413 |
}
|
414 |
|
415 |
|
416 |
+
/**
|
417 |
+
* @param \WP_Term_Query $query
|
418 |
+
*/
|
419 |
function exclude_hidden_terms_query( $query ) {
|
420 |
+
if ( current_user_can( 'administrator' ) || ! empty( $query->query_vars['um_ignore_exclude'] ) ) {
|
421 |
return;
|
422 |
}
|
423 |
|
424 |
+
$exclude = $this->exclude_terms_array( $query );
|
425 |
if ( ! empty( $exclude ) ) {
|
426 |
$query->query_vars['exclude'] = ! empty( $query->query_vars['exclude'] ) ? wp_parse_id_list( $query->query_vars['exclude'] ) : $exclude;
|
427 |
}
|
428 |
}
|
429 |
|
430 |
|
431 |
+
/**
|
432 |
+
* @param \WP_Query $query
|
433 |
+
*/
|
434 |
+
function exclude_posts( $query ) {
|
435 |
+
if ( current_user_can( 'administrator' ) ) {
|
436 |
+
return;
|
437 |
+
}
|
438 |
+
|
439 |
+
// use these functions is_search() || is_admin() for getting force hide all posts
|
440 |
+
// don't handle `hide from WP_Query` and show 404 option for searching and wp-admin query
|
441 |
+
if ( $query->is_main_query() || ! empty( $query->query_vars['um_main_query'] ) ) {
|
442 |
+
$force = is_feed() || is_search() || is_admin();
|
443 |
+
|
444 |
+
if ( is_object( $query ) ) {
|
445 |
+
$is_singular = $query->is_singular();
|
446 |
+
} else {
|
447 |
+
$is_singular = ! empty( $query->is_singular ) ? true : false;
|
448 |
+
}
|
449 |
+
|
450 |
+
if ( ! $is_singular ) {
|
451 |
+
// need to know what post type is here
|
452 |
+
$q_values = ! empty( $query->query_vars['post_type'] ) ? $query->query_vars['post_type'] : array();
|
453 |
+
if ( ! is_array( $q_values ) ) {
|
454 |
+
$q_values = explode( ',', $query->query_vars['post_type'] );
|
455 |
+
}
|
456 |
+
|
457 |
+
// 'any' will cause the query var to be ignored.
|
458 |
+
if ( in_array( 'any', $q_values, true ) || empty( $q_values ) ) {
|
459 |
+
$exclude_posts = $this->exclude_posts_array( $force );
|
460 |
+
} else {
|
461 |
+
$exclude_posts = $this->exclude_posts_array( $force, $q_values );
|
462 |
+
}
|
463 |
+
|
464 |
+
if ( ! empty( $exclude_posts ) ) {
|
465 |
+
$post__not_in = $query->get( 'post__not_in', array() );
|
466 |
+
$query->set( 'post__not_in', array_merge( wp_parse_id_list( $post__not_in ), $exclude_posts ) );
|
467 |
+
}
|
468 |
+
}
|
469 |
+
}
|
470 |
+
}
|
471 |
+
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Exclude restricted post from query if there is a single query that exclude post_not_in by default in \WP_Query
|
475 |
+
*
|
476 |
+
* @param string $where
|
477 |
+
* @param \WP_Query $query
|
478 |
+
*
|
479 |
+
* @return mixed
|
480 |
+
*/
|
481 |
+
function exclude_posts_where( $where, $query ) {
|
482 |
+
if ( current_user_can( 'administrator' ) ) {
|
483 |
+
return $where;
|
484 |
+
}
|
485 |
+
|
486 |
+
if ( ! $query->is_main_query() ) {
|
487 |
+
return $where;
|
488 |
+
}
|
489 |
+
|
490 |
+
if ( ! empty( $query->query_vars['p'] ) && $this->is_restricted( $query->query_vars['p'] ) ) {
|
491 |
+
$restriction_settings = $this->get_post_privacy_settings( $query->query_vars['p'] );
|
492 |
+
if ( ! empty( $restriction_settings['_um_access_hide_from_queries'] ) && ! empty( $query->query_vars['post__not_in'] ) ) {
|
493 |
+
global $wpdb;
|
494 |
+
$post__not_in = implode( ',', array_map( 'absint', $query->query_vars['post__not_in'] ) );
|
495 |
+
$where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)";
|
496 |
+
}
|
497 |
+
}
|
498 |
+
|
499 |
+
return $where;
|
500 |
+
}
|
501 |
+
|
502 |
+
|
503 |
+
/**
|
504 |
+
* Change the posts count based on restriction settings
|
505 |
+
*
|
506 |
+
* @param object $counts Post counts
|
507 |
+
* @param string $type Post type
|
508 |
+
* @param string $perm The permission to determine if the posts are 'readable'
|
509 |
+
* by the current user.
|
510 |
+
*
|
511 |
+
* @return object
|
512 |
+
*/
|
513 |
function custom_count_posts_handler( $counts, $type, $perm ) {
|
514 |
+
if ( current_user_can( 'administrator' ) ) {
|
515 |
+
return $counts;
|
516 |
+
}
|
517 |
+
|
518 |
global $wpdb;
|
519 |
|
520 |
+
static $cache = array();
|
521 |
+
|
522 |
+
$cache_key = _count_posts_cache_key( $type, $perm );
|
523 |
+
$force = is_feed() || is_search() || is_admin();
|
524 |
+
$cache_key .= $force ? 'force' : '';
|
525 |
+
|
526 |
+
if ( array_key_exists( $cache_key, $cache ) ) {
|
527 |
+
return $cache[ $cache_key ];
|
528 |
+
}
|
529 |
+
|
530 |
+
$exclude_posts = $this->exclude_posts_array( $force, array( $type ) );
|
531 |
if ( empty( $exclude_posts ) ) {
|
532 |
+
$cache[ $cache_key ] = $counts;
|
533 |
return $counts;
|
534 |
}
|
535 |
|
|
|
|
|
536 |
$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
|
537 |
|
538 |
if ( 'readable' === $perm && is_user_logged_in() ) {
|
557 |
}
|
558 |
|
559 |
$counts = (object) $counts;
|
|
|
560 |
|
561 |
+
$cache[ $cache_key ] = $counts;
|
562 |
return $counts;
|
563 |
}
|
564 |
|
565 |
|
566 |
+
/**
|
567 |
+
* Exclude restricted posts in Recent Posts widget
|
568 |
+
*
|
569 |
+
* @param array $array Query args
|
570 |
+
*
|
571 |
+
* @return array
|
572 |
+
*/
|
573 |
+
function exclude_restricted_posts_widget( $array ) {
|
574 |
+
if ( current_user_can( 'administrator' ) ) {
|
575 |
+
return $array;
|
576 |
}
|
577 |
|
578 |
+
$exclude_posts = $this->exclude_posts_array( false, 'post' );
|
579 |
+
if ( ! empty( $exclude_posts ) ) {
|
580 |
+
$post__not_in = ! empty( $array['post__not_in'] ) ? $array['post__not_in'] : array();
|
581 |
+
$array['post__not_in'] = array_merge( wp_parse_id_list( $post__not_in ), $exclude_posts );
|
582 |
}
|
583 |
|
584 |
+
return $array;
|
|
|
|
|
|
|
|
|
|
|
|
|
585 |
}
|
586 |
|
587 |
|
588 |
+
/**
|
589 |
+
* Exclude restricted posts in Recent Posts widget
|
590 |
+
*
|
591 |
+
* @param array $array Query args
|
592 |
+
*
|
593 |
+
* @return array
|
594 |
+
*/
|
595 |
+
function exclude_restricted_pages( $array ) {
|
596 |
+
if ( current_user_can( 'administrator' ) ) {
|
597 |
+
return $array;
|
|
|
|
|
|
|
|
|
598 |
}
|
599 |
|
600 |
+
$exclude_posts = $this->exclude_posts_array( false, 'page' );
|
601 |
if ( ! empty( $exclude_posts ) ) {
|
602 |
+
$array = array_merge( $array, $exclude_posts );
|
|
|
603 |
}
|
604 |
|
605 |
+
return $array;
|
606 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
607 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
608 |
|
609 |
+
/**
|
610 |
+
* Exclude restricted posts in widgets
|
611 |
+
*
|
612 |
+
* @param string $sql_where
|
613 |
+
* @param array $parsed_args
|
614 |
+
*
|
615 |
+
* @return string
|
616 |
+
*/
|
617 |
+
function exclude_restricted_posts_archives_widget( $sql_where, $parsed_args ) {
|
618 |
+
if ( current_user_can( 'administrator' ) ) {
|
619 |
+
return $sql_where;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
620 |
}
|
621 |
|
622 |
+
$exclude_posts = $this->exclude_posts_array( false, $parsed_args['post_type'] );
|
623 |
+
if ( ! empty( $exclude_posts ) ) {
|
624 |
+
$exclude_string = implode( ',', $exclude_posts );
|
625 |
+
$sql_where .= ' AND ID NOT IN ( ' . $exclude_string . ' )';
|
626 |
+
}
|
627 |
|
628 |
+
return $sql_where;
|
629 |
}
|
630 |
|
631 |
|
632 |
/**
|
633 |
+
* Exclude posts from next, previous navigation
|
634 |
*
|
635 |
+
* @param string $where
|
636 |
+
* @param bool $in_same_term
|
637 |
+
* @param array $excluded_terms
|
638 |
+
* @param string $taxonomy.
|
639 |
+
* @param \WP_Post $post
|
640 |
+
*
|
641 |
+
* @return string
|
642 |
*/
|
643 |
+
function exclude_navigation_posts( $where, $in_same_term, $excluded_terms, $taxonomy, $post ) {
|
644 |
+
if ( current_user_can( 'administrator' ) ) {
|
645 |
+
return $where;
|
646 |
+
}
|
647 |
+
|
648 |
+
$exclude_posts = $this->exclude_posts_array( false, $post->post_type );
|
649 |
+
if ( ! empty( $exclude_posts ) ) {
|
650 |
+
$exclude_string = implode( ',', $exclude_posts );
|
651 |
+
$where .= ' AND ID NOT IN ( ' . $exclude_string . ' )';
|
652 |
+
}
|
653 |
+
|
654 |
+
return $where;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
655 |
}
|
656 |
|
657 |
|
658 |
/**
|
659 |
+
* Replace titles of restricted posts
|
660 |
+
*
|
661 |
+
* @param string $title
|
662 |
+
* @param int|null $id
|
663 |
+
*
|
664 |
+
* @return string
|
665 |
*/
|
666 |
+
function filter_restricted_post_title( $title, $id = null ) {
|
667 |
+
if ( ! UM()->options()->get( 'restricted_post_title_replace' ) ) {
|
668 |
+
return $title;
|
|
|
669 |
}
|
670 |
|
671 |
+
if ( current_user_can( 'administrator' ) ) {
|
672 |
+
return $title;
|
673 |
+
}
|
|
|
|
|
|
|
|
|
674 |
|
675 |
+
if ( ! isset( $id ) ) {
|
676 |
+
return $title;
|
677 |
+
}
|
678 |
|
679 |
+
if ( ! is_numeric( $id ) ) {
|
680 |
+
$id = absint( $id );
|
681 |
}
|
682 |
|
683 |
+
$ignore = apply_filters( 'um_ignore_restricted_title', false, $id );
|
684 |
+
if ( $ignore ) {
|
685 |
+
return $title;
|
686 |
}
|
687 |
|
688 |
+
if ( $this->is_restricted( $id ) ) {
|
689 |
+
$restricted_global_title = UM()->options()->get( 'restricted_access_post_title' );
|
690 |
+
$title = stripslashes( $restricted_global_title );
|
691 |
+
}
|
|
|
692 |
|
693 |
+
return $title;
|
694 |
+
}
|
|
|
695 |
|
|
|
696 |
|
697 |
+
/**
|
698 |
+
* Replace content of restricted posts
|
699 |
+
*
|
700 |
+
* @param string $content
|
701 |
+
*
|
702 |
+
* @return string
|
703 |
+
*/
|
704 |
+
function filter_restricted_post_content( $content ) {
|
705 |
+
if ( current_user_can( 'administrator' ) ) {
|
706 |
+
return $content;
|
707 |
+
}
|
708 |
|
709 |
+
$id = get_the_ID();
|
710 |
+
if ( ! $id || is_admin() ) {
|
711 |
+
return $content;
|
712 |
+
}
|
713 |
|
714 |
+
$ignore = apply_filters( 'um_ignore_restricted_content', false, $id );
|
715 |
+
if ( $ignore ) {
|
716 |
+
return $content;
|
717 |
+
}
|
|
|
718 |
|
719 |
+
if ( $this->is_restricted( $id ) ) {
|
720 |
+
$restriction = $this->get_post_privacy_settings( $id );
|
721 |
|
722 |
+
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
723 |
+
$content = stripslashes( UM()->options()->get( 'restricted_access_message' ) );
|
724 |
+
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
725 |
+
$content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
726 |
}
|
727 |
}
|
728 |
+
|
729 |
+
return $content;
|
730 |
}
|
731 |
|
732 |
|
733 |
/**
|
734 |
+
* Replace excerpt of restricted posts
|
735 |
+
*
|
736 |
+
* @param string $post_excerpt
|
737 |
+
* @param \WP_Post $post
|
738 |
*
|
739 |
* @return string
|
740 |
*/
|
741 |
+
function filter_restricted_post_excerpt( $post_excerpt, $post ) {
|
742 |
+
if ( empty( $post ) ) {
|
743 |
+
return $post_excerpt;
|
744 |
+
}
|
745 |
|
746 |
+
if ( current_user_can( 'administrator' ) || is_admin() ) {
|
747 |
+
return $post_excerpt;
|
748 |
+
}
|
749 |
|
750 |
+
$ignore = apply_filters( 'um_ignore_restricted_excerpt', false, $post->ID );
|
751 |
+
if ( $ignore ) {
|
752 |
+
return $post_excerpt;
|
753 |
+
}
|
|
|
754 |
|
755 |
+
if ( $this->is_restricted( $post->ID ) ) {
|
756 |
+
$post_excerpt = '';
|
757 |
+
}
|
758 |
|
759 |
+
return $post_excerpt;
|
760 |
+
}
|
761 |
|
|
|
|
|
|
|
|
|
762 |
|
763 |
+
/**
|
764 |
+
* Hide attachment if the post is restricted
|
765 |
+
*
|
766 |
+
* @param string $url
|
767 |
+
* @param int $attachment_id
|
768 |
+
*
|
769 |
+
* @return boolean|string
|
770 |
+
*/
|
771 |
+
function filter_attachment( $url, $attachment_id ) {
|
772 |
+
if ( current_user_can( 'administrator' ) ) {
|
773 |
+
return $url;
|
774 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
775 |
|
776 |
+
return ( $attachment_id && $this->is_restricted( $attachment_id ) ) ? false : $url;
|
777 |
+
}
|
778 |
|
|
|
|
|
|
|
779 |
|
780 |
+
/**
|
781 |
+
* Hide attachment if the post is restricted
|
782 |
+
*
|
783 |
+
* @param $has_thumbnail
|
784 |
+
* @param $post
|
785 |
+
* @param $thumbnail_id
|
786 |
+
*
|
787 |
+
* @return bool
|
788 |
+
*/
|
789 |
+
function filter_post_thumbnail( $has_thumbnail, $post, $thumbnail_id ) {
|
790 |
+
if ( current_user_can( 'administrator' ) ) {
|
791 |
+
return $has_thumbnail;
|
792 |
+
}
|
793 |
|
794 |
+
if ( $this->is_restricted( $thumbnail_id ) ) {
|
795 |
+
$has_thumbnail = false;
|
796 |
+
} elseif ( ! empty( $post ) && ! empty( $post->ID ) ) {
|
797 |
+
if ( $this->is_restricted( $post->ID ) ) {
|
798 |
+
$has_thumbnail = false;
|
|
|
799 |
}
|
800 |
+
} else {
|
801 |
+
$post_id = get_the_ID();
|
802 |
+
if ( false !== $post_id && $this->is_restricted( $post_id ) ) {
|
803 |
+
$has_thumbnail = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
804 |
}
|
805 |
}
|
806 |
|
807 |
+
$has_thumbnail = apply_filters( 'um_restrict_post_thumbnail', $has_thumbnail, $post, $thumbnail_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
808 |
|
809 |
+
return $has_thumbnail;
|
|
|
|
|
|
|
|
|
|
|
810 |
}
|
811 |
|
812 |
|
813 |
+
|
814 |
/**
|
815 |
+
* Exclude comments from restricted posts in widgets
|
816 |
*
|
817 |
+
* @param \WP_Comment_Query $query
|
818 |
*/
|
819 |
+
function exclude_posts_comments( $query ) {
|
|
|
|
|
|
|
820 |
if ( current_user_can( 'administrator' ) ) {
|
821 |
return;
|
822 |
}
|
823 |
|
824 |
+
if ( ! empty( $query->query_vars['post_id'] ) ) {
|
825 |
+
$exclude_posts = array();
|
826 |
+
if ( $this->is_restricted( $query->query_vars['post_id'] ) ) {
|
827 |
+
$exclude_posts[] = $query->query_vars['post_id'];
|
828 |
+
}
|
829 |
} else {
|
830 |
+
$q_values = ! empty( $query->query_vars['post_type'] ) ? $query->query_vars['post_type'] : array();
|
831 |
+
if ( ! is_array( $q_values ) ) {
|
832 |
+
$q_values = explode( ',', $query->query_vars['post_type'] );
|
833 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
834 |
|
835 |
+
// 'any' will cause the query var to be ignored.
|
836 |
+
if ( in_array( 'any', $q_values, true ) || empty( $q_values ) ) {
|
837 |
+
$exclude_posts = $this->exclude_posts_array( true, $this->get_available_comments_post_types() );
|
838 |
+
} else {
|
839 |
+
$exclude_posts = $this->exclude_posts_array( true, $q_values );
|
840 |
+
}
|
841 |
}
|
842 |
|
843 |
+
if ( ! empty( $exclude_posts ) ) {
|
844 |
+
$post__not_in = ! empty( $query->query_vars['post__not_in'] ) ? $query->query_vars['post__not_in'] : array();
|
845 |
+
$query->query_vars['post__not_in'] = array_merge( wp_parse_id_list( $post__not_in ), $exclude_posts );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
846 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
847 |
}
|
848 |
|
849 |
|
850 |
/**
|
851 |
+
* @return array
|
|
|
|
|
852 |
*/
|
853 |
+
function get_available_comments_post_types() {
|
854 |
+
global $wp_taxonomies;
|
855 |
+
|
856 |
+
$restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' );
|
857 |
+
if ( empty( $restricted_posts ) ) {
|
858 |
+
$restricted_posts = array();
|
859 |
}
|
860 |
+
$restricted_posts = array_keys( $restricted_posts );
|
861 |
|
862 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
863 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
864 |
+
$restricted_taxonomies = array_keys( $restricted_taxonomies );
|
865 |
+
foreach ( $restricted_taxonomies as $k => $taxonomy ) {
|
866 |
+
if ( taxonomy_exists( $taxonomy ) ) {
|
867 |
+
$restricted_posts = array_merge( $restricted_posts, $wp_taxonomies[ $taxonomy ]->object_type );
|
868 |
+
}
|
869 |
+
}
|
870 |
}
|
871 |
|
872 |
+
$restricted_posts = array_unique( $restricted_posts );
|
873 |
+
foreach ( $restricted_posts as $k => $post_type ) {
|
874 |
+
if ( 'closed' === get_default_comment_status( $post_type ) ) {
|
875 |
+
unset( $restricted_posts[ $k ] );
|
876 |
+
}
|
877 |
+
}
|
878 |
+
|
879 |
+
$restricted_posts = array_values( $restricted_posts );
|
880 |
+
|
881 |
+
return $restricted_posts;
|
882 |
}
|
883 |
|
884 |
|
885 |
/**
|
886 |
+
* Exclude comments from comments feed
|
887 |
*
|
888 |
+
* @param string $where
|
889 |
+
* @param \WP_Query $query
|
890 |
*
|
891 |
* @return string
|
892 |
*/
|
893 |
+
function exclude_posts_comments_feed( $where, $query ) {
|
894 |
+
if ( current_user_can( 'administrator' ) ) {
|
895 |
+
return $where;
|
896 |
+
}
|
897 |
|
898 |
+
$exclude_posts = $this->exclude_posts_array( true, $this->get_available_comments_post_types() );
|
899 |
+
if ( ! empty( $exclude_posts ) ) {
|
900 |
+
$exclude_string = implode( ',', $exclude_posts );
|
901 |
+
$where .= ' AND comment_post_ID NOT IN ( ' . $exclude_string . ' )';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
902 |
}
|
903 |
|
904 |
+
return $where;
|
|
|
905 |
}
|
906 |
|
907 |
|
908 |
/**
|
909 |
+
* @param object $stats
|
910 |
+
* @param int $post_id Post ID. Can be 0 for the whole website
|
911 |
*
|
912 |
+
* @return object
|
|
|
|
|
913 |
*/
|
914 |
+
function custom_comments_count_handler( $stats, $post_id ) {
|
915 |
+
if ( ! empty( $stats ) || current_user_can( 'administrator' ) ) {
|
916 |
+
return $stats;
|
917 |
+
}
|
918 |
|
919 |
+
if ( $post_id === 0 ) {
|
920 |
+
$exclude_posts = $this->exclude_posts_array( true, $this->get_available_comments_post_types() );
|
921 |
+
if ( empty( $exclude_posts ) ) {
|
922 |
+
return $stats;
|
923 |
+
}
|
924 |
+
} else {
|
925 |
+
$exclude_posts = array();
|
926 |
+
if ( $this->is_restricted( $post_id ) ) {
|
927 |
+
$exclude_posts[] = $post_id;
|
928 |
}
|
929 |
}
|
930 |
|
931 |
+
$stats = $this->get_comment_count( $post_id, $exclude_posts );
|
932 |
+
$stats['moderated'] = $stats['awaiting_moderation'];
|
933 |
+
unset( $stats['awaiting_moderation'] );
|
934 |
+
|
935 |
+
$stats_object = (object) $stats;
|
936 |
+
|
937 |
+
return $stats_object;
|
938 |
}
|
939 |
|
940 |
|
941 |
/**
|
942 |
+
* @param int $post_id
|
943 |
+
* @param array $exclude_posts
|
|
|
944 |
*
|
945 |
+
* @return array
|
|
|
946 |
*/
|
947 |
+
function get_comment_count( $post_id = 0, $exclude_posts = array() ) {
|
948 |
static $cache = array();
|
949 |
|
950 |
+
if ( isset( $cache[ $post_id ] ) ) {
|
951 |
+
return $cache[ $post_id ];
|
|
|
|
|
|
|
|
|
|
|
|
|
952 |
}
|
953 |
|
954 |
+
global $wpdb;
|
|
|
|
|
|
|
|
|
955 |
|
956 |
+
$post_id = (int) $post_id;
|
|
|
|
|
957 |
|
958 |
+
$where = 'WHERE 1=1';
|
959 |
+
if ( $post_id > 0 ) {
|
960 |
+
$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
|
|
|
961 |
}
|
962 |
|
963 |
+
if ( ! empty( $exclude_posts ) ) {
|
964 |
+
$exclude_string = implode( ',', $exclude_posts );
|
965 |
+
$where .= ' AND comment_post_ID NOT IN ( ' . $exclude_string . ' )';
|
|
|
966 |
}
|
967 |
|
968 |
+
$totals = (array) $wpdb->get_results(
|
969 |
+
"
|
970 |
+
SELECT comment_approved, COUNT( * ) AS total
|
971 |
+
FROM {$wpdb->comments}
|
972 |
+
{$where}
|
973 |
+
GROUP BY comment_approved
|
974 |
+
",
|
975 |
+
ARRAY_A
|
976 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
977 |
|
978 |
+
$comment_count = array(
|
979 |
+
'approved' => 0,
|
980 |
+
'awaiting_moderation' => 0,
|
981 |
+
'spam' => 0,
|
982 |
+
'trash' => 0,
|
983 |
+
'post-trashed' => 0,
|
984 |
+
'total_comments' => 0,
|
985 |
+
'all' => 0,
|
986 |
+
);
|
987 |
|
988 |
+
foreach ( $totals as $row ) {
|
989 |
+
switch ( $row['comment_approved'] ) {
|
990 |
+
case 'trash':
|
991 |
+
$comment_count['trash'] = $row['total'];
|
992 |
+
break;
|
993 |
+
case 'post-trashed':
|
994 |
+
$comment_count['post-trashed'] = $row['total'];
|
995 |
+
break;
|
996 |
+
case 'spam':
|
997 |
+
$comment_count['spam'] = $row['total'];
|
998 |
+
$comment_count['total_comments'] += $row['total'];
|
999 |
+
break;
|
1000 |
+
case '1':
|
1001 |
+
$comment_count['approved'] = $row['total'];
|
1002 |
+
$comment_count['total_comments'] += $row['total'];
|
1003 |
+
$comment_count['all'] += $row['total'];
|
1004 |
+
break;
|
1005 |
+
case '0':
|
1006 |
+
$comment_count['awaiting_moderation'] = $row['total'];
|
1007 |
+
$comment_count['total_comments'] += $row['total'];
|
1008 |
+
$comment_count['all'] += $row['total'];
|
1009 |
+
break;
|
1010 |
+
default:
|
1011 |
+
break;
|
1012 |
}
|
1013 |
}
|
1014 |
|
1015 |
+
$comment_count = array_map( 'intval', $comment_count );
|
1016 |
+
$cache[ $post_id ] = $comment_count;
|
1017 |
|
1018 |
+
return $comment_count;
|
1019 |
+
}
|
1020 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1021 |
|
1022 |
+
/**
|
1023 |
+
* Disable comments if user has not permission to access this post
|
1024 |
+
*
|
1025 |
+
* @param mixed $open
|
1026 |
+
* @param int $post_id
|
1027 |
+
* @return boolean
|
1028 |
+
*/
|
1029 |
+
function disable_comments_open( $open, $post_id ) {
|
1030 |
+
if ( current_user_can( 'administrator' ) ) {
|
1031 |
+
return $open;
|
1032 |
}
|
1033 |
|
1034 |
+
static $cache = array();
|
|
|
|
|
1035 |
|
1036 |
+
if ( isset( $cache[ $post_id ] ) ) {
|
1037 |
+
return $cache[ $post_id ] ? $open : false;
|
|
|
|
|
|
|
|
|
|
|
|
|
1038 |
}
|
1039 |
|
1040 |
+
if ( ! $this->is_restricted( $post_id ) ) {
|
1041 |
+
$cache[ $post_id ] = $open;
|
1042 |
+
return $open;
|
1043 |
+
}
|
1044 |
+
|
1045 |
+
$open = false;
|
1046 |
+
|
1047 |
+
$cache[ $post_id ] = $open;
|
1048 |
+
return $open;
|
1049 |
}
|
1050 |
|
1051 |
|
1052 |
/**
|
1053 |
+
* Disable comments if user has not permission to access this post
|
|
|
|
|
|
|
1054 |
*
|
1055 |
+
* @param int $count
|
1056 |
+
* @param int $post_id
|
1057 |
+
* @return boolean
|
1058 |
*/
|
1059 |
+
function disable_comments_open_number( $count, $post_id ) {
|
1060 |
+
if ( current_user_can( 'administrator' ) ) {
|
1061 |
+
return $count;
|
1062 |
}
|
1063 |
|
1064 |
+
static $cache_number = array();
|
1065 |
+
|
1066 |
+
if ( isset( $cache_number[ $post_id ] ) ) {
|
1067 |
+
return $cache_number[ $post_id ];
|
1068 |
}
|
1069 |
|
1070 |
+
if ( ! $this->is_restricted( $post_id ) ) {
|
1071 |
+
$cache_number[ $post_id ] = $count;
|
1072 |
+
return $count;
|
1073 |
}
|
1074 |
|
1075 |
+
$count = 0;
|
1076 |
+
|
1077 |
+
$cache_number[ $post_id ] = $count;
|
1078 |
+
return $count;
|
1079 |
}
|
1080 |
|
1081 |
|
1082 |
/**
|
1083 |
+
* Protect Post Types in menu query
|
1084 |
* Restrict content new logic
|
1085 |
+
* @param $menu_items
|
1086 |
+
* @param $args
|
|
|
1087 |
* @return array
|
1088 |
*/
|
1089 |
+
function filter_menu( $menu_items, $args ) {
|
|
|
|
|
1090 |
//if empty
|
1091 |
+
if ( empty( $menu_items ) ) {
|
1092 |
+
return $menu_items;
|
1093 |
}
|
1094 |
|
1095 |
if ( current_user_can( 'administrator' ) ) {
|
1096 |
+
return $menu_items;
|
1097 |
}
|
1098 |
|
1099 |
+
$filtered_items = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1100 |
|
1101 |
//other filter
|
1102 |
+
foreach ( $menu_items as $menu_item ) {
|
1103 |
+
if ( ! empty( $menu_item->object_id ) && ! empty( $menu_item->object ) ) {
|
1104 |
+
if ( isset( $menu_item->type ) && 'taxonomy' === $menu_item->type ) {
|
1105 |
+
if ( ! $this->is_restricted_term( $menu_item->object_id ) ) {
|
1106 |
+
$filtered_items[] = $menu_item;
|
1107 |
+
continue;
|
1108 |
+
}
|
1109 |
+
} elseif ( isset( $menu_item->type ) && 'post_type' === $menu_item->type ) {
|
1110 |
+
if ( ! $this->is_restricted( $menu_item->object_id ) ) {
|
1111 |
+
$filtered_items[] = $menu_item;
|
1112 |
+
continue;
|
1113 |
+
} else {
|
1114 |
+
$restriction_settings = $this->get_post_privacy_settings( $menu_item->object_id );
|
1115 |
+
if ( UM()->options()->get( 'disable_restriction_pre_queries' ) || empty( $restriction_settings['_um_access_hide_from_queries'] ) ) {
|
1116 |
+
$filtered_items[] = $menu_item;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1117 |
continue;
|
1118 |
}
|
1119 |
+
}
|
1120 |
+
} elseif ( isset( $menu_item->type ) && 'custom' === $menu_item->type ) {
|
1121 |
+
$filtered_items[] = $menu_item;
|
1122 |
+
continue;
|
1123 |
+
} else {
|
1124 |
+
$filtered_items[] = $menu_item;
|
1125 |
+
continue;
|
1126 |
+
}
|
1127 |
+
} else {
|
1128 |
+
//add all other posts
|
1129 |
+
$filtered_items[] = $menu_item;
|
1130 |
+
}
|
1131 |
+
}
|
1132 |
|
1133 |
+
return $filtered_items;
|
1134 |
+
}
|
|
|
|
|
|
|
|
|
|
|
1135 |
|
|
|
1136 |
|
1137 |
+
/**
|
1138 |
+
* @param $block_content
|
1139 |
+
* @param $block
|
1140 |
+
*
|
1141 |
+
* @return string
|
1142 |
+
*/
|
1143 |
+
function restrict_blocks( $block_content, $block ) {
|
1144 |
+
if ( is_admin() ) {
|
1145 |
+
return $block_content;
|
1146 |
+
}
|
1147 |
|
1148 |
+
$restricted_blocks = UM()->options()->get( 'restricted_blocks' );
|
1149 |
+
if ( empty( $restricted_blocks ) ) {
|
1150 |
+
return $block_content;
|
1151 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1152 |
|
1153 |
+
if ( is_user_logged_in() && current_user_can( 'administrator' ) ) {
|
1154 |
+
return $block_content;
|
1155 |
+
}
|
1156 |
|
1157 |
+
if ( ! isset( $block['attrs']['um_is_restrict'] ) || $block['attrs']['um_is_restrict'] !== true ) {
|
1158 |
+
return $block_content;
|
1159 |
+
}
|
|
|
1160 |
|
1161 |
+
if ( empty( $block['attrs']['um_who_access'] ) ) {
|
1162 |
+
return $block_content;
|
1163 |
+
}
|
1164 |
|
1165 |
+
$default_message = UM()->options()->get( 'restricted_block_message' );
|
1166 |
+
switch ( $block['attrs']['um_who_access'] ) {
|
1167 |
+
case '1': {
|
1168 |
+
if ( ! is_user_logged_in() ) {
|
1169 |
+
$block_content = '';
|
1170 |
+
if ( isset( $block['attrs']['um_message_type'] ) ) {
|
1171 |
+
if ( $block['attrs']['um_message_type'] == '1' ) {
|
1172 |
+
$block_content = $default_message;
|
1173 |
+
} elseif ( $block['attrs']['um_message_type'] == '2' ) {
|
1174 |
+
$block_content = $block['attrs']['um_message_content'];
|
1175 |
+
}
|
1176 |
+
}
|
1177 |
+
} else {
|
1178 |
+
$display = true;
|
1179 |
|
1180 |
+
// What roles can access this content?
|
1181 |
+
if ( ! empty( $block['attrs']['um_roles_access'] ) ) {
|
1182 |
+
$display = false;
|
1183 |
+
foreach ( $block['attrs']['um_roles_access'] as $role ) {
|
1184 |
+
if ( current_user_can( $role ) ) {
|
1185 |
+
$display = true;
|
1186 |
+
}
|
1187 |
+
}
|
1188 |
+
}
|
1189 |
|
1190 |
+
$display = apply_filters( 'um_loggedin_block_restriction', $display, $block );
|
|
|
|
|
|
|
|
|
1191 |
|
1192 |
+
if ( ! $display ) {
|
1193 |
+
$block_content = '';
|
1194 |
+
if ( isset( $block['attrs']['um_message_type'] ) ) {
|
1195 |
+
if ( $block['attrs']['um_message_type'] == '1' ) {
|
1196 |
+
$block_content = $default_message;
|
1197 |
+
} elseif ( $block['attrs']['um_message_type'] == '2' ) {
|
1198 |
+
$block_content = $block['attrs']['um_message_content'];
|
1199 |
}
|
|
|
1200 |
}
|
1201 |
}
|
1202 |
}
|
1203 |
+
break;
|
1204 |
+
}
|
1205 |
+
case '2': {
|
1206 |
if ( is_user_logged_in() ) {
|
1207 |
+
$block_content = '';
|
1208 |
+
if ( isset( $block['attrs']['um_message_type'] ) ) {
|
1209 |
+
if ( $block['attrs']['um_message_type'] == '1' ) {
|
1210 |
+
$block_content = $default_message;
|
1211 |
+
} elseif ( $block['attrs']['um_message_type'] == '2' ) {
|
1212 |
+
$block_content = $block['attrs']['um_message_content'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1213 |
}
|
1214 |
}
|
1215 |
+
}
|
1216 |
+
break;
|
1217 |
+
}
|
1218 |
+
}
|
1219 |
|
1220 |
+
return $block_content;
|
1221 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1222 |
|
|
|
1223 |
|
1224 |
+
/**
|
1225 |
+
* Protect Post Types in query
|
1226 |
+
* Restrict content new logic
|
1227 |
+
*
|
1228 |
+
* @param $posts
|
1229 |
+
* @param \WP_Query $query
|
1230 |
+
* @return array
|
1231 |
+
*/
|
1232 |
+
function filter_protected_posts( $posts, $query ) {
|
1233 |
+
if ( current_user_can( 'administrator' ) ) {
|
1234 |
+
return $posts;
|
1235 |
+
}
|
1236 |
|
1237 |
+
//Woocommerce AJAX fixes....remove filtration on wc-ajax which goes to Front Page
|
1238 |
+
if ( ! empty( $_GET['wc-ajax'] ) && defined( 'WC_DOING_AJAX' ) && WC_DOING_AJAX ) {
|
1239 |
+
return $posts;
|
1240 |
+
}
|
1241 |
|
1242 |
+
//if empty
|
1243 |
+
if ( empty( $posts ) || is_admin() ) {
|
1244 |
+
return $posts;
|
1245 |
+
}
|
1246 |
|
1247 |
+
if ( is_object( $query ) ) {
|
1248 |
+
$is_singular = $query->is_singular();
|
1249 |
+
} else {
|
1250 |
+
$is_singular = ! empty( $query->is_singular ) ? true : false;
|
1251 |
+
}
|
1252 |
|
1253 |
+
if ( is_object( $query ) && is_a( $query, '\WP_Query' ) &&
|
1254 |
+
( $query->is_main_query() || ! empty( $query->query_vars['um_main_query'] ) ) ) {
|
1255 |
+
if ( $is_singular ) {
|
1256 |
+
if ( ! UM()->options()->get( 'disable_restriction_pre_queries' ) && $this->is_restricted( $posts[0]->ID ) ) {
|
1257 |
+
$content_restriction = $this->get_post_privacy_settings( $posts[0]->ID );
|
1258 |
+
if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) {
|
1259 |
+
unset( $posts[0] );
|
1260 |
+
return $posts;
|
1261 |
+
}
|
1262 |
+
}
|
1263 |
+
}
|
1264 |
+
}
|
1265 |
|
1266 |
+
$filtered_posts = array();
|
1267 |
|
1268 |
+
//other filter
|
1269 |
+
foreach ( $posts as $post ) {
|
1270 |
+
if ( is_user_logged_in() && isset( $post->post_author ) && $post->post_author == get_current_user_id() ) {
|
1271 |
+
$filtered_posts[] = $post;
|
1272 |
+
continue;
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
$restriction = $this->get_post_privacy_settings( $post );
|
1276 |
+
if ( ! $restriction ) {
|
1277 |
+
$filtered_posts[] = $post;
|
1278 |
+
continue;
|
1279 |
+
}
|
1280 |
|
1281 |
+
if ( $is_singular ) {
|
1282 |
+
$this->singular_page = true;
|
1283 |
+
}
|
1284 |
|
1285 |
+
if ( ! $this->is_restricted( $post->ID ) ) {
|
1286 |
+
$filtered_posts[] = $post;
|
1287 |
+
continue;
|
1288 |
+
} else {
|
1289 |
+
if ( $is_singular ) {
|
1290 |
+
if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) {
|
1291 |
+
if ( UM()->options()->get( 'disable_restriction_pre_queries' ) || empty( $restriction['_um_access_hide_from_queries'] ) ) {
|
1292 |
/**
|
1293 |
* UM hook
|
1294 |
*
|
1308 |
*/
|
1309 |
do_action( 'um_access_fix_external_post_content' );
|
1310 |
|
|
|
|
|
1311 |
$filtered_posts[] = $post;
|
1312 |
continue;
|
1313 |
+
}
|
1314 |
+
} elseif ( '1' == $restriction['_um_noaccess_action'] ) {
|
1315 |
+
$curr = UM()->permalinks()->get_current_url();
|
|
|
|
|
1316 |
|
1317 |
+
if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) {
|
1318 |
|
1319 |
+
exit( wp_redirect( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ) ) );
|
1320 |
|
1321 |
+
} elseif ( '1' == $restriction['_um_access_redirect'] ) {
|
|
|
|
|
|
|
|
|
1322 |
|
1323 |
+
if ( ! empty( $restriction['_um_access_redirect_url'] ) ) {
|
1324 |
+
$redirect = $restriction['_um_access_redirect_url'];
|
1325 |
+
} else {
|
1326 |
+
$redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) );
|
1327 |
}
|
1328 |
|
1329 |
+
exit( wp_redirect( $redirect ) );
|
1330 |
}
|
1331 |
}
|
|
|
1332 |
} else {
|
1333 |
+
if ( UM()->options()->get( 'disable_restriction_pre_queries' ) || empty( $restriction['_um_access_hide_from_queries'] ) ) {
|
1334 |
+
$filtered_posts[] = $post;
|
1335 |
+
continue;
|
1336 |
+
}
|
1337 |
+
}
|
1338 |
+
}
|
1339 |
+
}
|
1340 |
|
1341 |
+
return $filtered_posts;
|
1342 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1343 |
|
|
|
1344 |
|
1345 |
+
/**
|
1346 |
+
* Set custom access actions and redirection
|
1347 |
+
*
|
1348 |
+
* Old global restrict content logic
|
1349 |
+
*/
|
1350 |
+
function template_redirect() {
|
1351 |
+
global $post, $wp_query;
|
1352 |
|
1353 |
+
//if we logged by administrator it can access to all content
|
1354 |
+
if ( current_user_can( 'administrator' ) ) {
|
1355 |
+
return;
|
1356 |
+
}
|
1357 |
|
1358 |
+
if ( is_object( $wp_query ) ) {
|
1359 |
+
$is_singular = $wp_query->is_singular();
|
1360 |
+
} else {
|
1361 |
+
$is_singular = ! empty( $wp_query->is_singular ) ? true : false;
|
1362 |
+
}
|
1363 |
|
1364 |
+
//if we use individual restrict content options skip this function
|
1365 |
+
if ( $is_singular && $this->singular_page ) {
|
1366 |
+
return;
|
1367 |
+
}
|
1368 |
|
1369 |
+
//also skip if we currently at wp-admin or 404 page
|
1370 |
+
if ( is_admin() || is_404() ) {
|
1371 |
+
return;
|
1372 |
+
}
|
1373 |
+
|
1374 |
+
//also skip if we currently at UM Register|Login|Reset Password pages
|
1375 |
+
if ( um_is_core_post( $post, 'register' ) ||
|
1376 |
+
um_is_core_post( $post, 'password-reset' ) ||
|
1377 |
+
um_is_core_post( $post, 'login' ) ) {
|
1378 |
+
return;
|
1379 |
+
}
|
1380 |
|
1381 |
+
/**
|
1382 |
+
* UM hook
|
1383 |
+
*
|
1384 |
+
* @type action
|
1385 |
+
* @title um_roles_add_meta_boxes_um_role_meta
|
1386 |
+
* @description Check terms individual restrict options
|
1387 |
+
* @change_log
|
1388 |
+
* ["Since: 2.0"]
|
1389 |
+
* @usage add_action( 'um_access_check_individual_term_settings', 'function_name', 10 );
|
1390 |
+
* @example
|
1391 |
+
* <?php
|
1392 |
+
* add_action( 'um_access_check_individual_term_settings', 'my_access_check_individual_term_settings', 10 );
|
1393 |
+
* function my_access_check_individual_term_settings() {
|
1394 |
+
* // your code here
|
1395 |
+
* }
|
1396 |
+
* ?>
|
1397 |
+
*/
|
1398 |
+
do_action( 'um_access_check_individual_term_settings' );
|
1399 |
+
//exit from function if term page is accessible
|
1400 |
+
if ( $this->check_access() ) {
|
1401 |
+
return;
|
1402 |
+
}
|
1403 |
|
1404 |
+
/**
|
1405 |
+
* UM hook
|
1406 |
+
*
|
1407 |
+
* @type action
|
1408 |
+
* @title um_access_check_global_settings
|
1409 |
+
* @description Check global restrict content options
|
1410 |
+
* @change_log
|
1411 |
+
* ["Since: 2.0"]
|
1412 |
+
* @usage add_action( 'um_access_check_global_settings', 'function_name', 10 );
|
1413 |
+
* @example
|
1414 |
+
* <?php
|
1415 |
+
* add_action( 'um_access_check_global_settings', 'my_access_check_global_settings', 10 );
|
1416 |
+
* function my_access_check_global_settings() {
|
1417 |
+
* // your code here
|
1418 |
+
* }
|
1419 |
+
* ?>
|
1420 |
+
*/
|
1421 |
+
do_action( 'um_access_check_global_settings' );
|
1422 |
|
1423 |
+
$this->check_access();
|
1424 |
+
}
|
1425 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1426 |
|
1427 |
+
/**
|
1428 |
+
* Check individual term Content Restriction settings
|
1429 |
+
*/
|
1430 |
+
function um_access_check_individual_term_settings() {
|
1431 |
+
//check only tax|tags|categories - skip archive, author, and date lists
|
1432 |
+
if ( ! ( is_tax() || is_tag() || is_category() ) ) {
|
1433 |
+
return;
|
1434 |
+
}
|
1435 |
|
1436 |
+
$term_id = null;
|
1437 |
+
if ( is_tag() ) {
|
1438 |
+
$term_id = get_query_var( 'tag_id' );
|
1439 |
+
} elseif ( is_category() ) {
|
1440 |
+
$term_id = get_query_var( 'cat' );
|
1441 |
+
} elseif ( is_tax() ) {
|
1442 |
+
$tax_name = get_query_var( 'taxonomy' );
|
1443 |
|
1444 |
+
$term_name = get_query_var( 'term' );
|
1445 |
+
$term = get_term_by( 'slug', $term_name, $tax_name );
|
1446 |
|
1447 |
+
$term_id = ! empty( $term->term_id ) ? $term->term_id : $term_id;
|
1448 |
+
}
|
1449 |
|
1450 |
+
if ( ! isset( $term_id ) ) {
|
1451 |
+
return;
|
1452 |
+
}
|
1453 |
|
1454 |
+
if ( $this->is_restricted_term( $term_id, true ) ) {
|
1455 |
+
$restriction = get_term_meta( $term_id, 'um_content_restriction', true );
|
1456 |
+
if ( '1' == $restriction['_um_noaccess_action'] ) {
|
1457 |
+
$curr = UM()->permalinks()->get_current_url();
|
1458 |
|
1459 |
+
if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) {
|
|
|
|
|
|
|
|
|
1460 |
|
1461 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ), 'individual_term' );
|
1462 |
+
|
1463 |
+
} elseif ( '1' == $restriction['_um_access_redirect'] ) {
|
1464 |
+
|
1465 |
+
if ( ! empty( $restriction['_um_access_redirect_url'] ) ) {
|
1466 |
+
$redirect = $restriction['_um_access_redirect_url'];
|
1467 |
+
} else {
|
1468 |
+
$redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) );
|
1469 |
}
|
1470 |
+
|
1471 |
+
$this->redirect_handler = $this->set_referer( $redirect, 'individual_term' );
|
1472 |
+
|
1473 |
}
|
1474 |
+
} else {
|
1475 |
+
add_filter( 'tag_template', array( &$this, 'taxonomy_message' ), 10, 3 );
|
1476 |
+
add_filter( 'archive_template', array( &$this, 'taxonomy_message' ), 10, 3 );
|
1477 |
+
add_filter( 'category_template', array( &$this, 'taxonomy_message' ), 10, 3 );
|
1478 |
+
add_filter( 'taxonomy_template', array( &$this, 'taxonomy_message' ), 10, 3 );
|
1479 |
}
|
1480 |
}
|
|
|
|
|
1481 |
}
|
1482 |
|
1483 |
|
1484 |
/**
|
1485 |
+
* @param $template
|
1486 |
+
* @param $type
|
1487 |
+
* @param $templates
|
1488 |
*
|
1489 |
+
* @return string
|
1490 |
*/
|
1491 |
+
function taxonomy_message( $template, $type, $templates ) {
|
1492 |
+
return UM()->locate_template( 'restricted-taxonomy.php' );
|
1493 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1494 |
|
|
|
1495 |
|
1496 |
+
/**
|
1497 |
+
* Check global accessible settings
|
1498 |
+
*/
|
1499 |
+
function um_access_check_global_settings() {
|
1500 |
+
global $post;
|
1501 |
|
1502 |
+
$curr = UM()->permalinks()->get_current_url();
|
1503 |
+
$ms_empty_role_access = is_multisite() && is_user_logged_in() && ! UM()->roles()->get_priority_user_role( um_user( 'ID' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1504 |
|
1505 |
+
if ( is_front_page() ) {
|
1506 |
+
if ( is_user_logged_in() && ! $ms_empty_role_access ) {
|
1507 |
|
1508 |
+
$user_default_homepage = um_user( 'default_homepage' );
|
1509 |
+
if ( ! empty( $user_default_homepage ) ) {
|
1510 |
+
return;
|
1511 |
+
}
|
1512 |
|
1513 |
+
$redirect_homepage = um_user( 'redirect_homepage' );
|
1514 |
+
/**
|
1515 |
+
* UM hook
|
1516 |
+
*
|
1517 |
+
* @type filter
|
1518 |
+
* @title um_custom_homepage_redirect_url
|
1519 |
+
* @description Change custom homepage redirect
|
1520 |
+
* @input_vars
|
1521 |
+
* [{"var":"$url","type":"string","desc":"Redirect URL"},
|
1522 |
+
* {"var":"$id","type":"int","desc":"User ID"}]
|
1523 |
+
* @change_log
|
1524 |
+
* ["Since: 2.0"]
|
1525 |
+
* @usage
|
1526 |
+
* <?php add_filter( 'um_custom_homepage_redirect_url', 'function_name', 10, 2 ); ?>
|
1527 |
+
* @example
|
1528 |
+
* <?php
|
1529 |
+
* add_filter( 'um_custom_homepage_redirect_url', 'my_custom_homepage_redirect_url', 10, 2 );
|
1530 |
+
* function my_custom_homepage_redirect_url( $url, $id ) {
|
1531 |
+
* // your code here
|
1532 |
+
* return $url;
|
1533 |
+
* }
|
1534 |
+
* ?>
|
1535 |
+
*/
|
1536 |
+
$redirect_homepage = apply_filters( 'um_custom_homepage_redirect_url', $redirect_homepage, um_user( 'ID' ) );
|
1537 |
+
$redirect_to = ! empty( $redirect_homepage ) ? $redirect_homepage : um_get_core_page( 'user' );
|
1538 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect_to ) ), 'custom_homepage' );
|
1539 |
|
1540 |
+
} else {
|
1541 |
+
$access = UM()->options()->get( 'accessible' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1542 |
|
1543 |
+
if ( $access == 2 ) {
|
1544 |
+
//global settings for accessible home page
|
1545 |
+
$home_page_accessible = UM()->options()->get( 'home_page_accessible' );
|
|
|
|
|
1546 |
|
1547 |
+
if ( $home_page_accessible == 0 ) {
|
1548 |
+
//get redirect URL if not set get login page by default
|
1549 |
+
$redirect = UM()->options()->get( 'access_redirect' );
|
1550 |
+
if ( ! $redirect ) {
|
1551 |
+
$redirect = um_get_core_page( 'login' );
|
1552 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1553 |
|
1554 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect ) ), 'global' );
|
1555 |
+
} else {
|
1556 |
+
$this->allow_access = true;
|
1557 |
+
return;
|
1558 |
}
|
|
|
|
|
1559 |
}
|
1560 |
}
|
1561 |
+
} elseif ( is_category() ) {
|
1562 |
+
if ( ! is_user_logged_in() || $ms_empty_role_access ) {
|
1563 |
|
1564 |
+
$access = UM()->options()->get( 'accessible' );
|
|
|
1565 |
|
1566 |
+
if ( $access == 2 ) {
|
1567 |
+
//global settings for accessible home page
|
1568 |
+
$category_page_accessible = UM()->options()->get( 'category_page_accessible' );
|
1569 |
+
if ( $category_page_accessible == 0 ) {
|
1570 |
+
//get redirect URL if not set get login page by default
|
1571 |
+
$redirect = UM()->options()->get( 'access_redirect' );
|
1572 |
+
if ( ! $redirect ) {
|
1573 |
+
$redirect = um_get_core_page( 'login' );
|
|
|
|
|
1574 |
}
|
1575 |
+
|
1576 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect ) ), 'global' );
|
1577 |
+
} else {
|
1578 |
+
$this->allow_access = true;
|
1579 |
+
return;
|
1580 |
}
|
1581 |
}
|
1582 |
}
|
1583 |
}
|
1584 |
|
1585 |
+
$access = UM()->options()->get( 'accessible' );
|
1586 |
+
|
1587 |
+
if ( $access == 2 && ( ! is_user_logged_in() || $ms_empty_role_access ) ) {
|
1588 |
+
|
1589 |
+
//build exclude URLs pages
|
1590 |
+
$redirects = array();
|
1591 |
+
$redirects[] = trim( untrailingslashit( UM()->options()->get( 'access_redirect' ) ) );
|
1592 |
+
|
1593 |
+
$exclude_uris = UM()->options()->get( 'access_exclude_uris' );
|
1594 |
+
if ( ! empty( $exclude_uris ) ) {
|
1595 |
+
$exclude_uris = array_map( 'trim', $exclude_uris );
|
1596 |
+
$redirects = array_merge( $redirects, $exclude_uris );
|
1597 |
+
}
|
1598 |
+
|
1599 |
+
$redirects = array_unique( $redirects );
|
1600 |
+
|
1601 |
+
$current_url = UM()->permalinks()->get_current_url( get_option( 'permalink_structure' ) );
|
1602 |
+
$current_url = untrailingslashit( $current_url );
|
1603 |
+
$current_url_slash = trailingslashit( $current_url );
|
1604 |
|
1605 |
+
if ( ! ( isset( $post->ID ) && ( in_array( $current_url, $redirects ) || in_array( $current_url_slash, $redirects ) ) ) ) {
|
1606 |
+
//if current page not in exclude URLs
|
1607 |
+
//get redirect URL if not set get login page by default
|
1608 |
+
$redirect = UM()->options()->get( 'access_redirect' );
|
1609 |
+
if ( ! $redirect ) {
|
1610 |
+
$redirect = um_get_core_page( 'login' );
|
1611 |
+
}
|
1612 |
|
1613 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect ) ), 'global' );
|
1614 |
+
} else {
|
1615 |
+
$this->redirect_handler = false;
|
1616 |
+
$this->allow_access = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1617 |
}
|
1618 |
}
|
1619 |
}
|
1620 |
|
1621 |
|
1622 |
/**
|
1623 |
+
* Check access
|
1624 |
*
|
1625 |
+
* @return bool
|
1626 |
*/
|
1627 |
+
function check_access() {
|
1628 |
+
if ( $this->allow_access === true ) {
|
1629 |
+
return true;
|
|
|
|
|
1630 |
}
|
|
|
1631 |
|
1632 |
+
if ( $this->redirect_handler ) {
|
1633 |
+
wp_redirect( $this->redirect_handler );
|
1634 |
+
exit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1635 |
}
|
1636 |
|
1637 |
+
return false;
|
1638 |
}
|
1639 |
|
1640 |
|
1641 |
/**
|
1642 |
+
* Sets a custom access referer in a redirect URL
|
1643 |
*
|
1644 |
+
* @param string $url
|
1645 |
+
* @param string $referer
|
|
|
|
|
|
|
1646 |
*
|
1647 |
* @return string
|
1648 |
*/
|
1649 |
+
function set_referer( $url, $referer ) {
|
1650 |
+
|
1651 |
+
/**
|
1652 |
+
* UM hook
|
1653 |
+
*
|
1654 |
+
* @type filter
|
1655 |
+
* @title um_access_enable_referer
|
1656 |
+
* @description Access Referrer Enable/Disable
|
1657 |
+
* @input_vars
|
1658 |
+
* [{"var":"$referrer","type":"bool","desc":"Access referrer"}]
|
1659 |
+
* @change_log
|
1660 |
+
* ["Since: 2.0"]
|
1661 |
+
* @usage add_filter( 'um_access_enable_referer', 'function_name', 10, 1 );
|
1662 |
+
* @example
|
1663 |
+
* <?php
|
1664 |
+
* add_filter( 'um_access_enable_referer', 'my_access_enable_referer', 10, 1 );
|
1665 |
+
* function my_access_enable_referer( $referrer ) {
|
1666 |
+
* // your code here
|
1667 |
+
* return $referrer;
|
1668 |
+
* }
|
1669 |
+
* ?>
|
1670 |
+
*/
|
1671 |
+
$enable_referer = apply_filters( 'um_access_enable_referer', false );
|
1672 |
+
if ( ! $enable_referer ) {
|
1673 |
+
return $url;
|
1674 |
}
|
1675 |
|
1676 |
+
$url = add_query_arg( 'um_ref', $referer, $url );
|
1677 |
+
return $url;
|
1678 |
}
|
1679 |
|
1680 |
|
1681 |
/**
|
1682 |
+
* Get privacy settings for post
|
1683 |
+
* return false if post is not private
|
1684 |
+
* Restrict content new logic
|
1685 |
*
|
1686 |
+
* @param \WP_Post|int $post Post ID or object
|
1687 |
+
* @return bool|array
|
1688 |
*/
|
1689 |
+
function get_post_privacy_settings( $post ) {
|
1690 |
+
// break for incorrect post
|
1691 |
+
if ( empty( $post ) ) {
|
1692 |
+
return false;
|
|
|
1693 |
}
|
1694 |
|
1695 |
+
static $cache = array();
|
|
|
1696 |
|
1697 |
+
$cache_key = is_numeric( $post ) ? $post : $post->ID;
|
1698 |
|
1699 |
+
if ( isset( $cache[ $cache_key ] ) ) {
|
1700 |
+
return $cache[ $cache_key ];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1701 |
}
|
1702 |
|
1703 |
+
if ( is_numeric( $post ) ) {
|
1704 |
+
$post = get_post( $post );
|
1705 |
+
}
|
1706 |
+
|
1707 |
+
//if logged in administrator all pages are visible
|
1708 |
+
if ( current_user_can( 'administrator' ) ) {
|
1709 |
+
$cache[ $cache_key ] = false;
|
1710 |
+
return false;
|
1711 |
+
}
|
1712 |
|
1713 |
+
$exclude = false;
|
1714 |
+
//exclude from privacy UM default pages (except Members list and User(Profile) page)
|
1715 |
+
if ( ! empty( $post->post_type ) && $post->post_type === 'page' ) {
|
1716 |
|
1717 |
+
if ( um_is_core_post( $post, 'login' ) || um_is_core_post( $post, 'register' ) ||
|
1718 |
+
um_is_core_post( $post, 'account' ) || um_is_core_post( $post, 'logout' ) ||
|
1719 |
+
um_is_core_post( $post, 'password-reset' ) || ( is_user_logged_in() && um_is_core_post( $post, 'user' ) ) )
|
1720 |
+
$exclude = true;
|
|
|
|
|
|
|
|
|
1721 |
}
|
1722 |
|
1723 |
+
$exclude = apply_filters( 'um_exclude_posts_from_privacy', $exclude, $post );
|
1724 |
+
if ( $exclude ) {
|
1725 |
+
$cache[ $cache_key ] = false;
|
1726 |
+
return false;
|
1727 |
}
|
1728 |
|
1729 |
+
$restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' );
|
|
|
1730 |
|
1731 |
+
if ( ! empty( $post->post_type ) && ! empty( $restricted_posts[ $post->post_type ] ) ) {
|
1732 |
+
$restriction = get_post_meta( $post->ID, 'um_content_restriction', true );
|
1733 |
|
1734 |
+
if ( ! empty( $restriction['_um_custom_access_settings'] ) ) {
|
1735 |
+
if ( ! isset( $restriction['_um_accessible'] ) ) {
|
1736 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1737 |
|
1738 |
+
//get all taxonomies for current post type
|
1739 |
+
$taxonomies = get_object_taxonomies( $post );
|
1740 |
|
1741 |
+
//get all post terms
|
1742 |
+
$terms = array();
|
1743 |
+
if ( ! empty( $taxonomies ) ) {
|
1744 |
+
foreach ( $taxonomies as $taxonomy ) {
|
1745 |
+
if ( empty( $restricted_taxonomies[ $taxonomy ] ) ) {
|
1746 |
+
continue;
|
1747 |
+
}
|
|
|
|
|
1748 |
|
1749 |
+
$terms = array_merge( $terms, wp_get_post_terms( $post->ID, $taxonomy, array( 'fields' => 'ids', 'um_ignore_exclude' => true, ) ) );
|
1750 |
+
}
|
1751 |
+
}
|
1752 |
|
1753 |
+
//get restriction options for first term with privacy settigns
|
1754 |
+
foreach ( $terms as $term_id ) {
|
1755 |
+
$restriction = get_term_meta( $term_id, 'um_content_restriction', true );
|
|
|
|
|
|
|
|
|
|
|
|
|
1756 |
|
1757 |
+
if ( ! empty( $restriction['_um_custom_access_settings'] ) ) {
|
1758 |
+
if ( ! isset( $restriction['_um_accessible'] ) ) {
|
1759 |
+
continue;
|
1760 |
+
} else {
|
1761 |
+
$cache[ $cache_key ] = $restriction;
|
1762 |
+
return $restriction;
|
1763 |
+
}
|
1764 |
+
}
|
1765 |
+
}
|
1766 |
|
1767 |
+
$cache[ $cache_key ] = false;
|
1768 |
+
return false;
|
1769 |
+
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
1770 |
|
1771 |
+
// set default redirect if Profile page is restricted for not-logged in users and showing message instead of redirect
|
1772 |
+
// this snippet was added to make the same action for {site_url}/user and {site_url}/user/{user_slug} URLs
|
1773 |
+
// by default {site_url}/user is redirected to Homepage in rewrite rules because hasn't found username in query when user is not logged in
|
1774 |
+
if ( ! is_user_logged_in() && um_is_core_post( $post, 'user' ) && $restriction['_um_accessible'] == '2' && $restriction['_um_noaccess_action'] == '0' ) {
|
1775 |
+
if ( isset( $restriction['_um_access_roles'] ) ) {
|
1776 |
+
$restriction = array(
|
1777 |
+
'_um_accessible' => '2',
|
1778 |
+
'_um_access_roles' => $restriction['_um_access_roles'],
|
1779 |
+
'_um_noaccess_action' => '1',
|
1780 |
+
'_um_access_redirect' => '1',
|
1781 |
+
'_um_access_redirect_url' => get_home_url( get_current_blog_id() )
|
1782 |
+
);
|
1783 |
+
} else {
|
1784 |
+
$restriction = array(
|
1785 |
+
'_um_accessible' => '2',
|
1786 |
+
'_um_noaccess_action' => '1',
|
1787 |
+
'_um_access_redirect' => '1',
|
1788 |
+
'_um_access_redirect_url' => get_home_url( get_current_blog_id() )
|
1789 |
+
);
|
1790 |
+
}
|
1791 |
+
}
|
1792 |
+
|
1793 |
+
$restriction = apply_filters( 'um_post_content_restriction_settings', $restriction, $post );
|
1794 |
+
|
1795 |
+
$cache[ $cache_key ] = $restriction;
|
1796 |
+
return $restriction;
|
1797 |
+
}
|
1798 |
+
}
|
1799 |
}
|
1800 |
|
1801 |
+
//post hasn't privacy settings....check all terms of this post
|
1802 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
1803 |
+
|
1804 |
+
//get all taxonomies for current post type
|
1805 |
+
$taxonomies = get_object_taxonomies( $post );
|
1806 |
+
|
1807 |
+
//get all post terms
|
1808 |
+
$terms = array();
|
1809 |
+
if ( ! empty( $taxonomies ) ) {
|
1810 |
+
foreach ( $taxonomies as $taxonomy ) {
|
1811 |
+
if ( empty( $restricted_taxonomies[ $taxonomy ] ) ) {
|
1812 |
+
continue;
|
1813 |
+
}
|
1814 |
+
|
1815 |
+
$terms = array_merge( $terms, wp_get_post_terms( $post->ID, $taxonomy, array( 'fields' => 'ids', 'um_ignore_exclude' => true, ) ) );
|
1816 |
+
}
|
1817 |
+
}
|
1818 |
+
|
1819 |
+
//get restriction options for first term with privacy settings
|
1820 |
+
foreach ( $terms as $term_id ) {
|
1821 |
+
$restriction = get_term_meta( $term_id, 'um_content_restriction', true );
|
1822 |
+
|
1823 |
+
if ( ! empty( $restriction['_um_custom_access_settings'] ) ) {
|
1824 |
+
if ( ! isset( $restriction['_um_accessible'] ) ) {
|
1825 |
+
continue;
|
1826 |
+
} else {
|
1827 |
+
$cache[ $cache_key ] = $restriction;
|
1828 |
+
return $restriction;
|
1829 |
+
}
|
1830 |
+
}
|
1831 |
}
|
1832 |
|
1833 |
+
$cache[ $cache_key ] = false;
|
1834 |
+
//post is public
|
1835 |
+
return false;
|
|
|
1836 |
}
|
1837 |
|
1838 |
|
1839 |
/**
|
1840 |
+
* Helper for checking if the user can some of the roles array
|
1841 |
*
|
1842 |
+
* @param $user_id
|
1843 |
+
* @param $roles
|
1844 |
+
* @return bool
|
1845 |
*/
|
1846 |
+
function user_can( $user_id, $roles ) {
|
1847 |
+
$user_can = false;
|
1848 |
|
1849 |
+
if ( ! empty( $roles ) ) {
|
1850 |
+
foreach ( $roles as $key => $value ) {
|
1851 |
+
if ( ! empty( $value ) && user_can( $user_id, $key ) ) {
|
1852 |
+
$user_can = true;
|
1853 |
+
break;
|
1854 |
+
}
|
1855 |
+
}
|
1856 |
}
|
1857 |
|
1858 |
+
return $user_can;
|
1859 |
+
}
|
|
|
|
|
1860 |
|
|
|
1861 |
|
1862 |
+
/**
|
1863 |
+
* Helper for 3rd-party integrations with content restriction settings
|
1864 |
+
*
|
1865 |
+
* @param array $restriction
|
1866 |
+
*
|
1867 |
+
* @return bool
|
1868 |
+
*/
|
1869 |
+
function um_custom_restriction( $restriction ) {
|
1870 |
+
/**
|
1871 |
+
* UM hook
|
1872 |
+
*
|
1873 |
+
* @type filter
|
1874 |
+
* @title um_custom_restriction
|
1875 |
+
* @description Extend Sort Types for Member Directory
|
1876 |
+
* @input_vars
|
1877 |
+
* [{"var":"$custom_restriction","type":"bool","desc":"Custom Restriction"},
|
1878 |
+
* {"var":"$restriction","type":"array","desc":"Restriction settings"}]
|
1879 |
+
* @change_log
|
1880 |
+
* ["Since: 2.0"]
|
1881 |
+
* @usage add_filter( 'um_custom_restriction', 'function_name', 10, 2 );
|
1882 |
+
* @example
|
1883 |
+
* <?php
|
1884 |
+
* add_filter( 'um_custom_restriction', 'my_custom_restriction', 10, 2 );
|
1885 |
+
* function my_directory_sort_users_select( $custom_restriction, $restriction ) {
|
1886 |
+
* // your code here
|
1887 |
+
* return $custom_restriction;
|
1888 |
+
* }
|
1889 |
+
* ?>
|
1890 |
+
*/
|
1891 |
+
return apply_filters( 'um_custom_restriction', true, $restriction );
|
1892 |
}
|
1893 |
|
1894 |
|
1899 |
* @return bool
|
1900 |
*/
|
1901 |
function is_restricted( $post_id ) {
|
1902 |
+
// break for incorrect post
|
1903 |
+
if ( empty( $post_id ) ) {
|
1904 |
+
return false;
|
1905 |
+
}
|
1906 |
+
|
1907 |
static $cache = array();
|
1908 |
|
1909 |
if ( isset( $cache[ $post_id ] ) ) {
|
1915 |
return false;
|
1916 |
}
|
1917 |
|
1918 |
+
$post = get_post( $post_id );
|
1919 |
+
if ( is_user_logged_in() && isset( $post->post_author ) && $post->post_author == get_current_user_id() ) {
|
1920 |
+
$cache[ $post_id ] = false;
|
1921 |
+
return false;
|
1922 |
+
}
|
1923 |
+
|
1924 |
$restricted = true;
|
1925 |
|
1926 |
$restriction = $this->get_post_privacy_settings( $post_id );
|
1955 |
}
|
1956 |
}
|
1957 |
|
1958 |
+
$restricted = apply_filters( 'um_is_restricted_post', $restricted, $post_id );
|
1959 |
+
|
1960 |
$cache[ $post_id ] = $restricted;
|
1961 |
|
1962 |
return $restricted;
|
1967 |
* Is term restricted?
|
1968 |
*
|
1969 |
* @param int $term_id
|
1970 |
+
* @param bool $on_term_page
|
1971 |
* @return bool
|
1972 |
*/
|
1973 |
+
function is_restricted_term( $term_id, $on_term_page = false ) {
|
1974 |
static $cache = array();
|
1975 |
|
1976 |
if ( isset( $cache[ $term_id ] ) ) {
|
2008 |
if ( '0' == $restriction['_um_accessible'] ) {
|
2009 |
//term is private
|
2010 |
$restricted = false;
|
2011 |
+
if ( $on_term_page ) {
|
2012 |
+
$this->allow_access = true;
|
2013 |
+
}
|
2014 |
} elseif ( '1' == $restriction['_um_accessible'] ) {
|
2015 |
//if term for not logged in users and user is not logged in
|
2016 |
if ( ! is_user_logged_in() ) {
|
2017 |
$restricted = false;
|
2018 |
+
if ( $on_term_page ) {
|
2019 |
+
$this->allow_access = true;
|
2020 |
+
}
|
2021 |
}
|
2022 |
} elseif ( '2' == $restriction['_um_accessible'] ) {
|
2023 |
//if term for logged in users and user is not logged in
|
2027 |
if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) {
|
2028 |
if ( $custom_restrict ) {
|
2029 |
$restricted = false;
|
2030 |
+
if ( $on_term_page ) {
|
2031 |
+
$this->allow_access = true;
|
2032 |
+
}
|
2033 |
}
|
2034 |
} else {
|
2035 |
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
|
2036 |
|
2037 |
if ( $user_can && $custom_restrict ) {
|
2038 |
$restricted = false;
|
2039 |
+
if ( $on_term_page ) {
|
2040 |
+
$this->allow_access = true;
|
2041 |
+
}
|
2042 |
}
|
2043 |
}
|
2044 |
}
|
2046 |
}
|
2047 |
}
|
2048 |
|
2049 |
+
$restricted = apply_filters( 'um_is_restricted_term', $restricted, $term_id, $on_term_page );
|
2050 |
+
|
2051 |
$cache[ $term_id ] = $restricted;
|
2052 |
return $restricted;
|
2053 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2054 |
}
|
2055 |
}
|
includes/core/class-external-integrations.php
CHANGED
@@ -29,6 +29,7 @@ if ( ! class_exists( 'um\core\External_Integrations' ) ) {
|
|
29 |
|
30 |
add_action( 'um_access_fix_external_post_content', array( &$this, 'bbpress_no_access_message_fix' ), 10 );
|
31 |
add_action( 'um_access_fix_external_post_content', array( &$this, 'forumwp_fix' ), 11 );
|
|
|
32 |
|
33 |
add_filter( 'um_localize_permalink_filter', array( &$this, 'um_localize_permalink_filter' ), 10, 2 );
|
34 |
add_filter( 'icl_ls_languages', array( &$this, 'um_core_page_wpml_permalink' ), 10, 1 );
|
@@ -151,6 +152,30 @@ if ( ! class_exists( 'um\core\External_Integrations' ) ) {
|
|
151 |
}
|
152 |
|
153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
/**
|
155 |
* @param $profile_url
|
156 |
* @param $page_id
|
@@ -558,4 +583,4 @@ if ( ! class_exists( 'um\core\External_Integrations' ) ) {
|
|
558 |
|
559 |
|
560 |
}
|
561 |
-
}
|
29 |
|
30 |
add_action( 'um_access_fix_external_post_content', array( &$this, 'bbpress_no_access_message_fix' ), 10 );
|
31 |
add_action( 'um_access_fix_external_post_content', array( &$this, 'forumwp_fix' ), 11 );
|
32 |
+
add_action( 'um_access_fix_external_post_content', array( &$this, 'woocommerce_fix' ), 12 );
|
33 |
|
34 |
add_filter( 'um_localize_permalink_filter', array( &$this, 'um_localize_permalink_filter' ), 10, 2 );
|
35 |
add_filter( 'icl_ls_languages', array( &$this, 'um_core_page_wpml_permalink' ), 10, 1 );
|
152 |
}
|
153 |
|
154 |
|
155 |
+
/**
|
156 |
+
* Fixed Woocommerce access to Products message
|
157 |
+
*/
|
158 |
+
function woocommerce_fix() {
|
159 |
+
if ( UM()->dependencies()->woocommerce_active_check() ) {
|
160 |
+
add_filter( 'single_template', array( &$this, 'woocommerce_template' ), 9999999, 1 );
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
|
165 |
+
/**
|
166 |
+
* @param string $single_template
|
167 |
+
*
|
168 |
+
* @return string
|
169 |
+
*/
|
170 |
+
function woocommerce_template( $single_template ) {
|
171 |
+
if ( is_product() ) {
|
172 |
+
remove_filter( 'template_include', array( 'WC_Template_Loader', 'template_loader' ) );
|
173 |
+
}
|
174 |
+
|
175 |
+
return $single_template;
|
176 |
+
}
|
177 |
+
|
178 |
+
|
179 |
/**
|
180 |
* @param $profile_url
|
181 |
* @param $page_id
|
583 |
|
584 |
|
585 |
}
|
586 |
+
}
|
includes/core/class-fields.php
CHANGED
@@ -1,4779 +1,4794 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\core\Fields' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Fields
|
13 |
-
* @package um\core
|
14 |
-
*/
|
15 |
-
class Fields {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var string
|
20 |
-
*/
|
21 |
-
var $set_mode = '';
|
22 |
-
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @var int form_id
|
26 |
-
*/
|
27 |
-
public $set_id = null;
|
28 |
-
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Fields constructor.
|
32 |
-
*/
|
33 |
-
function __construct() {
|
34 |
-
$this->editing = false;
|
35 |
-
$this->viewing = false;
|
36 |
-
$this->timestamp = current_time( 'timestamp' );
|
37 |
-
}
|
38 |
-
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Standard checkbox field
|
42 |
-
*
|
43 |
-
* @param integer $id
|
44 |
-
* @param string $title
|
45 |
-
* @param bool $checked
|
46 |
-
*/
|
47 |
-
function checkbox( $id, $title, $checked = true ) {
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Set value on form submission
|
51 |
-
*/
|
52 |
-
if ( isset( $_REQUEST[ $id ] ) ) {
|
53 |
-
$checked = (bool) $_REQUEST[ $id ];
|
54 |
-
}
|
55 |
-
|
56 |
-
$class = $checked ? 'um-icon-android-checkbox-outline' : 'um-icon-android-checkbox-outline-blank';
|
57 |
-
|
58 |
-
?>
|
59 |
-
|
60 |
-
|
61 |
-
<div class="um-field um-field-c">
|
62 |
-
<div class="um-field-area">
|
63 |
-
<label class="um-field-checkbox<?php echo $checked ? ' active' : '' ?>">
|
64 |
-
<input type="checkbox" name="<?php echo esc_attr( $id ); ?>" value="1" <?php checked( $checked ) ?> />
|
65 |
-
<span class="um-field-checkbox-state"><i class="<?php echo esc_attr( $class ) ?>"></i></span>
|
66 |
-
<span class="um-field-checkbox-option"> <?php echo esc_html( $title ); ?></span>
|
67 |
-
</label>
|
68 |
-
</div>
|
69 |
-
</div>
|
70 |
-
|
71 |
-
<?php
|
72 |
-
}
|
73 |
-
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Shows social links
|
77 |
-
*/
|
78 |
-
function show_social_urls() {
|
79 |
-
$social = array();
|
80 |
-
|
81 |
-
$fields = UM()->builtin()->get_all_user_fields();
|
82 |
-
foreach ( $fields as $field => $args ) {
|
83 |
-
if ( isset( $args['advanced'] ) && $args['advanced'] == 'social' ) {
|
84 |
-
$social[ $field ] = $args;
|
85 |
-
}
|
86 |
-
}
|
87 |
-
|
88 |
-
foreach ( $social as $k => $arr ) {
|
89 |
-
if ( um_profile( $k ) ) { ?>
|
90 |
-
|
91 |
-
<a href="<?php echo esc_url( um_filtered_social_link( $k, $arr['match'] ) ); ?>"
|
92 |
-
style="background: <?php echo esc_attr( $arr['color'] ); ?>;" target="_blank" class="um-tip-n"
|
93 |
-
title="<?php echo esc_attr( $arr['title'] ); ?>"><i class="<?php echo esc_attr( $arr['icon'] ); ?>"></i></a>
|
94 |
-
|
95 |
-
<?php
|
96 |
-
}
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Hidden field inside a shortcode
|
103 |
-
*
|
104 |
-
* @param string $field
|
105 |
-
*/
|
106 |
-
function add_hidden_field( $field ) {
|
107 |
-
echo '<div style="display: none !important;">';
|
108 |
-
|
109 |
-
$fields = UM()->builtin()->get_specific_fields( $field );
|
110 |
-
|
111 |
-
$output = null;
|
112 |
-
|
113 |
-
foreach ( $fields as $key => $data ) {
|
114 |
-
$output .= UM()->fields()->edit_field( $key, $data );
|
115 |
-
}
|
116 |
-
|
117 |
-
echo $output;
|
118 |
-
|
119 |
-
echo '</div>';
|
120 |
-
}
|
121 |
-
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Get hidden field
|
125 |
-
*
|
126 |
-
* @param string $key
|
127 |
-
* @param string $value
|
128 |
-
*
|
129 |
-
* @return string
|
130 |
-
*/
|
131 |
-
function disabled_hidden_field( $key, $value ) {
|
132 |
-
return '<input type="hidden" name="' . esc_attr( $key ) . '" value="' . esc_attr( $value ) . '"/>';
|
133 |
-
}
|
134 |
-
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Updates a field globally
|
138 |
-
*
|
139 |
-
* @param integer $id
|
140 |
-
* @param array $args
|
141 |
-
*/
|
142 |
-
function globally_update_field( $id, $args ) {
|
143 |
-
$fields = UM()->builtin()->saved_fields;
|
144 |
-
|
145 |
-
$fields[ $id ] = $args;
|
146 |
-
|
147 |
-
unset( $fields[ $id ]['in_row'] );
|
148 |
-
unset( $fields[ $id ]['in_sub_row'] );
|
149 |
-
unset( $fields[ $id ]['in_column'] );
|
150 |
-
unset( $fields[ $id ]['in_group'] );
|
151 |
-
unset( $fields[ $id ]['position'] );
|
152 |
-
|
153 |
-
do_action( 'um_add_new_field', $id, $args );
|
154 |
-
|
155 |
-
update_option( 'um_fields', $fields );
|
156 |
-
}
|
157 |
-
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Updates a field in form only
|
161 |
-
*
|
162 |
-
* @param integer $id
|
163 |
-
* @param array $args
|
164 |
-
* @param integer $form_id
|
165 |
-
*/
|
166 |
-
function update_field( $id, $args, $form_id ) {
|
167 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
168 |
-
|
169 |
-
if ( $args['type'] == 'row' ) {
|
170 |
-
if ( isset( $fields[ $id ] ) ) {
|
171 |
-
$old_args = $fields[ $id ];
|
172 |
-
foreach ( $old_args as $k => $v ) {
|
173 |
-
if ( ! in_array( $k, array( 'sub_rows', 'cols' ) ) ) {
|
174 |
-
unset( $old_args[ $k ] );
|
175 |
-
}
|
176 |
-
}
|
177 |
-
$args = array_merge( $old_args, $args );
|
178 |
-
}
|
179 |
-
}
|
180 |
-
|
181 |
-
// custom fields support
|
182 |
-
if ( isset( UM()->builtin()->predefined_fields[ $id ] ) && isset( UM()->builtin()->predefined_fields[ $id ]['custom'] ) ) {
|
183 |
-
$args = array_merge( UM()->builtin()->predefined_fields[ $id ], $args );
|
184 |
-
}
|
185 |
-
|
186 |
-
$fields[ $id ] = $args;
|
187 |
-
|
188 |
-
// for group field only
|
189 |
-
if ( $args['type'] == 'group' ) {
|
190 |
-
$fields[ $id ]['in_group'] = '';
|
191 |
-
}
|
192 |
-
|
193 |
-
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
194 |
-
}
|
195 |
-
|
196 |
-
|
197 |
-
/**
|
198 |
-
* Deletes a field in form only
|
199 |
-
*
|
200 |
-
* @param integer $id
|
201 |
-
* @param integer $form_id
|
202 |
-
*/
|
203 |
-
function delete_field_from_form( $id, $form_id ) {
|
204 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
205 |
-
|
206 |
-
if ( isset( $fields[ $id ] ) ) {
|
207 |
-
$condition_fields = get_option( 'um_fields' );
|
208 |
-
|
209 |
-
if( ! is_array( $condition_fields ) ) $condition_fields = array();
|
210 |
-
|
211 |
-
foreach ( $condition_fields as $key => $value ) {
|
212 |
-
$deleted_field = array_search( $id, $value );
|
213 |
-
|
214 |
-
if ( $key != $id && $deleted_field != false ) {
|
215 |
-
$deleted_field_id = str_replace( 'conditional_field', '', $deleted_field );
|
216 |
-
|
217 |
-
if ( $deleted_field_id == '' ) {
|
218 |
-
$arr_id = 0;
|
219 |
-
} else {
|
220 |
-
$arr_id = $deleted_field_id;
|
221 |
-
}
|
222 |
-
|
223 |
-
unset( $condition_fields[ $key ][ 'conditional_action' . $deleted_field_id ] );
|
224 |
-
unset( $condition_fields[ $key ][ $deleted_field ] );
|
225 |
-
unset( $condition_fields[ $key ][ 'conditional_operator' . $deleted_field_id ] );
|
226 |
-
unset( $condition_fields[ $key ][ 'conditional_value' . $deleted_field_id ] );
|
227 |
-
unset( $condition_fields[ $key ]['conditions'][ $arr_id ] );
|
228 |
-
|
229 |
-
unset( $fields[ $key ][ 'conditional_action' . $deleted_field_id ] );
|
230 |
-
unset( $fields[ $key ][ $deleted_field ] );
|
231 |
-
unset( $fields[ $key ][ 'conditional_operator' . $deleted_field_id ] );
|
232 |
-
unset( $fields[ $key ][ 'conditional_value' . $deleted_field_id ] );
|
233 |
-
unset( $fields[ $key ]['conditions'][ $arr_id ] );
|
234 |
-
}
|
235 |
-
}
|
236 |
-
|
237 |
-
update_option( 'um_fields' , $condition_fields );
|
238 |
-
unset( $fields[ $id ] );
|
239 |
-
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
240 |
-
}
|
241 |
-
}
|
242 |
-
|
243 |
-
|
244 |
-
/**
|
245 |
-
* Deletes a field from custom fields
|
246 |
-
*
|
247 |
-
* @param integer $id
|
248 |
-
*/
|
249 |
-
function delete_field_from_db( $id ) {
|
250 |
-
$fields = UM()->builtin()->saved_fields;
|
251 |
-
if ( isset( $fields[ $id ] ) ) {
|
252 |
-
$args = $fields[ $id ];
|
253 |
-
|
254 |
-
unset( $fields[ $id ] );
|
255 |
-
|
256 |
-
do_action( 'um_delete_custom_field', $id, $args );
|
257 |
-
|
258 |
-
update_option( 'um_fields', $fields );
|
259 |
-
|
260 |
-
global $wpdb;
|
261 |
-
$forms = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'um_form'" );
|
262 |
-
foreach ( $forms as $form_id ) {
|
263 |
-
$form_fields = get_post_meta( $form_id, '_um_custom_fields', true );
|
264 |
-
unset( $form_fields[ $id ] );
|
265 |
-
update_post_meta( $form_id, '_um_custom_fields', $form_fields );
|
266 |
-
}
|
267 |
-
}
|
268 |
-
}
|
269 |
-
|
270 |
-
|
271 |
-
/**
|
272 |
-
* Quickly adds a field from custom fields
|
273 |
-
*
|
274 |
-
* @param integer $global_id
|
275 |
-
* @param integer $form_id
|
276 |
-
* @param array $position
|
277 |
-
*/
|
278 |
-
function add_field_from_list( $global_id, $form_id, $position = array() ) {
|
279 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
280 |
-
$field_scope = UM()->builtin()->saved_fields;
|
281 |
-
|
282 |
-
if ( ! isset( $fields[ $global_id ] ) ) {
|
283 |
-
|
284 |
-
$count = 1;
|
285 |
-
if ( ! empty( $fields ) ) {
|
286 |
-
$count = count( $fields ) + 1;
|
287 |
-
}
|
288 |
-
|
289 |
-
$fields[ $global_id ] = $field_scope[ $global_id ];
|
290 |
-
$fields[ $global_id ]['position'] = $count;
|
291 |
-
|
292 |
-
// set position
|
293 |
-
if ( $position ) {
|
294 |
-
foreach ( $position as $key => $val) {
|
295 |
-
$fields[ $global_id ][ $key ] = $val;
|
296 |
-
}
|
297 |
-
}
|
298 |
-
|
299 |
-
// add field to form
|
300 |
-
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
301 |
-
|
302 |
-
}
|
303 |
-
}
|
304 |
-
|
305 |
-
|
306 |
-
/**
|
307 |
-
* Quickly adds a field from pre-defined fields
|
308 |
-
*
|
309 |
-
* @param integer $global_id
|
310 |
-
* @param integer $form_id
|
311 |
-
* @param array $position
|
312 |
-
*/
|
313 |
-
function add_field_from_predefined( $global_id, $form_id, $position = array() ) {
|
314 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
315 |
-
$field_scope = UM()->builtin()->predefined_fields;
|
316 |
-
|
317 |
-
if ( ! isset( $fields[ $global_id ] ) ) {
|
318 |
-
|
319 |
-
$count = 1;
|
320 |
-
if ( ! empty( $fields ) ) {
|
321 |
-
$count = count( $fields ) + 1;
|
322 |
-
}
|
323 |
-
|
324 |
-
$fields[ $global_id ] = $field_scope[ $global_id ];
|
325 |
-
$fields[ $global_id ]['position'] = $count;
|
326 |
-
|
327 |
-
// set position
|
328 |
-
if ( $position ) {
|
329 |
-
foreach ( $position as $key => $val ) {
|
330 |
-
$fields[ $global_id ][ $key ] = $val;
|
331 |
-
}
|
332 |
-
}
|
333 |
-
|
334 |
-
// add field to form
|
335 |
-
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
336 |
-
}
|
337 |
-
}
|
338 |
-
|
339 |
-
|
340 |
-
/**
|
341 |
-
* Duplicates a frield by meta key
|
342 |
-
*
|
343 |
-
* @param integer $id
|
344 |
-
* @param integer $form_id
|
345 |
-
*/
|
346 |
-
function duplicate_field( $id, $form_id ) {
|
347 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
348 |
-
$all_fields = UM()->builtin()->saved_fields;
|
349 |
-
|
350 |
-
$inc = count( $fields ) + 1;
|
351 |
-
|
352 |
-
$duplicate = $fields[ $id ];
|
353 |
-
|
354 |
-
$new_metakey = $id . "_" . $inc;
|
355 |
-
$new_title = $fields[ $id ]['title'] . " #" . $inc;
|
356 |
-
$new_position = $inc;
|
357 |
-
|
358 |
-
$duplicate['title'] = $new_title;
|
359 |
-
$duplicate['metakey'] = $new_metakey;
|
360 |
-
$duplicate['position'] = $new_position;
|
361 |
-
|
362 |
-
$fields[ $new_metakey ] = $duplicate;
|
363 |
-
$all_fields[ $new_metakey ] = $duplicate;
|
364 |
-
|
365 |
-
// not global attributes
|
366 |
-
unset( $all_fields[ $new_metakey ]['in_row'] );
|
367 |
-
unset( $all_fields[ $new_metakey ]['in_sub_row'] );
|
368 |
-
unset( $all_fields[ $new_metakey ]['in_column'] );
|
369 |
-
unset( $all_fields[ $new_metakey ]['in_group'] );
|
370 |
-
unset( $all_fields[ $new_metakey ]['position'] );
|
371 |
-
|
372 |
-
|
373 |
-
do_action( 'um_add_new_field', $new_metakey, $duplicate );
|
374 |
-
|
375 |
-
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
376 |
-
update_option( 'um_fields', $all_fields );
|
377 |
-
}
|
378 |
-
|
379 |
-
|
380 |
-
/**
|
381 |
-
* Print field error
|
382 |
-
*
|
383 |
-
* @param string $text
|
384 |
-
* @param bool $force_show
|
385 |
-
*
|
386 |
-
* @return string
|
387 |
-
*/
|
388 |
-
function field_error( $text, $force_show = false ) {
|
389 |
-
|
390 |
-
if ( empty( $text ) ) {
|
391 |
-
return '';
|
392 |
-
}
|
393 |
-
|
394 |
-
if ( $force_show ) {
|
395 |
-
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
396 |
-
return $output;
|
397 |
-
}
|
398 |
-
|
399 |
-
|
400 |
-
if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) {
|
401 |
-
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
402 |
-
} else {
|
403 |
-
$output = '';
|
404 |
-
}
|
405 |
-
|
406 |
-
if ( ! UM()->form()->processing ) {
|
407 |
-
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
408 |
-
}
|
409 |
-
|
410 |
-
return $output;
|
411 |
-
}
|
412 |
-
|
413 |
-
|
414 |
-
/**
|
415 |
-
* Print field notice
|
416 |
-
*
|
417 |
-
* @param string $text
|
418 |
-
* @param bool $force_show
|
419 |
-
*
|
420 |
-
* @return string
|
421 |
-
*/
|
422 |
-
function field_notice( $text, $force_show = false ) {
|
423 |
-
|
424 |
-
if ( empty( $text ) ) {
|
425 |
-
return '';
|
426 |
-
}
|
427 |
-
|
428 |
-
if ( $force_show ) {
|
429 |
-
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
430 |
-
return $output;
|
431 |
-
}
|
432 |
-
|
433 |
-
|
434 |
-
if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) {
|
435 |
-
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
436 |
-
} else {
|
437 |
-
$output = '';
|
438 |
-
}
|
439 |
-
|
440 |
-
if ( ! UM()->form()->processing ) {
|
441 |
-
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
442 |
-
}
|
443 |
-
|
444 |
-
return $output;
|
445 |
-
}
|
446 |
-
|
447 |
-
|
448 |
-
/**
|
449 |
-
* Checks if field has a server-side error
|
450 |
-
*
|
451 |
-
* @param string $key
|
452 |
-
*
|
453 |
-
* @return boolean
|
454 |
-
*/
|
455 |
-
function is_error( $key ) {
|
456 |
-
return UM()->form()->has_error( $key );
|
457 |
-
}
|
458 |
-
|
459 |
-
/**
|
460 |
-
* Checks if field has a notice
|
461 |
-
*
|
462 |
-
* @param string $key
|
463 |
-
*
|
464 |
-
* @return boolean
|
465 |
-
*/
|
466 |
-
function is_notice( $key ) {
|
467 |
-
return UM()->form()->has_notice( $key );
|
468 |
-
}
|
469 |
-
|
470 |
-
|
471 |
-
/**
|
472 |
-
* Returns field error
|
473 |
-
*
|
474 |
-
* @param string $key
|
475 |
-
*
|
476 |
-
* @return string
|
477 |
-
*/
|
478 |
-
function show_error( $key ) {
|
479 |
-
return UM()->form()->errors[ $key ];
|
480 |
-
}
|
481 |
-
|
482 |
-
/**
|
483 |
-
* Returns field notices
|
484 |
-
*
|
485 |
-
* @param string $key
|
486 |
-
*
|
487 |
-
* @return string
|
488 |
-
*/
|
489 |
-
function show_notice( $key ) {
|
490 |
-
return UM()->form()->notices[ $key ];
|
491 |
-
}
|
492 |
-
|
493 |
-
|
494 |
-
/**
|
495 |
-
* Display field label
|
496 |
-
*
|
497 |
-
* @param string $label
|
498 |
-
* @param string $key
|
499 |
-
* @param array $data
|
500 |
-
*
|
501 |
-
* @return string
|
502 |
-
*/
|
503 |
-
function field_label( $label, $key, $data ) {
|
504 |
-
$output = null;
|
505 |
-
$output .= '<div class="um-field-label">';
|
506 |
-
|
507 |
-
if ( isset( $data['icon'] ) && $data['icon'] != '' && isset( $this->field_icons ) && $this->field_icons != 'off' && ( $this->field_icons == 'label' || $this->viewing == true ) ) {
|
508 |
-
$output .= '<div class="um-field-label-icon"><i class="' . esc_attr( $data['icon'] ) . '" aria-label="' . esc_attr( $label ) . '"></i></div>';
|
509 |
-
}
|
510 |
-
|
511 |
-
if ( $this->viewing == true ) {
|
512 |
-
/**
|
513 |
-
* UM hook
|
514 |
-
*
|
515 |
-
* @type filter
|
516 |
-
* @title um_view_label_{$key}
|
517 |
-
* @description Change field label on view by field $key
|
518 |
-
* @input_vars
|
519 |
-
* [{"var":"$label","type":"string","desc":"Field Label"}]
|
520 |
-
* @change_log
|
521 |
-
* ["Since: 2.0"]
|
522 |
-
* @usage add_filter( 'um_view_label_{$key}', 'function_name', 10, 1 );
|
523 |
-
* @example
|
524 |
-
* <?php
|
525 |
-
* add_filter( 'um_view_label_{$key}', 'my_view_label', 10, 1 );
|
526 |
-
* function my_view_label( $label ) {
|
527 |
-
* // your code here
|
528 |
-
* return $label;
|
529 |
-
* }
|
530 |
-
* ?>
|
531 |
-
*/
|
532 |
-
$label = apply_filters( "um_view_label_{$key}", $label );
|
533 |
-
} else {
|
534 |
-
/**
|
535 |
-
* UM hook
|
536 |
-
*
|
537 |
-
* @type filter
|
538 |
-
* @title um_edit_label_{$key}
|
539 |
-
* @description Change field label on edit by field $key
|
540 |
-
* @input_vars
|
541 |
-
* [{"var":"$label","type":"string","desc":"Field Label"}]
|
542 |
-
* @change_log
|
543 |
-
* ["Since: 2.0"]
|
544 |
-
* @usage add_filter( 'um_edit_label_{$key}', 'function_name', 10, 1 );
|
545 |
-
* @example
|
546 |
-
* <?php
|
547 |
-
* add_filter( 'um_edit_label_{$key}', 'my_edit_label', 10, 1 );
|
548 |
-
* function my_edit_label( $label ) {
|
549 |
-
* // your code here
|
550 |
-
* return $label;
|
551 |
-
* }
|
552 |
-
* ?>
|
553 |
-
*/
|
554 |
-
$label = apply_filters( "um_edit_label_{$key}", $label );
|
555 |
-
/**
|
556 |
-
* UM hook
|
557 |
-
*
|
558 |
-
* @type filter
|
559 |
-
* @title um_edit_label_all_fields
|
560 |
-
* @description Change field label on view by field $key
|
561 |
-
* @input_vars
|
562 |
-
* [{"var":"$label","type":"string","desc":"Field Label"},
|
563 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
564 |
-
* @change_log
|
565 |
-
* ["Since: 2.0"]
|
566 |
-
* @usage add_filter( 'um_edit_label_all_fields', 'function_name', 10, 2 );
|
567 |
-
* @example
|
568 |
-
* <?php
|
569 |
-
* add_filter( 'um_edit_label_all_fields', 'my_edit_label_all_fields', 10, 2 );
|
570 |
-
* function my_edit_label_all_fields( $label, $data ) {
|
571 |
-
* // your code here
|
572 |
-
* return $label;
|
573 |
-
* }
|
574 |
-
* ?>
|
575 |
-
*/
|
576 |
-
$label = apply_filters( 'um_edit_label_all_fields', $label, $data );
|
577 |
-
}
|
578 |
-
|
579 |
-
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
580 |
-
$for_attr = '';
|
581 |
-
if ( ! in_array( $data['type'], $fields_without_metakey ) ) {
|
582 |
-
$for_attr = ' for="' . esc_attr( $key . UM()->form()->form_suffix ) . '"';
|
583 |
-
}
|
584 |
-
|
585 |
-
$output .= '<label' . $for_attr . '>' . __( $label, 'ultimate-member' ) . '</label>';
|
586 |
-
|
587 |
-
if ( ! empty( $data['help'] ) && $this->viewing == false && ! strstr( $key, 'confirm_user_pass' ) ) {
|
588 |
-
|
589 |
-
if ( ! UM()->mobile()->isMobile() ) {
|
590 |
-
if ( ! isset( $this->disable_tooltips ) ) {
|
591 |
-
$output .= '<span class="um-tip um-tip-' . ( is_rtl() ? 'e' : 'w' ) . '" title="' . esc_attr__( $data['help'], 'ultimate-member' ) . '"><i class="um-icon-help-circled"></i></span>';
|
592 |
-
}
|
593 |
-
}
|
594 |
-
|
595 |
-
if ( UM()->mobile()->isMobile() || isset( $this->disable_tooltips ) ) {
|
596 |
-
$output .= '<span class="um-tip-text">' . __( $data['help'], 'ultimate-member' ) . '</span>';
|
597 |
-
}
|
598 |
-
|
599 |
-
}
|
600 |
-
|
601 |
-
$output .= '<div class="um-clear"></div></div>';
|
602 |
-
|
603 |
-
return $output;
|
604 |
-
}
|
605 |
-
|
606 |
-
|
607 |
-
/**
|
608 |
-
* Output field classes
|
609 |
-
*
|
610 |
-
* @param string $key
|
611 |
-
* @param array $data
|
612 |
-
* @param string $add
|
613 |
-
*
|
614 |
-
* @return string
|
615 |
-
*/
|
616 |
-
function get_class( $key, $data, $add = null ) {
|
617 |
-
$classes = null;
|
618 |
-
|
619 |
-
$classes .= 'um-form-field ';
|
620 |
-
|
621 |
-
if ( $this->is_error( $key ) ) {
|
622 |
-
$classes .= 'um-error ';
|
623 |
-
} else {
|
624 |
-
$classes .= 'valid ';
|
625 |
-
}
|
626 |
-
|
627 |
-
if ( ! isset( $data['required'] ) ) {
|
628 |
-
$classes .= 'not-required ';
|
629 |
-
}
|
630 |
-
|
631 |
-
if ( $data['type'] == 'date' ) {
|
632 |
-
$classes .= 'um-datepicker ';
|
633 |
-
}
|
634 |
-
|
635 |
-
if ( $data['type'] == 'time' ) {
|
636 |
-
$classes .= 'um-timepicker ';
|
637 |
-
}
|
638 |
-
|
639 |
-
if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
640 |
-
$classes .= 'um-iconed ';
|
641 |
-
}
|
642 |
-
|
643 |
-
if ( $add ) {
|
644 |
-
$classes .= $add . ' ';
|
645 |
-
}
|
646 |
-
|
647 |
-
/**
|
648 |
-
* UM hook
|
649 |
-
*
|
650 |
-
* @type filter
|
651 |
-
* @title um_extend_field_classes
|
652 |
-
* @description Change field classes
|
653 |
-
* @input_vars
|
654 |
-
* [{"var":"$classes","type":"string","desc":"Field Classes"},
|
655 |
-
* {"var":"$key","type":"string","desc":"Field Key"},
|
656 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
657 |
-
* @change_log
|
658 |
-
* ["Since: 2.0"]
|
659 |
-
* @usage add_filter( 'um_extend_field_classes', 'function_name', 10, 3 );
|
660 |
-
* @example
|
661 |
-
* <?php
|
662 |
-
* add_filter( 'um_extend_field_classes', 'my_extend_field_classes', 10, 3 );
|
663 |
-
* function my_extend_field_classes( $classes, $key, $data ) {
|
664 |
-
* // your code here
|
665 |
-
* return $classes;
|
666 |
-
* }
|
667 |
-
* ?>
|
668 |
-
*/
|
669 |
-
$classes = apply_filters( 'um_extend_field_classes', $classes, $key, $data );
|
670 |
-
|
671 |
-
return $classes;
|
672 |
-
}
|
673 |
-
|
674 |
-
|
675 |
-
/**
|
676 |
-
* Gets field value
|
677 |
-
*
|
678 |
-
* @param string $key
|
679 |
-
* @param boolean $default
|
680 |
-
* @param array $data
|
681 |
-
*
|
682 |
-
* @return mixed
|
683 |
-
*/
|
684 |
-
function field_value( $key, $default = false, $data = null ) {
|
685 |
-
// preview in backend
|
686 |
-
if ( isset( UM()->user()->preview ) && UM()->user()->preview ) {
|
687 |
-
if ( $this->set_mode == 'login' || $this->set_mode == 'register' ) {
|
688 |
-
return '';
|
689 |
-
} else {
|
690 |
-
$val = um_user( $key );
|
691 |
-
if ( ! empty( $val ) ) {
|
692 |
-
return $val;
|
693 |
-
} else {
|
694 |
-
return '';
|
695 |
-
}
|
696 |
-
}
|
697 |
-
}
|
698 |
-
|
699 |
-
if ( isset( $_SESSION ) && isset( $_SESSION['um_social_profile'][ $key ] ) && isset( $this->set_mode ) && $this->set_mode == 'register' ) {
|
700 |
-
return $_SESSION['um_social_profile'][ $key ];
|
701 |
-
}
|
702 |
-
|
703 |
-
$type = ( isset( $data['type'] ) ) ? $data['type'] : '';
|
704 |
-
|
705 |
-
// normal state
|
706 |
-
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
707 |
-
//show empty value for password fields
|
708 |
-
if ( strstr( $key, 'user_pass' ) && $this->set_mode != 'password' ) {
|
709 |
-
return '';
|
710 |
-
}
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
*
|
730 |
-
*
|
731 |
-
* @
|
732 |
-
*
|
733 |
-
* @
|
734 |
-
* @
|
735 |
-
*
|
736 |
-
*
|
737 |
-
*
|
738 |
-
*
|
739 |
-
*
|
740 |
-
*
|
741 |
-
*
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
*
|
746 |
-
*
|
747 |
-
*
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
*
|
752 |
-
*
|
753 |
-
* @
|
754 |
-
*
|
755 |
-
* @
|
756 |
-
* @
|
757 |
-
*
|
758 |
-
*
|
759 |
-
*
|
760 |
-
*
|
761 |
-
*
|
762 |
-
*
|
763 |
-
*
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
*
|
782 |
-
*
|
783 |
-
* @
|
784 |
-
*
|
785 |
-
* @
|
786 |
-
* @
|
787 |
-
*
|
788 |
-
*
|
789 |
-
*
|
790 |
-
*
|
791 |
-
*
|
792 |
-
*
|
793 |
-
*
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
*
|
808 |
-
*
|
809 |
-
*
|
810 |
-
* @
|
811 |
-
*
|
812 |
-
* @
|
813 |
-
*
|
814 |
-
*
|
815 |
-
*
|
816 |
-
*
|
817 |
-
*
|
818 |
-
*
|
819 |
-
*
|
820 |
-
*
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
*
|
825 |
-
*
|
826 |
-
*
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
*
|
831 |
-
*
|
832 |
-
* @
|
833 |
-
*
|
834 |
-
* @
|
835 |
-
* @
|
836 |
-
*
|
837 |
-
*
|
838 |
-
*
|
839 |
-
*
|
840 |
-
*
|
841 |
-
*
|
842 |
-
*
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
*
|
847 |
-
*
|
848 |
-
*
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
*
|
853 |
-
*
|
854 |
-
* @
|
855 |
-
*
|
856 |
-
* @
|
857 |
-
* @
|
858 |
-
*
|
859 |
-
*
|
860 |
-
*
|
861 |
-
*
|
862 |
-
*
|
863 |
-
*
|
864 |
-
*
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
*
|
881 |
-
*
|
882 |
-
* @
|
883 |
-
*
|
884 |
-
* @
|
885 |
-
* @
|
886 |
-
*
|
887 |
-
*
|
888 |
-
*
|
889 |
-
*
|
890 |
-
*
|
891 |
-
*
|
892 |
-
*
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
*
|
911 |
-
*
|
912 |
-
*
|
913 |
-
*
|
914 |
-
*
|
915 |
-
* @
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
*
|
929 |
-
*
|
930 |
-
*
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
*
|
943 |
-
*
|
944 |
-
*
|
945 |
-
* @
|
946 |
-
* @
|
947 |
-
*
|
948 |
-
*
|
949 |
-
*
|
950 |
-
*
|
951 |
-
*
|
952 |
-
*
|
953 |
-
*
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
}
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
$
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
*
|
1013 |
-
*
|
1014 |
-
*
|
1015 |
-
* @
|
1016 |
-
*
|
1017 |
-
* @
|
1018 |
-
*
|
1019 |
-
*
|
1020 |
-
*
|
1021 |
-
*
|
1022 |
-
*
|
1023 |
-
*
|
1024 |
-
*
|
1025 |
-
*
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
*
|
1031 |
-
*
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
*
|
1037 |
-
*
|
1038 |
-
*
|
1039 |
-
* @
|
1040 |
-
*
|
1041 |
-
* @
|
1042 |
-
*
|
1043 |
-
*
|
1044 |
-
*
|
1045 |
-
*
|
1046 |
-
*
|
1047 |
-
*
|
1048 |
-
*
|
1049 |
-
*
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
if ( !
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
*
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
*
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
*
|
1346 |
-
*
|
1347 |
-
* @
|
1348 |
-
*
|
1349 |
-
* @
|
1350 |
-
* @
|
1351 |
-
*
|
1352 |
-
*
|
1353 |
-
*
|
1354 |
-
*
|
1355 |
-
*
|
1356 |
-
*
|
1357 |
-
*
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
*
|
1400 |
-
*
|
1401 |
-
*
|
1402 |
-
* @
|
1403 |
-
* @
|
1404 |
-
*
|
1405 |
-
*
|
1406 |
-
*
|
1407 |
-
*
|
1408 |
-
*
|
1409 |
-
*
|
1410 |
-
*
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
$array[
|
1441 |
-
}
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
if ( ! isset( $array['
|
1446 |
-
$array['
|
1447 |
-
}
|
1448 |
-
if ( ! isset( $array['
|
1449 |
-
$array['
|
1450 |
-
}
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
$array['
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
$array['
|
1469 |
-
}
|
1470 |
-
|
1471 |
-
$
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
case '
|
1484 |
-
|
1485 |
-
$array['disabled'] = '';
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
$array['
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
$array['input'] = '
|
1498 |
-
|
1499 |
-
break;
|
1500 |
-
|
1501 |
-
case '
|
1502 |
-
|
1503 |
-
$array['
|
1504 |
-
|
1505 |
-
break;
|
1506 |
-
|
1507 |
-
case '
|
1508 |
-
|
1509 |
-
$array['
|
1510 |
-
|
1511 |
-
break;
|
1512 |
-
|
1513 |
-
case '
|
1514 |
-
|
1515 |
-
$array['input'] = 'text';
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
case 'M
|
1529 |
-
$js_format = 'mmm
|
1530 |
-
break;
|
1531 |
-
case 'F
|
1532 |
-
$js_format = 'mmmm
|
1533 |
-
break;
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
}
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
if ( ! isset( $array['
|
1545 |
-
$array['
|
1546 |
-
}
|
1547 |
-
if ( ! isset( $array['
|
1548 |
-
$array['
|
1549 |
-
}
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
$array['
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
$
|
1576 |
-
$
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
$
|
1585 |
-
$
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
$
|
1591 |
-
$array['
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
case '
|
1615 |
-
$js_format = '
|
1616 |
-
break;
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
}
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
if ( isset( $array['
|
1660 |
-
$array['
|
1661 |
-
} else {
|
1662 |
-
$array['
|
1663 |
-
}
|
1664 |
-
|
1665 |
-
if ( isset( $array['
|
1666 |
-
$array['
|
1667 |
-
} else {
|
1668 |
-
$array['
|
1669 |
-
}
|
1670 |
-
|
1671 |
-
if (
|
1672 |
-
$array['
|
1673 |
-
}
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
$array['
|
1687 |
-
}
|
1688 |
-
|
1689 |
-
|
1690 |
-
$array['crop_data'] =
|
1691 |
-
}
|
1692 |
-
|
1693 |
-
|
1694 |
-
$array['
|
1695 |
-
}
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
$array['
|
1701 |
-
}
|
1702 |
-
|
1703 |
-
if (
|
1704 |
-
$array['
|
1705 |
-
}
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
$array['
|
1741 |
-
}
|
1742 |
-
if ( ! isset( $array['
|
1743 |
-
$array['
|
1744 |
-
}
|
1745 |
-
if ( ! isset( $array['
|
1746 |
-
$array['
|
1747 |
-
}
|
1748 |
-
if ( ! isset( $array['
|
1749 |
-
$array['
|
1750 |
-
}
|
1751 |
-
if ( ! isset( $array['
|
1752 |
-
$array['
|
1753 |
-
}
|
1754 |
-
if ( ! isset( $array['
|
1755 |
-
$array['
|
1756 |
-
}
|
1757 |
-
if ( ! isset( $array['
|
1758 |
-
$array['
|
1759 |
-
}
|
1760 |
-
if ( ! isset( $array['
|
1761 |
-
$array['
|
1762 |
-
}
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
$array['
|
1776 |
-
}
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
$array['
|
1782 |
-
}
|
1783 |
-
if ( ! isset( $array['
|
1784 |
-
$array['
|
1785 |
-
}
|
1786 |
-
if ( ! isset( $array['
|
1787 |
-
$array['
|
1788 |
-
}
|
1789 |
-
if ( ! isset( $array['
|
1790 |
-
$array['
|
1791 |
-
}
|
1792 |
-
if ( ! isset( $array['
|
1793 |
-
$array['
|
1794 |
-
}
|
1795 |
-
if ( ! isset( $array['
|
1796 |
-
$array['
|
1797 |
-
}
|
1798 |
-
if ( ! isset( $array['
|
1799 |
-
$array['
|
1800 |
-
}
|
1801 |
-
if ( ! isset( $array['
|
1802 |
-
$array['
|
1803 |
-
}
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
*
|
1837 |
-
*
|
1838 |
-
*
|
1839 |
-
* @
|
1840 |
-
* @
|
1841 |
-
*
|
1842 |
-
*
|
1843 |
-
*
|
1844 |
-
*
|
1845 |
-
*
|
1846 |
-
*
|
1847 |
-
*
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
*
|
1869 |
-
*
|
1870 |
-
*
|
1871 |
-
* @
|
1872 |
-
* @
|
1873 |
-
*
|
1874 |
-
*
|
1875 |
-
*
|
1876 |
-
*
|
1877 |
-
*
|
1878 |
-
*
|
1879 |
-
*
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
*
|
1909 |
-
*
|
1910 |
-
* @
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
* @var string $
|
1933 |
-
* @var
|
1934 |
-
* @var
|
1935 |
-
* @var string $
|
1936 |
-
* @var string $
|
1937 |
-
* @var
|
1938 |
-
* @var
|
1939 |
-
* @var
|
1940 |
-
* @var
|
1941 |
-
* @var
|
1942 |
-
* @var
|
1943 |
-
* @var string $
|
1944 |
-
* @var
|
1945 |
-
* @var
|
1946 |
-
* @var string $
|
1947 |
-
* @var
|
1948 |
-
* @var
|
1949 |
-
* @var string $
|
1950 |
-
* @var string $
|
1951 |
-
* @var string $
|
1952 |
-
* @var string $
|
1953 |
-
* @var string $
|
1954 |
-
* @var string $
|
1955 |
-
* @var string $
|
1956 |
-
* @var string $
|
1957 |
-
* @var string $
|
1958 |
-
* @var string $
|
1959 |
-
* @var string $
|
1960 |
-
* @var string $
|
1961 |
-
* @var string $
|
1962 |
-
* @var string $
|
1963 |
-
* @var string $
|
1964 |
-
* @var string $
|
1965 |
-
* @var string $
|
1966 |
-
* @var string $
|
1967 |
-
* @var string $
|
1968 |
-
* @var string $
|
1969 |
-
* @var string $
|
1970 |
-
* @var string $
|
1971 |
-
* @var string $
|
1972 |
-
* @var string $
|
1973 |
-
* @var string $
|
1974 |
-
* @var string $
|
1975 |
-
* @var string $
|
1976 |
-
* @var string $
|
1977 |
-
* @var string $
|
1978 |
-
* @var string $
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
}
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
}
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
*
|
2075 |
-
*
|
2076 |
-
*
|
2077 |
-
* @
|
2078 |
-
* @
|
2079 |
-
*
|
2080 |
-
*
|
2081 |
-
*
|
2082 |
-
*
|
2083 |
-
*
|
2084 |
-
*
|
2085 |
-
*
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
case '
|
2097 |
-
case '
|
2098 |
-
$
|
2099 |
-
$
|
2100 |
-
break;
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
*
|
2114 |
-
*
|
2115 |
-
*
|
2116 |
-
* @
|
2117 |
-
*
|
2118 |
-
* @
|
2119 |
-
*
|
2120 |
-
*
|
2121 |
-
*
|
2122 |
-
*
|
2123 |
-
*
|
2124 |
-
*
|
2125 |
-
*
|
2126 |
-
*
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
*
|
2146 |
-
*
|
2147 |
-
* @
|
2148 |
-
*
|
2149 |
-
* @
|
2150 |
-
* @
|
2151 |
-
*
|
2152 |
-
*
|
2153 |
-
*
|
2154 |
-
*
|
2155 |
-
*
|
2156 |
-
*
|
2157 |
-
*
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
$output .= '<div
|
2176 |
-
|
2177 |
-
if (
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
2185 |
-
|
2186 |
-
|
2187 |
-
|
2188 |
-
|
2189 |
-
|
2190 |
-
|
2191 |
-
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
|
2197 |
-
$output .= $this->
|
2198 |
-
}
|
2199 |
-
|
2200 |
-
$
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
$output .= '
|
2207 |
-
|
2208 |
-
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
$output .= '<div
|
2213 |
-
|
2214 |
-
if (
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
|
2233 |
-
|
2234 |
-
$output .= $this->
|
2235 |
-
}
|
2236 |
-
|
2237 |
-
$
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
$output .= '
|
2244 |
-
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
$output .= '<div
|
2250 |
-
|
2251 |
-
if (
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
2257 |
-
$
|
2258 |
-
|
2259 |
-
$
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
$
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
$
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
$output .= '<div
|
2294 |
-
|
2295 |
-
if (
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
$
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
-
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
-
|
2323 |
-
|
2324 |
-
|
2325 |
-
$output .= '<div
|
2326 |
-
|
2327 |
-
if (
|
2328 |
-
|
2329 |
-
|
2330 |
-
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
$
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
$
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
$
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
$
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
$
|
2416 |
-
}
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
$
|
2433 |
-
|
2434 |
-
|
2435 |
-
|
2436 |
-
|
2437 |
-
|
2438 |
-
|
2439 |
-
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
-
|
2445 |
-
|
2446 |
-
|
2447 |
-
|
2448 |
-
|
2449 |
-
$output .= '<div
|
2450 |
-
|
2451 |
-
if (
|
2452 |
-
|
2453 |
-
|
2454 |
-
|
2455 |
-
|
2456 |
-
|
2457 |
-
|
2458 |
-
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
-
|
2465 |
-
|
2466 |
-
|
2467 |
-
$
|
2468 |
-
|
2469 |
-
|
2470 |
-
|
2471 |
-
|
2472 |
-
|
2473 |
-
$output .= '
|
2474 |
-
|
2475 |
-
|
2476 |
-
|
2477 |
-
|
2478 |
-
|
2479 |
-
$output .= '<div
|
2480 |
-
|
2481 |
-
if (
|
2482 |
-
|
2483 |
-
|
2484 |
-
|
2485 |
-
|
2486 |
-
|
2487 |
-
|
2488 |
-
|
2489 |
-
|
2490 |
-
|
2491 |
-
|
2492 |
-
|
2493 |
-
|
2494 |
-
|
2495 |
-
|
2496 |
-
|
2497 |
-
$
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
|
2502 |
-
|
2503 |
-
$output .= '
|
2504 |
-
|
2505 |
-
|
2506 |
-
|
2507 |
-
|
2508 |
-
|
2509 |
-
$output .= '<div
|
2510 |
-
|
2511 |
-
if (
|
2512 |
-
|
2513 |
-
|
2514 |
-
|
2515 |
-
|
2516 |
-
|
2517 |
-
|
2518 |
-
|
2519 |
-
|
2520 |
-
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
|
2527 |
-
$
|
2528 |
-
|
2529 |
-
|
2530 |
-
|
2531 |
-
|
2532 |
-
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
$output .= '<div
|
2544 |
-
|
2545 |
-
if ( isset( $data['
|
2546 |
-
|
2547 |
-
|
2548 |
-
|
2549 |
-
|
2550 |
-
|
2551 |
-
|
2552 |
-
|
2553 |
-
|
2554 |
-
|
2555 |
-
|
2556 |
-
|
2557 |
-
|
2558 |
-
|
2559 |
-
|
2560 |
-
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
|
2568 |
-
|
2569 |
-
*
|
2570 |
-
*
|
2571 |
-
*
|
2572 |
-
* @
|
2573 |
-
* @
|
2574 |
-
*
|
2575 |
-
*
|
2576 |
-
*
|
2577 |
-
*
|
2578 |
-
*
|
2579 |
-
*
|
2580 |
-
*
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
|
2589 |
-
|
2590 |
-
//
|
2591 |
-
|
2592 |
-
|
2593 |
-
|
2594 |
-
|
2595 |
-
|
2596 |
-
|
2597 |
-
|
2598 |
-
|
2599 |
-
|
2600 |
-
$
|
2601 |
-
|
2602 |
-
|
2603 |
-
|
2604 |
-
|
2605 |
-
|
2606 |
-
|
2607 |
-
|
2608 |
-
|
2609 |
-
|
2610 |
-
|
2611 |
-
|
2612 |
-
|
2613 |
-
|
2614 |
-
|
2615 |
-
|
2616 |
-
|
2617 |
-
|
2618 |
-
|
2619 |
-
|
2620 |
-
|
2621 |
-
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
-
|
2626 |
-
|
2627 |
-
|
2628 |
-
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
|
2635 |
-
|
2636 |
-
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
2641 |
-
|
2642 |
-
|
2643 |
-
|
2644 |
-
|
2645 |
-
|
2646 |
-
|
2647 |
-
|
2648 |
-
|
2649 |
-
|
2650 |
-
|
2651 |
-
|
2652 |
-
|
2653 |
-
|
2654 |
-
|
2655 |
-
|
2656 |
-
|
2657 |
-
|
2658 |
-
|
2659 |
-
|
2660 |
-
|
2661 |
-
|
2662 |
-
|
2663 |
-
|
2664 |
-
|
2665 |
-
|
2666 |
-
|
2667 |
-
|
2668 |
-
|
2669 |
-
|
2670 |
-
|
2671 |
-
|
2672 |
-
|
2673 |
-
|
2674 |
-
|
2675 |
-
|
2676 |
-
|
2677 |
-
|
2678 |
-
|
2679 |
-
$
|
2680 |
-
|
2681 |
-
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
|
2711 |
-
|
2712 |
-
$output .= '
|
2713 |
-
|
2714 |
-
|
2715 |
-
|
2716 |
-
|
2717 |
-
|
2718 |
-
|
2719 |
-
|
2720 |
-
$output .= '</div>';
|
2721 |
-
|
2722 |
-
|
2723 |
-
|
2724 |
-
|
2725 |
-
|
2726 |
-
|
2727 |
-
$output .= '
|
2728 |
-
|
2729 |
-
|
2730 |
-
|
2731 |
-
|
2732 |
-
|
2733 |
-
|
2734 |
-
$
|
2735 |
-
|
2736 |
-
|
2737 |
-
|
2738 |
-
|
2739 |
-
|
2740 |
-
|
2741 |
-
|
2742 |
-
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
-
if (
|
2747 |
-
$
|
2748 |
-
}
|
2749 |
-
|
2750 |
-
|
2751 |
-
|
2752 |
-
|
2753 |
-
|
2754 |
-
$
|
2755 |
-
|
2756 |
-
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
|
2762 |
-
|
2763 |
-
|
2764 |
-
|
2765 |
-
|
2766 |
-
|
2767 |
-
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
-
|
2772 |
-
|
2773 |
-
|
2774 |
-
|
2775 |
-
|
2776 |
-
|
2777 |
-
|
2778 |
-
|
2779 |
-
|
2780 |
-
|
2781 |
-
|
2782 |
-
|
2783 |
-
|
2784 |
-
|
2785 |
-
|
2786 |
-
|
2787 |
-
|
2788 |
-
|
2789 |
-
|
2790 |
-
|
2791 |
-
|
2792 |
-
|
2793 |
-
$
|
2794 |
-
|
2795 |
-
|
2796 |
-
|
2797 |
-
|
2798 |
-
|
2799 |
-
|
2800 |
-
|
2801 |
-
|
2802 |
-
|
2803 |
-
|
2804 |
-
|
2805 |
-
|
2806 |
-
|
2807 |
-
|
2808 |
-
|
2809 |
-
|
2810 |
-
|
2811 |
-
$output .= '
|
2812 |
-
|
2813 |
-
|
2814 |
-
|
2815 |
-
|
2816 |
-
|
2817 |
-
|
2818 |
-
|
2819 |
-
$output .= '</div>';
|
2820 |
-
|
2821 |
-
|
2822 |
-
|
2823 |
-
|
2824 |
-
|
2825 |
-
|
2826 |
-
$output .= '
|
2827 |
-
|
2828 |
-
|
2829 |
-
|
2830 |
-
|
2831 |
-
|
2832 |
-
|
2833 |
-
|
2834 |
-
|
2835 |
-
|
2836 |
-
|
2837 |
-
|
2838 |
-
|
2839 |
-
|
2840 |
-
|
2841 |
-
|
2842 |
-
|
2843 |
-
|
2844 |
-
|
2845 |
-
$
|
2846 |
-
$
|
2847 |
-
|
2848 |
-
|
2849 |
-
|
2850 |
-
|
2851 |
-
|
2852 |
-
|
2853 |
-
|
2854 |
-
|
2855 |
-
|
2856 |
-
|
2857 |
-
$
|
2858 |
-
|
2859 |
-
|
2860 |
-
|
2861 |
-
|
2862 |
-
|
2863 |
-
|
2864 |
-
|
2865 |
-
|
2866 |
-
|
2867 |
-
*
|
2868 |
-
*
|
2869 |
-
*
|
2870 |
-
* @
|
2871 |
-
* @
|
2872 |
-
*
|
2873 |
-
*
|
2874 |
-
*
|
2875 |
-
*
|
2876 |
-
*
|
2877 |
-
* }
|
2878 |
-
*
|
2879 |
-
|
2880 |
-
|
2881 |
-
|
2882 |
-
|
2883 |
-
|
2884 |
-
|
2885 |
-
|
2886 |
-
|
2887 |
-
|
2888 |
-
|
2889 |
-
|
2890 |
-
|
2891 |
-
|
2892 |
-
|
2893 |
-
|
2894 |
-
|
2895 |
-
|
2896 |
-
|
2897 |
-
|
2898 |
-
|
2899 |
-
|
2900 |
-
|
2901 |
-
|
2902 |
-
|
2903 |
-
|
2904 |
-
|
2905 |
-
|
2906 |
-
|
2907 |
-
|
2908 |
-
|
2909 |
-
|
2910 |
-
|
2911 |
-
|
2912 |
-
|
2913 |
-
|
2914 |
-
|
2915 |
-
|
2916 |
-
|
2917 |
-
|
2918 |
-
|
2919 |
-
*
|
2920 |
-
*
|
2921 |
-
*
|
2922 |
-
* @
|
2923 |
-
* @
|
2924 |
-
*
|
2925 |
-
*
|
2926 |
-
*
|
2927 |
-
*
|
2928 |
-
*
|
2929 |
-
* }
|
2930 |
-
*
|
2931 |
-
|
2932 |
-
|
2933 |
-
|
2934 |
-
|
2935 |
-
|
2936 |
-
*
|
2937 |
-
*
|
2938 |
-
|
2939 |
-
|
2940 |
-
|
2941 |
-
|
2942 |
-
|
2943 |
-
*
|
2944 |
-
*
|
2945 |
-
*
|
2946 |
-
* @
|
2947 |
-
* @
|
2948 |
-
*
|
2949 |
-
*
|
2950 |
-
*
|
2951 |
-
*
|
2952 |
-
*
|
2953 |
-
* }
|
2954 |
-
*
|
2955 |
-
|
2956 |
-
|
2957 |
-
|
2958 |
-
//
|
2959 |
-
|
2960 |
-
|
2961 |
-
|
2962 |
-
|
2963 |
-
|
2964 |
-
|
2965 |
-
|
2966 |
-
|
2967 |
-
|
2968 |
-
|
2969 |
-
|
2970 |
-
*
|
2971 |
-
*
|
2972 |
-
* @
|
2973 |
-
* @
|
2974 |
-
*
|
2975 |
-
*
|
2976 |
-
*
|
2977 |
-
*
|
2978 |
-
*
|
2979 |
-
* }
|
2980 |
-
*
|
2981 |
-
|
2982 |
-
|
2983 |
-
|
2984 |
-
|
2985 |
-
|
2986 |
-
|
2987 |
-
|
2988 |
-
|
2989 |
-
|
2990 |
-
|
2991 |
-
|
2992 |
-
|
2993 |
-
$options = $
|
2994 |
-
}
|
2995 |
-
|
2996 |
-
|
2997 |
-
|
2998 |
-
|
2999 |
-
|
3000 |
-
|
3001 |
-
|
3002 |
-
|
3003 |
-
|
3004 |
-
|
3005 |
-
|
3006 |
-
|
3007 |
-
*
|
3008 |
-
*
|
3009 |
-
*
|
3010 |
-
* @
|
3011 |
-
* @
|
3012 |
-
*
|
3013 |
-
*
|
3014 |
-
*
|
3015 |
-
*
|
3016 |
-
*
|
3017 |
-
*
|
3018 |
-
*
|
3019 |
-
|
3020 |
-
|
3021 |
-
|
3022 |
-
*
|
3023 |
-
*
|
3024 |
-
*
|
3025 |
-
*
|
3026 |
-
|
3027 |
-
|
3028 |
-
|
3029 |
-
*
|
3030 |
-
*
|
3031 |
-
* @
|
3032 |
-
* @
|
3033 |
-
*
|
3034 |
-
*
|
3035 |
-
*
|
3036 |
-
*
|
3037 |
-
*
|
3038 |
-
* }
|
3039 |
-
*
|
3040 |
-
|
3041 |
-
|
3042 |
-
|
3043 |
-
}
|
3044 |
-
|
3045 |
-
if ( $form_key === 'role' ) {
|
3046 |
-
$options = $this->get_available_roles( $form_key, $options );
|
3047 |
-
}
|
3048 |
-
|
3049 |
-
/**
|
3050 |
-
* UM hook
|
3051 |
-
*
|
3052 |
-
* @type filter
|
3053 |
-
* @title um_select_option_value
|
3054 |
-
* @description Enable options pair by field $data
|
3055 |
-
* @input_vars
|
3056 |
-
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3057 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3058 |
-
*/
|
3059 |
-
$options_pair = apply_filters( 'um_select_options_pair', null, $data );
|
3060 |
-
|
3061 |
-
// switch options pair for custom options from a callback function
|
3062 |
-
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
3063 |
-
$options_pair = true;
|
3064 |
-
}
|
3065 |
-
|
3066 |
-
$field_value = '';
|
3067 |
-
|
3068 |
-
if ( ! empty( $placeholder ) && is_string( $placeholder ) ) {
|
3069 |
-
$placeholder = strip_tags( $placeholder );
|
3070 |
-
}
|
3071 |
-
|
3072 |
-
$output .= '<select data-default="' . $data['default'] . '" ' . $disabled . ' ' . $select_original_option_value . ' ' . $disabled_by_parent_option . ' name="' . esc_attr( $form_key ) . '" id="' . esc_attr( $field_id ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" class="' . $this->get_class( $key, $data, $class ) . '" style="width: 100%" data-placeholder="' . esc_attr( $placeholder ) . '" ' . $atts_ajax . '>';
|
3073 |
-
|
3074 |
-
$output .= '<option value=""></option>';
|
3075 |
-
|
3076 |
-
// add options
|
3077 |
-
if ( ! empty( $options ) ) {
|
3078 |
-
foreach ( $options as $k => $v ) {
|
3079 |
-
|
3080 |
-
$v = rtrim( $v );
|
3081 |
-
|
3082 |
-
$option_value = $v;
|
3083 |
-
$um_field_checkbox_item_title = $v;
|
3084 |
-
|
3085 |
-
|
3086 |
-
if ( ! is_numeric( $k ) && in_array( $form_key, array( 'role' ) ) ||
|
3087 |
-
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
3088 |
-
$option_value = $k;
|
3089 |
-
$um_field_checkbox_item_title = $v;
|
3090 |
-
}
|
3091 |
-
|
3092 |
-
if ( isset( $options_pair ) ) {
|
3093 |
-
$option_value = $k;
|
3094 |
-
$um_field_checkbox_item_title = $v;
|
3095 |
-
}
|
3096 |
-
|
3097 |
-
$option_value = $this->filter_field_non_utf8_value( $option_value );
|
3098 |
-
|
3099 |
-
$output .= '<option value="' . $option_value . '" ';
|
3100 |
-
|
3101 |
-
if ( $this->is_selected( $form_key, $option_value, $data ) ) {
|
3102 |
-
$output .= 'selected';
|
3103 |
-
$field_value = $option_value;
|
3104 |
-
} elseif ( ! isset( $options_pair ) && $this->is_selected( $form_key, $v, $data ) ) {
|
3105 |
-
$output .= 'selected';
|
3106 |
-
$field_value = $v;
|
3107 |
-
}
|
3108 |
-
|
3109 |
-
$output .= '>' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</option>';
|
3110 |
-
}
|
3111 |
-
}
|
3112 |
-
|
3113 |
-
if ( ! empty( $disabled ) ) {
|
3114 |
-
$output .= $this->disabled_hidden_field( $form_key, $field_value );
|
3115 |
-
}
|
3116 |
-
|
3117 |
-
$output .= '</select>';
|
3118 |
-
|
3119 |
-
$output .= '</div>';
|
3120 |
-
|
3121 |
-
|
3122 |
-
if ( $this->is_error( $form_key ) ) {
|
3123 |
-
$output .= $this->field_error( $this->show_error( $form_key ) );
|
3124 |
-
} elseif ( $this->is_notice( $form_key ) ) {
|
3125 |
-
$output .= $this->field_notice( $this->show_notice( $form_key ) );
|
3126 |
-
}
|
3127 |
-
|
3128 |
-
|
3129 |
-
$output .= '</div>';
|
3130 |
-
break;
|
3131 |
-
|
3132 |
-
/* Multi-Select dropdown */
|
3133 |
-
case 'multiselect':
|
3134 |
-
|
3135 |
-
$max_selections = ( isset( $max_selections ) ) ? absint( $max_selections ) : 0;
|
3136 |
-
|
3137 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3138 |
-
|
3139 |
-
if ( isset( $data['allowclear'] ) && $data['allowclear'] == 0 ) {
|
3140 |
-
$class = 'um-s2';
|
3141 |
-
} else {
|
3142 |
-
$class = 'um-s1';
|
3143 |
-
}
|
3144 |
-
|
3145 |
-
if ( isset( $data['label'] ) ) {
|
3146 |
-
$output .= $this->field_label( $label, $key, $data );
|
3147 |
-
}
|
3148 |
-
|
3149 |
-
$field_icon = false;
|
3150 |
-
$field_icon_output = '';
|
3151 |
-
|
3152 |
-
/**
|
3153 |
-
* UM hook
|
3154 |
-
*
|
3155 |
-
* @type filter
|
3156 |
-
* @title um_multiselect_option_value
|
3157 |
-
* @description Change multiselect keyword data
|
3158 |
-
* @input_vars
|
3159 |
-
* [{"var":"$keyword","type":"int","desc":"Option Value"},
|
3160 |
-
* {"var":"$type","type":"string","desc":"Field Type"}]
|
3161 |
-
* @change_log
|
3162 |
-
* ["Since: 2.0"]
|
3163 |
-
* @usage add_filter( 'um_multiselect_option_value', 'function_name', 10, 2 );
|
3164 |
-
* @example
|
3165 |
-
* <?php
|
3166 |
-
* add_filter( 'um_multiselect_option_value', 'my_multiselect_option_value', 10, 2 );
|
3167 |
-
* function my_multiselect_option_value( $keyword, $type ) {
|
3168 |
-
* // your code here
|
3169 |
-
* return $keyword;
|
3170 |
-
* }
|
3171 |
-
* ?>
|
3172 |
-
*/
|
3173 |
-
$use_keyword = apply_filters( 'um_multiselect_option_value', 0, $data['type'] );
|
3174 |
-
|
3175 |
-
$output .= '<div class="um-field-area ' . (! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ? 'um-field-area-has-icon' : '' ) . ' ">';
|
3176 |
-
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
3177 |
-
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
3178 |
-
}
|
3179 |
-
|
3180 |
-
$output .= '<select ' . $disabled . ' multiple="multiple" name="' . esc_attr( $field_name ) . '[]" id="' . esc_attr( $field_id ) . '" data-maxsize="' . esc_attr( $max_selections ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" class="' . $this->get_class( $key, $data, $class ) . ' um-user-keyword_' . $use_keyword . '" style="width: 100%" data-placeholder="' . esc_attr( $placeholder ) . '">';
|
3181 |
-
|
3182 |
-
|
3183 |
-
if ( isset( $options ) && $options == 'builtin' ) {
|
3184 |
-
$options = UM()->builtin()->get( $filter );
|
3185 |
-
}
|
3186 |
-
|
3187 |
-
if ( ! isset( $options ) ) {
|
3188 |
-
$options = UM()->builtin()->get( 'countries' );
|
3189 |
-
}
|
3190 |
-
|
3191 |
-
if ( isset( $options ) ) {
|
3192 |
-
/**
|
3193 |
-
* UM hook
|
3194 |
-
*
|
3195 |
-
* @type filter
|
3196 |
-
* @title um_multiselect_options
|
3197 |
-
* @description Extend multiselect options
|
3198 |
-
* @input_vars
|
3199 |
-
* [{"var":"$options","type":"array","desc":"Multiselect Options"},
|
3200 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3201 |
-
* @change_log
|
3202 |
-
* ["Since: 2.0"]
|
3203 |
-
* @usage add_filter( 'um_multiselect_options', 'function_name', 10, 2 );
|
3204 |
-
* @example
|
3205 |
-
* <?php
|
3206 |
-
* add_filter( 'um_multiselect_options', 'my_multiselect_options', 10, 2 );
|
3207 |
-
* function my_multiselect_options( $options, $data ) {
|
3208 |
-
* // your code here
|
3209 |
-
* return $options;
|
3210 |
-
* }
|
3211 |
-
* ?>
|
3212 |
-
*/
|
3213 |
-
$options = apply_filters( 'um_multiselect_options', $options, $data );
|
3214 |
-
/**
|
3215 |
-
* UM hook
|
3216 |
-
*
|
3217 |
-
* @type filter
|
3218 |
-
* @title um_multiselect_options_{$key}
|
3219 |
-
* @description Extend multiselect options by field $key
|
3220 |
-
* @input_vars
|
3221 |
-
* [{"var":"$options","type":"array","desc":"Multiselect Options"}]
|
3222 |
-
* @change_log
|
3223 |
-
* ["Since: 2.0"]
|
3224 |
-
* @usage add_filter( 'um_multiselect_options_{$key}', 'function_name', 10, 1 );
|
3225 |
-
* @example
|
3226 |
-
* <?php
|
3227 |
-
* add_filter( 'um_multiselect_options_{$key}', 'my_multiselect_options', 10, 1 );
|
3228 |
-
* function my_multiselect_options( $options ) {
|
3229 |
-
* // your code here
|
3230 |
-
* return $options;
|
3231 |
-
* }
|
3232 |
-
* ?>
|
3233 |
-
*/
|
3234 |
-
$options = apply_filters( "um_multiselect_options_{$key}", $options );
|
3235 |
-
/**
|
3236 |
-
* UM hook
|
3237 |
-
*
|
3238 |
-
* @type filter
|
3239 |
-
* @title um_multiselect_options_{$type}
|
3240 |
-
* @description Extend multiselect options by field $type
|
3241 |
-
* @input_vars
|
3242 |
-
* [{"var":"$options","type":"array","desc":"Multiselect Options"},
|
3243 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3244 |
-
* @change_log
|
3245 |
-
* ["Since: 2.0"]
|
3246 |
-
* @usage add_filter( 'um_multiselect_options_{$type}', 'function_name', 10, 2 );
|
3247 |
-
* @example
|
3248 |
-
* <?php
|
3249 |
-
* add_filter( 'um_multiselect_options_{$type}', 'my_multiselect_options', 10, 2 );
|
3250 |
-
* function my_multiselect_option_value( $options, $data ) {
|
3251 |
-
* // your code here
|
3252 |
-
* return $options;
|
3253 |
-
* }
|
3254 |
-
* ?>
|
3255 |
-
*/
|
3256 |
-
$options = apply_filters( "um_multiselect_options_{$data['type']}", $options, $data );
|
3257 |
-
}
|
3258 |
-
|
3259 |
-
/**
|
3260 |
-
* UM hook
|
3261 |
-
*
|
3262 |
-
* @type filter
|
3263 |
-
* @title um_select_option_value
|
3264 |
-
* @description Enable options pair by field $data
|
3265 |
-
* @input_vars
|
3266 |
-
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3267 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3268 |
-
*/
|
3269 |
-
$use_keyword = apply_filters( 'um_select_options_pair', null, $data );
|
3270 |
-
|
3271 |
-
// switch options pair for custom options from a callback function
|
3272 |
-
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
3273 |
-
$use_keyword = true;
|
3274 |
-
}
|
3275 |
-
|
3276 |
-
// add an empty option!
|
3277 |
-
$output .= '<option value=""></option>';
|
3278 |
-
|
3279 |
-
$arr_selected = array();
|
3280 |
-
// add options
|
3281 |
-
if ( ! empty( $options ) && is_array( $options ) ) {
|
3282 |
-
foreach ( $options as $k => $v ) {
|
3283 |
-
|
3284 |
-
$v = rtrim( $v );
|
3285 |
-
|
3286 |
-
$um_field_checkbox_item_title = $v;
|
3287 |
-
$opt_value = $v;
|
3288 |
-
|
3289 |
-
if ( $use_keyword ) {
|
3290 |
-
$um_field_checkbox_item_title = $v;
|
3291 |
-
$opt_value = $k;
|
3292 |
-
}
|
3293 |
-
|
3294 |
-
$opt_value = $this->filter_field_non_utf8_value( $opt_value );
|
3295 |
-
|
3296 |
-
$output .= '<option value="' . $opt_value . '" ';
|
3297 |
-
if ( $this->is_selected( $key, $opt_value, $data ) ) {
|
3298 |
-
|
3299 |
-
$output .= 'selected';
|
3300 |
-
$arr_selected[ $opt_value ] = $opt_value;
|
3301 |
-
}
|
3302 |
-
|
3303 |
-
$output .= '>' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</option>';
|
3304 |
-
|
3305 |
-
}
|
3306 |
-
}
|
3307 |
-
|
3308 |
-
$output .= '</select>';
|
3309 |
-
|
3310 |
-
if ( ! empty( $disabled ) && ! empty( $arr_selected ) ) {
|
3311 |
-
foreach ( $arr_selected as $item ) {
|
3312 |
-
$output .= $this->disabled_hidden_field( $key . '[]', $item );
|
3313 |
-
}
|
3314 |
-
}
|
3315 |
-
|
3316 |
-
$output .= '</div>';
|
3317 |
-
|
3318 |
-
|
3319 |
-
if ( $this->is_error( $key ) ) {
|
3320 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
3321 |
-
}else if ( $this->is_notice( $key ) ) {
|
3322 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3323 |
-
}
|
3324 |
-
|
3325 |
-
$output .= '</div>';
|
3326 |
-
break;
|
3327 |
-
|
3328 |
-
/* Radio */
|
3329 |
-
case 'radio':
|
3330 |
-
|
3331 |
-
if ( isset( $options ) ) {
|
3332 |
-
/**
|
3333 |
-
* UM hook
|
3334 |
-
*
|
3335 |
-
* @type filter
|
3336 |
-
* @title um_radio_field_options
|
3337 |
-
* @description Extend radio field options
|
3338 |
-
* @input_vars
|
3339 |
-
* [{"var":"$options","type":"array","desc":"Radio Field Options"},
|
3340 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3341 |
-
* @change_log
|
3342 |
-
* ["Since: 2.0"]
|
3343 |
-
* @usage add_filter( 'um_radio_field_options', 'function_name', 10, 2 );
|
3344 |
-
* @example
|
3345 |
-
* <?php
|
3346 |
-
* add_filter( 'um_radio_field_options', 'my_radio_field_options', 10, 2 );
|
3347 |
-
* function my_radio_field_options( $options, $data ) {
|
3348 |
-
* // your code here
|
3349 |
-
* return $options;
|
3350 |
-
* }
|
3351 |
-
* ?>
|
3352 |
-
*/
|
3353 |
-
$options = apply_filters( 'um_radio_field_options', $options, $data );
|
3354 |
-
/**
|
3355 |
-
* UM hook
|
3356 |
-
*
|
3357 |
-
* @type filter
|
3358 |
-
* @title um_radio_field_options_{$key}
|
3359 |
-
* @description Extend radio field options by field $key
|
3360 |
-
* @input_vars
|
3361 |
-
* [{"var":"$options","type":"array","desc":"Radio field Options"}]
|
3362 |
-
* @change_log
|
3363 |
-
* ["Since: 2.0"]
|
3364 |
-
* @usage add_filter( 'um_radio_field_options_{$key}', 'function_name', 10, 1 );
|
3365 |
-
* @example
|
3366 |
-
* <?php
|
3367 |
-
* add_filter( 'um_radio_field_options_{$key}', 'my_radio_field_options', 10, 1 );
|
3368 |
-
* function my_radio_field_options( $options ) {
|
3369 |
-
* // your code here
|
3370 |
-
* return $options;
|
3371 |
-
* }
|
3372 |
-
* ?>
|
3373 |
-
*/
|
3374 |
-
$options = apply_filters( "um_radio_field_options_{$key}", $options );
|
3375 |
-
}
|
3376 |
-
|
3377 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3378 |
-
|
3379 |
-
if ( isset( $data['label'] ) ) {
|
3380 |
-
$output .= $this->field_label( $label, $key, $data );
|
3381 |
-
}
|
3382 |
-
|
3383 |
-
$output .= '<div class="um-field-area">';
|
3384 |
-
|
3385 |
-
$options = $this->get_available_roles( $form_key, $options );
|
3386 |
-
|
3387 |
-
// add options
|
3388 |
-
$i = 0;
|
3389 |
-
$field_value = array();
|
3390 |
-
|
3391 |
-
/**
|
3392 |
-
* UM hook
|
3393 |
-
*
|
3394 |
-
* @type filter
|
3395 |
-
* @title um_radio_option_value
|
3396 |
-
* @description Enable options pair by field $data
|
3397 |
-
* @input_vars
|
3398 |
-
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3399 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3400 |
-
*/
|
3401 |
-
$options_pair = apply_filters( "um_radio_options_pair__{$key}", false, $data );
|
3402 |
-
|
3403 |
-
|
3404 |
-
if ( ! empty( $options ) ) {
|
3405 |
-
foreach ( $options as $k => $v ) {
|
3406 |
-
|
3407 |
-
$v = rtrim( $v );
|
3408 |
-
|
3409 |
-
$um_field_checkbox_item_title = $v;
|
3410 |
-
$option_value = $v;
|
3411 |
-
|
3412 |
-
if ( ! is_numeric( $k ) && in_array( $form_key, array( 'role' ) ) ||
|
3413 |
-
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
3414 |
-
$um_field_checkbox_item_title = $v;
|
3415 |
-
$option_value = $k;
|
3416 |
-
}
|
3417 |
-
|
3418 |
-
if( $options_pair ){
|
3419 |
-
$um_field_checkbox_item_title = $v;
|
3420 |
-
$option_value = $k;
|
3421 |
-
}
|
3422 |
-
|
3423 |
-
$i++;
|
3424 |
-
if ($i % 2 == 0) {
|
3425 |
-
$col_class = 'right';
|
3426 |
-
} else {
|
3427 |
-
$col_class = '';
|
3428 |
-
}
|
3429 |
-
|
3430 |
-
if ( $this->is_radio_checked( $key, $option_value, $data ) ) {
|
3431 |
-
$active = 'active';
|
3432 |
-
$class = "um-icon-android-radio-button-on";
|
3433 |
-
} else {
|
3434 |
-
$active = '';
|
3435 |
-
$class = "um-icon-android-radio-button-off";
|
3436 |
-
}
|
3437 |
-
|
3438 |
-
|
3439 |
-
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
3440 |
-
$col_class .= " um-field-radio-state-disabled";
|
3441 |
-
}
|
3442 |
-
|
3443 |
-
$output .= '<label class="um-field-radio ' . esc_attr( $active ) . ' um-field-half ' . esc_attr( $col_class ) . '">';
|
3444 |
-
|
3445 |
-
$option_value = $this->filter_field_non_utf8_value( $option_value );
|
3446 |
-
|
3447 |
-
$output .= '<input ' . $disabled . ' type="radio" name="' . ( ( $form_key == 'role' ) ? esc_attr( $form_key ) : esc_attr( $form_key ) . '[]' ) . '" value="' . $option_value . '" ';
|
3448 |
-
|
3449 |
-
if ( $this->is_radio_checked( $key, $option_value, $data ) ) {
|
3450 |
-
$output .= 'checked';
|
3451 |
-
$field_value[ $key ] = $option_value;
|
3452 |
-
}
|
3453 |
-
|
3454 |
-
$output .= ' />';
|
3455 |
-
|
3456 |
-
$output .= '<span class="um-field-radio-state"><i class="' . esc_attr( $class ) . '"></i></span>';
|
3457 |
-
$output .= '<span class="um-field-radio-option">' . esc_html__( $um_field_checkbox_item_title, 'ultimate-member' ) . '</span>';
|
3458 |
-
$output .= '</label>';
|
3459 |
-
|
3460 |
-
if ( $i % 2 == 0 ) {
|
3461 |
-
$output .= '<div class="um-clear"></div>';
|
3462 |
-
}
|
3463 |
-
|
3464 |
-
}
|
3465 |
-
}
|
3466 |
-
|
3467 |
-
if ( ! empty( $disabled ) ) {
|
3468 |
-
foreach ( $field_value as $item ) {
|
3469 |
-
$output .= $this->disabled_hidden_field( $form_key, $item );
|
3470 |
-
}
|
3471 |
-
}
|
3472 |
-
|
3473 |
-
$output .= '<div class="um-clear"></div>';
|
3474 |
-
|
3475 |
-
$output .= '</div>';
|
3476 |
-
|
3477 |
-
if ( $this->is_error( $key ) ) {
|
3478 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
3479 |
-
}else if ( $this->is_notice( $key ) ) {
|
3480 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3481 |
-
}
|
3482 |
-
|
3483 |
-
$output .= '</div>';
|
3484 |
-
break;
|
3485 |
-
|
3486 |
-
/* Checkbox */
|
3487 |
-
case 'checkbox':
|
3488 |
-
|
3489 |
-
if ( isset( $options ) ) {
|
3490 |
-
/**
|
3491 |
-
* UM hook
|
3492 |
-
*
|
3493 |
-
* @type filter
|
3494 |
-
* @title um_checkbox_field_options
|
3495 |
-
* @description Extend checkbox options
|
3496 |
-
* @input_vars
|
3497 |
-
* [{"var":"$options","type":"array","desc":"Checkbox Options"},
|
3498 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3499 |
-
* @change_log
|
3500 |
-
* ["Since: 2.0"]
|
3501 |
-
* @usage add_filter( 'um_checkbox_field_options', 'function_name', 10, 2 );
|
3502 |
-
* @example
|
3503 |
-
* <?php
|
3504 |
-
* add_filter( 'um_checkbox_field_options', 'my_checkbox_options', 10, 2 );
|
3505 |
-
* function my_checkbox_options( $options, $data ) {
|
3506 |
-
* // your code here
|
3507 |
-
* return $options;
|
3508 |
-
* }
|
3509 |
-
* ?>
|
3510 |
-
*/
|
3511 |
-
$options = apply_filters( 'um_checkbox_field_options', $options, $data );
|
3512 |
-
/**
|
3513 |
-
* UM hook
|
3514 |
-
*
|
3515 |
-
* @type filter
|
3516 |
-
* @title um_checkbox_field_options_{$key}
|
3517 |
-
* @description Extend checkbox options by field $key
|
3518 |
-
* @input_vars
|
3519 |
-
* [{"var":"$options","type":"array","desc":"Checkbox Options"}]
|
3520 |
-
* @change_log
|
3521 |
-
* ["Since: 2.0"]
|
3522 |
-
* @usage add_filter( 'um_checkbox_field_options_{$key}', 'function_name', 10, 1 );
|
3523 |
-
* @example
|
3524 |
-
* <?php
|
3525 |
-
* add_filter( 'um_checkbox_field_options_{$key}', 'my_checkbox_options', 10, 1 );
|
3526 |
-
* function my_checkbox_options( $options ) {
|
3527 |
-
* // your code here
|
3528 |
-
* return $options;
|
3529 |
-
* }
|
3530 |
-
* ?>
|
3531 |
-
*/
|
3532 |
-
$options = apply_filters( "um_checkbox_field_options_{$key}", $options );
|
3533 |
-
}
|
3534 |
-
|
3535 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3536 |
-
|
3537 |
-
if ( isset( $data['label'] ) ) {
|
3538 |
-
$output .= $this->field_label( $label, $key, $data );
|
3539 |
-
}
|
3540 |
-
|
3541 |
-
$output .= '<div class="um-field-area">';
|
3542 |
-
|
3543 |
-
// add options
|
3544 |
-
$i = 0;
|
3545 |
-
|
3546 |
-
foreach ( $options as $k => $v ) {
|
3547 |
-
|
3548 |
-
$v = rtrim( $v );
|
3549 |
-
|
3550 |
-
$i++;
|
3551 |
-
if ( $i % 2 == 0 ) {
|
3552 |
-
$col_class = 'right';
|
3553 |
-
} else {
|
3554 |
-
$col_class = '';
|
3555 |
-
}
|
3556 |
-
|
3557 |
-
if ( $this->is_selected( $key, $v, $data ) ) {
|
3558 |
-
$active = 'active';
|
3559 |
-
$class = "um-icon-android-checkbox-outline";
|
3560 |
-
} else {
|
3561 |
-
$active = '';
|
3562 |
-
$class = "um-icon-android-checkbox-outline-blank";
|
3563 |
-
}
|
3564 |
-
|
3565 |
-
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
3566 |
-
$col_class .= " um-field-radio-state-disabled";
|
3567 |
-
}
|
3568 |
-
|
3569 |
-
$output .= '<label class="um-field-checkbox ' . esc_attr( $active ) . ' um-field-half ' . esc_attr( $col_class ) . '">';
|
3570 |
-
|
3571 |
-
$um_field_checkbox_item_title = $v;
|
3572 |
-
|
3573 |
-
$v = $this->filter_field_non_utf8_value( $v );
|
3574 |
-
|
3575 |
-
$output .= '<input ' . $disabled . ' type="checkbox" name="' . esc_attr( $key ) . '[]" value="' . strip_tags( $v ) . '" ';
|
3576 |
-
|
3577 |
-
if ( $this->is_selected( $key, $v, $data ) ) {
|
3578 |
-
$output .= 'checked';
|
3579 |
-
}
|
3580 |
-
|
3581 |
-
$output .= ' />';
|
3582 |
-
|
3583 |
-
if ( ! empty( $disabled ) && $this->is_selected( $key, $v, $data ) ) {
|
3584 |
-
$output .= $this->disabled_hidden_field( $key . '[]', strip_tags( $v ) );
|
3585 |
-
}
|
3586 |
-
|
3587 |
-
|
3588 |
-
$output .= '<span class="um-field-checkbox-state"><i class="' . esc_attr( $class ) . '"></i></span>';
|
3589 |
-
/**
|
3590 |
-
* UM hook
|
3591 |
-
*
|
3592 |
-
* @type filter
|
3593 |
-
* @title um_field_checkbox_item_title
|
3594 |
-
* @description Change Checkbox item title
|
3595 |
-
* @input_vars
|
3596 |
-
* [{"var":"$checkbox_item_title","type":"array","desc":"Item Title"},
|
3597 |
-
* {"var":"$key","type":"string","desc":"Field Key"},
|
3598 |
-
* {"var":"$value","type":"string","desc":"Field Value"},
|
3599 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3600 |
-
* @change_log
|
3601 |
-
* ["Since: 2.0"]
|
3602 |
-
* @usage add_filter( 'um_field_checkbox_item_title', 'function_name', 10, 4 );
|
3603 |
-
* @example
|
3604 |
-
* <?php
|
3605 |
-
* add_filter( 'um_field_checkbox_item_title', 'my_checkbox_item_title', 10, 4 );
|
3606 |
-
* function my_checkbox_item_title( $checkbox_item_title, $key, $value, $data ) {
|
3607 |
-
* // your code here
|
3608 |
-
* return $checkbox_item_title;
|
3609 |
-
* }
|
3610 |
-
* ?>
|
3611 |
-
*/
|
3612 |
-
$um_field_checkbox_item_title = apply_filters( 'um_field_checkbox_item_title', $um_field_checkbox_item_title, $key, $v, $data );
|
3613 |
-
$output .= '<span class="um-field-checkbox-option">' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</span>';
|
3614 |
-
$output .= '</label>';
|
3615 |
-
|
3616 |
-
if ( $i % 2 == 0 ) {
|
3617 |
-
$output .= '<div class="um-clear"></div>';
|
3618 |
-
}
|
3619 |
-
|
3620 |
-
}
|
3621 |
-
|
3622 |
-
$output .= '<div class="um-clear"></div>';
|
3623 |
-
|
3624 |
-
$output .= '</div>';
|
3625 |
-
|
3626 |
-
|
3627 |
-
if ( $this->is_error( $key ) ) {
|
3628 |
-
$output .= $this->field_error( $this->show_error( $key ) );
|
3629 |
-
}else if ( $this->is_notice( $key ) ) {
|
3630 |
-
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3631 |
-
}
|
3632 |
-
|
3633 |
-
$output .= '</div>';
|
3634 |
-
break;
|
3635 |
-
|
3636 |
-
/* HTML */
|
3637 |
-
case 'block':
|
3638 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
3639 |
-
break;
|
3640 |
-
|
3641 |
-
/* Shortcode */
|
3642 |
-
case 'shortcode':
|
3643 |
-
|
3644 |
-
$content = str_replace( '{profile_id}', um_profile_id(), $content );
|
3645 |
-
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
|
3646 |
-
$content = do_shortcode( $content );
|
3647 |
-
} else {
|
3648 |
-
$content = apply_shortcodes( $content );
|
3649 |
-
}
|
3650 |
-
|
3651 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
3652 |
-
break;
|
3653 |
-
|
3654 |
-
/* Unlimited Group */
|
3655 |
-
case 'group':
|
3656 |
-
|
3657 |
-
$fields = $this->get_fields_in_group( $key );
|
3658 |
-
if ( ! empty( $fields ) ) {
|
3659 |
-
|
3660 |
-
$output .= '<div class="um-field-group" data-max_entries="' . $max_entries . '">
|
3661 |
-
<div class="um-field-group-head"><i class="um-icon-plus"></i>' . esc_html__( $label, 'ultimate-member' ) . '</div>';
|
3662 |
-
$output .= '<div class="um-field-group-body"><a href="javascript:void(0);" class="um-field-group-cancel"><i class="um-icon-close"></i></a>';
|
3663 |
-
|
3664 |
-
foreach ( $fields as $subkey => $subdata ) {
|
3665 |
-
$output .= $this->edit_field( $subkey, $subdata, 'group' );
|
3666 |
-
}
|
3667 |
-
|
3668 |
-
$output .= '</div>';
|
3669 |
-
$output .= '</div>';
|
3670 |
-
|
3671 |
-
}
|
3672 |
-
|
3673 |
-
break;
|
3674 |
-
|
3675 |
-
}
|
3676 |
-
|
3677 |
-
// Custom filter for field output
|
3678 |
-
if ( isset( $this->set_mode ) ) {
|
3679 |
-
/**
|
3680 |
-
* UM hook
|
3681 |
-
*
|
3682 |
-
* @type filter
|
3683 |
-
* @title um_{$key}_form_edit_field
|
3684 |
-
* @description Change field HTML on edit mode by field $key
|
3685 |
-
* @input_vars
|
3686 |
-
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
3687 |
-
* {"var":"$mode","type":"string","desc":"Fields Mode"}]
|
3688 |
-
* @change_log
|
3689 |
-
* ["Since: 2.0"]
|
3690 |
-
* @usage add_filter( 'um_{$key}_form_edit_field', 'function_name', 10, 2 );
|
3691 |
-
* @example
|
3692 |
-
* <?php
|
3693 |
-
* add_filter( 'um_{$key}_form_edit_field', 'my_form_edit_field', 10, 2 );
|
3694 |
-
* function my_form_edit_field( $output, $mode ) {
|
3695 |
-
* // your code here
|
3696 |
-
* return $output;
|
3697 |
-
* }
|
3698 |
-
* ?>
|
3699 |
-
*/
|
3700 |
-
$output = apply_filters( "um_{$key}_form_edit_field", $output, $this->set_mode );
|
3701 |
-
}
|
3702 |
-
|
3703 |
-
return $output;
|
3704 |
-
}
|
3705 |
-
|
3706 |
-
|
3707 |
-
/**
|
3708 |
-
* Filter for user roles
|
3709 |
-
*
|
3710 |
-
* @param $form_key
|
3711 |
-
* @param array $options
|
3712 |
-
* @return array
|
3713 |
-
*/
|
3714 |
-
function get_available_roles( $form_key, $options = array() ) {
|
3715 |
-
if ( $form_key != 'role' ) {
|
3716 |
-
return $options;
|
3717 |
-
}
|
3718 |
-
|
3719 |
-
// role field
|
3720 |
-
global $wp_roles;
|
3721 |
-
$role_keys = array_map( function( $item ) {
|
3722 |
-
return 'um_' . $item;
|
3723 |
-
}, get_option( 'um_roles', array() ) );
|
3724 |
-
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
3725 |
-
|
3726 |
-
$roles = UM()->roles()->get_roles( false, $exclude_roles );
|
3727 |
-
|
3728 |
-
if ( ! empty( $options ) ) {
|
3729 |
-
|
3730 |
-
$roles = array_map( function( $item ) {
|
3731 |
-
return html_entity_decode( $item, ENT_QUOTES );
|
3732 |
-
}, $roles );
|
3733 |
-
|
3734 |
-
//fix when customers change options for role (radio/dropdown) fields
|
3735 |
-
$intersected_options = array();
|
3736 |
-
foreach ( $options as $key => $title ) {
|
3737 |
-
if ( false !== $search_key = array_search( $title, $roles ) ) {
|
3738 |
-
$intersected_options[ $search_key ] = $title;
|
3739 |
-
} elseif ( isset( $roles[ $key ] ) ) {
|
3740 |
-
$intersected_options[ $key ] = $title;
|
3741 |
-
}
|
3742 |
-
}
|
3743 |
-
|
3744 |
-
$options = $intersected_options;
|
3745 |
-
} else {
|
3746 |
-
$options = $roles;
|
3747 |
-
}
|
3748 |
-
|
3749 |
-
return $options;
|
3750 |
-
}
|
3751 |
-
|
3752 |
-
|
3753 |
-
/**
|
3754 |
-
* Sorts columns array
|
3755 |
-
*
|
3756 |
-
* @param array $arr
|
3757 |
-
* @param string $col
|
3758 |
-
* @param string $dir
|
3759 |
-
*
|
3760 |
-
* @return array $arr
|
3761 |
-
*/
|
3762 |
-
function array_sort_by_column( $arr, $col, $dir = SORT_ASC ) {
|
3763 |
-
$sort_col = array();
|
3764 |
-
foreach ( $arr as $key => $row ) {
|
3765 |
-
if ( $key == 'form_id' ) {
|
3766 |
-
unset( $arr['form_id'] );
|
3767 |
-
continue;
|
3768 |
-
}
|
3769 |
-
|
3770 |
-
if ( isset( $row[ $col ] ) ) {
|
3771 |
-
$sort_col[ $key ] = $row[ $col ];
|
3772 |
-
} else {
|
3773 |
-
unset( $arr[ $key ] );
|
3774 |
-
}
|
3775 |
-
}
|
3776 |
-
|
3777 |
-
array_multisort( $sort_col, $dir, $arr );
|
3778 |
-
|
3779 |
-
return $arr;
|
3780 |
-
}
|
3781 |
-
|
3782 |
-
|
3783 |
-
/**
|
3784 |
-
* Get fields in row
|
3785 |
-
*
|
3786 |
-
* @param int $row_id
|
3787 |
-
*
|
3788 |
-
* @return string
|
3789 |
-
*/
|
3790 |
-
function get_fields_by_row( $row_id ) {
|
3791 |
-
if ( ! isset( $this->get_fields ) ) {
|
3792 |
-
return '';
|
3793 |
-
}
|
3794 |
-
|
3795 |
-
foreach ( $this->get_fields as $key => $array ) {
|
3796 |
-
if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
|
3797 |
-
$results[ $key ] = $array;
|
3798 |
-
}
|
3799 |
-
}
|
3800 |
-
|
3801 |
-
return ( isset ( $results ) ) ? $results : '';
|
3802 |
-
}
|
3803 |
-
|
3804 |
-
|
3805 |
-
/**
|
3806 |
-
* Get fields by sub row
|
3807 |
-
*
|
3808 |
-
* @param string $row_fields
|
3809 |
-
* @param integer $subrow_id
|
3810 |
-
*
|
3811 |
-
* @return mixed
|
3812 |
-
*/
|
3813 |
-
function get_fields_in_subrow( $row_fields, $subrow_id ) {
|
3814 |
-
if ( ! is_array( $row_fields ) ) {
|
3815 |
-
return '';
|
3816 |
-
}
|
3817 |
-
foreach ( $row_fields as $key => $array ) {
|
3818 |
-
if ( ! isset( $array['in_sub_row'] ) || ( isset( $array['in_sub_row'] ) && $array['in_sub_row'] == $subrow_id ) ) {
|
3819 |
-
$results[ $key ] = $array;
|
3820 |
-
}
|
3821 |
-
}
|
3822 |
-
|
3823 |
-
return ( isset ( $results ) ) ? $results : '';
|
3824 |
-
}
|
3825 |
-
|
3826 |
-
|
3827 |
-
/**
|
3828 |
-
* Get fields in group
|
3829 |
-
*
|
3830 |
-
* @param integer $group_id
|
3831 |
-
*
|
3832 |
-
* @return mixed
|
3833 |
-
*/
|
3834 |
-
function get_fields_in_group( $group_id ) {
|
3835 |
-
foreach ( $this->get_fields as $key => $array ) {
|
3836 |
-
if ( isset( $array['in_group'] ) && $array['in_group'] == $group_id ) {
|
3837 |
-
$results[ $key ] = $array;
|
3838 |
-
}
|
3839 |
-
}
|
3840 |
-
|
3841 |
-
return ( isset ( $results ) ) ? $results : '';
|
3842 |
-
}
|
3843 |
-
|
3844 |
-
|
3845 |
-
/**
|
3846 |
-
* Get fields in column
|
3847 |
-
*
|
3848 |
-
* @param array $fields
|
3849 |
-
* @param integer $col_number
|
3850 |
-
*
|
3851 |
-
* @return mixed
|
3852 |
-
*/
|
3853 |
-
function get_fields_in_column( $fields, $col_number ) {
|
3854 |
-
foreach ( $fields as $key => $array ) {
|
3855 |
-
if ( isset( $array['in_column'] ) && $array['in_column'] == $col_number ) {
|
3856 |
-
$results[ $key ] = $array;
|
3857 |
-
}
|
3858 |
-
}
|
3859 |
-
|
3860 |
-
return ( isset ( $results ) ) ? $results : '';
|
3861 |
-
}
|
3862 |
-
|
3863 |
-
|
3864 |
-
/**
|
3865 |
-
* Display fields
|
3866 |
-
*
|
3867 |
-
* @param string $mode
|
3868 |
-
* @param array $args
|
3869 |
-
*
|
3870 |
-
* @return string|null
|
3871 |
-
* @throws \Exception
|
3872 |
-
*/
|
3873 |
-
function display( $mode, $args ) {
|
3874 |
-
$output = null;
|
3875 |
-
|
3876 |
-
$this->global_args = $args;
|
3877 |
-
|
3878 |
-
UM()->form()->form_suffix = '-' . $this->global_args['form_id'];
|
3879 |
-
|
3880 |
-
$this->set_mode = $mode;
|
3881 |
-
$this->set_id = $this->global_args['form_id'];
|
3882 |
-
|
3883 |
-
$this->field_icons = ( isset( $this->global_args['icons'] ) ) ? $this->global_args['icons'] : 'label';
|
3884 |
-
|
3885 |
-
// start output here
|
3886 |
-
$this->get_fields = $this->get_fields();
|
3887 |
-
|
3888 |
-
if ( ! empty( $this->get_fields ) ) {
|
3889 |
-
|
3890 |
-
// find rows
|
3891 |
-
foreach ( $this->get_fields as $key => $array ) {
|
3892 |
-
if ( $array['type'] == 'row' ) {
|
3893 |
-
$this->rows[ $key ] = $array;
|
3894 |
-
unset( $this->get_fields[ $key ] ); // not needed anymore
|
3895 |
-
}
|
3896 |
-
}
|
3897 |
-
|
3898 |
-
// rows fallback
|
3899 |
-
if ( ! isset( $this->rows ) ) {
|
3900 |
-
$this->rows = array(
|
3901 |
-
'_um_row_1' => array(
|
3902 |
-
'type' => 'row',
|
3903 |
-
'id' => '_um_row_1',
|
3904 |
-
'sub_rows' => 1,
|
3905 |
-
'cols' => 1,
|
3906 |
-
),
|
3907 |
-
);
|
3908 |
-
}
|
3909 |
-
|
3910 |
-
// master rows
|
3911 |
-
foreach ( $this->rows as $row_id => $row_array ) {
|
3912 |
-
|
3913 |
-
$row_fields = $this->get_fields_by_row( $row_id );
|
3914 |
-
if ( $row_fields ) {
|
3915 |
-
|
3916 |
-
$output .= $this->new_row_output( $row_id, $row_array );
|
3917 |
-
|
3918 |
-
$sub_rows = ( isset( $row_array['sub_rows'] ) ) ? $row_array['sub_rows'] : 1;
|
3919 |
-
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
3920 |
-
|
3921 |
-
// cols
|
3922 |
-
$cols = isset( $row_array['cols'] ) ? $row_array['cols'] : 1;
|
3923 |
-
if ( is_numeric( $cols ) ) {
|
3924 |
-
$cols_num = (int) $cols;
|
3925 |
-
} else {
|
3926 |
-
if ( strstr( $cols, ':' ) ) {
|
3927 |
-
$col_split = explode( ':', $cols );
|
3928 |
-
} else {
|
3929 |
-
$col_split = array( $cols );
|
3930 |
-
}
|
3931 |
-
$cols_num = $col_split[ $c ];
|
3932 |
-
}
|
3933 |
-
|
3934 |
-
// sub row fields
|
3935 |
-
$subrow_fields = null;
|
3936 |
-
$subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
|
3937 |
-
|
3938 |
-
if ( is_array( $subrow_fields ) ) {
|
3939 |
-
|
3940 |
-
$subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position' );
|
3941 |
-
|
3942 |
-
if ( $cols_num == 1 ) {
|
3943 |
-
|
3944 |
-
$output .= '<div class="um-col-1">';
|
3945 |
-
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
3946 |
-
if ( $col1_fields ) {
|
3947 |
-
foreach ( $col1_fields as $key => $data ) {
|
3948 |
-
$output .= $this->edit_field( $key, $data );
|
3949 |
-
}
|
3950 |
-
}
|
3951 |
-
$output .= '</div>';
|
3952 |
-
|
3953 |
-
} else if ($cols_num == 2) {
|
3954 |
-
|
3955 |
-
$output .= '<div class="um-col-121">';
|
3956 |
-
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
3957 |
-
if ( $col1_fields ) {
|
3958 |
-
foreach ( $col1_fields as $key => $data ) {
|
3959 |
-
$output .= $this->edit_field( $key, $data );
|
3960 |
-
}
|
3961 |
-
}
|
3962 |
-
$output .= '</div>';
|
3963 |
-
|
3964 |
-
$output .= '<div class="um-col-122">';
|
3965 |
-
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
3966 |
-
if ( $col2_fields ) {
|
3967 |
-
foreach ( $col2_fields as $key => $data ) {
|
3968 |
-
$output .= $this->edit_field( $key, $data );
|
3969 |
-
}
|
3970 |
-
}
|
3971 |
-
$output .= '</div><div class="um-clear"></div>';
|
3972 |
-
|
3973 |
-
} else {
|
3974 |
-
|
3975 |
-
$output .= '<div class="um-col-131">';
|
3976 |
-
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
3977 |
-
if ( $col1_fields ) {
|
3978 |
-
foreach ( $col1_fields as $key => $data ) {
|
3979 |
-
$output .= $this->edit_field( $key, $data );
|
3980 |
-
}
|
3981 |
-
}
|
3982 |
-
$output .= '</div>';
|
3983 |
-
|
3984 |
-
$output .= '<div class="um-col-132">';
|
3985 |
-
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
3986 |
-
if ( $col2_fields ) {
|
3987 |
-
foreach ( $col2_fields as $key => $data ) {
|
3988 |
-
$output .= $this->edit_field( $key, $data );
|
3989 |
-
}
|
3990 |
-
}
|
3991 |
-
$output .= '</div>';
|
3992 |
-
|
3993 |
-
$output .= '<div class="um-col-133">';
|
3994 |
-
$col3_fields = $this->get_fields_in_column( $subrow_fields, 3 );
|
3995 |
-
if ( $col3_fields ) {
|
3996 |
-
foreach ( $col3_fields as $key => $data ) {
|
3997 |
-
$output .= $this->edit_field( $key, $data );
|
3998 |
-
}
|
3999 |
-
}
|
4000 |
-
$output .= '</div><div class="um-clear"></div>';
|
4001 |
-
|
4002 |
-
}
|
4003 |
-
|
4004 |
-
}
|
4005 |
-
|
4006 |
-
}
|
4007 |
-
|
4008 |
-
$output .= '</div>';
|
4009 |
-
|
4010 |
-
}
|
4011 |
-
|
4012 |
-
}
|
4013 |
-
|
4014 |
-
}
|
4015 |
-
|
4016 |
-
return $output;
|
4017 |
-
}
|
4018 |
-
|
4019 |
-
|
4020 |
-
/**
|
4021 |
-
* Gets a field in `view mode`
|
4022 |
-
*
|
4023 |
-
* @param string $key
|
4024 |
-
* @param array $data
|
4025 |
-
* @param bool $rule
|
4026 |
-
*
|
4027 |
-
* @return string|null
|
4028 |
-
* @throws \Exception
|
4029 |
-
*/
|
4030 |
-
function view_field( $key, $data, $rule = false ) {
|
4031 |
-
$output = '';
|
4032 |
-
|
4033 |
-
// get whole field data
|
4034 |
-
if ( is_array( $data ) ) {
|
4035 |
-
$data = $this->get_field( $key );
|
4036 |
-
|
4037 |
-
if ( is_array( $data ) ) {
|
4038 |
-
/**
|
4039 |
-
* @var $visibility
|
4040 |
-
* @var $type
|
4041 |
-
* @var $default
|
4042 |
-
* @var $classes
|
4043 |
-
* @var $conditional
|
4044 |
-
* @var $content
|
4045 |
-
* @var $divider_text
|
4046 |
-
* @var $spacing
|
4047 |
-
* @var $borderwidth
|
4048 |
-
* @var $borderstyle
|
4049 |
-
* @var $bordercolor
|
4050 |
-
* @var $label
|
4051 |
-
*/
|
4052 |
-
extract( $data );
|
4053 |
-
}
|
4054 |
-
}
|
4055 |
-
|
4056 |
-
//hide if empty type
|
4057 |
-
if ( ! isset( $data['type'] ) ) {
|
4058 |
-
return '';
|
4059 |
-
}
|
4060 |
-
|
4061 |
-
if ( isset( $data['in_group'] ) && $data['in_group'] != '' && $rule != 'group' ) {
|
4062 |
-
return '';
|
4063 |
-
}
|
4064 |
-
|
4065 |
-
//invisible on profile page
|
4066 |
-
if ( $visibility == 'edit' || $type == 'password' ) {
|
4067 |
-
return '';
|
4068 |
-
}
|
4069 |
-
|
4070 |
-
//hide if empty
|
4071 |
-
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
4072 |
-
if ( ! in_array( $type, $fields_without_metakey ) ) {
|
4073 |
-
$_field_value = $this->field_value( $key, $default, $data );
|
4074 |
-
|
4075 |
-
if ( ! isset( $_field_value ) || $_field_value == '' ) {
|
4076 |
-
return '';
|
4077 |
-
}
|
4078 |
-
}
|
4079 |
-
|
4080 |
-
if ( ! um_can_view_field( $data ) ) {
|
4081 |
-
return '';
|
4082 |
-
}
|
4083 |
-
|
4084 |
-
// disable these fields in profile view only
|
4085 |
-
if ( in_array( $key, array( 'user_password' ) ) && $this->set_mode == 'profile' ) {
|
4086 |
-
return '';
|
4087 |
-
}
|
4088 |
-
|
4089 |
-
if ( ! um_field_conditions_are_met( $data ) ) {
|
4090 |
-
return '';
|
4091 |
-
}
|
4092 |
-
|
4093 |
-
|
4094 |
-
if ( isset( $data['classes'] ) ) {
|
4095 |
-
$classes = explode( " ", $data['classes'] );
|
4096 |
-
}
|
4097 |
-
|
4098 |
-
switch ( $type ) {
|
4099 |
-
|
4100 |
-
/* Default */
|
4101 |
-
default:
|
4102 |
-
|
4103 |
-
$_field_value = $this->field_value( $key, $default, $data );
|
4104 |
-
|
4105 |
-
if ( ! in_array( $type, $fields_without_metakey ) && ( ! isset( $_field_value ) || $_field_value == '' ) ) {
|
4106 |
-
$output = '';
|
4107 |
-
} else {
|
4108 |
-
|
4109 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
4110 |
-
|
4111 |
-
if ( isset( $data['label'] ) || ! empty( $data['icon'] ) ) {
|
4112 |
-
|
4113 |
-
if ( ! isset( $data['label'] ) ) {
|
4114 |
-
$data['label'] = '';
|
4115 |
-
}
|
4116 |
-
|
4117 |
-
$output .= $this->field_label( $data['label'], $key, $data );
|
4118 |
-
}
|
4119 |
-
|
4120 |
-
$res = $this->field_value( $key, $default, $data );
|
4121 |
-
|
4122 |
-
if ( ! empty( $res ) ) {
|
4123 |
-
$res = stripslashes( $res );
|
4124 |
-
}
|
4125 |
-
|
4126 |
-
$data['is_view_field'] = true;
|
4127 |
-
/**
|
4128 |
-
* UM hook
|
4129 |
-
*
|
4130 |
-
* @type filter
|
4131 |
-
* @title um_view_field
|
4132 |
-
* @description Change field HTML on view mode
|
4133 |
-
* @input_vars
|
4134 |
-
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4135 |
-
* {"var":"$data","type":"string","desc":"Field Data"},
|
4136 |
-
* {"var":"$type","type":"string","desc":"Field Type"}]
|
4137 |
-
* @change_log
|
4138 |
-
* ["Since: 2.0"]
|
4139 |
-
* @usage add_filter( 'um_view_field', 'function_name', 10, 3 );
|
4140 |
-
* @example
|
4141 |
-
* <?php
|
4142 |
-
* add_filter( 'um_view_field', 'my_view_field', 10, 3 );
|
4143 |
-
* function my_form_edit_field( $output, $data, $type ) {
|
4144 |
-
* // your code here
|
4145 |
-
* return $output;
|
4146 |
-
* }
|
4147 |
-
* ?>
|
4148 |
-
*/
|
4149 |
-
$res = apply_filters( 'um_view_field', $res, $data, $type );
|
4150 |
-
/**
|
4151 |
-
* UM hook
|
4152 |
-
*
|
4153 |
-
* @type filter
|
4154 |
-
* @title um_view_field_value_{$type}
|
4155 |
-
* @description Change field HTML on view mode by field type
|
4156 |
-
* @input_vars
|
4157 |
-
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4158 |
-
* {"var":"$data","type":"string","desc":"Field Data"}]
|
4159 |
-
* @change_log
|
4160 |
-
* ["Since: 2.0"]
|
4161 |
-
* @usage add_filter( 'um_view_field_value_{$type}', 'function_name', 10, 2 );
|
4162 |
-
* @example
|
4163 |
-
* <?php
|
4164 |
-
* add_filter( 'um_view_field_value_{$type}', 'my_view_field', 10, 2 );
|
4165 |
-
* function my_form_edit_field( $output, $data ) {
|
4166 |
-
* // your code here
|
4167 |
-
* return $output;
|
4168 |
-
* }
|
4169 |
-
* ?>
|
4170 |
-
*/
|
4171 |
-
$res = apply_filters( "um_view_field_value_{$type}", $res, $data );
|
4172 |
-
|
4173 |
-
$id_attr = '';
|
4174 |
-
if ( ! in_array( $type, $fields_without_metakey ) ) {
|
4175 |
-
$id_attr = ' id="' . esc_attr( $key . UM()->form()->form_suffix ) . '"';
|
4176 |
-
}
|
4177 |
-
|
4178 |
-
if ( empty( $res ) ) {
|
4179 |
-
$output = '';
|
4180 |
-
} else {
|
4181 |
-
$output .= '<div class="um-field-area">';
|
4182 |
-
$output .= '<div class="um-field-value"' . $id_attr . '>' . $res . '</div>';
|
4183 |
-
$output .= '</div>';
|
4184 |
-
|
4185 |
-
$output .= '</div>';
|
4186 |
-
}
|
4187 |
-
}
|
4188 |
-
|
4189 |
-
break;
|
4190 |
-
|
4191 |
-
/* HTML */
|
4192 |
-
case 'block':
|
4193 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
4194 |
-
break;
|
4195 |
-
|
4196 |
-
/* Shortcode */
|
4197 |
-
case 'shortcode':
|
4198 |
-
|
4199 |
-
$content = str_replace( '{profile_id}', um_profile_id(), $content );
|
4200 |
-
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
|
4201 |
-
$content = do_shortcode( $content );
|
4202 |
-
} else {
|
4203 |
-
$content = apply_shortcodes( $content );
|
4204 |
-
}
|
4205 |
-
|
4206 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
4207 |
-
break;
|
4208 |
-
|
4209 |
-
/* Gap/Space */
|
4210 |
-
case 'spacing':
|
4211 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'height' => $spacing ) ) . '></div>';
|
4212 |
-
break;
|
4213 |
-
|
4214 |
-
/* A line divider */
|
4215 |
-
case 'divider':
|
4216 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'border-bottom' => $borderwidth . 'px ' . $borderstyle . ' ' . $bordercolor ) ) . '>';
|
4217 |
-
if ( $divider_text ) {
|
4218 |
-
$output .= '<div class="um-field-divider-text"><span>' . $divider_text . '</span></div>';
|
4219 |
-
}
|
4220 |
-
$output .= '</div>';
|
4221 |
-
break;
|
4222 |
-
|
4223 |
-
/* Rating */
|
4224 |
-
case 'rating':
|
4225 |
-
|
4226 |
-
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
4227 |
-
|
4228 |
-
if ( isset( $data['label'] ) || ! empty( $data['icon'] ) ) {
|
4229 |
-
$output .= $this->field_label( $label, $key, $data );
|
4230 |
-
}
|
4231 |
-
|
4232 |
-
ob_start(); ?>
|
4233 |
-
|
4234 |
-
<div class="um-field-area">
|
4235 |
-
<div class="um-field-value">
|
4236 |
-
<div class="um-rating-readonly um-raty" id="<?php echo esc_attr( $key ) ?>"
|
4237 |
-
data-key="<?php echo esc_attr( $key ) ?>" data-number="<?php echo esc_attr( $data['number'] ) ?>"
|
4238 |
-
data-score="<?php echo $this->field_value( $key, $default, $data ) ?>"></div>
|
4239 |
-
</div>
|
4240 |
-
</div>
|
4241 |
-
|
4242 |
-
<?php $output .= ob_get_clean();
|
4243 |
-
$output .= '</div>';
|
4244 |
-
|
4245 |
-
break;
|
4246 |
-
|
4247 |
-
}
|
4248 |
-
|
4249 |
-
// Custom filter for field output
|
4250 |
-
if ( isset( $this->set_mode ) ) {
|
4251 |
-
/**
|
4252 |
-
* UM hook
|
4253 |
-
*
|
4254 |
-
* @type filter
|
4255 |
-
* @title um_{$key}_form_show_field
|
4256 |
-
* @description Change field HTML by field $key
|
4257 |
-
* @input_vars
|
4258 |
-
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4259 |
-
* {"var":"$mode","type":"string","desc":"Form Mode"}]
|
4260 |
-
* @change_log
|
4261 |
-
* ["Since: 2.0"]
|
4262 |
-
* @usage add_filter( 'um_{$key}_form_show_field', 'function_name', 10, 2 );
|
4263 |
-
* @example
|
4264 |
-
* <?php
|
4265 |
-
* add_filter( 'um_{$key}_form_show_field', 'my_form_show_field', 10, 2 );
|
4266 |
-
* function my_form_show_field( $output, $mode ) {
|
4267 |
-
* // your code here
|
4268 |
-
* return $output;
|
4269 |
-
* }
|
4270 |
-
* ?>
|
4271 |
-
*/
|
4272 |
-
$output = apply_filters( "um_{$key}_form_show_field", $output, $this->set_mode );
|
4273 |
-
/**
|
4274 |
-
* UM hook
|
4275 |
-
*
|
4276 |
-
* @type filter
|
4277 |
-
* @title um_{$type}_form_show_field
|
4278 |
-
* @description Change field HTML by field $type
|
4279 |
-
* @input_vars
|
4280 |
-
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4281 |
-
* {"var":"$mode","type":"string","desc":"Form Mode"}]
|
4282 |
-
* @change_log
|
4283 |
-
* ["Since: 2.0"]
|
4284 |
-
* @usage add_filter( 'um_{$type}_form_show_field', 'function_name', 10, 2 );
|
4285 |
-
* @example
|
4286 |
-
* <?php
|
4287 |
-
* add_filter( 'um_{$type}_form_show_field', 'my_form_show_field', 10, 2 );
|
4288 |
-
* function my_form_show_field( $output, $mode ) {
|
4289 |
-
* // your code here
|
4290 |
-
* return $output;
|
4291 |
-
* }
|
4292 |
-
* ?>
|
4293 |
-
*/
|
4294 |
-
$output = apply_filters( "um_{$type}_form_show_field", $output, $this->set_mode );
|
4295 |
-
}
|
4296 |
-
|
4297 |
-
return $output;
|
4298 |
-
}
|
4299 |
-
|
4300 |
-
|
4301 |
-
/**
|
4302 |
-
* Filter field data
|
4303 |
-
*
|
4304 |
-
* @param array $data
|
4305 |
-
*
|
4306 |
-
* @return array
|
4307 |
-
*/
|
4308 |
-
function view_field_output( $data ) {
|
4309 |
-
/**
|
4310 |
-
* UM hook
|
4311 |
-
*
|
4312 |
-
* @type filter
|
4313 |
-
* @title um_view_field_output_{$type}
|
4314 |
-
* @description Change field data output by $type
|
4315 |
-
* @input_vars
|
4316 |
-
* [{"var":"$data","type":"array","desc":"Field Data"}]
|
4317 |
-
* @change_log
|
4318 |
-
* ["Since: 2.0"]
|
4319 |
-
* @usage add_filter( 'um_view_field_output_{$type}', 'function_name', 10, 1 );
|
4320 |
-
* @example
|
4321 |
-
* <?php
|
4322 |
-
* add_filter( 'um_view_field_output_{$type}', 'my_view_field_output', 10, 1 );
|
4323 |
-
* function my_view_field_output( $data ) {
|
4324 |
-
* // your code here
|
4325 |
-
* return $data;
|
4326 |
-
* }
|
4327 |
-
* ?>
|
4328 |
-
*/
|
4329 |
-
return apply_filters( "um_view_field_output_" . $data['type'], $data );
|
4330 |
-
}
|
4331 |
-
|
4332 |
-
|
4333 |
-
/**
|
4334 |
-
* Display fields ( view mode )
|
4335 |
-
*
|
4336 |
-
* @param string $mode
|
4337 |
-
* @param array $args
|
4338 |
-
*
|
4339 |
-
* @return string|null
|
4340 |
-
* @throws \Exception
|
4341 |
-
*/
|
4342 |
-
function display_view( $mode, $args ) {
|
4343 |
-
$output = null;
|
4344 |
-
|
4345 |
-
$this->global_args = $args;
|
4346 |
-
|
4347 |
-
UM()->form()->form_suffix = '-' . $this->global_args['form_id'];
|
4348 |
-
|
4349 |
-
$this->set_mode = $mode;
|
4350 |
-
$this->set_id = $this->global_args['form_id'];
|
4351 |
-
|
4352 |
-
$this->field_icons = ( isset( $this->global_args['icons'] ) ) ? $this->global_args['icons'] : 'label';
|
4353 |
-
|
4354 |
-
// start output here
|
4355 |
-
$this->get_fields = $this->get_fields();
|
4356 |
-
|
4357 |
-
if ( UM()->options()->get( 'profile_empty_text' ) ) {
|
4358 |
-
|
4359 |
-
$emo = UM()->options()->get( 'profile_empty_text_emo' );
|
4360 |
-
if ( $emo ) {
|
4361 |
-
$emo = '<i class="um-faicon-frown-o"></i>';
|
4362 |
-
} else {
|
4363 |
-
$emo = false;
|
4364 |
-
}
|
4365 |
-
|
4366 |
-
if ( um_is_myprofile() ) {
|
4367 |
-
$output .= '<p class="um-profile-note">' . $emo . '<span>' . sprintf( __( 'Your profile is looking a little empty. Why not <a href="%s">add</a> some information!', 'ultimate-member' ), esc_url( um_edit_profile_url() ) ) . '</span></p>';
|
4368 |
-
} else {
|
4369 |
-
$output .= '<p class="um-profile-note">' . $emo . '<span>' . __( 'This user has not added any information to their profile yet.', 'ultimate-member' ) . '</span></p>';
|
4370 |
-
}
|
4371 |
-
}
|
4372 |
-
|
4373 |
-
if ( ! empty( $this->get_fields ) ) {
|
4374 |
-
|
4375 |
-
// find rows
|
4376 |
-
foreach ( $this->get_fields as $key => $array ) {
|
4377 |
-
if ( $array['type'] == 'row' ) {
|
4378 |
-
$this->rows[ $key ] = $array;
|
4379 |
-
unset( $this->get_fields[ $key ] ); // not needed anymore
|
4380 |
-
}
|
4381 |
-
}
|
4382 |
-
|
4383 |
-
// rows fallback
|
4384 |
-
if ( ! isset( $this->rows ) ) {
|
4385 |
-
$this->rows = array(
|
4386 |
-
'_um_row_1' => array(
|
4387 |
-
'type' => 'row',
|
4388 |
-
'id' => '_um_row_1',
|
4389 |
-
'sub_rows' => 1,
|
4390 |
-
'cols' => 1,
|
4391 |
-
),
|
4392 |
-
);
|
4393 |
-
}
|
4394 |
-
|
4395 |
-
// master rows
|
4396 |
-
foreach ( $this->rows as $row_id => $row_array ) {
|
4397 |
-
|
4398 |
-
$row_fields = $this->get_fields_by_row( $row_id );
|
4399 |
-
|
4400 |
-
if ( $row_fields ) {
|
4401 |
-
|
4402 |
-
$output .= $this->new_row_output( $row_id, $row_array );
|
4403 |
-
|
4404 |
-
$sub_rows = ( isset( $row_array['sub_rows'] ) ) ? $row_array['sub_rows'] : 1;
|
4405 |
-
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
4406 |
-
|
4407 |
-
// cols
|
4408 |
-
$cols = isset( $row_array['cols'] ) ? $row_array['cols'] : 1;
|
4409 |
-
if ( is_numeric( $cols ) ) {
|
4410 |
-
$cols_num = (int) $cols;
|
4411 |
-
} else {
|
4412 |
-
if ( strstr( $cols, ':' ) ) {
|
4413 |
-
$col_split = explode( ':', $cols );
|
4414 |
-
} else {
|
4415 |
-
$col_split = array( $cols );
|
4416 |
-
}
|
4417 |
-
$cols_num = $col_split[ $c ];
|
4418 |
-
}
|
4419 |
-
|
4420 |
-
// sub row fields
|
4421 |
-
$subrow_fields = null;
|
4422 |
-
$subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
|
4423 |
-
|
4424 |
-
if ( is_array( $subrow_fields ) ) {
|
4425 |
-
|
4426 |
-
$subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position' );
|
4427 |
-
|
4428 |
-
if ( $cols_num == 1 ) {
|
4429 |
-
|
4430 |
-
$output .= '<div class="um-col-1">';
|
4431 |
-
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4432 |
-
if ( $col1_fields ) {
|
4433 |
-
foreach ( $col1_fields as $key => $data ) {
|
4434 |
-
|
4435 |
-
$data = $this->view_field_output( $data );
|
4436 |
-
$output .= $this->view_field( $key, $data );
|
4437 |
-
|
4438 |
-
}
|
4439 |
-
}
|
4440 |
-
$output .= '</div>';
|
4441 |
-
|
4442 |
-
} elseif ( $cols_num == 2 ) {
|
4443 |
-
|
4444 |
-
$output .= '<div class="um-col-121">';
|
4445 |
-
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4446 |
-
if ( $col1_fields ) {
|
4447 |
-
foreach ( $col1_fields as $key => $data ) {
|
4448 |
-
|
4449 |
-
$data = $this->view_field_output( $data );
|
4450 |
-
$output .= $this->view_field( $key, $data );
|
4451 |
-
|
4452 |
-
}
|
4453 |
-
}
|
4454 |
-
$output .= '</div>';
|
4455 |
-
|
4456 |
-
$output .= '<div class="um-col-122">';
|
4457 |
-
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4458 |
-
if ( $col2_fields ) {
|
4459 |
-
foreach ( $col2_fields as $key => $data ) {
|
4460 |
-
|
4461 |
-
$data = $this->view_field_output( $data );
|
4462 |
-
$output .= $this->view_field( $key, $data );
|
4463 |
-
|
4464 |
-
}
|
4465 |
-
}
|
4466 |
-
$output .= '</div><div class="um-clear"></div>';
|
4467 |
-
|
4468 |
-
} else {
|
4469 |
-
|
4470 |
-
$output .= '<div class="um-col-131">';
|
4471 |
-
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4472 |
-
if ( $col1_fields ) {
|
4473 |
-
foreach ( $col1_fields as $key => $data ) {
|
4474 |
-
|
4475 |
-
$data = $this->view_field_output( $data );
|
4476 |
-
$output .= $this->view_field( $key, $data );
|
4477 |
-
|
4478 |
-
}
|
4479 |
-
}
|
4480 |
-
$output .= '</div>';
|
4481 |
-
|
4482 |
-
$output .= '<div class="um-col-132">';
|
4483 |
-
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4484 |
-
if ( $col2_fields ) {
|
4485 |
-
foreach ( $col2_fields as $key => $data ) {
|
4486 |
-
|
4487 |
-
$data = $this->view_field_output( $data );
|
4488 |
-
$output .= $this->view_field( $key, $data );
|
4489 |
-
|
4490 |
-
}
|
4491 |
-
}
|
4492 |
-
$output .= '</div>';
|
4493 |
-
|
4494 |
-
$output .= '<div class="um-col-133">';
|
4495 |
-
$col3_fields = $this->get_fields_in_column( $subrow_fields, 3 );
|
4496 |
-
if ( $col3_fields ) {
|
4497 |
-
foreach ( $col3_fields as $key => $data ) {
|
4498 |
-
|
4499 |
-
$data = $this->view_field_output( $data );
|
4500 |
-
$output .= $this->view_field( $key, $data );
|
4501 |
-
|
4502 |
-
}
|
4503 |
-
}
|
4504 |
-
$output .= '</div><div class="um-clear"></div>';
|
4505 |
-
|
4506 |
-
}
|
4507 |
-
|
4508 |
-
}
|
4509 |
-
|
4510 |
-
}
|
4511 |
-
|
4512 |
-
$output .= '</div>';
|
4513 |
-
|
4514 |
-
}
|
4515 |
-
|
4516 |
-
}
|
4517 |
-
|
4518 |
-
}
|
4519 |
-
|
4520 |
-
return $output;
|
4521 |
-
}
|
4522 |
-
|
4523 |
-
|
4524 |
-
/**
|
4525 |
-
* Get new row in form
|
4526 |
-
*
|
4527 |
-
* @param string $row_id
|
4528 |
-
* @param array $row_array
|
4529 |
-
*
|
4530 |
-
* @return string
|
4531 |
-
*/
|
4532 |
-
function new_row_output( $row_id, $row_array ) {
|
4533 |
-
$output = null;
|
4534 |
-
extract( $row_array );
|
4535 |
-
|
4536 |
-
$padding = ( isset( $padding ) ) ? $padding : '';
|
4537 |
-
$margin = ( isset( $margin ) ) ? $margin : '';
|
4538 |
-
$background = ( isset( $background ) ) ? $background : '';
|
4539 |
-
$text_color = ( isset( $text_color ) ) ? $text_color : '';
|
4540 |
-
$borderradius = ( isset( $borderradius ) ) ? $borderradius : '';
|
4541 |
-
$border = ( isset( $border ) ) ? $border : '';
|
4542 |
-
$bordercolor = ( isset( $bordercolor ) ) ? $bordercolor : '';
|
4543 |
-
$borderstyle = ( isset( $borderstyle ) ) ? $borderstyle : '';
|
4544 |
-
$heading = ( isset( $heading ) ) ? $heading : '';
|
4545 |
-
$css_class = ( isset( $css_class ) ) ? $css_class : '';
|
4546 |
-
|
4547 |
-
$css_padding = '';
|
4548 |
-
$css_margin = '';
|
4549 |
-
$css_background = '';
|
4550 |
-
$css_borderradius = '';
|
4551 |
-
$css_border = '';
|
4552 |
-
$css_bordercolor = '';
|
4553 |
-
$css_borderstyle = '';
|
4554 |
-
$css_heading_background_color = '';
|
4555 |
-
$css_heading_padding = '';
|
4556 |
-
$css_heading_text_color = '';
|
4557 |
-
$css_heading_borderradius = '';
|
4558 |
-
$css_text_color = '';
|
4559 |
-
|
4560 |
-
// row css rules
|
4561 |
-
if ( $padding ) {
|
4562 |
-
$css_padding = 'padding: ' . $padding . ';';
|
4563 |
-
}
|
4564 |
-
if ( $margin ) {
|
4565 |
-
$css_margin = 'margin: ' . $margin . ';';
|
4566 |
-
} else {
|
4567 |
-
$css_margin = 'margin: 0 0 30px 0;';
|
4568 |
-
}
|
4569 |
-
|
4570 |
-
if ( $background ) {
|
4571 |
-
$css_background = 'background-color: ' . $background . ';';
|
4572 |
-
}
|
4573 |
-
if ( $borderradius ) {
|
4574 |
-
$css_borderradius = 'border-radius: 0px 0px ' . $borderradius . ' ' . $borderradius . ';';
|
4575 |
-
}
|
4576 |
-
if ( $border ) {
|
4577 |
-
$css_border = 'border-width: ' . $border . ';';
|
4578 |
-
}
|
4579 |
-
if ( $bordercolor ) {
|
4580 |
-
$css_bordercolor = 'border-color: ' . $bordercolor . ';';
|
4581 |
-
}
|
4582 |
-
if ( $borderstyle ) {
|
4583 |
-
$css_borderstyle = 'border-style: ' . $borderstyle . ';';
|
4584 |
-
}
|
4585 |
-
if ( $text_color ) {
|
4586 |
-
$css_text_color = 'color: ' . $text_color . ' !important;';
|
4587 |
-
$css_class .= ' um-customized-row';
|
4588 |
-
}
|
4589 |
-
|
4590 |
-
// show the heading
|
4591 |
-
if ( $heading ) {
|
4592 |
-
|
4593 |
-
if ( ! empty( $heading_background_color ) ) {
|
4594 |
-
$css_heading_background_color = "background-color: $heading_background_color;";
|
4595 |
-
$css_heading_padding = 'padding: 10px 15px;';
|
4596 |
-
}
|
4597 |
-
|
4598 |
-
$css_heading_borderradius = empty( $borderradius ) ? '' : "border-radius: $borderradius $borderradius 0px 0px;";
|
4599 |
-
$css_heading_border = $css_border . $css_borderstyle . $css_bordercolor . $css_heading_borderradius . 'border-bottom-width: 0px;';
|
4600 |
-
$css_heading_margin = $css_margin . 'margin-bottom: 0px;';
|
4601 |
-
$css_heading_text_color = empty( $heading_text_color ) ? '' : "color: $heading_text_color;";
|
4602 |
-
$css_icon_color = empty( $icon_color ) ? '' : "color: $icon_color;";
|
4603 |
-
|
4604 |
-
$output .= '<div class="um-row-heading" style="' . $css_heading_margin . $css_heading_padding . $css_heading_border . $css_heading_background_color . $css_heading_text_color . '">';
|
4605 |
-
|
4606 |
-
if ( ! empty( $icon ) ) {
|
4607 |
-
$output .= '<span class="um-row-heading-icon" style="' . $css_icon_color . '"><i class="' . $icon . '"></i></span>';
|
4608 |
-
}
|
4609 |
-
if ( ! empty( $heading_text ) ) {
|
4610 |
-
$output .= htmlspecialchars( $heading_text );
|
4611 |
-
}
|
4612 |
-
|
4613 |
-
$output .= '</div>';
|
4614 |
-
|
4615 |
-
$css_border .= 'border-top-width: 0px;';
|
4616 |
-
$css_margin .= 'margin-top: 0px;';
|
4617 |
-
|
4618 |
-
} else {
|
4619 |
-
|
4620 |
-
// no heading
|
4621 |
-
$css_borderradius = empty( $borderradius ) ? '' : "border-radius: $borderradius;";
|
4622 |
-
|
4623 |
-
}
|
4624 |
-
|
4625 |
-
$output .= '<div class="um-row ' . $row_id . ' ' . $css_class . '" style="' . $css_padding . $css_background . $css_margin . $css_border . $css_borderstyle . $css_bordercolor . $css_borderradius . $css_text_color . '">';
|
4626 |
-
|
4627 |
-
return $output;
|
4628 |
-
}
|
4629 |
-
|
4630 |
-
|
4631 |
-
/**
|
4632 |
-
*
|
4633 |
-
*/
|
4634 |
-
function do_ajax_action() {
|
4635 |
-
UM()->admin()->check_ajax_nonce();
|
4636 |
-
|
4637 |
-
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
4638 |
-
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
4639 |
-
}
|
4640 |
-
|
4641 |
-
/**
|
4642 |
-
* @var $in_row
|
4643 |
-
* @var $in_sub_row
|
4644 |
-
* @var $in_column
|
4645 |
-
* @var $in_group
|
4646 |
-
* @var $act_id
|
4647 |
-
* @var $arg1
|
4648 |
-
* @var $arg2
|
4649 |
-
*/
|
4650 |
-
extract( $_POST );
|
4651 |
-
|
4652 |
-
$output = null;
|
4653 |
-
|
4654 |
-
$position = array();
|
4655 |
-
if ( ! empty( $in_column ) ) {
|
4656 |
-
$position['in_row'] = '_um_row_' . ( (int) $in_row + 1 );
|
4657 |
-
$position['in_sub_row'] = $in_sub_row;
|
4658 |
-
$position['in_column'] = $in_column;
|
4659 |
-
$position['in_group'] = $in_group;
|
4660 |
-
}
|
4661 |
-
|
4662 |
-
switch ( $act_id ) {
|
4663 |
-
|
4664 |
-
case 'um_admin_duplicate_field':
|
4665 |
-
$this->duplicate_field( $arg1, $arg2 );
|
4666 |
-
break;
|
4667 |
-
|
4668 |
-
case 'um_admin_remove_field_global':
|
4669 |
-
$this->delete_field_from_db( $arg1 );
|
4670 |
-
break;
|
4671 |
-
|
4672 |
-
case 'um_admin_remove_field':
|
4673 |
-
$this->delete_field_from_form( $arg1, $arg2 );
|
4674 |
-
break;
|
4675 |
-
|
4676 |
-
case 'um_admin_add_field_from_predefined':
|
4677 |
-
$this->add_field_from_predefined( $arg1, $arg2, $position );
|
4678 |
-
break;
|
4679 |
-
|
4680 |
-
case 'um_admin_add_field_from_list':
|
4681 |
-
$this->add_field_from_list( $arg1, $arg2, $position );
|
4682 |
-
break;
|
4683 |
-
|
4684 |
-
}
|
4685 |
-
|
4686 |
-
if ( is_array( $output ) ) {
|
4687 |
-
print_r( $output );
|
4688 |
-
} else {
|
4689 |
-
echo $output;
|
4690 |
-
}
|
4691 |
-
die;
|
4692 |
-
|
4693 |
-
}
|
4694 |
-
|
4695 |
-
|
4696 |
-
|
4697 |
-
/**
|
4698 |
-
* Get rendered field attributes
|
4699 |
-
*
|
4700 |
-
* @since 2.1.2
|
4701 |
-
*
|
4702 |
-
* @param string $key
|
4703 |
-
* @param array $classes
|
4704 |
-
* @param string $conditional
|
4705 |
-
* @param array $data
|
4706 |
-
* @param array $field_style
|
4707 |
-
*
|
4708 |
-
* @return string/html
|
4709 |
-
*/
|
4710 |
-
function get_atts( $key, $classes, $conditional, $data, $field_style = array() ) {
|
4711 |
-
|
4712 |
-
array_unshift( $classes, 'um-field-' . $data['type'] );
|
4713 |
-
array_unshift( $classes, 'um-field' );
|
4714 |
-
|
4715 |
-
$field_atts = array(
|
4716 |
-
'id' => array(
|
4717 |
-
"um_field_{$this->set_id}_{$key}",
|
4718 |
-
),
|
4719 |
-
'class' => $classes,
|
4720 |
-
'data-key' => array(
|
4721 |
-
esc_attr( $key )
|
4722 |
-
)
|
4723 |
-
);
|
4724 |
-
|
4725 |
-
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
4726 |
-
|
4727 |
-
if ( in_array( $data['type'], $fields_without_metakey ) ) {
|
4728 |
-
unset( $field_atts['id'] );
|
4729 |
-
|
4730 |
-
if ( empty( $field_atts['data-key'] ) ) {
|
4731 |
-
unset( $field_atts['data-key'] );
|
4732 |
-
}
|
4733 |
-
}
|
4734 |
-
|
4735 |
-
if ( ! empty( $field_style ) && is_array( $field_style ) ) {
|
4736 |
-
|
4737 |
-
$arr_inline_style = '';
|
4738 |
-
foreach ( $field_style as $style_attr => $style_value ) {
|
4739 |
-
$arr_inline_style .= esc_attr( $style_attr ) . ':' . esc_attr( $style_value ) . ';';
|
4740 |
-
}
|
4741 |
-
$field_atts['style'] = array( $arr_inline_style );
|
4742 |
-
}
|
4743 |
-
|
4744 |
-
/**
|
4745 |
-
* UM hook
|
4746 |
-
*
|
4747 |
-
* @type filter
|
4748 |
-
* @title um_field_extra_atts
|
4749 |
-
* @description user for adding extra field attributes
|
4750 |
-
* @input_vars
|
4751 |
-
* [{"var":"$field_atts","type":"array","desc":"Field attributes"},
|
4752 |
-
* [{"var":"$key","type":"string","desc":"Field id"},
|
4753 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
4754 |
-
* @change_log
|
4755 |
-
* ["Since: 2.0.57"]
|
4756 |
-
* @usage add_filter( 'um_field_extra_atts', 'function_name', 10, 3 );
|
4757 |
-
* @example
|
4758 |
-
* <?php
|
4759 |
-
* add_filter( 'um_field_extra_atts', 'function_name', 10, 3 );
|
4760 |
-
* function function_name( $field_atts, $key, $data ) {
|
4761 |
-
* // your code here
|
4762 |
-
* return $array_extra_atts;
|
4763 |
-
* }
|
4764 |
-
* ?>
|
4765 |
-
*/
|
4766 |
-
$field_atts = apply_filters( 'um_field_extra_atts', $field_atts, $key, $data );
|
4767 |
-
|
4768 |
-
$html_atts = '';
|
4769 |
-
foreach ( $field_atts as $att_name => $att_values ) {
|
4770 |
-
$att_values = implode( " ", $att_values );
|
4771 |
-
$html_atts .= " {$att_name}=\"" . esc_attr( $att_values ) . "\"";
|
4772 |
-
}
|
4773 |
-
|
4774 |
-
$html_atts .= $conditional;
|
4775 |
-
|
4776 |
-
return $html_atts;
|
4777 |
-
}
|
4778 |
-
}
|
4779 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\core\Fields' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Fields
|
13 |
+
* @package um\core
|
14 |
+
*/
|
15 |
+
class Fields {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
var $set_mode = '';
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var int form_id
|
26 |
+
*/
|
27 |
+
public $set_id = null;
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Fields constructor.
|
32 |
+
*/
|
33 |
+
function __construct() {
|
34 |
+
$this->editing = false;
|
35 |
+
$this->viewing = false;
|
36 |
+
$this->timestamp = current_time( 'timestamp' );
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Standard checkbox field
|
42 |
+
*
|
43 |
+
* @param integer $id
|
44 |
+
* @param string $title
|
45 |
+
* @param bool $checked
|
46 |
+
*/
|
47 |
+
function checkbox( $id, $title, $checked = true ) {
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Set value on form submission
|
51 |
+
*/
|
52 |
+
if ( isset( $_REQUEST[ $id ] ) ) {
|
53 |
+
$checked = (bool) $_REQUEST[ $id ];
|
54 |
+
}
|
55 |
+
|
56 |
+
$class = $checked ? 'um-icon-android-checkbox-outline' : 'um-icon-android-checkbox-outline-blank';
|
57 |
+
|
58 |
+
?>
|
59 |
+
|
60 |
+
|
61 |
+
<div class="um-field um-field-c">
|
62 |
+
<div class="um-field-area">
|
63 |
+
<label class="um-field-checkbox<?php echo $checked ? ' active' : '' ?>">
|
64 |
+
<input type="checkbox" name="<?php echo esc_attr( $id ); ?>" value="1" <?php checked( $checked ) ?> />
|
65 |
+
<span class="um-field-checkbox-state"><i class="<?php echo esc_attr( $class ) ?>"></i></span>
|
66 |
+
<span class="um-field-checkbox-option"> <?php echo esc_html( $title ); ?></span>
|
67 |
+
</label>
|
68 |
+
</div>
|
69 |
+
</div>
|
70 |
+
|
71 |
+
<?php
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Shows social links
|
77 |
+
*/
|
78 |
+
function show_social_urls() {
|
79 |
+
$social = array();
|
80 |
+
|
81 |
+
$fields = UM()->builtin()->get_all_user_fields();
|
82 |
+
foreach ( $fields as $field => $args ) {
|
83 |
+
if ( isset( $args['advanced'] ) && $args['advanced'] == 'social' ) {
|
84 |
+
$social[ $field ] = $args;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
foreach ( $social as $k => $arr ) {
|
89 |
+
if ( um_profile( $k ) ) { ?>
|
90 |
+
|
91 |
+
<a href="<?php echo esc_url( um_filtered_social_link( $k, $arr['match'] ) ); ?>"
|
92 |
+
style="background: <?php echo esc_attr( $arr['color'] ); ?>;" target="_blank" class="um-tip-n"
|
93 |
+
title="<?php echo esc_attr( $arr['title'] ); ?>"><i class="<?php echo esc_attr( $arr['icon'] ); ?>"></i></a>
|
94 |
+
|
95 |
+
<?php
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Hidden field inside a shortcode
|
103 |
+
*
|
104 |
+
* @param string $field
|
105 |
+
*/
|
106 |
+
function add_hidden_field( $field ) {
|
107 |
+
echo '<div style="display: none !important;">';
|
108 |
+
|
109 |
+
$fields = UM()->builtin()->get_specific_fields( $field );
|
110 |
+
|
111 |
+
$output = null;
|
112 |
+
|
113 |
+
foreach ( $fields as $key => $data ) {
|
114 |
+
$output .= UM()->fields()->edit_field( $key, $data );
|
115 |
+
}
|
116 |
+
|
117 |
+
echo $output;
|
118 |
+
|
119 |
+
echo '</div>';
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Get hidden field
|
125 |
+
*
|
126 |
+
* @param string $key
|
127 |
+
* @param string $value
|
128 |
+
*
|
129 |
+
* @return string
|
130 |
+
*/
|
131 |
+
function disabled_hidden_field( $key, $value ) {
|
132 |
+
return '<input type="hidden" name="' . esc_attr( $key ) . '" value="' . esc_attr( $value ) . '"/>';
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Updates a field globally
|
138 |
+
*
|
139 |
+
* @param integer $id
|
140 |
+
* @param array $args
|
141 |
+
*/
|
142 |
+
function globally_update_field( $id, $args ) {
|
143 |
+
$fields = UM()->builtin()->saved_fields;
|
144 |
+
|
145 |
+
$fields[ $id ] = $args;
|
146 |
+
|
147 |
+
unset( $fields[ $id ]['in_row'] );
|
148 |
+
unset( $fields[ $id ]['in_sub_row'] );
|
149 |
+
unset( $fields[ $id ]['in_column'] );
|
150 |
+
unset( $fields[ $id ]['in_group'] );
|
151 |
+
unset( $fields[ $id ]['position'] );
|
152 |
+
|
153 |
+
do_action( 'um_add_new_field', $id, $args );
|
154 |
+
|
155 |
+
update_option( 'um_fields', $fields );
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Updates a field in form only
|
161 |
+
*
|
162 |
+
* @param integer $id
|
163 |
+
* @param array $args
|
164 |
+
* @param integer $form_id
|
165 |
+
*/
|
166 |
+
function update_field( $id, $args, $form_id ) {
|
167 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
168 |
+
|
169 |
+
if ( $args['type'] == 'row' ) {
|
170 |
+
if ( isset( $fields[ $id ] ) ) {
|
171 |
+
$old_args = $fields[ $id ];
|
172 |
+
foreach ( $old_args as $k => $v ) {
|
173 |
+
if ( ! in_array( $k, array( 'sub_rows', 'cols' ) ) ) {
|
174 |
+
unset( $old_args[ $k ] );
|
175 |
+
}
|
176 |
+
}
|
177 |
+
$args = array_merge( $old_args, $args );
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
// custom fields support
|
182 |
+
if ( isset( UM()->builtin()->predefined_fields[ $id ] ) && isset( UM()->builtin()->predefined_fields[ $id ]['custom'] ) ) {
|
183 |
+
$args = array_merge( UM()->builtin()->predefined_fields[ $id ], $args );
|
184 |
+
}
|
185 |
+
|
186 |
+
$fields[ $id ] = $args;
|
187 |
+
|
188 |
+
// for group field only
|
189 |
+
if ( $args['type'] == 'group' ) {
|
190 |
+
$fields[ $id ]['in_group'] = '';
|
191 |
+
}
|
192 |
+
|
193 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
194 |
+
}
|
195 |
+
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Deletes a field in form only
|
199 |
+
*
|
200 |
+
* @param integer $id
|
201 |
+
* @param integer $form_id
|
202 |
+
*/
|
203 |
+
function delete_field_from_form( $id, $form_id ) {
|
204 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
205 |
+
|
206 |
+
if ( isset( $fields[ $id ] ) ) {
|
207 |
+
$condition_fields = get_option( 'um_fields' );
|
208 |
+
|
209 |
+
if( ! is_array( $condition_fields ) ) $condition_fields = array();
|
210 |
+
|
211 |
+
foreach ( $condition_fields as $key => $value ) {
|
212 |
+
$deleted_field = array_search( $id, $value );
|
213 |
+
|
214 |
+
if ( $key != $id && $deleted_field != false ) {
|
215 |
+
$deleted_field_id = str_replace( 'conditional_field', '', $deleted_field );
|
216 |
+
|
217 |
+
if ( $deleted_field_id == '' ) {
|
218 |
+
$arr_id = 0;
|
219 |
+
} else {
|
220 |
+
$arr_id = $deleted_field_id;
|
221 |
+
}
|
222 |
+
|
223 |
+
unset( $condition_fields[ $key ][ 'conditional_action' . $deleted_field_id ] );
|
224 |
+
unset( $condition_fields[ $key ][ $deleted_field ] );
|
225 |
+
unset( $condition_fields[ $key ][ 'conditional_operator' . $deleted_field_id ] );
|
226 |
+
unset( $condition_fields[ $key ][ 'conditional_value' . $deleted_field_id ] );
|
227 |
+
unset( $condition_fields[ $key ]['conditions'][ $arr_id ] );
|
228 |
+
|
229 |
+
unset( $fields[ $key ][ 'conditional_action' . $deleted_field_id ] );
|
230 |
+
unset( $fields[ $key ][ $deleted_field ] );
|
231 |
+
unset( $fields[ $key ][ 'conditional_operator' . $deleted_field_id ] );
|
232 |
+
unset( $fields[ $key ][ 'conditional_value' . $deleted_field_id ] );
|
233 |
+
unset( $fields[ $key ]['conditions'][ $arr_id ] );
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
update_option( 'um_fields' , $condition_fields );
|
238 |
+
unset( $fields[ $id ] );
|
239 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Deletes a field from custom fields
|
246 |
+
*
|
247 |
+
* @param integer $id
|
248 |
+
*/
|
249 |
+
function delete_field_from_db( $id ) {
|
250 |
+
$fields = UM()->builtin()->saved_fields;
|
251 |
+
if ( isset( $fields[ $id ] ) ) {
|
252 |
+
$args = $fields[ $id ];
|
253 |
+
|
254 |
+
unset( $fields[ $id ] );
|
255 |
+
|
256 |
+
do_action( 'um_delete_custom_field', $id, $args );
|
257 |
+
|
258 |
+
update_option( 'um_fields', $fields );
|
259 |
+
|
260 |
+
global $wpdb;
|
261 |
+
$forms = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'um_form'" );
|
262 |
+
foreach ( $forms as $form_id ) {
|
263 |
+
$form_fields = get_post_meta( $form_id, '_um_custom_fields', true );
|
264 |
+
unset( $form_fields[ $id ] );
|
265 |
+
update_post_meta( $form_id, '_um_custom_fields', $form_fields );
|
266 |
+
}
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Quickly adds a field from custom fields
|
273 |
+
*
|
274 |
+
* @param integer $global_id
|
275 |
+
* @param integer $form_id
|
276 |
+
* @param array $position
|
277 |
+
*/
|
278 |
+
function add_field_from_list( $global_id, $form_id, $position = array() ) {
|
279 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
280 |
+
$field_scope = UM()->builtin()->saved_fields;
|
281 |
+
|
282 |
+
if ( ! isset( $fields[ $global_id ] ) ) {
|
283 |
+
|
284 |
+
$count = 1;
|
285 |
+
if ( ! empty( $fields ) ) {
|
286 |
+
$count = count( $fields ) + 1;
|
287 |
+
}
|
288 |
+
|
289 |
+
$fields[ $global_id ] = $field_scope[ $global_id ];
|
290 |
+
$fields[ $global_id ]['position'] = $count;
|
291 |
+
|
292 |
+
// set position
|
293 |
+
if ( $position ) {
|
294 |
+
foreach ( $position as $key => $val) {
|
295 |
+
$fields[ $global_id ][ $key ] = $val;
|
296 |
+
}
|
297 |
+
}
|
298 |
+
|
299 |
+
// add field to form
|
300 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
301 |
+
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Quickly adds a field from pre-defined fields
|
308 |
+
*
|
309 |
+
* @param integer $global_id
|
310 |
+
* @param integer $form_id
|
311 |
+
* @param array $position
|
312 |
+
*/
|
313 |
+
function add_field_from_predefined( $global_id, $form_id, $position = array() ) {
|
314 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
315 |
+
$field_scope = UM()->builtin()->predefined_fields;
|
316 |
+
|
317 |
+
if ( ! isset( $fields[ $global_id ] ) ) {
|
318 |
+
|
319 |
+
$count = 1;
|
320 |
+
if ( ! empty( $fields ) ) {
|
321 |
+
$count = count( $fields ) + 1;
|
322 |
+
}
|
323 |
+
|
324 |
+
$fields[ $global_id ] = $field_scope[ $global_id ];
|
325 |
+
$fields[ $global_id ]['position'] = $count;
|
326 |
+
|
327 |
+
// set position
|
328 |
+
if ( $position ) {
|
329 |
+
foreach ( $position as $key => $val ) {
|
330 |
+
$fields[ $global_id ][ $key ] = $val;
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
// add field to form
|
335 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Duplicates a frield by meta key
|
342 |
+
*
|
343 |
+
* @param integer $id
|
344 |
+
* @param integer $form_id
|
345 |
+
*/
|
346 |
+
function duplicate_field( $id, $form_id ) {
|
347 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
348 |
+
$all_fields = UM()->builtin()->saved_fields;
|
349 |
+
|
350 |
+
$inc = count( $fields ) + 1;
|
351 |
+
|
352 |
+
$duplicate = $fields[ $id ];
|
353 |
+
|
354 |
+
$new_metakey = $id . "_" . $inc;
|
355 |
+
$new_title = $fields[ $id ]['title'] . " #" . $inc;
|
356 |
+
$new_position = $inc;
|
357 |
+
|
358 |
+
$duplicate['title'] = $new_title;
|
359 |
+
$duplicate['metakey'] = $new_metakey;
|
360 |
+
$duplicate['position'] = $new_position;
|
361 |
+
|
362 |
+
$fields[ $new_metakey ] = $duplicate;
|
363 |
+
$all_fields[ $new_metakey ] = $duplicate;
|
364 |
+
|
365 |
+
// not global attributes
|
366 |
+
unset( $all_fields[ $new_metakey ]['in_row'] );
|
367 |
+
unset( $all_fields[ $new_metakey ]['in_sub_row'] );
|
368 |
+
unset( $all_fields[ $new_metakey ]['in_column'] );
|
369 |
+
unset( $all_fields[ $new_metakey ]['in_group'] );
|
370 |
+
unset( $all_fields[ $new_metakey ]['position'] );
|
371 |
+
|
372 |
+
|
373 |
+
do_action( 'um_add_new_field', $new_metakey, $duplicate );
|
374 |
+
|
375 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
376 |
+
update_option( 'um_fields', $all_fields );
|
377 |
+
}
|
378 |
+
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Print field error
|
382 |
+
*
|
383 |
+
* @param string $text
|
384 |
+
* @param bool $force_show
|
385 |
+
*
|
386 |
+
* @return string
|
387 |
+
*/
|
388 |
+
function field_error( $text, $force_show = false ) {
|
389 |
+
|
390 |
+
if ( empty( $text ) ) {
|
391 |
+
return '';
|
392 |
+
}
|
393 |
+
|
394 |
+
if ( $force_show ) {
|
395 |
+
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
396 |
+
return $output;
|
397 |
+
}
|
398 |
+
|
399 |
+
|
400 |
+
if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) {
|
401 |
+
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
402 |
+
} else {
|
403 |
+
$output = '';
|
404 |
+
}
|
405 |
+
|
406 |
+
if ( ! UM()->form()->processing ) {
|
407 |
+
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
408 |
+
}
|
409 |
+
|
410 |
+
return $output;
|
411 |
+
}
|
412 |
+
|
413 |
+
|
414 |
+
/**
|
415 |
+
* Print field notice
|
416 |
+
*
|
417 |
+
* @param string $text
|
418 |
+
* @param bool $force_show
|
419 |
+
*
|
420 |
+
* @return string
|
421 |
+
*/
|
422 |
+
function field_notice( $text, $force_show = false ) {
|
423 |
+
|
424 |
+
if ( empty( $text ) ) {
|
425 |
+
return '';
|
426 |
+
}
|
427 |
+
|
428 |
+
if ( $force_show ) {
|
429 |
+
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
430 |
+
return $output;
|
431 |
+
}
|
432 |
+
|
433 |
+
|
434 |
+
if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) {
|
435 |
+
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
436 |
+
} else {
|
437 |
+
$output = '';
|
438 |
+
}
|
439 |
+
|
440 |
+
if ( ! UM()->form()->processing ) {
|
441 |
+
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
442 |
+
}
|
443 |
+
|
444 |
+
return $output;
|
445 |
+
}
|
446 |
+
|
447 |
+
|
448 |
+
/**
|
449 |
+
* Checks if field has a server-side error
|
450 |
+
*
|
451 |
+
* @param string $key
|
452 |
+
*
|
453 |
+
* @return boolean
|
454 |
+
*/
|
455 |
+
function is_error( $key ) {
|
456 |
+
return UM()->form()->has_error( $key );
|
457 |
+
}
|
458 |
+
|
459 |
+
/**
|
460 |
+
* Checks if field has a notice
|
461 |
+
*
|
462 |
+
* @param string $key
|
463 |
+
*
|
464 |
+
* @return boolean
|
465 |
+
*/
|
466 |
+
function is_notice( $key ) {
|
467 |
+
return UM()->form()->has_notice( $key );
|
468 |
+
}
|
469 |
+
|
470 |
+
|
471 |
+
/**
|
472 |
+
* Returns field error
|
473 |
+
*
|
474 |
+
* @param string $key
|
475 |
+
*
|
476 |
+
* @return string
|
477 |
+
*/
|
478 |
+
function show_error( $key ) {
|
479 |
+
return UM()->form()->errors[ $key ];
|
480 |
+
}
|
481 |
+
|
482 |
+
/**
|
483 |
+
* Returns field notices
|
484 |
+
*
|
485 |
+
* @param string $key
|
486 |
+
*
|
487 |
+
* @return string
|
488 |
+
*/
|
489 |
+
function show_notice( $key ) {
|
490 |
+
return UM()->form()->notices[ $key ];
|
491 |
+
}
|
492 |
+
|
493 |
+
|
494 |
+
/**
|
495 |
+
* Display field label
|
496 |
+
*
|
497 |
+
* @param string $label
|
498 |
+
* @param string $key
|
499 |
+
* @param array $data
|
500 |
+
*
|
501 |
+
* @return string
|
502 |
+
*/
|
503 |
+
function field_label( $label, $key, $data ) {
|
504 |
+
$output = null;
|
505 |
+
$output .= '<div class="um-field-label">';
|
506 |
+
|
507 |
+
if ( isset( $data['icon'] ) && $data['icon'] != '' && isset( $this->field_icons ) && $this->field_icons != 'off' && ( $this->field_icons == 'label' || $this->viewing == true ) ) {
|
508 |
+
$output .= '<div class="um-field-label-icon"><i class="' . esc_attr( $data['icon'] ) . '" aria-label="' . esc_attr( $label ) . '"></i></div>';
|
509 |
+
}
|
510 |
+
|
511 |
+
if ( $this->viewing == true ) {
|
512 |
+
/**
|
513 |
+
* UM hook
|
514 |
+
*
|
515 |
+
* @type filter
|
516 |
+
* @title um_view_label_{$key}
|
517 |
+
* @description Change field label on view by field $key
|
518 |
+
* @input_vars
|
519 |
+
* [{"var":"$label","type":"string","desc":"Field Label"}]
|
520 |
+
* @change_log
|
521 |
+
* ["Since: 2.0"]
|
522 |
+
* @usage add_filter( 'um_view_label_{$key}', 'function_name', 10, 1 );
|
523 |
+
* @example
|
524 |
+
* <?php
|
525 |
+
* add_filter( 'um_view_label_{$key}', 'my_view_label', 10, 1 );
|
526 |
+
* function my_view_label( $label ) {
|
527 |
+
* // your code here
|
528 |
+
* return $label;
|
529 |
+
* }
|
530 |
+
* ?>
|
531 |
+
*/
|
532 |
+
$label = apply_filters( "um_view_label_{$key}", $label );
|
533 |
+
} else {
|
534 |
+
/**
|
535 |
+
* UM hook
|
536 |
+
*
|
537 |
+
* @type filter
|
538 |
+
* @title um_edit_label_{$key}
|
539 |
+
* @description Change field label on edit by field $key
|
540 |
+
* @input_vars
|
541 |
+
* [{"var":"$label","type":"string","desc":"Field Label"}]
|
542 |
+
* @change_log
|
543 |
+
* ["Since: 2.0"]
|
544 |
+
* @usage add_filter( 'um_edit_label_{$key}', 'function_name', 10, 1 );
|
545 |
+
* @example
|
546 |
+
* <?php
|
547 |
+
* add_filter( 'um_edit_label_{$key}', 'my_edit_label', 10, 1 );
|
548 |
+
* function my_edit_label( $label ) {
|
549 |
+
* // your code here
|
550 |
+
* return $label;
|
551 |
+
* }
|
552 |
+
* ?>
|
553 |
+
*/
|
554 |
+
$label = apply_filters( "um_edit_label_{$key}", $label );
|
555 |
+
/**
|
556 |
+
* UM hook
|
557 |
+
*
|
558 |
+
* @type filter
|
559 |
+
* @title um_edit_label_all_fields
|
560 |
+
* @description Change field label on view by field $key
|
561 |
+
* @input_vars
|
562 |
+
* [{"var":"$label","type":"string","desc":"Field Label"},
|
563 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
564 |
+
* @change_log
|
565 |
+
* ["Since: 2.0"]
|
566 |
+
* @usage add_filter( 'um_edit_label_all_fields', 'function_name', 10, 2 );
|
567 |
+
* @example
|
568 |
+
* <?php
|
569 |
+
* add_filter( 'um_edit_label_all_fields', 'my_edit_label_all_fields', 10, 2 );
|
570 |
+
* function my_edit_label_all_fields( $label, $data ) {
|
571 |
+
* // your code here
|
572 |
+
* return $label;
|
573 |
+
* }
|
574 |
+
* ?>
|
575 |
+
*/
|
576 |
+
$label = apply_filters( 'um_edit_label_all_fields', $label, $data );
|
577 |
+
}
|
578 |
+
|
579 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
580 |
+
$for_attr = '';
|
581 |
+
if ( ! in_array( $data['type'], $fields_without_metakey ) ) {
|
582 |
+
$for_attr = ' for="' . esc_attr( $key . UM()->form()->form_suffix ) . '"';
|
583 |
+
}
|
584 |
+
|
585 |
+
$output .= '<label' . $for_attr . '>' . __( $label, 'ultimate-member' ) . '</label>';
|
586 |
+
|
587 |
+
if ( ! empty( $data['help'] ) && $this->viewing == false && ! strstr( $key, 'confirm_user_pass' ) ) {
|
588 |
+
|
589 |
+
if ( ! UM()->mobile()->isMobile() ) {
|
590 |
+
if ( ! isset( $this->disable_tooltips ) ) {
|
591 |
+
$output .= '<span class="um-tip um-tip-' . ( is_rtl() ? 'e' : 'w' ) . '" title="' . esc_attr__( $data['help'], 'ultimate-member' ) . '"><i class="um-icon-help-circled"></i></span>';
|
592 |
+
}
|
593 |
+
}
|
594 |
+
|
595 |
+
if ( UM()->mobile()->isMobile() || isset( $this->disable_tooltips ) ) {
|
596 |
+
$output .= '<span class="um-tip-text">' . __( $data['help'], 'ultimate-member' ) . '</span>';
|
597 |
+
}
|
598 |
+
|
599 |
+
}
|
600 |
+
|
601 |
+
$output .= '<div class="um-clear"></div></div>';
|
602 |
+
|
603 |
+
return $output;
|
604 |
+
}
|
605 |
+
|
606 |
+
|
607 |
+
/**
|
608 |
+
* Output field classes
|
609 |
+
*
|
610 |
+
* @param string $key
|
611 |
+
* @param array $data
|
612 |
+
* @param string $add
|
613 |
+
*
|
614 |
+
* @return string
|
615 |
+
*/
|
616 |
+
function get_class( $key, $data, $add = null ) {
|
617 |
+
$classes = null;
|
618 |
+
|
619 |
+
$classes .= 'um-form-field ';
|
620 |
+
|
621 |
+
if ( $this->is_error( $key ) ) {
|
622 |
+
$classes .= 'um-error ';
|
623 |
+
} else {
|
624 |
+
$classes .= 'valid ';
|
625 |
+
}
|
626 |
+
|
627 |
+
if ( ! isset( $data['required'] ) ) {
|
628 |
+
$classes .= 'not-required ';
|
629 |
+
}
|
630 |
+
|
631 |
+
if ( $data['type'] == 'date' ) {
|
632 |
+
$classes .= 'um-datepicker ';
|
633 |
+
}
|
634 |
+
|
635 |
+
if ( $data['type'] == 'time' ) {
|
636 |
+
$classes .= 'um-timepicker ';
|
637 |
+
}
|
638 |
+
|
639 |
+
if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
640 |
+
$classes .= 'um-iconed ';
|
641 |
+
}
|
642 |
+
|
643 |
+
if ( $add ) {
|
644 |
+
$classes .= $add . ' ';
|
645 |
+
}
|
646 |
+
|
647 |
+
/**
|
648 |
+
* UM hook
|
649 |
+
*
|
650 |
+
* @type filter
|
651 |
+
* @title um_extend_field_classes
|
652 |
+
* @description Change field classes
|
653 |
+
* @input_vars
|
654 |
+
* [{"var":"$classes","type":"string","desc":"Field Classes"},
|
655 |
+
* {"var":"$key","type":"string","desc":"Field Key"},
|
656 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
657 |
+
* @change_log
|
658 |
+
* ["Since: 2.0"]
|
659 |
+
* @usage add_filter( 'um_extend_field_classes', 'function_name', 10, 3 );
|
660 |
+
* @example
|
661 |
+
* <?php
|
662 |
+
* add_filter( 'um_extend_field_classes', 'my_extend_field_classes', 10, 3 );
|
663 |
+
* function my_extend_field_classes( $classes, $key, $data ) {
|
664 |
+
* // your code here
|
665 |
+
* return $classes;
|
666 |
+
* }
|
667 |
+
* ?>
|
668 |
+
*/
|
669 |
+
$classes = apply_filters( 'um_extend_field_classes', $classes, $key, $data );
|
670 |
+
|
671 |
+
return $classes;
|
672 |
+
}
|
673 |
+
|
674 |
+
|
675 |
+
/**
|
676 |
+
* Gets field value
|
677 |
+
*
|
678 |
+
* @param string $key
|
679 |
+
* @param boolean $default
|
680 |
+
* @param array $data
|
681 |
+
*
|
682 |
+
* @return mixed
|
683 |
+
*/
|
684 |
+
function field_value( $key, $default = false, $data = null ) {
|
685 |
+
// preview in backend
|
686 |
+
if ( isset( UM()->user()->preview ) && UM()->user()->preview ) {
|
687 |
+
if ( $this->set_mode == 'login' || $this->set_mode == 'register' ) {
|
688 |
+
return '';
|
689 |
+
} else {
|
690 |
+
$val = um_user( $key );
|
691 |
+
if ( ! empty( $val ) ) {
|
692 |
+
return $val;
|
693 |
+
} else {
|
694 |
+
return '';
|
695 |
+
}
|
696 |
+
}
|
697 |
+
}
|
698 |
+
|
699 |
+
if ( isset( $_SESSION ) && isset( $_SESSION['um_social_profile'][ $key ] ) && isset( $this->set_mode ) && $this->set_mode == 'register' ) {
|
700 |
+
return $_SESSION['um_social_profile'][ $key ];
|
701 |
+
}
|
702 |
+
|
703 |
+
$type = ( isset( $data['type'] ) ) ? $data['type'] : '';
|
704 |
+
|
705 |
+
// normal state
|
706 |
+
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
707 |
+
//show empty value for password fields
|
708 |
+
if ( strstr( $key, 'user_pass' ) && $this->set_mode != 'password' ) {
|
709 |
+
return '';
|
710 |
+
}
|
711 |
+
|
712 |
+
if ( 'profile' === $this->set_mode ) {
|
713 |
+
if ( ! isset( UM()->form()->post_form['profile_nonce'] ) || false === wp_verify_nonce( UM()->form()->post_form['profile_nonce'], 'um-profile-nonce' . UM()->user()->target_id ) ) {
|
714 |
+
return '';
|
715 |
+
}
|
716 |
+
}
|
717 |
+
|
718 |
+
return stripslashes_deep( UM()->form()->post_form[ $key ] );
|
719 |
+
|
720 |
+
} elseif ( um_user( $key ) && $this->editing == true ) {
|
721 |
+
|
722 |
+
//show empty value for password fields
|
723 |
+
if ( strstr( $key, 'user_pass' ) || $type == 'password' ) {
|
724 |
+
return '';
|
725 |
+
}
|
726 |
+
|
727 |
+
$value = um_user( $key );
|
728 |
+
/**
|
729 |
+
* UM hook
|
730 |
+
*
|
731 |
+
* @type filter
|
732 |
+
* @title um_edit_{$key}_field_value
|
733 |
+
* @description Change field value on edit by field $key
|
734 |
+
* @input_vars
|
735 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
736 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
737 |
+
* @change_log
|
738 |
+
* ["Since: 2.0"]
|
739 |
+
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
740 |
+
* @example
|
741 |
+
* <?php
|
742 |
+
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
743 |
+
* function my_edit_field_value( $value, $key ) {
|
744 |
+
* // your code here
|
745 |
+
* return $value;
|
746 |
+
* }
|
747 |
+
* ?>
|
748 |
+
*/
|
749 |
+
$value = apply_filters( "um_edit_{$key}_field_value", $value, $key );
|
750 |
+
/**
|
751 |
+
* UM hook
|
752 |
+
*
|
753 |
+
* @type filter
|
754 |
+
* @title um_edit_{$type}_field_value
|
755 |
+
* @description Change field value on edit by field $type
|
756 |
+
* @input_vars
|
757 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
758 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
759 |
+
* @change_log
|
760 |
+
* ["Since: 2.0"]
|
761 |
+
* @usage add_filter( 'um_edit_{$type}_field_value', 'function_name', 10, 2 );
|
762 |
+
* @example
|
763 |
+
* <?php
|
764 |
+
* add_filter( 'um_edit_{$type}_field_value', 'my_edit_field_value', 10, 2 );
|
765 |
+
* function my_edit_field_value( $value, $key ) {
|
766 |
+
* // your code here
|
767 |
+
* return $value;
|
768 |
+
* }
|
769 |
+
* ?>
|
770 |
+
*/
|
771 |
+
$value = apply_filters( "um_edit_{$type}_field_value", $value, $key );
|
772 |
+
|
773 |
+
} elseif ( ( um_user( $key ) || isset( $data['show_anyway'] ) ) && $this->viewing == true ) {
|
774 |
+
|
775 |
+
return um_filtered_value( $key, $data );
|
776 |
+
|
777 |
+
} elseif ( isset( UM()->user()->profile[ $key ] ) ) {
|
778 |
+
|
779 |
+
$value = UM()->user()->profile[ $key ];
|
780 |
+
/**
|
781 |
+
* UM hook
|
782 |
+
*
|
783 |
+
* @type filter
|
784 |
+
* @title um_edit_{$key}_field_value
|
785 |
+
* @description Change field value on edit by field $key
|
786 |
+
* @input_vars
|
787 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
788 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
789 |
+
* @change_log
|
790 |
+
* ["Since: 2.0"]
|
791 |
+
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
792 |
+
* @example
|
793 |
+
* <?php
|
794 |
+
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
795 |
+
* function my_edit_field_value( $value, $key ) {
|
796 |
+
* // your code here
|
797 |
+
* return $value;
|
798 |
+
* }
|
799 |
+
* ?>
|
800 |
+
*/
|
801 |
+
$value = apply_filters( "um_edit_{$key}_field_value", $value, $key );
|
802 |
+
$value = maybe_unserialize( $value );
|
803 |
+
|
804 |
+
} elseif ( $default ) {
|
805 |
+
|
806 |
+
/**
|
807 |
+
* UM hook
|
808 |
+
*
|
809 |
+
* @type filter
|
810 |
+
* @title um_field_default_value
|
811 |
+
* @description Change field default value
|
812 |
+
* @input_vars
|
813 |
+
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
814 |
+
* {"var":"$data","type":"array","desc":"Field Data"},
|
815 |
+
* {"var":"$type","type":"string","desc":"Field Type"}]
|
816 |
+
* @change_log
|
817 |
+
* ["Since: 2.0"]
|
818 |
+
* @usage add_filter( 'um_field_default_value', 'function_name', 10, 2 );
|
819 |
+
* @example
|
820 |
+
* <?php
|
821 |
+
* add_filter( 'um_field_default_value', 'my_field_default_value', 10, 2 );
|
822 |
+
* function my_field_default_value( $default, $data, $type ) {
|
823 |
+
* // your code here
|
824 |
+
* return $default;
|
825 |
+
* }
|
826 |
+
* ?>
|
827 |
+
*/
|
828 |
+
$default = apply_filters( 'um_field_default_value', $default, $data, $type );
|
829 |
+
/**
|
830 |
+
* UM hook
|
831 |
+
*
|
832 |
+
* @type filter
|
833 |
+
* @title um_field_{$key}_default_value
|
834 |
+
* @description Change field default value by $key
|
835 |
+
* @input_vars
|
836 |
+
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
837 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
838 |
+
* @change_log
|
839 |
+
* ["Since: 2.0"]
|
840 |
+
* @usage add_filter( 'um_field_{$key}_default_value', 'function_name', 10, 2 );
|
841 |
+
* @example
|
842 |
+
* <?php
|
843 |
+
* add_filter( 'um_field_{$key}_default_value', 'my_field_default_value', 10, 2 );
|
844 |
+
* function my_field_default_value( $default, $data ) {
|
845 |
+
* // your code here
|
846 |
+
* return $default;
|
847 |
+
* }
|
848 |
+
* ?>
|
849 |
+
*/
|
850 |
+
$default = apply_filters( "um_field_{$key}_default_value", $default, $data );
|
851 |
+
/**
|
852 |
+
* UM hook
|
853 |
+
*
|
854 |
+
* @type filter
|
855 |
+
* @title um_field_{$type}_default_value
|
856 |
+
* @description Change field default value by $type
|
857 |
+
* @input_vars
|
858 |
+
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
859 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
860 |
+
* @change_log
|
861 |
+
* ["Since: 2.0"]
|
862 |
+
* @usage add_filter( 'um_field_{$type}_default_value', 'function_name', 10, 2 );
|
863 |
+
* @example
|
864 |
+
* <?php
|
865 |
+
* add_filter( 'um_field_{$type}_default_value', 'my_field_default_value', 10, 2 );
|
866 |
+
* function my_field_default_value( $default, $data ) {
|
867 |
+
* // your code here
|
868 |
+
* return $default;
|
869 |
+
* }
|
870 |
+
* ?>
|
871 |
+
*/
|
872 |
+
$default = apply_filters( "um_field_{$type}_default_value", $default, $data );
|
873 |
+
|
874 |
+
}
|
875 |
+
|
876 |
+
// Default Value for Registration Form and Profile Form editing
|
877 |
+
if ( ! isset( $value ) && ( $this->set_mode == 'register' || $this->editing == true ) ) {
|
878 |
+
|
879 |
+
/**
|
880 |
+
* UM hook
|
881 |
+
*
|
882 |
+
* @type filter
|
883 |
+
* @title um_edit_{$key}_field_value
|
884 |
+
* @description Change field value on edit by field $key
|
885 |
+
* @input_vars
|
886 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
887 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
888 |
+
* @change_log
|
889 |
+
* ["Since: 2.0"]
|
890 |
+
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
891 |
+
* @example
|
892 |
+
* <?php
|
893 |
+
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
894 |
+
* function my_edit_field_value( $value, $key ) {
|
895 |
+
* // your code here
|
896 |
+
* return $value;
|
897 |
+
* }
|
898 |
+
* ?>
|
899 |
+
*/
|
900 |
+
$value = apply_filters( "um_edit_{$key}_field_value", $default, $key );
|
901 |
+
|
902 |
+
} elseif ( isset( $value ) && is_array( $value ) && ! count( $value ) ) {
|
903 |
+
$value = '';
|
904 |
+
} elseif ( ! isset( $value ) ) {
|
905 |
+
$value = '';
|
906 |
+
}
|
907 |
+
|
908 |
+
|
909 |
+
/**
|
910 |
+
* UM hook
|
911 |
+
*
|
912 |
+
* @type filter
|
913 |
+
* @title um_field_value
|
914 |
+
* @description Change field value
|
915 |
+
* @input_vars
|
916 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
917 |
+
* {"var":"$key","type":"string","desc":"Field Key"},,
|
918 |
+
* {"var":"$type","type":"string","desc":"Field Type"}
|
919 |
+
* {"var":"$default","type":"string","desc":"Field Default Value"},
|
920 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
921 |
+
* @usage add_filter( 'um_field_value', 'function_name', 10, 5 );
|
922 |
+
*/
|
923 |
+
return apply_filters( 'um_field_value', $value, $default, $key, $type, $data );
|
924 |
+
}
|
925 |
+
|
926 |
+
|
927 |
+
/**
|
928 |
+
* Checks if an option is selected
|
929 |
+
*
|
930 |
+
* is used by Select, Multiselect and Checkbox fields
|
931 |
+
*
|
932 |
+
* @param string $key
|
933 |
+
* @param string $value
|
934 |
+
* @param array $data
|
935 |
+
*
|
936 |
+
* @return boolean
|
937 |
+
*/
|
938 |
+
function is_selected( $key, $value, $data ) {
|
939 |
+
global $wpdb;
|
940 |
+
|
941 |
+
/**
|
942 |
+
* UM hook
|
943 |
+
*
|
944 |
+
* @type filter
|
945 |
+
* @title um_is_selected_filter_key
|
946 |
+
* @description Change is selected filter key
|
947 |
+
* @input_vars
|
948 |
+
* [{"var":"$key","type":"string","desc":"Selected filter key"}]
|
949 |
+
* @change_log
|
950 |
+
* ["Since: 2.0"]
|
951 |
+
* @usage add_filter( 'um_is_selected_filter_key', 'function_name', 10, 1 );
|
952 |
+
* @example
|
953 |
+
* <?php
|
954 |
+
* add_filter( 'um_is_selected_filter_key', 'my_selected_filter_key', 10, 1 );
|
955 |
+
* function my_selected_filter_key( $key ) {
|
956 |
+
* // your code here
|
957 |
+
* return $key;
|
958 |
+
* }
|
959 |
+
* ?>
|
960 |
+
*/
|
961 |
+
$key = apply_filters( 'um_is_selected_filter_key', $key );
|
962 |
+
|
963 |
+
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
964 |
+
|
965 |
+
if ( is_array( UM()->form()->post_form[ $key ] ) ) {
|
966 |
+
|
967 |
+
if ( in_array( $value, UM()->form()->post_form[ $key ] ) ) {
|
968 |
+
return true;
|
969 |
+
}
|
970 |
+
|
971 |
+
$stripslashed = array_map( 'stripslashes', UM()->form()->post_form[ $key ] );
|
972 |
+
if ( in_array( $value, $stripslashed ) ) {
|
973 |
+
return true;
|
974 |
+
}
|
975 |
+
|
976 |
+
if ( in_array( html_entity_decode( $value ), UM()->form()->post_form[ $key ] ) ) {
|
977 |
+
return true;
|
978 |
+
}
|
979 |
+
} else {
|
980 |
+
|
981 |
+
if ( $value == UM()->form()->post_form[ $key ] ) {
|
982 |
+
return true;
|
983 |
+
}
|
984 |
+
|
985 |
+
}
|
986 |
+
|
987 |
+
} else {
|
988 |
+
|
989 |
+
$field_value = um_user( $key );
|
990 |
+
if ( ! $field_value ) {
|
991 |
+
$field_value = 0;
|
992 |
+
}
|
993 |
+
|
994 |
+
if ( $field_value == 0 && $value == '0' ) {
|
995 |
+
$value = (int) $value;
|
996 |
+
}
|
997 |
+
|
998 |
+
if ( strstr( $key, 'role_' ) || $key == 'role' ) {
|
999 |
+
$field_value = strtolower( UM()->roles()->get_editable_priority_user_role( um_user( 'ID' ) ) );
|
1000 |
+
|
1001 |
+
$role_keys = get_option( 'um_roles', array() );
|
1002 |
+
|
1003 |
+
if ( ! empty( $role_keys ) ) {
|
1004 |
+
if ( in_array( $field_value, $role_keys ) ) {
|
1005 |
+
$field_value = 'um_' . $field_value;
|
1006 |
+
}
|
1007 |
+
}
|
1008 |
+
}
|
1009 |
+
|
1010 |
+
|
1011 |
+
/**
|
1012 |
+
* UM hook
|
1013 |
+
*
|
1014 |
+
* @type filter
|
1015 |
+
* @title um_is_selected_filter_value
|
1016 |
+
* @description Change is selected filter value
|
1017 |
+
* @input_vars
|
1018 |
+
* [{"var":"$value","type":"string","desc":"Selected filter value"},
|
1019 |
+
* {"var":"$key","type":"string","desc":"Selected filter key"},
|
1020 |
+
* {"var":"$value","type":"string","desc":"Selected filter value"}]
|
1021 |
+
* @change_log
|
1022 |
+
* ["Since: 2.0"]
|
1023 |
+
* @usage add_filter( 'um_is_selected_filter_value', 'function_name', 10, 2 );
|
1024 |
+
* @example
|
1025 |
+
* <?php
|
1026 |
+
* add_filter( 'um_is_selected_filter_value', 'my_selected_filter_value', 10, 2 );
|
1027 |
+
* function my_selected_filter_value( $value, $key ) {
|
1028 |
+
* // your code here
|
1029 |
+
* return $field_value;
|
1030 |
+
* }
|
1031 |
+
* ?>
|
1032 |
+
*/
|
1033 |
+
$field_value = apply_filters( 'um_is_selected_filter_value', $field_value, $key, $value );
|
1034 |
+
|
1035 |
+
/**
|
1036 |
+
* UM hook
|
1037 |
+
*
|
1038 |
+
* @type filter
|
1039 |
+
* @title um_is_selected_filter_data
|
1040 |
+
* @description Change is selected filter data
|
1041 |
+
* @input_vars
|
1042 |
+
* [{"var":"$data","type":"array","desc":"Selected filter value"},
|
1043 |
+
* {"var":"$key","type":"string","desc":"Selected filter key"},
|
1044 |
+
* {"var":"$value","type":"string","desc":"Selected filter value"}]
|
1045 |
+
* @change_log
|
1046 |
+
* ["Since: 2.0"]
|
1047 |
+
* @usage add_filter( 'um_is_selected_filter_data', 'function_name', 10, 3 );
|
1048 |
+
* @example
|
1049 |
+
* <?php
|
1050 |
+
* add_filter( 'um_is_selected_filter_data', 'my_selected_filter_data', 10, 3 );
|
1051 |
+
* function my_selected_filter_data( $data, $key, $value ) {
|
1052 |
+
* // your code here
|
1053 |
+
* return $data;
|
1054 |
+
* }
|
1055 |
+
* ?>
|
1056 |
+
*/
|
1057 |
+
$data = apply_filters( 'um_is_selected_filter_data', $data, $key, $field_value );
|
1058 |
+
|
1059 |
+
if ( ! $this->editing || 'custom' == $this->set_mode ) {
|
1060 |
+
// show default on register screen if there is default
|
1061 |
+
if ( isset( $data['default'] ) ) {
|
1062 |
+
|
1063 |
+
if ( ! is_array( $data['default'] ) && $data['default'] === $value ) {
|
1064 |
+
return true;
|
1065 |
+
}
|
1066 |
+
|
1067 |
+
if ( is_array( $data['default'] ) && in_array( $value, $data['default'] ) ) {
|
1068 |
+
return true;
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
if ( is_array( $data['default'] ) && array_intersect( $data['options'], $data['default'] ) ) {
|
1072 |
+
return true;
|
1073 |
+
}
|
1074 |
+
|
1075 |
+
// default value with comma
|
1076 |
+
if ( is_string( $data['default'] ) && strstr( $data['default'], ',' ) ) {
|
1077 |
+
$choices = array_map( 'trim', explode( ',', $data['default'] ) );
|
1078 |
+
if ( in_array( $value, $choices ) ) {
|
1079 |
+
return true;
|
1080 |
+
}
|
1081 |
+
}
|
1082 |
+
|
1083 |
+
}
|
1084 |
+
} else {
|
1085 |
+
|
1086 |
+
if ( $field_value && is_array( $field_value ) && ( in_array( $value, $field_value ) || in_array( html_entity_decode( $value ), $field_value ) ) ) {
|
1087 |
+
return true;
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
if ( $field_value == 0 && ! is_array( $field_value ) && $field_value === $value ) {
|
1091 |
+
return true;
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
if ( $field_value && ! is_array( $field_value ) && $field_value == $value ) {
|
1095 |
+
return true;
|
1096 |
+
}
|
1097 |
+
|
1098 |
+
if ( $field_value && ! is_array( $field_value ) && html_entity_decode( $field_value ) == html_entity_decode( $value ) ) {
|
1099 |
+
return true;
|
1100 |
+
}
|
1101 |
+
|
1102 |
+
// show default on edit screen if there isn't meta row in usermeta table
|
1103 |
+
$direct_db_value = $wpdb->get_var( $wpdb->prepare( "SELECT ISNULL( meta_value ) FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = %s", um_user( 'ID' ), $key ) );
|
1104 |
+
if ( ! isset( $direct_db_value ) && isset( $data['default'] ) ) {
|
1105 |
+
if ( ! is_array( $data['default'] ) && strstr( $data['default'], ', ' ) ) {
|
1106 |
+
$data['default'] = explode( ', ', $data['default'] );
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
if ( ! is_array( $data['default'] ) && $data['default'] === $value ) {
|
1110 |
+
return true;
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
if ( is_array( $data['default'] ) && in_array( $value, $data['default'] ) ) {
|
1114 |
+
return true;
|
1115 |
+
}
|
1116 |
+
}
|
1117 |
+
}
|
1118 |
+
|
1119 |
+
}
|
1120 |
+
|
1121 |
+
return false;
|
1122 |
+
}
|
1123 |
+
|
1124 |
+
|
1125 |
+
/**
|
1126 |
+
* Checks if a radio button is selected
|
1127 |
+
*
|
1128 |
+
* @param string $key
|
1129 |
+
* @param string $value
|
1130 |
+
* @param array $data
|
1131 |
+
*
|
1132 |
+
* @return boolean
|
1133 |
+
*/
|
1134 |
+
function is_radio_checked( $key, $value, $data ) {
|
1135 |
+
global $wpdb;
|
1136 |
+
|
1137 |
+
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
1138 |
+
if ( is_array( UM()->form()->post_form[ $key ] ) && in_array( $value, UM()->form()->post_form[ $key ] ) ) {
|
1139 |
+
return true;
|
1140 |
+
} elseif ( $value == UM()->form()->post_form[ $key ] ) {
|
1141 |
+
return true;
|
1142 |
+
}
|
1143 |
+
} else {
|
1144 |
+
|
1145 |
+
if ( $this->editing && 'custom' !== $this->set_mode ) {
|
1146 |
+
if ( um_user( $key ) ) {
|
1147 |
+
|
1148 |
+
$um_user_value = um_user( $key );
|
1149 |
+
|
1150 |
+
if ( strstr( $key, 'role_' ) || $key == 'role' ) {
|
1151 |
+
$um_user_value = strtolower( UM()->roles()->get_editable_priority_user_role( um_user( 'ID' ) ) );
|
1152 |
+
|
1153 |
+
$role_keys = get_option( 'um_roles', array() );
|
1154 |
+
|
1155 |
+
if ( ! empty( $role_keys ) ) {
|
1156 |
+
if ( in_array( $um_user_value, $role_keys ) ) {
|
1157 |
+
$um_user_value = 'um_' . $um_user_value;
|
1158 |
+
}
|
1159 |
+
}
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
if ( $um_user_value == $value ) {
|
1163 |
+
return true;
|
1164 |
+
}
|
1165 |
+
|
1166 |
+
if ( is_array( $um_user_value ) && in_array( $value, $um_user_value ) ) {
|
1167 |
+
return true;
|
1168 |
+
}
|
1169 |
+
|
1170 |
+
if ( is_array( $um_user_value ) ) {
|
1171 |
+
foreach ( $um_user_value as $u ) {
|
1172 |
+
if ( $u == html_entity_decode( $value ) ) {
|
1173 |
+
return true;
|
1174 |
+
}
|
1175 |
+
}
|
1176 |
+
}
|
1177 |
+
} else {
|
1178 |
+
|
1179 |
+
// show default on edit screen if there isn't meta row in usermeta table
|
1180 |
+
$direct_db_value = $wpdb->get_var( $wpdb->prepare( "SELECT ISNULL( meta_value ) FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = %s", um_user( 'ID' ), $key ) );
|
1181 |
+
if ( ! isset( $direct_db_value ) && isset( $data['default'] ) && $data['default'] == $value ) {
|
1182 |
+
return true;
|
1183 |
+
}
|
1184 |
+
|
1185 |
+
}
|
1186 |
+
} else {
|
1187 |
+
if ( isset( $data['default'] ) && $data['default'] == $value ) {
|
1188 |
+
return true;
|
1189 |
+
}
|
1190 |
+
}
|
1191 |
+
}
|
1192 |
+
|
1193 |
+
return false;
|
1194 |
+
}
|
1195 |
+
|
1196 |
+
|
1197 |
+
/**
|
1198 |
+
* Get field icon
|
1199 |
+
*
|
1200 |
+
* @param string $key
|
1201 |
+
*
|
1202 |
+
* @return string
|
1203 |
+
*/
|
1204 |
+
function get_field_icon( $key ) {
|
1205 |
+
$fields = UM()->builtin()->all_user_fields;
|
1206 |
+
if ( isset( $fields[ $key ]['icon'] ) ) {
|
1207 |
+
return $fields[ $key ]['icon'];
|
1208 |
+
}
|
1209 |
+
|
1210 |
+
return '';
|
1211 |
+
}
|
1212 |
+
|
1213 |
+
|
1214 |
+
/**
|
1215 |
+
* Gets selected option value from a callback function
|
1216 |
+
*
|
1217 |
+
* @param string $value
|
1218 |
+
* @param array $data
|
1219 |
+
* @param string $type
|
1220 |
+
*
|
1221 |
+
* @return string
|
1222 |
+
*/
|
1223 |
+
function get_option_value_from_callback( $value, $data, $type ) {
|
1224 |
+
|
1225 |
+
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
|
1226 |
+
|
1227 |
+
$has_custom_source = apply_filters( "um_has_dropdown_options_source__{$data['metakey']}", false );
|
1228 |
+
|
1229 |
+
if ( $has_custom_source ) {
|
1230 |
+
|
1231 |
+
$opts = apply_filters( "um_get_field__{$data['metakey']}", array() );
|
1232 |
+
$arr_options = $opts['options'];
|
1233 |
+
|
1234 |
+
} elseif ( function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1235 |
+
if ( isset( $data['parent_dropdown_relationship'] ) ) {
|
1236 |
+
$_POST['parent_option_name'] = $data['parent_dropdown_relationship'];
|
1237 |
+
$_POST['parent_option'] = um_user( $data['parent_dropdown_relationship'] );
|
1238 |
+
|
1239 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
1240 |
+
} else {
|
1241 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
|
1242 |
+
}
|
1243 |
+
}
|
1244 |
+
|
1245 |
+
if ( $has_custom_source || function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1246 |
+
if ( $type == 'select' ) {
|
1247 |
+
if ( ! empty( $arr_options[ $value ] ) ) {
|
1248 |
+
return $arr_options[ $value ];
|
1249 |
+
} elseif ( ! empty( $data['default'] ) && empty( $arr_options[ $value ] ) ) {
|
1250 |
+
return $arr_options[ $data['default'] ];
|
1251 |
+
} else {
|
1252 |
+
return '';
|
1253 |
+
}
|
1254 |
+
} elseif ( $type == 'multiselect' ) {
|
1255 |
+
|
1256 |
+
if ( is_array( $value ) ) {
|
1257 |
+
$values = $value;
|
1258 |
+
} else {
|
1259 |
+
$values = explode( ', ', $value );
|
1260 |
+
}
|
1261 |
+
|
1262 |
+
$arr_paired_options = array();
|
1263 |
+
|
1264 |
+
foreach ( $values as $option ) {
|
1265 |
+
if ( isset( $arr_options[ $option ] ) ) {
|
1266 |
+
$arr_paired_options[] = $arr_options[ $option ];
|
1267 |
+
}
|
1268 |
+
}
|
1269 |
+
|
1270 |
+
return implode( ', ', $arr_paired_options );
|
1271 |
+
}
|
1272 |
+
}
|
1273 |
+
|
1274 |
+
|
1275 |
+
}
|
1276 |
+
|
1277 |
+
return $value;
|
1278 |
+
}
|
1279 |
+
|
1280 |
+
|
1281 |
+
/**
|
1282 |
+
* Get select options from a callback function
|
1283 |
+
*
|
1284 |
+
* @param array $data
|
1285 |
+
* @param string $type
|
1286 |
+
*
|
1287 |
+
* @return array $arr_options
|
1288 |
+
*/
|
1289 |
+
function get_options_from_callback( $data, $type ) {
|
1290 |
+
$arr_options = array();
|
1291 |
+
|
1292 |
+
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
|
1293 |
+
|
1294 |
+
if ( function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1295 |
+
if ( isset( $data['parent_dropdown_relationship'] ) ) {
|
1296 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
1297 |
+
} else {
|
1298 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
|
1299 |
+
}
|
1300 |
+
}
|
1301 |
+
|
1302 |
+
}
|
1303 |
+
|
1304 |
+
return $arr_options;
|
1305 |
+
}
|
1306 |
+
|
1307 |
+
|
1308 |
+
/**
|
1309 |
+
* Get field type
|
1310 |
+
*
|
1311 |
+
* @param string $key
|
1312 |
+
*
|
1313 |
+
* @return string
|
1314 |
+
*/
|
1315 |
+
function get_field_type( $key ) {
|
1316 |
+
$fields = UM()->builtin()->all_user_fields;
|
1317 |
+
if ( isset( $fields[ $key ]['type'] ) ) {
|
1318 |
+
return $fields[ $key ]['type'];
|
1319 |
+
}
|
1320 |
+
|
1321 |
+
return '';
|
1322 |
+
}
|
1323 |
+
|
1324 |
+
|
1325 |
+
/**
|
1326 |
+
* Get field label
|
1327 |
+
*
|
1328 |
+
* @param string $key
|
1329 |
+
*
|
1330 |
+
* @return string
|
1331 |
+
*/
|
1332 |
+
function get_label( $key ) {
|
1333 |
+
$label = '';
|
1334 |
+
|
1335 |
+
$fields = UM()->builtin()->all_user_fields;
|
1336 |
+
if ( isset( $fields[ $key ]['label'] ) ) {
|
1337 |
+
$label = stripslashes( $fields[ $key ]['label'] );
|
1338 |
+
}
|
1339 |
+
|
1340 |
+
if ( empty( $label ) && isset( $fields[ $key ]['title'] ) ) {
|
1341 |
+
$label = stripslashes( $fields[ $key ]['title'] );
|
1342 |
+
}
|
1343 |
+
|
1344 |
+
/**
|
1345 |
+
* UM hook
|
1346 |
+
*
|
1347 |
+
* @type filter
|
1348 |
+
* @title um_change_field_label
|
1349 |
+
* @description Change Field Label
|
1350 |
+
* @input_vars
|
1351 |
+
* [{"var":"$label","type":"string","desc":"Field Label"},
|
1352 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
1353 |
+
* @change_log
|
1354 |
+
* ["Since: 2.0.30"]
|
1355 |
+
* @usage add_filter( 'um_change_field_label', 'function_name', 10, 2 );
|
1356 |
+
* @example
|
1357 |
+
* <?php
|
1358 |
+
* add_filter( 'um_change_field_label', 'my_change_field_label', 10, 2 );
|
1359 |
+
* function my_form_fields( $label, $key ) {
|
1360 |
+
* // your code here
|
1361 |
+
* return $label;
|
1362 |
+
* }
|
1363 |
+
* ?>
|
1364 |
+
*/
|
1365 |
+
$label = apply_filters( 'um_change_field_label', $label, $key );
|
1366 |
+
|
1367 |
+
$label = sprintf( __( '%s', 'ultimate-member' ), $label );
|
1368 |
+
return $label;
|
1369 |
+
}
|
1370 |
+
|
1371 |
+
|
1372 |
+
/**
|
1373 |
+
* Get field title
|
1374 |
+
*
|
1375 |
+
* @param string $key
|
1376 |
+
*
|
1377 |
+
* @return string
|
1378 |
+
*/
|
1379 |
+
function get_field_title( $key ) {
|
1380 |
+
$fields = UM()->builtin()->all_user_fields;
|
1381 |
+
if ( isset( $fields[ $key ]['title'] ) ) {
|
1382 |
+
return $fields[ $key ]['title'];
|
1383 |
+
}
|
1384 |
+
if ( isset( $fields[ $key ]['label'] ) ) {
|
1385 |
+
return $fields[ $key ]['label'];
|
1386 |
+
}
|
1387 |
+
|
1388 |
+
return __( 'Custom Field', 'ultimate-member' );
|
1389 |
+
}
|
1390 |
+
|
1391 |
+
|
1392 |
+
/**
|
1393 |
+
* Get form fields
|
1394 |
+
*
|
1395 |
+
* @return array
|
1396 |
+
*/
|
1397 |
+
function get_fields() {
|
1398 |
+
/**
|
1399 |
+
* UM hook
|
1400 |
+
*
|
1401 |
+
* @type filter
|
1402 |
+
* @title um_get_form_fields
|
1403 |
+
* @description Extend form fields
|
1404 |
+
* @input_vars
|
1405 |
+
* [{"var":"$fields","type":"array","desc":"Selected filter value"}]
|
1406 |
+
* @change_log
|
1407 |
+
* ["Since: 2.0"]
|
1408 |
+
* @usage add_filter( 'um_get_form_fields', 'function_name', 10, 1 );
|
1409 |
+
* @example
|
1410 |
+
* <?php
|
1411 |
+
* add_filter( 'um_get_form_fields', 'my_form_fields', 10, 1 );
|
1412 |
+
* function my_form_fields( $fields ) {
|
1413 |
+
* // your code here
|
1414 |
+
* return $fields;
|
1415 |
+
* }
|
1416 |
+
* ?>
|
1417 |
+
*/
|
1418 |
+
$this->fields = apply_filters( 'um_get_form_fields', array() );
|
1419 |
+
return $this->fields;
|
1420 |
+
}
|
1421 |
+
|
1422 |
+
|
1423 |
+
/**
|
1424 |
+
* Get specific field
|
1425 |
+
*
|
1426 |
+
* @param $key
|
1427 |
+
*
|
1428 |
+
* @return mixed
|
1429 |
+
* @throws \Exception
|
1430 |
+
*/
|
1431 |
+
function get_field( $key ) {
|
1432 |
+
$fields = $this->get_fields();
|
1433 |
+
|
1434 |
+
if ( isset( $fields ) && is_array( $fields ) && isset( $fields[ $key ] ) ) {
|
1435 |
+
$array = $fields[ $key ];
|
1436 |
+
} else {
|
1437 |
+
if ( ! isset( UM()->builtin()->predefined_fields[ $key ] ) && ! isset( UM()->builtin()->all_user_fields[ $key ] ) ) {
|
1438 |
+
return '';
|
1439 |
+
}
|
1440 |
+
$array = ( isset( UM()->builtin()->predefined_fields[ $key ] ) ) ? UM()->builtin()->predefined_fields[ $key ] : UM()->builtin()->all_user_fields[ $key ];
|
1441 |
+
}
|
1442 |
+
|
1443 |
+
$array['classes'] = null;
|
1444 |
+
|
1445 |
+
if ( ! isset( $array['placeholder'] ) ) {
|
1446 |
+
$array['placeholder'] = null;
|
1447 |
+
}
|
1448 |
+
if ( ! isset( $array['required'] ) ) {
|
1449 |
+
$array['required'] = null;
|
1450 |
+
}
|
1451 |
+
if ( ! isset( $array['validate'] ) ) {
|
1452 |
+
$array['validate'] = null;
|
1453 |
+
}
|
1454 |
+
if ( ! isset( $array['default'] ) ) {
|
1455 |
+
$array['default'] = null;
|
1456 |
+
}
|
1457 |
+
|
1458 |
+
if ( isset( $array['conditions'] ) && is_array( $array['conditions'] ) && ! $this->viewing ) {
|
1459 |
+
$array['conditional'] = '';
|
1460 |
+
|
1461 |
+
foreach ( $array['conditions'] as $cond_id => $cond ) {
|
1462 |
+
$array['conditional'] .= ' data-cond-' . $cond_id . '-action="' . esc_attr( $cond[0] ) . '" data-cond-' . $cond_id . '-field="' . esc_attr( $cond[1] ) . '" data-cond-' . $cond_id . '-operator="' . esc_attr( $cond[2] ) . '" data-cond-' . $cond_id . '-value="' . esc_attr( $cond[3] ) . '"';
|
1463 |
+
}
|
1464 |
+
|
1465 |
+
$array['classes'] .= ' um-is-conditional';
|
1466 |
+
|
1467 |
+
} else {
|
1468 |
+
$array['conditional'] = null;
|
1469 |
+
}
|
1470 |
+
|
1471 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
1472 |
+
|
1473 |
+
if ( ! in_array( $array['type'], $fields_without_metakey ) ) {
|
1474 |
+
$array['classes'] .= ' um-field-' . esc_attr( $key );
|
1475 |
+
}
|
1476 |
+
$array['classes'] .= ' um-field-' . esc_attr( $array['type'] );
|
1477 |
+
$array['classes'] .= ' um-field-type_' . esc_attr( $array['type'] );
|
1478 |
+
|
1479 |
+
switch ( $array['type'] ) {
|
1480 |
+
|
1481 |
+
case 'googlemap':
|
1482 |
+
case 'youtube_video':
|
1483 |
+
case 'vimeo_video':
|
1484 |
+
case 'soundcloud_track':
|
1485 |
+
$array['disabled'] = '';
|
1486 |
+
$array['input'] = 'text';
|
1487 |
+
break;
|
1488 |
+
|
1489 |
+
case 'text':
|
1490 |
+
|
1491 |
+
$array['disabled'] = '';
|
1492 |
+
|
1493 |
+
if ( $key == 'user_login' && isset( $this->set_mode ) && $this->set_mode == 'account' ) {
|
1494 |
+
$array['disabled'] = 'disabled="disabled"';
|
1495 |
+
}
|
1496 |
+
|
1497 |
+
$array['input'] = 'text';
|
1498 |
+
|
1499 |
+
break;
|
1500 |
+
|
1501 |
+
case 'password':
|
1502 |
+
|
1503 |
+
$array['input'] = 'password';
|
1504 |
+
|
1505 |
+
break;
|
1506 |
+
|
1507 |
+
case 'number':
|
1508 |
+
|
1509 |
+
$array['disabled'] = '';
|
1510 |
+
|
1511 |
+
break;
|
1512 |
+
|
1513 |
+
case 'url':
|
1514 |
+
|
1515 |
+
$array['input'] = 'text';
|
1516 |
+
|
1517 |
+
break;
|
1518 |
+
|
1519 |
+
case 'date':
|
1520 |
+
|
1521 |
+
$array['input'] = 'text';
|
1522 |
+
|
1523 |
+
if ( ! isset( $array['format'] ) ) {
|
1524 |
+
$array['format'] = 'j M Y';
|
1525 |
+
}
|
1526 |
+
|
1527 |
+
switch ( $array['format'] ) {
|
1528 |
+
case 'j M Y':
|
1529 |
+
$js_format = 'd mmm yyyy';
|
1530 |
+
break;
|
1531 |
+
case 'j F Y':
|
1532 |
+
$js_format = 'd mmmm yyyy';
|
1533 |
+
break;
|
1534 |
+
case 'M j Y':
|
1535 |
+
$js_format = 'mmm d yyyy';
|
1536 |
+
break;
|
1537 |
+
case 'F j Y':
|
1538 |
+
$js_format = 'mmmm d yyyy';
|
1539 |
+
break;
|
1540 |
+
}
|
1541 |
+
|
1542 |
+
$array['js_format'] = $js_format;
|
1543 |
+
|
1544 |
+
if ( ! isset( $array['range'] ) ) {
|
1545 |
+
$array['range'] = 'years';
|
1546 |
+
}
|
1547 |
+
if ( ! isset( $array['years'] ) ) {
|
1548 |
+
$array['years'] = 100;
|
1549 |
+
}
|
1550 |
+
if ( ! isset( $array['years_x'] ) ) {
|
1551 |
+
$array['years_x'] = 'past';
|
1552 |
+
}
|
1553 |
+
if ( ! isset( $array['disabled_weekdays'] ) ) {
|
1554 |
+
$array['disabled_weekdays'] = '';
|
1555 |
+
}
|
1556 |
+
|
1557 |
+
if ( ! empty( $array['disabled_weekdays'] ) ) {
|
1558 |
+
$array['disabled_weekdays'] = '[' . implode( ',', $array['disabled_weekdays'] ) . ']';
|
1559 |
+
}
|
1560 |
+
|
1561 |
+
// When date range is strictly defined
|
1562 |
+
if ( $array['range'] == 'date_range' ) {
|
1563 |
+
|
1564 |
+
$array['date_min'] = str_replace( '/', ',', $array['range_start'] );
|
1565 |
+
$array['date_max'] = str_replace( '/', ',', $array['range_end'] );
|
1566 |
+
|
1567 |
+
} else {
|
1568 |
+
|
1569 |
+
if ( $array['years_x'] == 'past' ) {
|
1570 |
+
|
1571 |
+
$date = new \DateTime( date( 'Y-n-d' ) );
|
1572 |
+
$past = $date->modify( '-' . $array['years'] . ' years' );
|
1573 |
+
$past = $date->format( 'Y,n,d' );
|
1574 |
+
|
1575 |
+
$array['date_min'] = $past;
|
1576 |
+
$array['date_max'] = date( 'Y,n,d' );
|
1577 |
+
|
1578 |
+
} elseif ( $array['years_x'] == 'future' ) {
|
1579 |
+
|
1580 |
+
$date = new \DateTime( date( 'Y-n-d' ) );
|
1581 |
+
$future = $date->modify( '+' . $array['years'] . ' years' );
|
1582 |
+
$future = $date->format( 'Y,n,d' );
|
1583 |
+
|
1584 |
+
$array['date_min'] = date( 'Y,n,d' );
|
1585 |
+
$array['date_max'] = $future;
|
1586 |
+
|
1587 |
+
} else {
|
1588 |
+
|
1589 |
+
$date = new \DateTime( date( 'Y-n-d' ) );
|
1590 |
+
$date_f = new \DateTime( date( 'Y-n-d' ) );
|
1591 |
+
$past = $date->modify( '-' . ( $array['years'] / 2 ) . ' years' );
|
1592 |
+
$past = $date->format( 'Y,n,d' );
|
1593 |
+
$future = $date_f->modify( '+' . ( $array['years'] / 2 ) . ' years' );
|
1594 |
+
$future = $date_f->format( 'Y,n,d' );
|
1595 |
+
|
1596 |
+
$array['date_min'] = $past;
|
1597 |
+
$array['date_max'] = $future;
|
1598 |
+
|
1599 |
+
}
|
1600 |
+
|
1601 |
+
}
|
1602 |
+
|
1603 |
+
break;
|
1604 |
+
|
1605 |
+
case 'time':
|
1606 |
+
|
1607 |
+
$array['input'] = 'text';
|
1608 |
+
|
1609 |
+
if ( ! isset( $array['format'] ) ) {
|
1610 |
+
$array['format'] = 'g:i a';
|
1611 |
+
}
|
1612 |
+
|
1613 |
+
switch ( $array['format'] ) {
|
1614 |
+
case 'g:i a':
|
1615 |
+
$js_format = 'h:i a';
|
1616 |
+
break;
|
1617 |
+
case 'g:i A':
|
1618 |
+
$js_format = 'h:i A';
|
1619 |
+
break;
|
1620 |
+
case 'H:i':
|
1621 |
+
$js_format = 'HH:i';
|
1622 |
+
break;
|
1623 |
+
}
|
1624 |
+
|
1625 |
+
$array['js_format'] = $js_format;
|
1626 |
+
|
1627 |
+
if ( ! isset( $array['intervals'] ) ) {
|
1628 |
+
$array['intervals'] = 60;
|
1629 |
+
}
|
1630 |
+
|
1631 |
+
break;
|
1632 |
+
|
1633 |
+
case 'textarea':
|
1634 |
+
|
1635 |
+
if ( ! isset( $array['height'] ) ) {
|
1636 |
+
$array['height'] = '100px';
|
1637 |
+
}
|
1638 |
+
|
1639 |
+
break;
|
1640 |
+
|
1641 |
+
case 'rating':
|
1642 |
+
|
1643 |
+
if ( ! isset( $array['number'] ) ) {
|
1644 |
+
$array['number'] = 5;
|
1645 |
+
}
|
1646 |
+
|
1647 |
+
break;
|
1648 |
+
|
1649 |
+
case 'spacing':
|
1650 |
+
|
1651 |
+
if ( ! isset( $array['spacing'] ) ) {
|
1652 |
+
$array['spacing'] = '20px';
|
1653 |
+
}
|
1654 |
+
|
1655 |
+
break;
|
1656 |
+
|
1657 |
+
case 'divider':
|
1658 |
+
|
1659 |
+
if ( isset( $array['width'] ) ) {
|
1660 |
+
$array['borderwidth'] = $array['width'];
|
1661 |
+
} else {
|
1662 |
+
$array['borderwidth'] = 4;
|
1663 |
+
}
|
1664 |
+
|
1665 |
+
if ( isset( $array['color'] ) ) {
|
1666 |
+
$array['bordercolor'] = $array['color'];
|
1667 |
+
} else {
|
1668 |
+
$array['bordercolor'] = '#eee';
|
1669 |
+
}
|
1670 |
+
|
1671 |
+
if ( isset( $array['style'] ) ) {
|
1672 |
+
$array['borderstyle'] = $array['style'];
|
1673 |
+
} else {
|
1674 |
+
$array['borderstyle'] = 'solid';
|
1675 |
+
}
|
1676 |
+
|
1677 |
+
if ( ! isset( $array['divider_text'] ) ) {
|
1678 |
+
$array['divider_text'] = '';
|
1679 |
+
}
|
1680 |
+
|
1681 |
+
break;
|
1682 |
+
|
1683 |
+
case 'image':
|
1684 |
+
|
1685 |
+
if ( ! isset( $array['crop'] ) ) {
|
1686 |
+
$array['crop'] = 0;
|
1687 |
+
}
|
1688 |
+
|
1689 |
+
if ( $array['crop'] == 0 ) {
|
1690 |
+
$array['crop_data'] = 0;
|
1691 |
+
} elseif ( $array['crop'] == 1 ) {
|
1692 |
+
$array['crop_data'] = 'square';
|
1693 |
+
} elseif ( $array['crop'] == 2 ) {
|
1694 |
+
$array['crop_data'] = 'cover';
|
1695 |
+
} else {
|
1696 |
+
$array['crop_data'] = 'user';
|
1697 |
+
}
|
1698 |
+
|
1699 |
+
if ( ! isset( $array['modal_size'] ) ) {
|
1700 |
+
$array['modal_size'] = 'normal';
|
1701 |
+
}
|
1702 |
+
|
1703 |
+
if ( $array['crop'] > 0 ) {
|
1704 |
+
$array['crop_class'] = 'crop';
|
1705 |
+
} else {
|
1706 |
+
$array['crop_class'] = '';
|
1707 |
+
}
|
1708 |
+
|
1709 |
+
if ( ! isset( $array['ratio'] ) ) {
|
1710 |
+
$array['ratio'] = 1.0;
|
1711 |
+
}
|
1712 |
+
|
1713 |
+
if ( ! isset( $array['min_width'] ) ) {
|
1714 |
+
$array['min_width'] = '';
|
1715 |
+
}
|
1716 |
+
if ( ! isset( $array['min_height'] ) ) {
|
1717 |
+
$array['min_height'] = '';
|
1718 |
+
}
|
1719 |
+
|
1720 |
+
if ( $array['min_width'] == '' && $array['crop'] == 1 ) {
|
1721 |
+
$array['min_width'] = 600;
|
1722 |
+
}
|
1723 |
+
if ( $array['min_height'] == '' && $array['crop'] == 1 ) {
|
1724 |
+
$array['min_height'] = 600;
|
1725 |
+
}
|
1726 |
+
|
1727 |
+
if ( $array['min_width'] == '' && $array['crop'] == 3 ) {
|
1728 |
+
$array['min_width'] = 600;
|
1729 |
+
}
|
1730 |
+
if ( $array['min_height'] == '' && $array['crop'] == 3 ) {
|
1731 |
+
$array['min_height'] = 600;
|
1732 |
+
}
|
1733 |
+
|
1734 |
+
if ( ! isset( $array['invalid_image'] ) ) {
|
1735 |
+
$array['invalid_image'] = __( 'Please upload a valid image!', 'ultimate-member' );
|
1736 |
+
}
|
1737 |
+
if ( ! isset( $array['allowed_types'] ) ) {
|
1738 |
+
$array['allowed_types'] = 'gif,jpg,jpeg,png';
|
1739 |
+
} else {
|
1740 |
+
$array['allowed_types'] = implode( ',', $array['allowed_types'] );
|
1741 |
+
}
|
1742 |
+
if ( ! isset( $array['upload_text'] ) ) {
|
1743 |
+
$array['upload_text'] = '';
|
1744 |
+
}
|
1745 |
+
if ( ! isset( $array['button_text'] ) ) {
|
1746 |
+
$array['button_text'] = __( 'Upload', 'ultimate-member' );
|
1747 |
+
}
|
1748 |
+
if ( ! isset( $array['extension_error'] ) ) {
|
1749 |
+
$array['extension_error'] = __( 'Sorry this is not a valid image.', 'ultimate-member' );
|
1750 |
+
}
|
1751 |
+
if ( ! isset( $array['max_size_error'] ) ) {
|
1752 |
+
$array['max_size_error'] = __( 'This image is too large!', 'ultimate-member' );
|
1753 |
+
}
|
1754 |
+
if ( ! isset( $array['min_size_error'] ) ) {
|
1755 |
+
$array['min_size_error'] = __( 'This image is too small!', 'ultimate-member' );
|
1756 |
+
}
|
1757 |
+
if ( ! isset( $array['max_files_error'] ) ) {
|
1758 |
+
$array['max_files_error'] = __( 'You can only upload one image', 'ultimate-member' );
|
1759 |
+
}
|
1760 |
+
if ( ! isset( $array['max_size'] ) ) {
|
1761 |
+
$array['max_size'] = 999999999;
|
1762 |
+
}
|
1763 |
+
if ( ! isset( $array['upload_help_text'] ) ) {
|
1764 |
+
$array['upload_help_text'] = '';
|
1765 |
+
}
|
1766 |
+
if ( ! isset( $array['icon'] ) ) {
|
1767 |
+
$array['icon'] = '';
|
1768 |
+
}
|
1769 |
+
|
1770 |
+
break;
|
1771 |
+
|
1772 |
+
case 'file':
|
1773 |
+
|
1774 |
+
if ( ! isset( $array['modal_size'] ) ) {
|
1775 |
+
$array['modal_size'] = 'normal';
|
1776 |
+
}
|
1777 |
+
|
1778 |
+
if ( ! isset( $array['allowed_types'] ) ) {
|
1779 |
+
$array['allowed_types'] = 'pdf,txt';
|
1780 |
+
} else {
|
1781 |
+
$array['allowed_types'] = implode( ',', $array['allowed_types'] );
|
1782 |
+
}
|
1783 |
+
if ( ! isset( $array['upload_text'] ) ) {
|
1784 |
+
$array['upload_text'] = '';
|
1785 |
+
}
|
1786 |
+
if ( ! isset( $array['button_text'] ) ) {
|
1787 |
+
$array['button_text'] = __( 'Upload', 'ultimate-member' );
|
1788 |
+
}
|
1789 |
+
if ( ! isset( $array['extension_error'] ) ) {
|
1790 |
+
$array['extension_error'] = __( 'Sorry this is not a valid file.', 'ultimate-member' );
|
1791 |
+
}
|
1792 |
+
if ( ! isset( $array['max_size_error'] ) ) {
|
1793 |
+
$array['max_size_error'] = __( 'This file is too large!', 'ultimate-member' );
|
1794 |
+
}
|
1795 |
+
if ( ! isset( $array['min_size_error'] ) ) {
|
1796 |
+
$array['min_size_error'] = __( 'This file is too small!', 'ultimate-member' );
|
1797 |
+
}
|
1798 |
+
if ( ! isset( $array['max_files_error'] ) ) {
|
1799 |
+
$array['max_files_error'] = __( 'You can only upload one file', 'ultimate-member' );
|
1800 |
+
}
|
1801 |
+
if ( ! isset( $array['max_size'] ) ) {
|
1802 |
+
$array['max_size'] = 999999999;
|
1803 |
+
}
|
1804 |
+
if ( ! isset( $array['upload_help_text'] ) ) {
|
1805 |
+
$array['upload_help_text'] = '';
|
1806 |
+
}
|
1807 |
+
if ( ! isset( $array['icon'] ) ) {
|
1808 |
+
$array['icon'] = '';
|
1809 |
+
}
|
1810 |
+
|
1811 |
+
break;
|
1812 |
+
|
1813 |
+
case 'select':
|
1814 |
+
|
1815 |
+
break;
|
1816 |
+
|
1817 |
+
case 'multiselect':
|
1818 |
+
|
1819 |
+
break;
|
1820 |
+
|
1821 |
+
case 'group':
|
1822 |
+
|
1823 |
+
if ( ! isset( $array['max_entries'] ) ) {
|
1824 |
+
$array['max_entries'] = 0;
|
1825 |
+
}
|
1826 |
+
|
1827 |
+
break;
|
1828 |
+
|
1829 |
+
}
|
1830 |
+
|
1831 |
+
if ( ! isset( $array['visibility'] ) ) {
|
1832 |
+
$array['visibility'] = 'all';
|
1833 |
+
}
|
1834 |
+
|
1835 |
+
/**
|
1836 |
+
* UM hook
|
1837 |
+
*
|
1838 |
+
* @type filter
|
1839 |
+
* @title um_get_field__{$key}
|
1840 |
+
* @description Extend field data by field $key
|
1841 |
+
* @input_vars
|
1842 |
+
* [{"var":"$data","type":"array","desc":"Field Data"}]
|
1843 |
+
* @change_log
|
1844 |
+
* ["Since: 2.0"]
|
1845 |
+
* @usage add_filter( 'um_get_field__{$key}', 'function_name', 10, 1 );
|
1846 |
+
* @example
|
1847 |
+
* <?php
|
1848 |
+
* add_filter( 'um_get_field__{$key}', 'my_get_field', 10, 1 );
|
1849 |
+
* function my_get_field( $data ) {
|
1850 |
+
* // your code here
|
1851 |
+
* return $data;
|
1852 |
+
* }
|
1853 |
+
* ?>
|
1854 |
+
*/
|
1855 |
+
$array = apply_filters( "um_get_field__{$key}", $array );
|
1856 |
+
|
1857 |
+
return $array;
|
1858 |
+
}
|
1859 |
+
|
1860 |
+
|
1861 |
+
/**
|
1862 |
+
* @param $option_value
|
1863 |
+
*
|
1864 |
+
* @return mixed|void
|
1865 |
+
*/
|
1866 |
+
function filter_field_non_utf8_value( $option_value ) {
|
1867 |
+
/**
|
1868 |
+
* UM hook
|
1869 |
+
*
|
1870 |
+
* @type filter
|
1871 |
+
* @title um_field_non_utf8_value
|
1872 |
+
* @description Change dropdown option text
|
1873 |
+
* @input_vars
|
1874 |
+
* [{"var":"$value","type":"string","desc":"Option Value"}]
|
1875 |
+
* @change_log
|
1876 |
+
* ["Since: 2.0"]
|
1877 |
+
* @usage add_filter( 'um_field_non_utf8_value', 'function_name', 10, 1 );
|
1878 |
+
* @example
|
1879 |
+
* <?php
|
1880 |
+
* add_filter( 'um_field_non_utf8_value', 'my_field_non_utf8_value', 10, 1 );
|
1881 |
+
* function my_field_non_utf8_value( $value ) {
|
1882 |
+
* // your code here
|
1883 |
+
* return $value;
|
1884 |
+
* }
|
1885 |
+
* ?>
|
1886 |
+
*/
|
1887 |
+
return apply_filters( 'um_field_non_utf8_value', $option_value );
|
1888 |
+
}
|
1889 |
+
|
1890 |
+
|
1891 |
+
/**
|
1892 |
+
* Getting the fields that need to be disabled in edit mode (profile)
|
1893 |
+
*
|
1894 |
+
* @param bool $_um_profile_id
|
1895 |
+
*
|
1896 |
+
* @return array
|
1897 |
+
*/
|
1898 |
+
function get_restricted_fields_for_edit( $_um_profile_id = false ) {
|
1899 |
+
// fields that need to be disabled in edit mode (profile)
|
1900 |
+
$arr_restricted_fields = array( 'user_email', 'username', 'user_login', 'user_password', '_um_last_login' );
|
1901 |
+
$arr_restricted_fields = apply_filters( 'um_user_profile_restricted_edit_fields', $arr_restricted_fields, $_um_profile_id );
|
1902 |
+
|
1903 |
+
return $arr_restricted_fields;
|
1904 |
+
}
|
1905 |
+
|
1906 |
+
|
1907 |
+
/**
|
1908 |
+
* Gets a field in 'input mode'
|
1909 |
+
*
|
1910 |
+
* @param string $key
|
1911 |
+
* @param array $data
|
1912 |
+
* @param bool $rule
|
1913 |
+
* @param array $args
|
1914 |
+
*
|
1915 |
+
* @return string|null
|
1916 |
+
* @throws \Exception
|
1917 |
+
*/
|
1918 |
+
function edit_field( $key, $data, $rule = false, $args = array() ) {
|
1919 |
+
global $_um_profile_id;
|
1920 |
+
|
1921 |
+
$output = '';
|
1922 |
+
$disabled = '';
|
1923 |
+
if ( empty( $_um_profile_id ) ) {
|
1924 |
+
$_um_profile_id = um_user( 'ID' );
|
1925 |
+
}
|
1926 |
+
|
1927 |
+
// get whole field data
|
1928 |
+
if ( isset( $data ) && is_array( $data ) ) {
|
1929 |
+
$data = $this->get_field( $key );
|
1930 |
+
if ( is_array( $data ) ) {
|
1931 |
+
/**
|
1932 |
+
* @var string $in_row
|
1933 |
+
* @var boolean $in_sub_row
|
1934 |
+
* @var boolean $in_column
|
1935 |
+
* @var string $type
|
1936 |
+
* @var string $metakey
|
1937 |
+
* @var int $position
|
1938 |
+
* @var string $title
|
1939 |
+
* @var string $help
|
1940 |
+
* @var array $options
|
1941 |
+
* @var string $visibility
|
1942 |
+
* @var string $label
|
1943 |
+
* @var string $placeholder
|
1944 |
+
* @var boolean $public
|
1945 |
+
* @var boolean $editable
|
1946 |
+
* @var string $icon
|
1947 |
+
* @var boolean $in_group
|
1948 |
+
* @var boolean $required
|
1949 |
+
* @var string $validate
|
1950 |
+
* @var string $default
|
1951 |
+
* @var string $conditional
|
1952 |
+
* @var string $input
|
1953 |
+
* @var string $js_format
|
1954 |
+
* @var string $date_max
|
1955 |
+
* @var string $date_min
|
1956 |
+
* @var string $disabled_weekdays
|
1957 |
+
* @var string $years_x
|
1958 |
+
* @var string $years
|
1959 |
+
* @var string $range
|
1960 |
+
* @var string $intervals
|
1961 |
+
* @var string $height
|
1962 |
+
* @var string $spacing
|
1963 |
+
* @var string $borderwidth
|
1964 |
+
* @var string $borderstyle
|
1965 |
+
* @var string $bordercolor
|
1966 |
+
* @var string $divider_text
|
1967 |
+
* @var string $crop_class
|
1968 |
+
* @var string $crop_data
|
1969 |
+
* @var string $modal_size
|
1970 |
+
* @var string $ratio
|
1971 |
+
* @var string $min_width
|
1972 |
+
* @var string $min_height
|
1973 |
+
* @var string $button_text
|
1974 |
+
* @var string $max_size
|
1975 |
+
* @var string $max_size_error
|
1976 |
+
* @var string $extension_error
|
1977 |
+
* @var string $allowed_types
|
1978 |
+
* @var string $upload_text
|
1979 |
+
* @var string $max_files_error
|
1980 |
+
* @var string $upload_help_text
|
1981 |
+
* @var string $min_size_error
|
1982 |
+
* @var string $filter
|
1983 |
+
* @var string $content
|
1984 |
+
* @var string $max_entries
|
1985 |
+
*/
|
1986 |
+
extract( $data );
|
1987 |
+
}
|
1988 |
+
}
|
1989 |
+
|
1990 |
+
if ( ! isset( $data['type'] ) ) {
|
1991 |
+
return '';
|
1992 |
+
}
|
1993 |
+
|
1994 |
+
if ( isset( $data['in_group'] ) && $data['in_group'] != '' && $rule != 'group' ) {
|
1995 |
+
return '';
|
1996 |
+
}
|
1997 |
+
|
1998 |
+
// forbidden in edit mode? 'edit_forbidden' - it's field attribute predefined in the field data in code
|
1999 |
+
if ( isset( $data['edit_forbidden'] ) ) {
|
2000 |
+
return '';
|
2001 |
+
}
|
2002 |
+
|
2003 |
+
// required option? 'required_opt' - it's field attribute predefined in the field data in code
|
2004 |
+
if ( isset( $data['required_opt'] ) ) {
|
2005 |
+
$opt = $data['required_opt'];
|
2006 |
+
if ( UM()->options()->get( $opt[0] ) != $opt[1] ) {
|
2007 |
+
return '';
|
2008 |
+
}
|
2009 |
+
}
|
2010 |
+
|
2011 |
+
// required user permission 'required_perm' - it's field attribute predefined in the field data in code
|
2012 |
+
if ( isset( $data['required_perm'] ) ) {
|
2013 |
+
if ( ! UM()->roles()->um_user_can( $data['required_perm'] ) ) {
|
2014 |
+
return '';
|
2015 |
+
}
|
2016 |
+
}
|
2017 |
+
|
2018 |
+
// fields that need to be disabled in edit mode (profile) (email, username, etc.)
|
2019 |
+
$arr_restricted_fields = $this->get_restricted_fields_for_edit( $_um_profile_id );
|
2020 |
+
if ( in_array( $key, $arr_restricted_fields ) && $this->editing == true && $this->set_mode == 'profile' ) {
|
2021 |
+
return '';
|
2022 |
+
}
|
2023 |
+
|
2024 |
+
|
2025 |
+
if ( $visibility == 'view' && $this->set_mode != 'register' ) {
|
2026 |
+
return '';
|
2027 |
+
}
|
2028 |
+
|
2029 |
+
if ( ! um_can_view_field( $data ) ) {
|
2030 |
+
return '';
|
2031 |
+
}
|
2032 |
+
|
2033 |
+
um_fetch_user( $_um_profile_id );
|
2034 |
+
|
2035 |
+
// Stop return empty values build field attributes:
|
2036 |
+
|
2037 |
+
if ( $visibility == 'view' && $this->set_mode == 'register' ) {
|
2038 |
+
|
2039 |
+
um_fetch_user( get_current_user_id() );
|
2040 |
+
if ( ! um_user( 'can_edit_everyone' ) ) {
|
2041 |
+
$disabled = ' disabled="disabled" ';
|
2042 |
+
}
|
2043 |
+
|
2044 |
+
um_fetch_user( $_um_profile_id );
|
2045 |
+
if ( isset( $data['public'] ) && $data['public'] == '-2' && $data['roles'] ) {
|
2046 |
+
$current_user_roles = um_user( 'roles' );
|
2047 |
+
if ( ! empty( $current_user_roles ) && count( array_intersect( $current_user_roles, $data['roles'] ) ) > 0 ) {
|
2048 |
+
$disabled = '';
|
2049 |
+
}
|
2050 |
+
}
|
2051 |
+
}
|
2052 |
+
|
2053 |
+
if ( ! empty( $this->editing ) && $this->set_mode == 'profile' ) {
|
2054 |
+
if ( ! UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
2055 |
+
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
2056 |
+
$disabled = ' disabled="disabled" ';
|
2057 |
+
}
|
2058 |
+
}
|
2059 |
+
}
|
2060 |
+
|
2061 |
+
$disabled = apply_filters( 'um_is_field_disabled', $disabled, $data );
|
2062 |
+
|
2063 |
+
if ( ! isset( $data['autocomplete'] ) ) {
|
2064 |
+
$autocomplete = 'off';
|
2065 |
+
}
|
2066 |
+
|
2067 |
+
if ( isset( $data['classes'] ) ) {
|
2068 |
+
$classes = explode( " ", $data['classes'] );
|
2069 |
+
}
|
2070 |
+
|
2071 |
+
um_fetch_user( $_um_profile_id );
|
2072 |
+
|
2073 |
+
/**
|
2074 |
+
* UM hook
|
2075 |
+
*
|
2076 |
+
* @type filter
|
2077 |
+
* @title um_hook_for_field_{$type}
|
2078 |
+
* @description Change field type
|
2079 |
+
* @input_vars
|
2080 |
+
* [{"var":"$type","type":"string","desc":"Field Type"}]
|
2081 |
+
* @change_log
|
2082 |
+
* ["Since: 2.0"]
|
2083 |
+
* @usage add_filter( 'um_hook_for_field_{$type}', 'function_name', 10, 1 );
|
2084 |
+
* @example
|
2085 |
+
* <?php
|
2086 |
+
* add_filter( 'um_hook_for_field_{$type}', 'my_field_type', 10, 1 );
|
2087 |
+
* function my_get_field( $type ) {
|
2088 |
+
* // your code here
|
2089 |
+
* return $type;
|
2090 |
+
* }
|
2091 |
+
* ?>
|
2092 |
+
*/
|
2093 |
+
$type = apply_filters( "um_hook_for_field_{$type}", $type );
|
2094 |
+
switch ( $type ) {
|
2095 |
+
|
2096 |
+
case 'textarea':
|
2097 |
+
case 'multiselect':
|
2098 |
+
$field_id = $field_name = $key;
|
2099 |
+
$field_value = $this->field_value( $key, $default, $data );
|
2100 |
+
break;
|
2101 |
+
|
2102 |
+
case 'select':
|
2103 |
+
case 'radio':
|
2104 |
+
$form_key = str_replace( array( 'role_select', 'role_radio' ), 'role', $key );
|
2105 |
+
$field_id = $form_key;
|
2106 |
+
break;
|
2107 |
+
default:
|
2108 |
+
$field_id = '';
|
2109 |
+
break;
|
2110 |
+
}
|
2111 |
+
|
2112 |
+
/**
|
2113 |
+
* UM hook
|
2114 |
+
*
|
2115 |
+
* @type filter
|
2116 |
+
* @title um_completeness_field_id
|
2117 |
+
* @description use for change core id not allowed duplicate
|
2118 |
+
* @input_vars
|
2119 |
+
* [{"var":"$field_id","type":"string","desc":"Field id"},
|
2120 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2121 |
+
* {"var":"$args","type":"array","desc":"Optional field arguments"}]
|
2122 |
+
* @change_log
|
2123 |
+
* ["Since: 2.0.13"]
|
2124 |
+
* @usage add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
|
2125 |
+
* @example
|
2126 |
+
* <?php
|
2127 |
+
* add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
|
2128 |
+
* function function_name( $field_id, $data, $args ) {
|
2129 |
+
* // your code here
|
2130 |
+
* return $field_id;
|
2131 |
+
* }
|
2132 |
+
* ?>
|
2133 |
+
*/
|
2134 |
+
$field_id = apply_filters( 'um_completeness_field_id', $field_id, $data, $args );
|
2135 |
+
|
2136 |
+
|
2137 |
+
/* Begin by field type */
|
2138 |
+
switch ( $type ) {
|
2139 |
+
|
2140 |
+
/* Default: Integration */
|
2141 |
+
default:
|
2142 |
+
$mode = ( isset( $this->set_mode ) ) ? $this->set_mode : 'no_mode';
|
2143 |
+
|
2144 |
+
/**
|
2145 |
+
* UM hook
|
2146 |
+
*
|
2147 |
+
* @type filter
|
2148 |
+
* @title um_edit_field_{$mode}_{$type}
|
2149 |
+
* @description Change field html by $mode and field $type
|
2150 |
+
* @input_vars
|
2151 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
2152 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2153 |
+
* @change_log
|
2154 |
+
* ["Since: 2.0"]
|
2155 |
+
* @usage add_filter( 'um_edit_field_{$mode}_{$type}', 'function_name', 10, 2 );
|
2156 |
+
* @example
|
2157 |
+
* <?php
|
2158 |
+
* add_filter( 'um_edit_field_{$mode}_{$type}', 'my_edit_field_html', 10, 2 );
|
2159 |
+
* function my_edit_field_html( $output, $data ) {
|
2160 |
+
* // your code here
|
2161 |
+
* return $output;
|
2162 |
+
* }
|
2163 |
+
* ?>
|
2164 |
+
*/
|
2165 |
+
|
2166 |
+
$output .= apply_filters( "um_edit_field_{$mode}_{$type}", $output, $data );
|
2167 |
+
break;
|
2168 |
+
|
2169 |
+
/* Other fields */
|
2170 |
+
case 'googlemap':
|
2171 |
+
case 'youtube_video':
|
2172 |
+
case 'vimeo_video':
|
2173 |
+
case 'soundcloud_track':
|
2174 |
+
|
2175 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2176 |
+
|
2177 |
+
if ( isset( $data['label'] ) ) {
|
2178 |
+
$output .= $this->field_label( $label, $key, $data );
|
2179 |
+
}
|
2180 |
+
|
2181 |
+
$output .= '<div class="um-field-area">';
|
2182 |
+
|
2183 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2184 |
+
|
2185 |
+
$output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
|
2186 |
+
|
2187 |
+
}
|
2188 |
+
|
2189 |
+
$field_name = $key . UM()->form()->form_suffix;
|
2190 |
+
$field_value = htmlspecialchars( $this->field_value( $key, $default, $data ) );
|
2191 |
+
|
2192 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_name ) . '" value="' . esc_attr( $field_value ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2193 |
+
|
2194 |
+
</div>';
|
2195 |
+
|
2196 |
+
if ( ! empty( $disabled ) ) {
|
2197 |
+
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2198 |
+
}
|
2199 |
+
|
2200 |
+
if ( $this->is_error( $key ) ) {
|
2201 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2202 |
+
}else if ( $this->is_notice( $key ) ) {
|
2203 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2204 |
+
}
|
2205 |
+
|
2206 |
+
$output .= '</div>';
|
2207 |
+
break;
|
2208 |
+
|
2209 |
+
/* Text */
|
2210 |
+
case 'text':
|
2211 |
+
|
2212 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2213 |
+
|
2214 |
+
if ( isset( $data['label'] ) ) {
|
2215 |
+
$output .= $this->field_label( $label, $key, $data );
|
2216 |
+
}
|
2217 |
+
|
2218 |
+
$output .= '<div class="um-field-area">';
|
2219 |
+
|
2220 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2221 |
+
|
2222 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2223 |
+
|
2224 |
+
}
|
2225 |
+
|
2226 |
+
$field_name = $key . UM()->form()->form_suffix;
|
2227 |
+
$field_value = htmlspecialchars( $this->field_value( $key, $default, $data ) );
|
2228 |
+
|
2229 |
+
$output .= '<input ' . $disabled . ' autocomplete="' . esc_attr( $autocomplete ) . '" class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_name ) . '" value="' . esc_attr( $field_value ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2230 |
+
|
2231 |
+
</div>';
|
2232 |
+
|
2233 |
+
if ( ! empty( $disabled ) ) {
|
2234 |
+
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2235 |
+
}
|
2236 |
+
|
2237 |
+
if ( $this->is_error( $key ) ) {
|
2238 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2239 |
+
}else if ( $this->is_notice( $key ) ) {
|
2240 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2241 |
+
}
|
2242 |
+
|
2243 |
+
$output .= '</div>';
|
2244 |
+
break;
|
2245 |
+
|
2246 |
+
/* Number */
|
2247 |
+
case 'number':
|
2248 |
+
|
2249 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2250 |
+
|
2251 |
+
if ( isset( $data['label'] ) ) {
|
2252 |
+
$output .= $this->field_label( $label, $key, $data );
|
2253 |
+
}
|
2254 |
+
|
2255 |
+
$output .= '<div class="um-field-area">';
|
2256 |
+
|
2257 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2258 |
+
|
2259 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2260 |
+
|
2261 |
+
}
|
2262 |
+
|
2263 |
+
$number_limit = '';
|
2264 |
+
if ( isset( $min ) ) {
|
2265 |
+
$number_limit .= ' min="' . esc_attr( $min ) . '" ';
|
2266 |
+
}
|
2267 |
+
if ( isset( $max ) ) {
|
2268 |
+
$number_limit .= ' max="' . esc_attr( $max ) . '" ';
|
2269 |
+
}
|
2270 |
+
|
2271 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="number" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . esc_attr( htmlspecialchars( $this->field_value( $key, $default, $data ) ) ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" ' . $number_limit . ' />
|
2272 |
+
|
2273 |
+
</div>';
|
2274 |
+
|
2275 |
+
if ( $this->is_error( $key ) ) {
|
2276 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2277 |
+
}else if ( $this->is_notice( $key ) ) {
|
2278 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2279 |
+
}
|
2280 |
+
|
2281 |
+
$output .= '</div>';
|
2282 |
+
break;
|
2283 |
+
|
2284 |
+
/* Password */
|
2285 |
+
case 'password':
|
2286 |
+
|
2287 |
+
$original_key = $key;
|
2288 |
+
|
2289 |
+
if ( $key == 'single_user_password' ) {
|
2290 |
+
|
2291 |
+
$key = $original_key;
|
2292 |
+
|
2293 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2294 |
+
|
2295 |
+
if ( isset( $data['label'] ) ) {
|
2296 |
+
$output .= $this->field_label( $label, $key, $data );
|
2297 |
+
}
|
2298 |
+
|
2299 |
+
$output .= '<div class="um-field-area">';
|
2300 |
+
|
2301 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2302 |
+
|
2303 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2304 |
+
|
2305 |
+
}
|
2306 |
+
|
2307 |
+
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2308 |
+
|
2309 |
+
</div>';
|
2310 |
+
|
2311 |
+
if ( $this->is_error( $key ) ) {
|
2312 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2313 |
+
}else if ( $this->is_notice( $key ) ) {
|
2314 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2315 |
+
}
|
2316 |
+
|
2317 |
+
$output .= '</div>';
|
2318 |
+
|
2319 |
+
} else {
|
2320 |
+
|
2321 |
+
if ( UM()->account()->current_password_is_required( 'password' ) &&
|
2322 |
+
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
2323 |
+
|
2324 |
+
$key = 'current_' . $original_key;
|
2325 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2326 |
+
|
2327 |
+
if ( isset( $data['label'] ) ) {
|
2328 |
+
$output .= $this->field_label( __( 'Current Password', 'ultimate-member' ), $key, $data );
|
2329 |
+
}
|
2330 |
+
|
2331 |
+
$output .= '<div class="um-field-area">';
|
2332 |
+
|
2333 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
2334 |
+
|
2335 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2336 |
+
|
2337 |
+
}
|
2338 |
+
|
2339 |
+
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2340 |
+
|
2341 |
+
</div>';
|
2342 |
+
|
2343 |
+
if ( $this->is_error( $key ) ) {
|
2344 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2345 |
+
} elseif ( $this->is_notice( $key ) ) {
|
2346 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2347 |
+
}
|
2348 |
+
|
2349 |
+
$output .= '</div>';
|
2350 |
+
|
2351 |
+
}
|
2352 |
+
|
2353 |
+
$key = $original_key;
|
2354 |
+
|
2355 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2356 |
+
|
2357 |
+
if ( $this->set_mode == 'account' && um_is_core_page( 'account' ) || $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2358 |
+
|
2359 |
+
$output .= $this->field_label( __( 'New Password', 'ultimate-member' ), $key, $data );
|
2360 |
+
|
2361 |
+
} elseif ( isset( $data['label'] ) ) {
|
2362 |
+
|
2363 |
+
$output .= $this->field_label( $label, $key, $data );
|
2364 |
+
|
2365 |
+
}
|
2366 |
+
|
2367 |
+
$output .= '<div class="um-field-area">';
|
2368 |
+
|
2369 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
2370 |
+
|
2371 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2372 |
+
|
2373 |
+
}
|
2374 |
+
|
2375 |
+
$name = $key . UM()->form()->form_suffix;
|
2376 |
+
if ( $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2377 |
+
$name = $key;
|
2378 |
+
}
|
2379 |
+
|
2380 |
+
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $name ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2381 |
+
|
2382 |
+
</div>';
|
2383 |
+
|
2384 |
+
if ( $this->is_error( $key ) ) {
|
2385 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2386 |
+
} elseif ( $this->is_notice( $key ) ) {
|
2387 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2388 |
+
}
|
2389 |
+
|
2390 |
+
$output .= '</div>';
|
2391 |
+
|
2392 |
+
if ( $this->set_mode != 'login' && isset( $data['force_confirm_pass'] ) && $data['force_confirm_pass'] == 1 ) {
|
2393 |
+
|
2394 |
+
$key = 'confirm_' . $original_key;
|
2395 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2396 |
+
|
2397 |
+
if ( ! empty( $data['label_confirm_pass'] ) ) {
|
2398 |
+
$label_confirm_pass = __( $data['label_confirm_pass'], 'ultimate-member' );
|
2399 |
+
$output .= $this->field_label( $label_confirm_pass, $key, $data );
|
2400 |
+
} elseif ( isset( $data['label'] ) ) {
|
2401 |
+
$data['label'] = __( $data['label'], 'ultimate-member' );
|
2402 |
+
$output .= $this->field_label( sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] ), $key, $data );
|
2403 |
+
}
|
2404 |
+
|
2405 |
+
$output .= '<div class="um-field-area">';
|
2406 |
+
|
2407 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2408 |
+
|
2409 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2410 |
+
|
2411 |
+
}
|
2412 |
+
|
2413 |
+
$name = $key . UM()->form()->form_suffix;
|
2414 |
+
if ( $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2415 |
+
$name = $key;
|
2416 |
+
}
|
2417 |
+
|
2418 |
+
if ( ! empty( $label_confirm_pass ) ) {
|
2419 |
+
$placeholder = $label_confirm_pass;
|
2420 |
+
} elseif( ! empty( $placeholder ) && ! isset( $data['label'] ) ) {
|
2421 |
+
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $placeholder );
|
2422 |
+
} elseif( isset( $data['label'] ) ) {
|
2423 |
+
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] );
|
2424 |
+
}
|
2425 |
+
|
2426 |
+
|
2427 |
+
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $name ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />';
|
2428 |
+
|
2429 |
+
|
2430 |
+
$output .= '</div>';
|
2431 |
+
|
2432 |
+
if ( $this->is_error( $key ) ) {
|
2433 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2434 |
+
}else if ( $this->is_notice( $key ) ) {
|
2435 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2436 |
+
}
|
2437 |
+
|
2438 |
+
$output .= '</div>';
|
2439 |
+
|
2440 |
+
}
|
2441 |
+
|
2442 |
+
}
|
2443 |
+
|
2444 |
+
break;
|
2445 |
+
|
2446 |
+
/* URL */
|
2447 |
+
case 'url':
|
2448 |
+
|
2449 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2450 |
+
|
2451 |
+
if ( isset( $data['label'] ) ) {
|
2452 |
+
$output .= $this->field_label( $label, $key, $data );
|
2453 |
+
}
|
2454 |
+
|
2455 |
+
$output .= '<div class="um-field-area">';
|
2456 |
+
|
2457 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2458 |
+
|
2459 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2460 |
+
|
2461 |
+
}
|
2462 |
+
|
2463 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . esc_attr( $this->field_value( $key, $default, $data ) ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2464 |
+
|
2465 |
+
</div>';
|
2466 |
+
|
2467 |
+
if ( $this->is_error( $key ) ) {
|
2468 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2469 |
+
}else if ( $this->is_notice( $key ) ) {
|
2470 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2471 |
+
}
|
2472 |
+
|
2473 |
+
$output .= '</div>';
|
2474 |
+
break;
|
2475 |
+
|
2476 |
+
/* Date */
|
2477 |
+
case 'date':
|
2478 |
+
|
2479 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2480 |
+
|
2481 |
+
if (isset( $data['label'] )) {
|
2482 |
+
$output .= $this->field_label( $label, $key, $data );
|
2483 |
+
}
|
2484 |
+
|
2485 |
+
$output .= '<div class="um-field-area">';
|
2486 |
+
|
2487 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2488 |
+
|
2489 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2490 |
+
|
2491 |
+
}
|
2492 |
+
|
2493 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" data-range="' . esc_attr( $range ) . '" data-years="' . esc_attr( $years ) . '" data-years_x="' . esc_attr( $years_x ) . '" data-disabled_weekdays="' . esc_attr( $disabled_weekdays ) . '" data-date_min="' . esc_attr( $date_min ) . '" data-date_max="' . esc_attr( $date_max ) . '" data-format="' . esc_attr( $js_format ) . '" data-value="' . $this->field_value( $key, $default, $data ) . '" />
|
2494 |
+
|
2495 |
+
</div>';
|
2496 |
+
|
2497 |
+
if ( $this->is_error( $key ) ) {
|
2498 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2499 |
+
}else if ( $this->is_notice( $key ) ) {
|
2500 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2501 |
+
}
|
2502 |
+
|
2503 |
+
$output .= '</div>';
|
2504 |
+
break;
|
2505 |
+
|
2506 |
+
/* Time */
|
2507 |
+
case 'time':
|
2508 |
+
|
2509 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2510 |
+
|
2511 |
+
if (isset( $data['label'] )) {
|
2512 |
+
$output .= $this->field_label( $label, $key, $data );
|
2513 |
+
}
|
2514 |
+
|
2515 |
+
$output .= '<div class="um-field-area">';
|
2516 |
+
|
2517 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2518 |
+
|
2519 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2520 |
+
|
2521 |
+
}
|
2522 |
+
|
2523 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" data-format="' . esc_attr( $js_format ) . '" data-intervals="' . esc_attr( $intervals ) . '" data-value="' . $this->field_value( $key, $default, $data ) . '" />
|
2524 |
+
|
2525 |
+
</div>';
|
2526 |
+
|
2527 |
+
if ( $this->is_error( $key ) ) {
|
2528 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2529 |
+
}else if ( $this->is_notice( $key ) ) {
|
2530 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2531 |
+
}
|
2532 |
+
|
2533 |
+
$output .= '</div>';
|
2534 |
+
break;
|
2535 |
+
|
2536 |
+
/* Row */
|
2537 |
+
case 'row':
|
2538 |
+
$output .= '';
|
2539 |
+
break;
|
2540 |
+
|
2541 |
+
/* Textarea */
|
2542 |
+
case 'textarea':
|
2543 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2544 |
+
|
2545 |
+
if ( isset( $data['label'] ) ) {
|
2546 |
+
$output .= $this->field_label( $label, $key, $data );
|
2547 |
+
}
|
2548 |
+
|
2549 |
+
$output .= '<div class="um-field-area">';
|
2550 |
+
|
2551 |
+
if ( isset( $data['html'] ) && $data['html'] != 0 && $key != "description" ) {
|
2552 |
+
|
2553 |
+
$textarea_settings = array(
|
2554 |
+
'media_buttons' => false,
|
2555 |
+
'wpautop' => false,
|
2556 |
+
'editor_class' => $this->get_class( $key, $data ),
|
2557 |
+
'editor_height' => $height,
|
2558 |
+
'tinymce' => array(
|
2559 |
+
'toolbar1' => 'formatselect,bullist,numlist,bold,italic,underline,forecolor,blockquote,hr,removeformat,link,unlink,undo,redo',
|
2560 |
+
'toolbar2' => '',
|
2561 |
+
)
|
2562 |
+
);
|
2563 |
+
|
2564 |
+
if ( ! empty( $disabled ) ) {
|
2565 |
+
$textarea_settings['tinymce']['readonly'] = true;
|
2566 |
+
}
|
2567 |
+
|
2568 |
+
/**
|
2569 |
+
* UM hook
|
2570 |
+
*
|
2571 |
+
* @type filter
|
2572 |
+
* @title um_form_fields_textarea_settings
|
2573 |
+
* @description Change WP Editor options for textarea init
|
2574 |
+
* @input_vars
|
2575 |
+
* [{"var":"$textarea_settings","type":"array","desc":"WP Editor settings"}]
|
2576 |
+
* @change_log
|
2577 |
+
* ["Since: 2.0"]
|
2578 |
+
* @usage add_filter( 'um_form_fields_textarea_settings', 'function_name', 10, 1 );
|
2579 |
+
* @example
|
2580 |
+
* <?php
|
2581 |
+
* add_filter( 'um_form_fields_textarea_settings', 'my_textarea_settings', 10, 1 );
|
2582 |
+
* function my_edit_field_html( $textarea_settings ) {
|
2583 |
+
* // your code here
|
2584 |
+
* return $textarea_settings;
|
2585 |
+
* }
|
2586 |
+
* ?>
|
2587 |
+
*/
|
2588 |
+
$textarea_settings = apply_filters( 'um_form_fields_textarea_settings', $textarea_settings );
|
2589 |
+
|
2590 |
+
// turn on the output buffer
|
2591 |
+
ob_start();
|
2592 |
+
|
2593 |
+
// echo the editor to the buffer
|
2594 |
+
wp_editor( $field_value, $key, $textarea_settings );
|
2595 |
+
|
2596 |
+
// add the contents of the buffer to the output variable
|
2597 |
+
$output .= ob_get_clean();
|
2598 |
+
$output .= '<br /><span class="description">' . $placeholder . '</span>';
|
2599 |
+
} else {
|
2600 |
+
$textarea_field_value = ! empty( $data['html'] ) ? $field_value : strip_tags( $field_value );
|
2601 |
+
$output .= '<textarea ' . $disabled . ' style="height: ' . esc_attr( $height ) . ';" class="' . $this->get_class( $key, $data ) . '" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" placeholder="' . esc_attr( $placeholder ) . '">' . esc_textarea( $textarea_field_value ) . '</textarea>';
|
2602 |
+
}
|
2603 |
+
|
2604 |
+
$output .= '</div>';
|
2605 |
+
|
2606 |
+
if ( ! empty( $disabled ) ) {
|
2607 |
+
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2608 |
+
}
|
2609 |
+
|
2610 |
+
if ( $this->is_error( $key ) ) {
|
2611 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2612 |
+
}else if ( $this->is_notice( $key ) ) {
|
2613 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2614 |
+
}
|
2615 |
+
|
2616 |
+
$output .= '</div>';
|
2617 |
+
break;
|
2618 |
+
|
2619 |
+
/* Rating */
|
2620 |
+
case 'rating':
|
2621 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2622 |
+
|
2623 |
+
if ( isset( $data['label'] ) ) {
|
2624 |
+
$output .= $this->field_label( $label, $key, $data );
|
2625 |
+
}
|
2626 |
+
|
2627 |
+
$output .= '<div class="um-field-area">';
|
2628 |
+
|
2629 |
+
$output .= '<div class="um-rating um-raty" id="' . esc_attr( $key ) . '" data-key="' . esc_attr( $key ) . '" data-number="' . esc_attr( $data['number'] ) . '" data-score="' . $this->field_value( $key, $default, $data ) . '"></div>';
|
2630 |
+
$output .= '</div>';
|
2631 |
+
|
2632 |
+
if ( $this->is_error( $key ) ) {
|
2633 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2634 |
+
} elseif ( $this->is_notice( $key ) ) {
|
2635 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2636 |
+
}
|
2637 |
+
|
2638 |
+
$output .= '</div>';
|
2639 |
+
|
2640 |
+
break;
|
2641 |
+
|
2642 |
+
/* Gap/Space */
|
2643 |
+
case 'spacing':
|
2644 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'height' => $spacing ) ) . '></div>';
|
2645 |
+
break;
|
2646 |
+
|
2647 |
+
/* A line divider */
|
2648 |
+
case 'divider':
|
2649 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'border-bottom' => $borderwidth . 'px ' . $borderstyle . ' ' . $bordercolor ) ) . '>';
|
2650 |
+
if ( $divider_text ) {
|
2651 |
+
$output .= '<div class="um-field-divider-text"><span>' . esc_html( $divider_text ) . '</span></div>';
|
2652 |
+
}
|
2653 |
+
$output .= '</div>';
|
2654 |
+
break;
|
2655 |
+
|
2656 |
+
/* Single Image Upload */
|
2657 |
+
case 'image':
|
2658 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . ' data-mode="' . esc_attr( $this->set_mode ) . '" data-upload-label="' . ( ! empty( $data['button_text'] ) ? esc_attr( $data['button_text'] ) : esc_attr__( 'Upload', 'ultimate-member' ) ) . '">';
|
2659 |
+
if ( in_array( $key, array( 'profile_photo', 'cover_photo' ) ) ) {
|
2660 |
+
$field_value = '';
|
2661 |
+
} else {
|
2662 |
+
$field_value = $this->field_value( $key, $default, $data );
|
2663 |
+
}
|
2664 |
+
$output .= '<input type="hidden" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $field_value . '" />';
|
2665 |
+
if ( isset( $data['label'] ) ) {
|
2666 |
+
$output .= $this->field_label( $label, $key, $data );
|
2667 |
+
}
|
2668 |
+
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __( 'Upload Photo', 'ultimate-member' );
|
2669 |
+
$output .= '<div class="um-field-area" style="text-align: center;">';
|
2670 |
+
|
2671 |
+
if ( ! empty( $field_value ) && $field_value != 'empty_file' ) {
|
2672 |
+
if ( ! in_array( $key, array( 'profile_photo', 'cover_photo' ) ) ) {
|
2673 |
+
if ( isset( $this->set_mode ) && 'register' == $this->set_mode ) {
|
2674 |
+
$image_info = get_transient("um_{$field_value}");
|
2675 |
+
} else {
|
2676 |
+
$image_info = um_user( $data['metakey']."_metadata" );
|
2677 |
+
}
|
2678 |
+
|
2679 |
+
if ( ( isset( $this->set_mode ) && $this->set_mode == 'register' ) || file_exists( UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $field_value ) ) {
|
2680 |
+
$imgValue = UM()->uploader()->get_core_temp_url() . "/" . $this->field_value( $key, $default, $data );
|
2681 |
+
} else {
|
2682 |
+
$imgValue = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) );
|
2683 |
+
}
|
2684 |
+
$img = '<img src="' . $imgValue . '" alt="" />';
|
2685 |
+
} else {
|
2686 |
+
$img = '';
|
2687 |
+
}
|
2688 |
+
$output .= '<div class="um-single-image-preview show ' . $crop_class . '" data-crop="' . $crop_data . '" data-key="' . $key . '">
|
2689 |
+
<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>' . $img . '
|
2690 |
+
</div><a href="javascript:void(0);" data-modal="um_upload_single" data-modal-size="' . $modal_size . '" data-modal-copy="1" class="um-button um-btn-auto-width">' . __( 'Change photo', 'ultimate-member' ) . '</a>';
|
2691 |
+
} else {
|
2692 |
+
$output .= '<div class="um-single-image-preview ' . $crop_class . '" data-crop="' . $crop_data . '" data-key="' . $key . '">
|
2693 |
+
<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>
|
2694 |
+
<img src="" alt="" />
|
2695 |
+
<div class="um-clear"></div></div><a href="javascript:void(0);" data-modal="um_upload_single" data-modal-size="' . $modal_size . '" data-modal-copy="1" class="um-button um-btn-auto-width">' . $button_text . '</a>';
|
2696 |
+
}
|
2697 |
+
$output .= '</div>';
|
2698 |
+
/* modal hidden */
|
2699 |
+
$output .= '<div class="um-modal-hidden-content">';
|
2700 |
+
$output .= '<div class="um-modal-header"> ' . $modal_label . '</div>';
|
2701 |
+
$output .= '<div class="um-modal-body">';
|
2702 |
+
if (isset( $this->set_id )) {
|
2703 |
+
$set_id = $this->set_id;
|
2704 |
+
$set_mode = $this->set_mode;
|
2705 |
+
} else {
|
2706 |
+
$set_id = 0;
|
2707 |
+
$set_mode = '';
|
2708 |
+
}
|
2709 |
+
$nonce = wp_create_nonce( 'um_upload_nonce-' . $this->timestamp );
|
2710 |
+
$output .= '<div class="um-single-image-preview ' . $crop_class . '" data-crop="' . $crop_data . '" data-ratio="' . $ratio . '" data-min_width="' . $min_width . '" data-min_height="' . $min_height . '" data-coord=""><a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a><img src="" alt="" /><div class="um-clear"></div></div><div class="um-clear"></div>';
|
2711 |
+
$output .= '<div class="um-single-image-upload" data-user_id="' . esc_attr( $_um_profile_id ) . '" data-nonce="' . $nonce . '" data-timestamp="' . esc_attr( $this->timestamp ) . '" data-icon="' . esc_attr( $icon ) . '" data-set_id="' . esc_attr( $set_id ) . '" data-set_mode="' . esc_attr( $set_mode ) . '" data-type="' . esc_attr( $type ) . '" data-key="' . esc_attr( $key ) . '" data-max_size="' . esc_attr( $max_size ) . '" data-max_size_error="' . esc_attr( $max_size_error ) . '" data-min_size_error="' . esc_attr( $min_size_error ) . '" data-extension_error="' . esc_attr( $extension_error ) . '" data-allowed_types="' . esc_attr( $allowed_types ) . '" data-upload_text="' . esc_attr( $upload_text ) . '" data-max_files_error="' . esc_attr( $max_files_error ) . '" data-upload_help_text="' . esc_attr( $upload_help_text ) . '">' . $button_text . '</div>';
|
2712 |
+
$output .= '<div class="um-modal-footer">
|
2713 |
+
<div class="um-modal-right">
|
2714 |
+
<a href="javascript:void(0);" class="um-modal-btn um-finish-upload image disabled" data-key="' . $key . '" data-change="' . __( 'Change photo', 'ultimate-member' ) . '" data-processing="' . __( 'Processing...', 'ultimate-member' ) . '"> ' . __( 'Apply', 'ultimate-member' ) . '</a>
|
2715 |
+
<a href="javascript:void(0);" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __( 'Cancel', 'ultimate-member' ) . '</a>
|
2716 |
+
</div>
|
2717 |
+
<div class="um-clear"></div>
|
2718 |
+
</div>';
|
2719 |
+
$output .= '</div>';
|
2720 |
+
$output .= '</div>';
|
2721 |
+
/* end */
|
2722 |
+
if ( $this->is_error( $key ) ) {
|
2723 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2724 |
+
}else if ( $this->is_notice( $key ) ) {
|
2725 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2726 |
+
}
|
2727 |
+
$output .= '</div>';
|
2728 |
+
|
2729 |
+
break;
|
2730 |
+
|
2731 |
+
/* Single File Upload */
|
2732 |
+
case 'file':
|
2733 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . ' data-mode="' . esc_attr( $this->set_mode ) . '" data-upload-label="' . ( ! empty( $data['button_text'] ) ? esc_attr( $data['button_text'] ) : esc_attr__( 'Upload', 'ultimate-member' ) ) . '">';
|
2734 |
+
$output .= '<input type="hidden" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" />';
|
2735 |
+
if ( isset( $data['label'] ) ) {
|
2736 |
+
$output .= $this->field_label( $label, $key, $data );
|
2737 |
+
}
|
2738 |
+
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __( 'Upload File', 'ultimate-member' );
|
2739 |
+
$output .= '<div class="um-field-area" style="text-align: center;">';
|
2740 |
+
|
2741 |
+
$file_field_value = $this->field_value( $key, $default, $data );
|
2742 |
+
|
2743 |
+
if ( ! empty( $file_field_value ) && 'empty_file' !== $file_field_value ) {
|
2744 |
+
$file_type = wp_check_filetype( $file_field_value );
|
2745 |
+
|
2746 |
+
if ( um_is_temp_file( $file_field_value ) ) {
|
2747 |
+
$file_info = get_transient( "um_{$file_field_value}" );
|
2748 |
+
} else {
|
2749 |
+
$file_info = um_user( $data['metakey'] . "_metadata" );
|
2750 |
+
}
|
2751 |
+
|
2752 |
+
$file_field_name = $file_field_value;
|
2753 |
+
if ( ! empty( $file_info['original_name'] ) ) {
|
2754 |
+
$file_field_name = $file_info['original_name'];
|
2755 |
+
}
|
2756 |
+
|
2757 |
+
if ( ( isset( $this->set_mode ) && 'register' == $this->set_mode ) || file_exists( UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $file_field_value ) ) {
|
2758 |
+
$file_url = UM()->uploader()->get_core_temp_url() . DIRECTORY_SEPARATOR . $file_field_value;
|
2759 |
+
$file_dir = UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $file_field_value;
|
2760 |
+
} else {
|
2761 |
+
$file_url = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) );
|
2762 |
+
$file_dir = UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $this->field_value( $key, $default, $data );
|
2763 |
+
}
|
2764 |
+
|
2765 |
+
//multisite fix for old customers
|
2766 |
+
if ( ! file_exists( $file_dir ) && is_multisite() ) {
|
2767 |
+
$file_dir = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $file_dir );
|
2768 |
+
}
|
2769 |
+
|
2770 |
+
if ( file_exists( $file_dir ) ) {
|
2771 |
+
$output .= "<div class=\"um-single-file-preview show\" data-key=\"{$key}\">
|
2772 |
+
<a href=\"#\" class=\"cancel\"><i class=\"um-icon-close\"></i></a>
|
2773 |
+
<div class=\"um-single-fileinfo\">
|
2774 |
+
<a href=\"{$file_url}\" target=\"_blank\">
|
2775 |
+
<span class=\"icon\" style=\"background:" . UM()->files()->get_fonticon_bg_by_ext( $file_type['ext'] ) . "\"><i class=\"" . UM()->files()->get_fonticon_by_ext( $file_type['ext'] ) . "\"></i></span>
|
2776 |
+
<span class=\"filename\">{$file_field_name}</span>
|
2777 |
+
</a>
|
2778 |
+
</div></div>";
|
2779 |
+
} else {
|
2780 |
+
$output .= "<div class=\"um-single-file-preview show\" data-key=\"{$key}\">" . __('This file has been removed.','ultimate-member') . "</div>";
|
2781 |
+
}
|
2782 |
+
|
2783 |
+
$output .= "<a href=\"#\" data-modal=\"um_upload_single\" data-modal-size=\"{$modal_size}\" data-modal-copy=\"1\" class=\"um-button um-btn-auto-width\">" . __( 'Change file', 'ultimate-member' ) . "</a>";
|
2784 |
+
} else {
|
2785 |
+
$output .= "<div class=\"um-single-file-preview\" data-key=\"{$key}\">
|
2786 |
+
</div><a href=\"#\" data-modal=\"um_upload_single\" data-modal-size=\"{$modal_size}\" data-modal-copy=\"1\" class=\"um-button um-btn-auto-width\">{$button_text}</a>";
|
2787 |
+
}
|
2788 |
+
$output .= '</div>';
|
2789 |
+
/* modal hidden */
|
2790 |
+
$output .= '<div class="um-modal-hidden-content">';
|
2791 |
+
$output .= '<div class="um-modal-header"> ' . $modal_label . '</div>';
|
2792 |
+
$output .= '<div class="um-modal-body">';
|
2793 |
+
if ( isset( $this->set_id ) ) {
|
2794 |
+
$set_id = $this->set_id;
|
2795 |
+
$set_mode = $this->set_mode;
|
2796 |
+
} else {
|
2797 |
+
$set_id = 0;
|
2798 |
+
$set_mode = '';
|
2799 |
+
}
|
2800 |
+
$output .= '<div class="um-single-file-preview">
|
2801 |
+
<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>
|
2802 |
+
<div class="um-single-fileinfo">
|
2803 |
+
<a href="" target="_blank">
|
2804 |
+
<span class="icon"><i></i></span>
|
2805 |
+
<span class="filename"></span>
|
2806 |
+
</a>
|
2807 |
+
</div>
|
2808 |
+
</div>';
|
2809 |
+
$nonce = wp_create_nonce( 'um_upload_nonce-' . $this->timestamp );
|
2810 |
+
$output .= '<div class="um-single-file-upload" data-user_id="' . esc_attr( $_um_profile_id ) . '" data-timestamp="' . esc_attr( $this->timestamp ) . '" data-nonce="' . $nonce . '" data-icon="' . esc_attr( $icon ) . '" data-set_id="' . esc_attr( $set_id ) . '" data-set_mode="' . esc_attr( $set_mode ) . '" data-type="' . esc_attr( $type ) . '" data-key="' . esc_attr( $key ) . '" data-max_size="' . esc_attr( $max_size ) . '" data-max_size_error="' . esc_attr( $max_size_error ) . '" data-min_size_error="' . esc_attr( $min_size_error ) . '" data-extension_error="' . esc_attr( $extension_error ) . '" data-allowed_types="' . esc_attr( $allowed_types ) . '" data-upload_text="' . esc_attr( $upload_text ) . '" data-max_files_error="' . esc_attr( $max_files_error ) . '" data-upload_help_text="' . esc_attr( $upload_help_text ) . '">' . $button_text . '</div>';
|
2811 |
+
$output .= '<div class="um-modal-footer">
|
2812 |
+
<div class="um-modal-right">
|
2813 |
+
<a href="javascript:void(0);" class="um-modal-btn um-finish-upload file disabled" data-key="' . esc_attr( $key ) . '" data-change="' . esc_attr__( 'Change file' ) . '" data-processing="' . esc_attr__( 'Processing...', 'ultimate-member' ) . '"> ' . __( 'Save', 'ultimate-member' ) . '</a>
|
2814 |
+
<a href="javascript:void(0);" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __( 'Cancel', 'ultimate-member' ) . '</a>
|
2815 |
+
</div>
|
2816 |
+
<div class="um-clear"></div>
|
2817 |
+
</div>';
|
2818 |
+
$output .= '</div>';
|
2819 |
+
$output .= '</div>';
|
2820 |
+
/* end */
|
2821 |
+
if ( $this->is_error( $key ) ) {
|
2822 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2823 |
+
}else if ( $this->is_notice( $key ) ) {
|
2824 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2825 |
+
}
|
2826 |
+
$output .= '</div>';
|
2827 |
+
|
2828 |
+
break;
|
2829 |
+
|
2830 |
+
/* Select dropdown */
|
2831 |
+
case 'select':
|
2832 |
+
|
2833 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2834 |
+
|
2835 |
+
if ( isset( $data['allowclear'] ) && $data['allowclear'] == 0 ) {
|
2836 |
+
$class = 'um-s2';
|
2837 |
+
} else {
|
2838 |
+
$class = 'um-s1';
|
2839 |
+
}
|
2840 |
+
|
2841 |
+
if ( isset( $data['label'] ) ) {
|
2842 |
+
$output .= $this->field_label( $label, $key, $data );
|
2843 |
+
}
|
2844 |
+
|
2845 |
+
$output .= '<div class="um-field-area ' . ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ? 'um-field-area-has-icon' : '' ) . ' ">';
|
2846 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2847 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2848 |
+
}
|
2849 |
+
|
2850 |
+
$options = array();
|
2851 |
+
$has_parent_option = false;
|
2852 |
+
$disabled_by_parent_option = '';
|
2853 |
+
$atts_ajax = '';
|
2854 |
+
$select_original_option_value = '';
|
2855 |
+
|
2856 |
+
if ( isset( $data[ 'options' ] ) && is_array( $data[ 'options' ] ) ) {
|
2857 |
+
$options = $data[ 'options' ];
|
2858 |
+
}
|
2859 |
+
|
2860 |
+
if ( ! empty( $data['parent_dropdown_relationship'] ) && ! UM()->user()->preview ) {
|
2861 |
+
|
2862 |
+
$disabled_by_parent_option = 'disabled = disabled';
|
2863 |
+
|
2864 |
+
$has_parent_option = true;
|
2865 |
+
|
2866 |
+
/**
|
2867 |
+
* UM hook
|
2868 |
+
*
|
2869 |
+
* @type filter
|
2870 |
+
* @title um_custom_dropdown_options_parent__{$form_key}
|
2871 |
+
* @description Change parent dropdown relationship by $form_key
|
2872 |
+
* @input_vars
|
2873 |
+
* [{"var":"$parent","type":"string","desc":"Parent dropdown relationship"},
|
2874 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2875 |
+
* @change_log
|
2876 |
+
* ["Since: 2.0"]
|
2877 |
+
* @usage add_filter( 'um_custom_dropdown_options_parent__{$form_key}', 'function_name', 10, 2 );
|
2878 |
+
* @example
|
2879 |
+
* <?php
|
2880 |
+
* add_filter( 'um_custom_dropdown_options_parent__{$form_key}', 'my_custom_dropdown_options_parent', 10, 2 );
|
2881 |
+
* function my_custom_dropdown_options_parent( $parent, $data ) {
|
2882 |
+
* // your code here
|
2883 |
+
* return $parent;
|
2884 |
+
* }
|
2885 |
+
* ?>
|
2886 |
+
*/
|
2887 |
+
$parent_dropdown_relationship = apply_filters( "um_custom_dropdown_options_parent__{$form_key}", $data['parent_dropdown_relationship'], $data );
|
2888 |
+
$atts_ajax .= " data-um-parent='{$parent_dropdown_relationship}' ";
|
2889 |
+
|
2890 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option && function_exists( $data['custom_dropdown_options_source'] ) &&
|
2891 |
+
um_user( $data['parent_dropdown_relationship'] )
|
2892 |
+
) {
|
2893 |
+
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
2894 |
+
|
2895 |
+
$disabled_by_parent_option = '';
|
2896 |
+
if ( um_user( $form_key ) ) {
|
2897 |
+
$select_original_option_value = " data-um-original-value='" . um_user( $form_key ) . "' ";
|
2898 |
+
}
|
2899 |
+
}
|
2900 |
+
}
|
2901 |
+
|
2902 |
+
// Child dropdown option selected
|
2903 |
+
if ( isset( UM()->form()->post_form[ $form_key ] ) ) {
|
2904 |
+
$select_original_option_value = " data-um-original-value='" . esc_attr( UM()->form()->post_form[ $form_key ] ) . "' ";
|
2905 |
+
}
|
2906 |
+
|
2907 |
+
// Child dropdown
|
2908 |
+
if ( $has_parent_option ) {
|
2909 |
+
|
2910 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option &&
|
2911 |
+
function_exists( $data['custom_dropdown_options_source'] ) && isset( UM()->form()->post_form[ $form_key ] ) ) {
|
2912 |
+
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
2913 |
+
}
|
2914 |
+
}
|
2915 |
+
|
2916 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
2917 |
+
|
2918 |
+
/**
|
2919 |
+
* UM hook
|
2920 |
+
*
|
2921 |
+
* @type filter
|
2922 |
+
* @title um_custom_dropdown_options_source__{$form_key}
|
2923 |
+
* @description Change custom dropdown options source by $form_key
|
2924 |
+
* @input_vars
|
2925 |
+
* [{"var":"$source","type":"string","desc":"Dropdown options source"},
|
2926 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2927 |
+
* @change_log
|
2928 |
+
* ["Since: 2.0"]
|
2929 |
+
* @usage add_filter( 'um_custom_dropdown_options_source__{$form_key}', 'function_name', 10, 2 );
|
2930 |
+
* @example
|
2931 |
+
* <?php
|
2932 |
+
* add_filter( 'um_custom_dropdown_options_source__{$form_key}', 'my_custom_dropdown_options_source', 10, 2 );
|
2933 |
+
* function my_custom_dropdown_options_source( $source, $data ) {
|
2934 |
+
* // your code here
|
2935 |
+
* return $source;
|
2936 |
+
* }
|
2937 |
+
* ?>
|
2938 |
+
*/
|
2939 |
+
$ajax_source = apply_filters( "um_custom_dropdown_options_source__{$form_key}", $data['custom_dropdown_options_source'], $data );
|
2940 |
+
$atts_ajax .= ' data-um-ajax-source="' . esc_attr( $ajax_source ) . '" ';
|
2941 |
+
|
2942 |
+
/**
|
2943 |
+
* UM hook
|
2944 |
+
*
|
2945 |
+
* @type filter
|
2946 |
+
* @title um_custom_dropdown_options_source_url__{$form_key}
|
2947 |
+
* @description Change custom dropdown options source URL by $form_key
|
2948 |
+
* @input_vars
|
2949 |
+
* [{"var":"$url","type":"string","desc":"Dropdown options source URL"},
|
2950 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2951 |
+
* @change_log
|
2952 |
+
* ["Since: 2.0"]
|
2953 |
+
* @usage add_filter( 'um_custom_dropdown_options_source_url__{$form_key}', 'function_name', 10, 2 );
|
2954 |
+
* @example
|
2955 |
+
* <?php
|
2956 |
+
* add_filter( 'um_custom_dropdown_options_source_url__{$form_key}', 'my_custom_dropdown_options_source_url', 10, 2 );
|
2957 |
+
* function my_custom_dropdown_options_source( $url, $data ) {
|
2958 |
+
* // your code here
|
2959 |
+
* return $url;
|
2960 |
+
* }
|
2961 |
+
* ?>
|
2962 |
+
*/
|
2963 |
+
// todo maybe deprecate
|
2964 |
+
// $ajax_source_url = apply_filters( "um_custom_dropdown_options_source_url__{$form_key}", admin_url( 'admin-ajax.php' ), $data );
|
2965 |
+
// $atts_ajax .= ' data-um-ajax-url="' . esc_url( $ajax_source_url ) . '" ';
|
2966 |
+
|
2967 |
+
}
|
2968 |
+
|
2969 |
+
/**
|
2970 |
+
* UM hook
|
2971 |
+
*
|
2972 |
+
* @type filter
|
2973 |
+
* @title um_fields_options_enable_pairs__{$key}
|
2974 |
+
* @description Enable options pairs by field $key
|
2975 |
+
* @input_vars
|
2976 |
+
* [{"var":"$options_pairs","type":"string","desc":"Enable pairs"}]
|
2977 |
+
* @change_log
|
2978 |
+
* ["Since: 2.0"]
|
2979 |
+
* @usage add_filter( 'um_fields_options_enable_pairs__{$key}', 'function_name', 10, 1 );
|
2980 |
+
* @example
|
2981 |
+
* <?php
|
2982 |
+
* add_filter( 'um_fields_options_enable_pairs__{$key}', 'my_fields_options_enable_pairs', 10, 1 );
|
2983 |
+
* function my_fields_options_enable_pairs( $options_pairs ) {
|
2984 |
+
* // your code here
|
2985 |
+
* return $options_pairs;
|
2986 |
+
* }
|
2987 |
+
* ?>
|
2988 |
+
*/
|
2989 |
+
$enable_options_pair = apply_filters( "um_fields_options_enable_pairs__{$key}", false );
|
2990 |
+
|
2991 |
+
if ( ! $has_parent_option ) {
|
2992 |
+
if ( isset( $options ) && $options == 'builtin' ) {
|
2993 |
+
$options = UM()->builtin()->get ( $filter );
|
2994 |
+
}
|
2995 |
+
|
2996 |
+
// 'country'
|
2997 |
+
if ( $key === 'country' && empty( $options ) ) {
|
2998 |
+
$options = UM()->builtin()->get( 'countries' );
|
2999 |
+
} else if ( empty( $options ) && isset( $data['options'] ) ) {
|
3000 |
+
$options = $data['options'];
|
3001 |
+
}
|
3002 |
+
|
3003 |
+
$options = apply_filters( 'um_selectbox_options', $options, $key );
|
3004 |
+
|
3005 |
+
if ( isset( $options ) ) {
|
3006 |
+
/**
|
3007 |
+
* UM hook
|
3008 |
+
*
|
3009 |
+
* @type filter
|
3010 |
+
* @title um_select_dropdown_dynamic_options
|
3011 |
+
* @description Extend dropdown dynamic options
|
3012 |
+
* @input_vars
|
3013 |
+
* [{"var":"$options","type":"array","desc":"Dynamic options"},
|
3014 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3015 |
+
* @change_log
|
3016 |
+
* ["Since: 2.0"]
|
3017 |
+
* @usage add_filter( 'um_select_dropdown_dynamic_options', 'function_name', 10, 2 );
|
3018 |
+
* @example
|
3019 |
+
* <?php
|
3020 |
+
* add_filter( 'um_select_dropdown_dynamic_options', 'my_select_dropdown_dynamic_options', 10, 2 );
|
3021 |
+
* function my_select_dropdown_dynamic_options( $options, $data ) {
|
3022 |
+
* // your code here
|
3023 |
+
* return $options;
|
3024 |
+
* }
|
3025 |
+
* ?>
|
3026 |
+
*/
|
3027 |
+
$options = apply_filters( 'um_select_dropdown_dynamic_options', $options, $data );
|
3028 |
+
/**
|
3029 |
+
* UM hook
|
3030 |
+
*
|
3031 |
+
* @type filter
|
3032 |
+
* @title um_select_dropdown_dynamic_options_{$key}
|
3033 |
+
* @description Extend dropdown dynamic options by field $key
|
3034 |
+
* @input_vars
|
3035 |
+
* [{"var":"$options","type":"array","desc":"Dynamic options"}]
|
3036 |
+
* @change_log
|
3037 |
+
* ["Since: 2.0"]
|
3038 |
+
* @usage add_filter( 'um_select_dropdown_dynamic_options_{$key}', 'function_name', 10, 1 );
|
3039 |
+
* @example
|
3040 |
+
* <?php
|
3041 |
+
* add_filter( 'um_select_dropdown_dynamic_options_{$key}', 'my_select_dropdown_dynamic_options', 10, 1 );
|
3042 |
+
* function my_select_dropdown_dynamic_op
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|