diff --git a/assets/css/admin/forms.css b/assets/css/admin/forms.css index 40f2862c..8ffe133b 100644 --- a/assets/css/admin/forms.css +++ b/assets/css/admin/forms.css @@ -1,9 +1,6 @@ .um-form-table .um-forms-line[data-conditional] { display: none; } -.um-form-table .um-forms-line[data-field_type="checkbox"] td label { - font-style: italic; } - .um-form-table .um-forms-line label .um-req { color: #a00; margin: 0 0 0 3px; @@ -68,10 +65,6 @@ display: block; margin: 0 0 5px 0; } -.um-form-table .description { - font-style: italic; - clear: both; } - .um_admin_fonticon_wrapper { display: flex; flex-direction: row; diff --git a/assets/css/admin/forms.min.css b/assets/css/admin/forms.min.css index c7df2078..7ef70bc9 100644 --- a/assets/css/admin/forms.min.css +++ b/assets/css/admin/forms.min.css @@ -1 +1 @@ -.um-form-table .um-forms-line[data-conditional]{display:none}.um-form-table .um-forms-line[data-field_type=checkbox] td label{font-style:italic}.um-form-table .um-forms-line label .um-req{color:#a00;margin:0 0 0 3px;font-weight:400}.um-form-table .um-forms-line .um-text-delete{color:#a00;float:left}.um-form-table .um-forms-line .um-text-delete:hover{color:red}.um-form-table .um-forms-line .um-multi-text-add-option{margin-bottom:14px}.um-form-table .um-forms-line .icon_preview{display:none;max-width:200px;max-height:200px;padding:5px;cursor:pointer;border:1px solid #e3e3e3;background:#f7f7f7;border-radius:3px;height:auto;width:auto!important}.um-form-table .um-forms-line td .um-same-page-update-wrapper{display:none;margin:7px 0 0 0}.um-form-table .um-forms-line td .um-same-page-update-wrapper input.um-admin-form-same-page-update{margin:7px 0 0 0}.um-form-table .um-forms-line td .um-same-page-update-wrapper .upgrade_log{margin:7px 0 0 0;width:100%;height:150px;overflow:auto;border:1px solid #a1a1a1}.um-form-table .um-forms-line[data-field_type=same_page_update]{vertical-align:baseline}.um-form-table .um-forms-line[data-field_type=same_page_update] td,.um-form-table .um-forms-line[data-field_type=same_page_update] th{vertical-align:baseline}.um-form-table.um-third-column .um-forms-line th{width:33%}.um-form-table.um-half-column .um-forms-line th{width:50%}.um-form-table.um-two-thirds-column .um-forms-line th{width:83%}.um-form-table.um-top-label .um-forms-line td{padding:0 0 15px 0}.um-form-table.um-top-label .um-forms-line td label{margin:0 0 5px 0;display:inline-block}.um-form-table.um-top-label .um-forms-line[data-field_type=icon] td label{width:100%;display:block;margin:0 0 5px 0}.um-form-table .description{font-style:italic;clear:both}.um_admin_fonticon_wrapper{display:flex;flex-direction:row;justify-content:flex-start;align-items:center;flex-wrap:nowrap}.um_admin_fonticon_wrapper .um-admin-icon-value{line-height:1}.um_admin_fonticon_wrapper .um-admin-icon-value i{top:0}input[type=date].um-forms-field,input[type=number].um-forms-field,input[type=password].um-forms-field,input[type=text].um-forms-field,input[type=time].um-forms-field,input[type=url].um-forms-field,select.um-forms-field,textarea.um-forms-field{box-sizing:border-box}input[type=date].um-forms-field.um-long-field,input[type=number].um-forms-field.um-long-field,input[type=password].um-forms-field.um-long-field,input[type=text].um-forms-field.um-long-field,input[type=time].um-forms-field.um-long-field,input[type=url].um-forms-field.um-long-field,select.um-forms-field.um-long-field,textarea.um-forms-field.um-long-field{width:100%!important}input[type=date].um-forms-field.um-medium-field,input[type=number].um-forms-field.um-medium-field,input[type=password].um-forms-field.um-medium-field,input[type=text].um-forms-field.um-medium-field,input[type=time].um-forms-field.um-medium-field,input[type=url].um-forms-field.um-medium-field,select.um-forms-field.um-medium-field,textarea.um-forms-field.um-medium-field{width:50%!important}input[type=date].um-forms-field.um-small-field,input[type=number].um-forms-field.um-small-field,input[type=password].um-forms-field.um-small-field,input[type=text].um-forms-field.um-small-field,input[type=time].um-forms-field.um-small-field,input[type=url].um-forms-field.um-small-field,select.um-forms-field.um-small-field,textarea.um-forms-field.um-small-field{width:25%!important}input[type=number].um-forms-field{padding-right:0}.um-md-default-filters-list,.um-multi-selects-list,.um-multi-text-list{float:left;width:100%;margin:0 0 10px 0}.um-hidden-md-default-filters,.um-hidden-multi-selects,.um-hidden-multi-text{display:none!important}.um-md-default-filters-option-line{float:left;width:100%;clear:both;border-bottom:1px solid #eee;padding:0 0 5px 0;margin:5px 0 0 0}.um-md-default-filters-option-line .um-field-wrapper{float:left;width:calc(100% - 60px);line-height:30px;box-sizing:border-box}.um-md-default-filters-option-line .um-field-wrapper2{float:left;width:calc(100% - 60px);line-height:30px;box-sizing:border-box}.um-md-default-filters-option-line .um-field-wrapper2.um{margin:5px 0 0 0}.um-md-default-filters-option-line .um-field-wrapper2 .ui-slider-range.ui-widget-header{background:#44b0ec;border:1px solid #44b0ec!important;margin-top:-1px}.um-md-default-filters-option-line .um-field-wrapper2>select{width:100%;float:left}.um-md-default-filters-option-line .um-field-wrapper2>input{width:100%;float:left}.um-md-default-filters-option-line .um-field-wrapper2>input.um-datepicker-filter,.um-md-default-filters-option-line .um-field-wrapper2>input.um-timepicker-filter{width:calc(50% - 7px)!important;float:left}.um-md-default-filters-option-line .um-field-wrapper2>input.um-datepicker-filter:first-child,.um-md-default-filters-option-line .um-field-wrapper2>input.um-timepicker-filter:first-child{margin-right:11px}.um-md-default-filters-option-line .um-field-wrapper2 .um-slider{margin:5px 9px 0 9px;width:calc(100% - 18px);box-sizing:border-box;display:block}.um-md-default-filters-option-line .um-field-control{float:left;width:60px;line-height:30px;padding:0 10px;box-sizing:border-box}.um-multi-selects-option-line{float:left;width:100%;padding:0;clear:both;margin:0 0 5px 0}.um-multi-selects-option-line.um-admin-drag-fld{display:flex;flex-direction:row;justify-content:flex-start;align-items:center;flex-wrap:nowrap;background:0 0;border:none}.um-multi-selects-option-line.um-admin-drag-fld .um-field-wrapper{width:calc(100% - 90px)}.um-multi-selects-option-line.um-admin-drag-fld .um-field-icon{float:left;width:20px;text-align:left;line-height:30px}.um-multi-selects-option-line .um-field-wrapper{float:left;width:calc(100% - 60px);line-height:30px;box-sizing:border-box}.um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields{margin:5px 0 0 0}.um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields label{float:left;width:100%;line-height:30px;box-sizing:border-box;margin:0!important;padding:0!important;font-weight:700;display:flex;flex-direction:row;justify-content:space-beetween;align-items:baseline;flex-wrap:nowrap}.um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields label input[type=text],.um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields label select{width:auto;display:inline;font-weight:400;max-width:70%;flex:.9}.um-multi-selects-option-line .um-field-wrapper input,.um-multi-selects-option-line .um-field-wrapper select{float:left;width:100%;margin:0}.um-multi-selects-option-line .um-field-control{float:left;width:60px;line-height:30px;padding:0 10px;box-sizing:border-box}.um-multi-text-option-line{float:left;width:100%;padding:0;clear:both;margin:0 0 5px 0}.um-multi-text-option-line .um-field-wrapper{float:left;width:calc(100% - 90px);line-height:30px;box-sizing:border-box}.um-multi-text-option-line .um-field-wrapper input,.um-multi-text-option-line .um-field-wrapper select{float:left;width:100%;margin:0}.um-multi-text-option-line .um-field-control{float:left;width:60px;line-height:30px;padding:0 10px;box-sizing:border-box}.um-form-fields-section{float:left;clear:none;margin:0;padding:0 10px 0 0;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}.um-form-fields-section label{float:left;width:100%;margin:0;padding:0}.um-form-fields-section label input{float:left;margin-top:0}.um-form-fields-section label span{float:left;width:calc(100% - 20px)}@media screen and (max-width:782px){input[type=text].um-forms-field.um-medium-field,select.um-forms-field.um-medium-field,textarea.um-forms-field.um-medium-field{width:100%!important}input[type=text].um-forms-field.um-small-field,select.um-forms-field.um-small-field,textarea.um-forms-field.um-small-field{width:50%!important}.um-form-fields-section{width:100%!important}.um-admin-metabox .um-form-fields-section label{line-height:22px!important;margin:0 0 12px 0!important}.um-admin-metabox .um-form-fields-section label span{width:calc(100% - 30px)}.um-multi-selects-option-line,.um-multi-text-option-line{margin:0 0 6px 0}.um-forms-line label{float:left;width:100%}.um-form-table.um-half-column .um-forms-line th,.um-form-table.um-third-column .um-forms-line th,.um-form-table.um-two-thirds-column .um-forms-line th{float:left;width:100%;margin-bottom:5px}.um-form-table.um-half-column .um-forms-line th label,.um-form-table.um-third-column .um-forms-line th label,.um-form-table.um-two-thirds-column .um-forms-line th label{float:left;width:100%}.um-form-table.um-half-column .um-forms-line td,.um-form-table.um-third-column .um-forms-line td,.um-form-table.um-two-thirds-column .um-forms-line td{float:left;width:100%}}.um-sortable-items-field .um-sortable-item{cursor:move!important;padding:5px;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;border:1px solid #7e8993;border-radius:4px;-moz-border-radius:4px;background:#fff;height:42px;line-height:28px;display:flex;flex-direction:row;justify-content:flex-start;align-items:center;flex-wrap:nowrap}.um-sortable-items-field .um-sortable-item.um-hidden-item{display:none}.um-sortable-items-field .um-sortable-item .um-field-icon{width:20px;text-align:left;margin:0 10px 0 0}.wp-picker-container input.wp-color-picker[type=text]{width:68px!important;float:left!important;padding:2px 4px!important;border-width:1px!important}span.um-admin-icon-value{margin:0 10px;font-size:13px}span.um-admin-icon-value i{font-size:28px;color:#0085ba;position:relative;top:5px}span.um-admin-icon-clear{display:none;cursor:pointer;position:relative;color:#ccc}span.um-admin-icon-clear.show{display:inline-block}span.um-admin-icon-clear:hover{color:#777}span.um-admin-icon-clear i{font-size:20px;vertical-align:middle} \ No newline at end of file +.um-form-table .um-forms-line[data-conditional]{display:none}.um-form-table .um-forms-line label .um-req{color:#a00;margin:0 0 0 3px;font-weight:400}.um-form-table .um-forms-line .um-text-delete{color:#a00;float:left}.um-form-table .um-forms-line .um-text-delete:hover{color:red}.um-form-table .um-forms-line .um-multi-text-add-option{margin-bottom:14px}.um-form-table .um-forms-line .icon_preview{display:none;max-width:200px;max-height:200px;padding:5px;cursor:pointer;border:1px solid #e3e3e3;background:#f7f7f7;border-radius:3px;height:auto;width:auto!important}.um-form-table .um-forms-line td .um-same-page-update-wrapper{display:none;margin:7px 0 0 0}.um-form-table .um-forms-line td .um-same-page-update-wrapper input.um-admin-form-same-page-update{margin:7px 0 0 0}.um-form-table .um-forms-line td .um-same-page-update-wrapper .upgrade_log{margin:7px 0 0 0;width:100%;height:150px;overflow:auto;border:1px solid #a1a1a1}.um-form-table .um-forms-line[data-field_type=same_page_update]{vertical-align:baseline}.um-form-table .um-forms-line[data-field_type=same_page_update] td,.um-form-table .um-forms-line[data-field_type=same_page_update] th{vertical-align:baseline}.um-form-table.um-third-column .um-forms-line th{width:33%}.um-form-table.um-half-column .um-forms-line th{width:50%}.um-form-table.um-two-thirds-column .um-forms-line th{width:83%}.um-form-table.um-top-label .um-forms-line td{padding:0 0 15px 0}.um-form-table.um-top-label .um-forms-line td label{margin:0 0 5px 0;display:inline-block}.um-form-table.um-top-label .um-forms-line[data-field_type=icon] td label{width:100%;display:block;margin:0 0 5px 0}.um_admin_fonticon_wrapper{display:flex;flex-direction:row;justify-content:flex-start;align-items:center;flex-wrap:nowrap}.um_admin_fonticon_wrapper .um-admin-icon-value{line-height:1}.um_admin_fonticon_wrapper .um-admin-icon-value i{top:0}input[type=date].um-forms-field,input[type=number].um-forms-field,input[type=password].um-forms-field,input[type=text].um-forms-field,input[type=time].um-forms-field,input[type=url].um-forms-field,select.um-forms-field,textarea.um-forms-field{box-sizing:border-box}input[type=date].um-forms-field.um-long-field,input[type=number].um-forms-field.um-long-field,input[type=password].um-forms-field.um-long-field,input[type=text].um-forms-field.um-long-field,input[type=time].um-forms-field.um-long-field,input[type=url].um-forms-field.um-long-field,select.um-forms-field.um-long-field,textarea.um-forms-field.um-long-field{width:100%!important}input[type=date].um-forms-field.um-medium-field,input[type=number].um-forms-field.um-medium-field,input[type=password].um-forms-field.um-medium-field,input[type=text].um-forms-field.um-medium-field,input[type=time].um-forms-field.um-medium-field,input[type=url].um-forms-field.um-medium-field,select.um-forms-field.um-medium-field,textarea.um-forms-field.um-medium-field{width:50%!important}input[type=date].um-forms-field.um-small-field,input[type=number].um-forms-field.um-small-field,input[type=password].um-forms-field.um-small-field,input[type=text].um-forms-field.um-small-field,input[type=time].um-forms-field.um-small-field,input[type=url].um-forms-field.um-small-field,select.um-forms-field.um-small-field,textarea.um-forms-field.um-small-field{width:25%!important}input[type=number].um-forms-field{padding-right:0}.um-md-default-filters-list,.um-multi-selects-list,.um-multi-text-list{float:left;width:100%;margin:0 0 10px 0}.um-hidden-md-default-filters,.um-hidden-multi-selects,.um-hidden-multi-text{display:none!important}.um-md-default-filters-option-line{float:left;width:100%;clear:both;border-bottom:1px solid #eee;padding:0 0 5px 0;margin:5px 0 0 0}.um-md-default-filters-option-line .um-field-wrapper{float:left;width:calc(100% - 60px);line-height:30px;box-sizing:border-box}.um-md-default-filters-option-line .um-field-wrapper2{float:left;width:calc(100% - 60px);line-height:30px;box-sizing:border-box}.um-md-default-filters-option-line .um-field-wrapper2.um{margin:5px 0 0 0}.um-md-default-filters-option-line .um-field-wrapper2 .ui-slider-range.ui-widget-header{background:#44b0ec;border:1px solid #44b0ec!important;margin-top:-1px}.um-md-default-filters-option-line .um-field-wrapper2 select{width:100%;float:left}.um-md-default-filters-option-line .um-field-wrapper2 input{width:100%;float:left}.um-md-default-filters-option-line .um-field-wrapper2 input.um-datepicker-filter,.um-md-default-filters-option-line .um-field-wrapper2 input.um-timepicker-filter{width:calc(50% - 7px)!important;float:left}.um-md-default-filters-option-line .um-field-wrapper2 input.um-datepicker-filter:first-child,.um-md-default-filters-option-line .um-field-wrapper2 input.um-timepicker-filter:first-child{margin-right:11px}.um-md-default-filters-option-line .um-field-wrapper2 .um-slider{margin:5px 9px 0 9px;width:calc(100% - 18px);box-sizing:border-box;display:block}.um-md-default-filters-option-line .um-field-control{float:left;width:60px;line-height:30px;padding:0 10px;box-sizing:border-box}.um-multi-selects-option-line{float:left;width:100%;padding:0;clear:both;margin:0 0 5px 0}.um-multi-selects-option-line.um-admin-drag-fld{display:flex;flex-direction:row;justify-content:flex-start;align-items:center;flex-wrap:nowrap;background:0 0;border:none}.um-multi-selects-option-line.um-admin-drag-fld .um-field-wrapper{width:calc(100% - 90px)}.um-multi-selects-option-line.um-admin-drag-fld .um-field-icon{float:left;width:20px;text-align:left;line-height:30px}.um-multi-selects-option-line .um-field-wrapper{float:left;width:calc(100% - 60px);line-height:30px;box-sizing:border-box}.um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields{margin:5px 0 0 0}.um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields label{float:left;width:100%;line-height:30px;box-sizing:border-box;margin:0!important;padding:0!important;font-weight:700;display:flex;flex-direction:row;justify-content:space-beetween;align-items:baseline;flex-wrap:nowrap}.um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields label input[type=text],.um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields label select{width:auto;display:inline;font-weight:400;max-width:70%;flex:.9}.um-multi-selects-option-line .um-field-wrapper input,.um-multi-selects-option-line .um-field-wrapper select{float:left;width:100%;margin:0}.um-multi-selects-option-line .um-field-control{float:left;width:60px;line-height:30px;padding:0 10px;box-sizing:border-box}.um-multi-text-option-line{float:left;width:100%;padding:0;clear:both;margin:0 0 5px 0}.um-multi-text-option-line .um-field-wrapper{float:left;width:calc(100% - 90px);line-height:30px;box-sizing:border-box}.um-multi-text-option-line .um-field-wrapper input,.um-multi-text-option-line .um-field-wrapper select{float:left;width:100%;margin:0}.um-multi-text-option-line .um-field-control{float:left;width:60px;line-height:30px;padding:0 10px;box-sizing:border-box}.um-form-fields-section{float:left;clear:none;margin:0;padding:0 10px 0 0;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}.um-form-fields-section label{float:left;width:100%;margin:0;padding:0}.um-form-fields-section label input{float:left;margin-top:0}.um-form-fields-section label span{float:left;width:calc(100% - 20px)}@media screen and (max-width:782px){input[type=text].um-forms-field.um-medium-field,select.um-forms-field.um-medium-field,textarea.um-forms-field.um-medium-field{width:100%!important}input[type=text].um-forms-field.um-small-field,select.um-forms-field.um-small-field,textarea.um-forms-field.um-small-field{width:50%!important}.um-form-fields-section{width:100%!important}.um-admin-metabox .um-form-fields-section label{line-height:22px!important;margin:0 0 12px 0!important}.um-admin-metabox .um-form-fields-section label span{width:calc(100% - 30px)}.um-multi-selects-option-line,.um-multi-text-option-line{margin:0 0 6px 0}.um-forms-line label{float:left;width:100%}.um-form-table.um-half-column .um-forms-line th,.um-form-table.um-third-column .um-forms-line th,.um-form-table.um-two-thirds-column .um-forms-line th{float:left;width:100%;margin-bottom:5px}.um-form-table.um-half-column .um-forms-line th label,.um-form-table.um-third-column .um-forms-line th label,.um-form-table.um-two-thirds-column .um-forms-line th label{float:left;width:100%}.um-form-table.um-half-column .um-forms-line td,.um-form-table.um-third-column .um-forms-line td,.um-form-table.um-two-thirds-column .um-forms-line td{float:left;width:100%}}.um-sortable-items-field .um-sortable-item{cursor:move!important;padding:5px;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;border:1px solid #7e8993;border-radius:4px;-moz-border-radius:4px;background:#fff;height:42px;line-height:28px;display:flex;flex-direction:row;justify-content:flex-start;align-items:center;flex-wrap:nowrap}.um-sortable-items-field .um-sortable-item.um-hidden-item{display:none}.um-sortable-items-field .um-sortable-item .um-field-icon{width:20px;text-align:left;margin:0 10px 0 0}.wp-picker-container input.wp-color-picker[type=text]{width:68px!important;float:left!important;padding:2px 4px!important;border-width:1px!important}span.um-admin-icon-value{margin:0 10px;font-size:13px}span.um-admin-icon-value i{font-size:28px;color:#0085ba;position:relative;top:5px}span.um-admin-icon-clear{display:none;cursor:pointer;position:relative;color:#ccc}span.um-admin-icon-clear.show{display:inline-block}span.um-admin-icon-clear:hover{color:#777}span.um-admin-icon-clear i{font-size:20px;vertical-align:middle} diff --git a/assets/css/admin/forms.sass b/assets/css/admin/forms.sass index d7f37f03..2b7d5c60 100644 --- a/assets/css/admin/forms.sass +++ b/assets/css/admin/forms.sass @@ -7,10 +7,6 @@ .#{$prefix}forms-line &[data-conditional] display: none - &[data-field_type="checkbox"] - td - label - font-style: italic label .#{$prefix}req color: $required-asterisk @@ -95,9 +91,9 @@ width: 100% display: block margin: 0 0 5px 0 - .description - font-style: italic - clear: both + //.description + // font-style: italic + // clear: both .um_admin_fonticon_wrapper +flex( row, flex-start, center, nowrap ) diff --git a/assets/css/admin/settings.css b/assets/css/admin/settings.css index 567c6ff5..55cec4ca 100644 --- a/assets/css/admin/settings.css +++ b/assets/css/admin/settings.css @@ -1,14 +1,3 @@ -#um-settings-wrap .subsubsub { - display: flex; - flex-direction: row; - justify-content: flex-start; - align-items: center; - flex-wrap: wrap; - margin-left: -3px; - margin-right: -3px; } - #um-settings-wrap .subsubsub a { - margin: 0 3px; } - .um-settings-section .description { font-style: italic; } @@ -37,8 +26,8 @@ width: 25%; } .column-configure { - width: 60px; - text-align: center; } + width: 10%; + text-align: right; } th.column-email.column-primary { padding-left: 48px; } @@ -46,16 +35,19 @@ th.column-email.column-primary { .um-form-table .um-forms-line td { padding-right: 0; } -#um-settings-template-versions .wp-list-table .column-core_version { - width: 100px; - text-align: center; } +#um-settings-emails { + margin: 15px 0; } -#um-settings-template-versions .wp-list-table .column-theme_version { - width: 100px; - text-align: center; } - -#um-settings-template-versions .wp-list-table .column-status { - width: 260px; } +#um-settings-template-versions { + margin: 15px 0; } + #um-settings-template-versions .wp-list-table .column-core_version { + width: 100px; + text-align: center; } + #um-settings-template-versions .wp-list-table .column-theme_version { + width: 100px; + text-align: center; } + #um-settings-template-versions .wp-list-table .column-status { + width: 260px; } #um-settings-form { float: left; @@ -64,6 +56,12 @@ th.column-email.column-primary { #um-settings-form .subsubsub { float: left; width: 100%; } + #um-settings-form h2.title a.um-back-button { + font-weight: normal; + font-size: 30px; + line-height: 1; + text-decoration: none; + margin-right: 5px; } .um-settings-line .multi-checkbox-line { float: left; diff --git a/assets/css/admin/settings.min.css b/assets/css/admin/settings.min.css index a086dd80..414d88ee 100644 --- a/assets/css/admin/settings.min.css +++ b/assets/css/admin/settings.min.css @@ -1 +1 @@ -#um-settings-wrap .subsubsub{display:flex;flex-direction:row;justify-content:flex-start;align-items:center;flex-wrap:wrap;margin-left:-3px;margin-right:-3px}#um-settings-wrap .subsubsub a{margin:0 3px}.um-settings-section .description{font-style:italic}.um-notification-status{margin-right:18px;font-size:28px;line-height:22px;color:#c74a4a;float:left;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}.um-notification-status.um-notification-is-active{color:#7acf58}.um-email-configure span{line-height:24px}.um-long-field{width:100%}.um-medium-field{width:50%}.um-small-field{width:25%}.column-configure{width:60px;text-align:center}th.column-email.column-primary{padding-left:48px}.um-form-table .um-forms-line td{padding-right:0}#um-settings-template-versions .wp-list-table .column-core_version{width:100px;text-align:center}#um-settings-template-versions .wp-list-table .column-theme_version{width:100px;text-align:center}#um-settings-template-versions .wp-list-table .column-status{width:260px}#um-settings-form{float:left;width:100%;margin:0}#um-settings-form .subsubsub{float:left;width:100%}.um-settings-line .multi-checkbox-line{float:left;width:100%;clear:both;margin:0 0 10px 0;padding:0}.um-settings-line .multi-checkbox-column{float:left;margin:0;padding:0}.um-settings-line .multi-checkbox-column label{float:left;width:100%}.wrap-licenses .form-table,.wrap-licenses caption,.wrap-licenses tbody,.wrap-licenses td,.wrap-licenses tfoot,.wrap-licenses th,.wrap-licenses thead,.wrap-licenses tr{display:block}.wrap-licenses .form-table tr{float:left;margin:0 15px 15px 0;background:#fff;border:1px solid #ccc;width:30.5%;max-width:350px;padding:14px;min-height:240px;position:relative;box-sizing:border-box}.wrap-licenses .form-table th{background:#f9f9f9;padding:14px;border-bottom:1px solid #ccc;margin:-14px -14px 20px;width:100%}.wrap-licenses .form-table td{padding:0}.wrap-licenses td input.regular-text{margin:0 0 8px;width:100%}.wrap-licenses .edd-license-data[class*=edd-license-]{position:absolute;background:#fafafa;padding:14px;border-top:1px solid #eee;margin:20px -14px -14px;min-height:67px;width:100%;bottom:14px;box-sizing:border-box}.wrap-licenses .edd-license-data[class*=edd-license-] a{color:#444}.wrap-licenses .edd-license-data[class*=edd-license-] a:hover{text-decoration:none}.wrap-licenses .edd-license-data.license-expires-soon-notice{background-color:#00a0d2;color:#fff;border-color:#00a0d2}.wrap-licenses .edd-license-data.license-expires-soon-notice a{color:#fff}.wrap-licenses .edd-license-data.license-expires-soon-notice a:hover{text-decoration:none}.wrap-licenses .edd-license-data.edd-license-expired{background-color:#e24e4e;color:#fff;border-color:#e24e4e}.wrap-licenses .edd-license-data.edd-license-expired a{color:#fff}.wrap-licenses .edd-license-data.edd-license-expired a:hover{text-decoration:none}.wrap-licenses .edd-license-data.edd-license-valid{background-color:#5abc55;color:#fff;border-color:#5abc55}.wrap-licenses .edd-license-data.edd-license-error,.wrap-licenses .edd-license-data.edd-license-invalid,.wrap-licenses .edd-license-data.edd-license-item_name_mismatch,.wrap-licenses .edd-license-data.edd-license-missing,.wrap-licenses .edd-license-data.edd-license-site_inactive{background-color:#ffebcd;border-color:#ffebcd}.wrap-licenses .edd-license-data p{font-size:13px;margin-top:0}.wrap-licenses~p.submit{clear:both}@media screen and (max-width:980px){.wrap-licenses .form-table tr{width:calc(50% - 15px);max-width:none}}@media screen and (max-width:782px){#um-settings-template-versions .wp-list-table .column-core_version,#um-settings-template-versions .wp-list-table .column-theme_version{width:auto;text-align:left}.wrap-licenses .form-table tr{width:100%;margin-right:0;max-width:none}.um-settings-line .multi-checkbox-column{width:100%!important}.um-settings-line .multi-checkbox-column label{line-height:30px!important}.um-medium-field{width:100%}.um-small-field{width:50%}}.um_setting_ajax_button_response.complete{color:#7acf58;font-style:italic}.wp-core-ui .button.um_license_activate,.wp-core-ui .button.um_license_deactivate,.wp-core-ui .button.um_license_reactivate{margin-top:5px}.um-media-upload .um-media-upload-url{margin-bottom:5px} \ No newline at end of file +.um-settings-section .description{font-style:italic}.um-notification-status{margin-right:18px;font-size:28px;line-height:22px;color:#c74a4a;float:left;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}.um-notification-status.um-notification-is-active{color:#7acf58}.um-email-configure span{line-height:24px}.um-long-field{width:100%}.um-medium-field{width:50%}.um-small-field{width:25%}.column-configure{width:10%;text-align:right}th.column-email.column-primary{padding-left:48px}.um-form-table .um-forms-line td{padding-right:0}#um-settings-emails{margin:15px 0}#um-settings-template-versions{margin:15px 0}#um-settings-template-versions .wp-list-table .column-core_version{width:100px;text-align:center}#um-settings-template-versions .wp-list-table .column-theme_version{width:100px;text-align:center}#um-settings-template-versions .wp-list-table .column-status{width:260px}#um-settings-form{float:left;width:100%;margin:0}#um-settings-form .subsubsub{float:left;width:100%}#um-settings-form h2.title a.um-back-button{font-weight:400;font-size:30px;line-height:1;text-decoration:none;margin-right:5px}.um-settings-line .multi-checkbox-line{float:left;width:100%;clear:both;margin:0 0 10px 0;padding:0}.um-settings-line .multi-checkbox-column{float:left;margin:0;padding:0}.um-settings-line .multi-checkbox-column label{float:left;width:100%}.wrap-licenses .form-table,.wrap-licenses caption,.wrap-licenses tbody,.wrap-licenses td,.wrap-licenses tfoot,.wrap-licenses th,.wrap-licenses thead,.wrap-licenses tr{display:block}.wrap-licenses .form-table tr{float:left;margin:0 15px 15px 0;background:#fff;border:1px solid #ccc;width:30.5%;max-width:350px;padding:14px;min-height:240px;position:relative;box-sizing:border-box}.wrap-licenses .form-table th{background:#f9f9f9;padding:14px;border-bottom:1px solid #ccc;margin:-14px -14px 20px;width:100%}.wrap-licenses .form-table td{padding:0}.wrap-licenses td input.regular-text{margin:0 0 8px;width:100%}.wrap-licenses .edd-license-data[class*=edd-license-]{position:absolute;background:#fafafa;padding:14px;border-top:1px solid #eee;margin:20px -14px -14px;min-height:67px;width:100%;bottom:14px;box-sizing:border-box}.wrap-licenses .edd-license-data[class*=edd-license-] a{color:#444}.wrap-licenses .edd-license-data[class*=edd-license-] a:hover{text-decoration:none}.wrap-licenses .edd-license-data.license-expires-soon-notice{background-color:#00a0d2;color:#fff;border-color:#00a0d2}.wrap-licenses .edd-license-data.license-expires-soon-notice a{color:#fff}.wrap-licenses .edd-license-data.license-expires-soon-notice a:hover{text-decoration:none}.wrap-licenses .edd-license-data.edd-license-expired{background-color:#e24e4e;color:#fff;border-color:#e24e4e}.wrap-licenses .edd-license-data.edd-license-expired a{color:#fff}.wrap-licenses .edd-license-data.edd-license-expired a:hover{text-decoration:none}.wrap-licenses .edd-license-data.edd-license-valid{background-color:#5abc55;color:#fff;border-color:#5abc55}.wrap-licenses .edd-license-data.edd-license-error,.wrap-licenses .edd-license-data.edd-license-invalid,.wrap-licenses .edd-license-data.edd-license-item_name_mismatch,.wrap-licenses .edd-license-data.edd-license-missing,.wrap-licenses .edd-license-data.edd-license-site_inactive{background-color:#ffebcd;border-color:#ffebcd}.wrap-licenses .edd-license-data p{font-size:13px;margin-top:0}.wrap-licenses~p.submit{clear:both}@media screen and (max-width:980px){.wrap-licenses .form-table tr{width:calc(50% - 15px);max-width:none}}@media screen and (max-width:782px){#um-settings-template-versions .wp-list-table .column-core_version,#um-settings-template-versions .wp-list-table .column-theme_version{width:auto;text-align:left}.wrap-licenses .form-table tr{width:100%;margin-right:0;max-width:none}.um-settings-line .multi-checkbox-column{width:100%!important}.um-settings-line .multi-checkbox-column label{line-height:30px!important}.um-medium-field{width:100%}.um-small-field{width:50%}}.um_setting_ajax_button_response.complete{color:#7acf58;font-style:italic}.wp-core-ui .button.um_license_activate,.wp-core-ui .button.um_license_deactivate,.wp-core-ui .button.um_license_reactivate{margin-top:5px}.um-media-upload .um-media-upload-url{margin-bottom:5px} \ No newline at end of file diff --git a/assets/css/admin/settings.sass b/assets/css/admin/settings.sass index e6eec3c2..f0683e88 100644 --- a/assets/css/admin/settings.sass +++ b/assets/css/admin/settings.sass @@ -2,13 +2,13 @@ @import "mixins" @import "colors" -##{$prefix}settings-wrap - .subsubsub - +flex( row, flex-start, center, wrap ) - margin-left: -3px - margin-right: -3px - a - margin: 0 3px +//##{$prefix}settings-wrap +// .subsubsub +// +flex( row, flex-start, center, wrap ) +// margin-left: -3px +// margin-right: -3px +// a +// margin: 0 3px .#{$prefix}settings-section .description @@ -38,8 +38,8 @@ width: 25% .column-configure - width: 60px - text-align: center + width: 10% + text-align: right th.column-email.column-primary padding-left: 48px @@ -50,7 +50,11 @@ th.column-email.column-primary td padding-right: 0 +##{$prefix}settings-emails + margin: 15px 0 + ##{$prefix}settings-template-versions + margin: 15px 0 .wp-list-table .column-core_version width: 100px @@ -68,6 +72,13 @@ th.column-email.column-primary .subsubsub float: left width: 100% + h2.title + a.um-back-button + font-weight: normal + font-size: 30px + line-height: 1 + text-decoration: none + margin-right: 5px .#{$prefix}settings-line diff --git a/assets/js/admin/forms.js b/assets/js/admin/forms.js index e97d52e1..f1eecce0 100644 --- a/assets/js/admin/forms.js +++ b/assets/js/admin/forms.js @@ -97,6 +97,52 @@ function um_admin_init_users_select() { } +function um_admin_init_pages_select() { + // multiple select with AJAX search + jQuery('.um-pages-select2').select2({ + ajax: { + url: wp.ajax.settings.url, + dataType: 'json', + delay: 250, // delay in ms while typing when to perform a AJAX search + data: function( params ) { + return { + search: params.term, // search query + action: 'um_get_pages_list', // AJAX action for admin-ajax.php + page: params.page || 1, // infinite scroll pagination + nonce: um_admin_scripts.nonce + }; + }, + processResults: function( data, params ) { + params.page = params.page || 1; + var options = []; + + if ( data ) { + + // data is the array of arrays, and each of them contains ID and the Label of the option + jQuery.each( data, function( index, text ) { // do not forget that "index" is just auto incremented value + if ( index === 'total_count' ) { + return; + } + options.push( { id: text[0], text: text[1] } ); + }); + + } + + return { + results: options, + pagination: { + more: ( params.page * 10 ) < data.total_count + } + }; + }, + cache: true + }, + placeholder: jQuery(this).data('placeholder'), + minimumInputLength: 0, // the minimum of symbols to input before perform a search + allowClear: true, + }); +} + /** * * @param field_key @@ -123,6 +169,7 @@ function um_same_page_something_wrong( field_key ) { jQuery(document).ready( function() { um_admin_init_users_select(); + um_admin_init_pages_select(); /** * Same page upgrade field @@ -130,9 +177,9 @@ jQuery(document).ready( function() { jQuery( document.body ).on( 'click', '.um-forms-field[data-log-object]', function() { var obj = jQuery( this ).data( 'log-object' ); if ( jQuery( this ).is( ':checked' ) ) { - jQuery( this ).siblings( '.um-same-page-update-' + obj ).show(); + jQuery( this ).parents('label').siblings( '.um-same-page-update-' + obj ).show(); } else { - jQuery( this ).siblings( '.um-same-page-update-' + obj ).hide(); + jQuery( this ).parents('label').siblings( '.um-same-page-update-' + obj ).hide(); } }); diff --git a/assets/js/admin/forms.min.js b/assets/js/admin/forms.min.js index 7a60235d..7117ccbf 100644 --- a/assets/js/admin/forms.min.js +++ b/assets/js/admin/forms.min.js @@ -1 +1 @@ -function um_admin_init_users_select(){function e(a){var t;if(!a.id)return a.text;if(void 0!==a.img)t=jQuery(' '+a.text+"");else{let e;t=(e=void 0!==a.element&&void 0!==a.element.attributes["data-img"]?a.element.attributes["data-img"].value:e)?jQuery(' '+a.text+""):jQuery(""+a.text+"")}return t}var a,t;jQuery(".um-user-select-field:visible:not(.um-select2-inited)").length&&(a={ajax:{url:wp.ajax.settings.url,dataType:"json",delay:250,data:function(e){var a={action:"um_get_users",search:e.term,page:e.page||1,nonce:um_admin_scripts.nonce};return jQuery.each(jQuery(this)[0].attributes,function(){var e;this.specified&&-1!==this.name.indexOf("data-ajax-args-")&&(e=this.name.replace("data-ajax-args-","").trim(),a[e]=this.value)}),a},processResults:function(e,a){a.page=a.page||1;var t=[];return e.data.users&&jQuery.each(e.data.users,function(e,a){void 0!==a.img?t.push({id:a.ID,text:a.user_login+" (#"+a.ID+")",img:a.img}):t.push({id:a.ID,text:a.user_login+" (#"+a.ID+")"})}),{results:t,pagination:{more:20*a.page")}function um_same_page_wrong_ajax(e){um_add_same_page_log(e,wp.i18n.__("Wrong AJAX response...","ultimate-member")),um_add_same_page_log(e,wp.i18n.__("Your upgrade was crashed, please contact with support","ultimate-member"))}function um_same_page_something_wrong(e){um_add_same_page_log(e,wp.i18n.__("Something went wrong with AJAX request...","ultimate-member")),um_add_same_page_log(e,wp.i18n.__("Your upgrade was crashed, please contact with support","ultimate-member"))}jQuery(document).ready(function(){um_admin_init_users_select(),jQuery(document.body).on("click",".um-forms-field[data-log-object]",function(){var e=jQuery(this).data("log-object");jQuery(this).is(":checked")?jQuery(this).siblings(".um-same-page-update-"+e).show():jQuery(this).siblings(".um-same-page-update-"+e).hide()}),jQuery(document.body).on("click",".um-admin-form-same-page-update",function(){var t,a,i,s=jQuery(this).data("upgrade_cb");jQuery(this).prop("disabled",!0),um_add_same_page_log(s,wp.i18n.__("Upgrade Process Started...","ultimate-member")),"sync_metatable"===s?(t=0,a=500,jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_same_page_update",cb_func:"um_usermeta_fields",nonce:um_admin_scripts.nonce},success:function(e){i=1,um_add_same_page_log(s,wp.i18n.__("Getting metadata","ultimate-member")),jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_same_page_update",cb_func:"um_get_metadata",nonce:um_admin_scripts.nonce},success:function(e){void 0!==e.data.count?(um_add_same_page_log(s,wp.i18n.__("There are ","ultimate-member")+e.data.count+wp.i18n.__(" metadata rows...","ultimate-member")),um_add_same_page_log(s,wp.i18n.__("Start metadata upgrading...","ultimate-member")),t=Math.ceil(e.data.count/a),function a(){i<=t?jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_same_page_update",cb_func:"um_update_metadata_per_page",page:i,nonce:um_admin_scripts.nonce},success:function(e){void 0!==e.data?(um_add_same_page_log(s,e.data.message),i++,a()):um_same_page_wrong_ajax(s)},error:function(){um_same_page_something_wrong(s)}}):window.location=um_forms_data.successfully_redirect}()):um_same_page_wrong_ajax(s)},error:function(){um_same_page_something_wrong(s)}})},error:function(){um_same_page_something_wrong(s)}})):wp.hooks.doAction("um_same_page_upgrade",s)}),jQuery(".um-sortable-items-field").sortable({items:".um-sortable-item",connectWith:".um-admin-drag-col,.um-admin-drag-group",forcePlaceholderSize:!0,update:function(e,a){var t=[];jQuery(this).find("li").each(function(){jQuery(this).hasClass("um-hidden-item")||t.push(jQuery(this).data("tab-id"))}),jQuery(this).siblings(".um-sortable-items-value").val(t.join(","))}}),jQuery(".um-multi-selects-list.um-sortable-multi-selects").sortable({items:".um-admin-drag-fld",connectWith:".um-admin-drag-col,.um-admin-drag-group",forcePlaceholderSize:!0}),jQuery('.um-multi-selects-list[data-field_id="_um_sorting_fields"] li').each(function(){"other"===jQuery(this).find(".um-field-wrapper:not(.um-custom-order-fields) select").val()?jQuery(this).find(".um-field-wrapper.um-custom-order-fields").show():jQuery(this).find(".um-field-wrapper.um-custom-order-fields").hide()}),jQuery('.um-forms-line[data-field_type="md_sorting_fields"] .um-multi-selects-add-option').on("click",function(){var e=jQuery(this).siblings("ul.um-multi-selects-list"),a=e.hasClass("um-sortable-multi-selects"),t=(e.data("field_id"),0),i=(0").append(e.siblings(".um-hidden-multi-selects").clone()).html()),s='
  • ';a&&(s+='');let l="";jQuery.each(um_forms_data.md_sorting_data_types,function(e,a){l+='"}),s+=''+i+''+wp.i18n.__("Remove","ultimate-member")+'
  • ',e.append(s),e.find("li:last .um-hidden-multi-selects").attr("name",jQuery(this).data("name")).addClass("um-forms-field um-long-field").removeClass("um-hidden-multi-selects").attr("id",e.data("id_attr")+"-"+t).trigger("change"),jQuery("#"+e.data("id_attr")+"-"+t).parents("li").find('.um-field-wrapper.um-custom-order-fields input[name="meta_key"]').attr("name","um_metadata[_um_sorting_fields][other_data]["+t+"][meta_key]"),jQuery("#"+e.data("id_attr")+"-"+t).parents("li").find('.um-field-wrapper.um-custom-order-fields input[name="label"]').attr("name","um_metadata[_um_sorting_fields][other_data]["+t+"][label]"),jQuery("#"+e.data("id_attr")+"-"+t).parents("li").find('.um-field-wrapper.um-custom-order-fields select[name="data_type"]').attr("name","um_metadata[_um_sorting_fields][other_data]["+t+"][data_type]"),jQuery("#"+e.data("id_attr")+"-"+t).parents("li").find('.um-field-wrapper.um-custom-order-fields select[name="order"]').attr("name","um_metadata[_um_sorting_fields][other_data]["+t+"][order]")}),jQuery(document.body).on("change",'.um-multi-selects-list[data-field_id="_um_sorting_fields"] .um-field-wrapper:not(.um-custom-order-fields) select',function(){"other"===jQuery(this).val()?jQuery(this).parents("li").find(".um-field-wrapper.um-custom-order-fields").show():jQuery(this).parents("li").find(".um-field-wrapper.um-custom-order-fields").hide()}),jQuery(document.body).on("click",".um-multi-selects-option-line .um-select-delete",function(){jQuery(this).parents("li.um-multi-selects-option-line").remove()}),jQuery(document.body).on("click",".um-md-default-filters-option-line .um-select-delete",function(){jQuery(this).parents("li.um-md-default-filters-option-line").remove()}),jQuery(".um-multi-selects-add-option").on("click",function(){var e,a,t,i;jQuery(this).parents('.um-forms-line[data-field_type="md_sorting_fields"]').length||(a=(e=jQuery(this).siblings("ul.um-multi-selects-list")).hasClass("um-sortable-multi-selects"),e.data("field_id"),(t=0)',a&&(i+=''),i+=''+jQuery("
    ").append(e.siblings(".um-hidden-multi-selects").clone()).html()+''+wp.i18n.__("Remove","ultimate-member")+"",e.append(i),e.find("li:last .um-hidden-multi-selects").attr("name",jQuery(this).data("name")).addClass("um-forms-field um-long-field").removeClass("um-hidden-multi-selects").attr("id",e.data("id_attr")+"-"+t))});var t,e=-(new Date).getTimezoneOffset()/60,i=(jQuery('input[name="um-gmt-offset"]').val(e),jQuery(".um-admin-metabox").find(".um-slider").each(function(){var e=jQuery(this),a=parseInt(e.data("min")),t=parseInt(e.data("max")),a=[a=void 0!==jQuery("#"+e.data("field_name")+"_min").val()?jQuery("#"+e.data("field_name")+"_min").val():a,t=void 0!==jQuery("#"+e.data("field_name")+"_max").val()?jQuery("#"+e.data("field_name")+"_max").val():t];e.slider({range:!0,min:parseInt(e.data("min")),max:parseInt(e.data("max")),values:a,create:function(e,a){},step:1,slide:function(e,a){s(jQuery(this),a)},stop:function(e,a){}}),s(e)}),jQuery(".um-admin-metabox").find(".um-datepicker-filter").each(function(){var e=jQuery(this),a=new Date(1e3*e.data("date_min")),t=new Date(1e3*e.data("date_max"));e.pickadate({selectYears:!0,min:a,max:t,formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){e.blur(),e.siblings(".picker").find(".picker__button--close").addClass("button")},onClose:function(){e.blur()},onSet:function(e){}}).pickadate("picker").set("select",1e3*e.data("value"))}),jQuery(".um-admin-metabox").find(".um-timepicker-filter").each(function(){var e=jQuery(this),a=e.data("min"),t=e.data("max"),a=a.split(":"),t=t.split(":");e.pickatime({format:e.data("format"),interval:parseInt(e.data("intervals")),min:[a[0],a[1]],max:[t[0],t[1]],formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()},onSet:function(e){}})}),!1);function s(e,a){var t,i="",s=e.siblings(".um-slider-range").data("placeholder-s"),l=e.siblings(".um-slider-range").data("placeholder-p"),a=a?(i=(a.values[0]===a.values[1]?s.replace("{value}",a.values[0]):l.replace("{min_range}",a.values[0]).replace("{max_range}",a.values[1])).replace("{field_label}",e.siblings(".um-slider-range").data("label")),t=a.values[0],a.values[1]):(i=(e.slider("values",0)===e.slider("values",1)?s.replace("{value}",e.slider("values",0)):l.replace("{min_range}",e.slider("values",0)).replace("{max_range}",e.slider("values",1))).replace("{field_label}",e.siblings(".um-slider-range").data("label")),t=e.slider("values",0),e.slider("values",1));e.siblings(".um-slider-range").html(i),e.siblings(".um_range_min").val(t),e.siblings(".um_range_max").val(a)}function a(){jQuery(".um-forms-line").removeClass("um-forms-line-conditioned").each(function(){void 0===jQuery(this).data("conditional")||jQuery(this).hasClass("um-forms-line-conditioned")||(!function i(e){e.addClass("um-forms-line-conditioned");var a=e.data("conditional");var t=a[1];var s=a[2];var l=e.data("prefix");var n=!0;{var r,u;"="===t||"!="===t?-1===a[0].indexOf("||")&&void 0!==(u=jQuery("#"+l+"_"+a[0])).parents(".um-forms-line").data("conditional")&&(n=i(u.parents(".um-forms-line"))):"~"===t?(m=a[0].split("|"),r=[],jQuery.each(m,function(e){r.push(jQuery("#"+l+"_"+m[e]))}),void 0!==r[0].parents(".um-forms-line").data("conditional")&&(n=i(r[0].parents(".um-forms-line")))):"><"===t&&void 0!==(u=jQuery("#"+l+"_"+a[0]+"_"+a[2])).parents(".um-forms-line").data("conditional")&&(n=i(u.parents(".um-forms-line")))}var d=!1;{var m,o,c,p,f,_,h,g;if("="===t)return-1!==a[0].indexOf("||")?(m=a[0].split("||"),o=!1,jQuery.each(m,function(e){var a,e=jQuery("#"+l+"_"+m[e]),t=(n=!(d=!1),void 0!==e.parents(".um-forms-line").data("conditional")&&(n=i(e.parents(".um-forms-line"))),e.prop("tagName").toLowerCase());"input"===t?(a=e.attr("type"),d="checkbox"===a?"1"==s?e.is(":checked"):!e.is(":checked"):Array.isArray(s)?-1!==s.indexOf(e.val()):e.val()==s):"select"===t&&(d=Array.isArray(s)?-1!==s.indexOf(e.val()):e.val()==s),d&&n&&(o=!0)}),o):("input"==(h=u.prop("tagName").toLowerCase())?(g=u.attr("type"),d="checkbox"==g?"1"==s?u.is(":checked"):!u.is(":checked"):Array.isArray(s)?-1!==s.indexOf(u.val()):u.val()==s):"select"==h&&(d=Array.isArray(s)?-1!==s.indexOf(u.val()):u.val()==s),d&&n);if("!="===t)return-1!==a[0].indexOf("||")?(m=a[0].split("||"),o=!1,jQuery.each(m,function(e){var a,e=jQuery("#"+l+"_"+m[e]),t=(n=!(d=!1),void 0!==e.parents(".um-forms-line").data("conditional")&&(n=i(e.parents(".um-forms-line"))),e.prop("tagName").toLowerCase());"input"===t?(a=e.attr("type"),d="checkbox"===a?"1"==s?!e.is(":checked"):e.is(":checked"):e.val()!=s):"select"===t&&(d=e.val()!=s),d&&n&&(o=!0)}),o):("input"==(h=u.prop("tagName").toLowerCase())?(g=u.attr("type"),d="checkbox"==g?"1"==s?!u.is(":checked"):u.is(":checked"):u.val()!=s):"select"==h&&(d=u.val()!=s),d&&n);if("~"===t)return p=[],"sortable_items"===e.data("field_type")?(c=e.find(".um-sortable-items-value").data("field_id"),jQuery.each(r,function(e){var e=r[e],a=e.prop("tagName").toLowerCase();"input"===a?"checkbox"===e.attr("type")&&"1"==s&&e.is(":checked")&&p.push(e.data("fill_"+c)):"select"==a&&!s&&e.val()&&(p=(p=p.concat(e.val())).filter(y))}),f=jQuery('[data-field_id="'+c+'"]'),p.length?(f.siblings(".um-sortable-items-field").find("li").addClass("um-hidden-item"),jQuery.each(p,function(e){f.siblings(".um-sortable-items-field").find('li[data-tab-id="'+p[e]+'"]').removeClass("um-hidden-item")}),_=[],f.siblings(".um-sortable-items-field").find("li").each(function(){jQuery(this).hasClass("um-hidden-item")||_.push(jQuery(this).data("tab-id"))}),f.val(_.join(",")),f.siblings(".um-sortable-items-field").sortable("refresh"),d=!0):f.val(null)):(c=e.find(e.data("field_type")).data("field_id"),jQuery.each(r,function(e){var e=r[e],a=e.prop("tagName").toLowerCase();"input"===a?"checkbox"===e.attr("type")&&"1"==s&&e.is(":checked")&&p.push(e.data("fill_"+c)):"select"==a&&!s&&e.val()&&(p=(p=p.concat(e.val())).filter(y))}),f=jQuery('[data-field_id="'+c+'"]'),p.length?(f.find("option").hide(),jQuery.each(p,function(e){f.find('option[value="'+p[e]+'"]').show()}),-1===p.indexOf(f.val())&&(f.val(p[0]),f.find("option").attr("selected",!1).prop("selected",!1),f.find('option[value="'+p[0]+'"]').attr("selected",!0).prop("selected",!0)),d=!0):(f.val(null),f.find("option").attr("selected",!1).prop("selected",!1))),d&&n;if("><"===t)return h=u.prop("tagName").toLowerCase(),(d="input"==h&&"checkbox"==(g=u.attr("type"))?u.is(":checked"):d)&&n}return!1}(jQuery(this))?jQuery(this).hide():(jQuery(this).show(),um_admin_init_users_select()))})}function y(e,a,t){return t.indexOf(e)===a}jQuery(document.body).on("change",".um-md-default-filters-option-line .um-field-wrapper select",function(){var t,e,a;i||(e=(t=jQuery(this)).val(),a=t.data("member_directory"),i=!0,wp.ajax.send("um_member_directory_default_filter_settings",{data:{key:e,directory_id:a,nonce:um_admin_scripts.nonce},success:function(e){var a=t.parents(".um-md-default-filters-option-line").find(".um-field-wrapper2");a.html(e.field_html),i=!1,a.find(".um-slider").each(function(){var e=jQuery(this),a=[parseInt(e.data("min")),parseInt(e.data("max"))];e.slider({range:!0,min:parseInt(e.data("min")),max:parseInt(e.data("max")),values:a,create:function(e,a){},step:1,slide:function(e,a){s(jQuery(this),a)},stop:function(e,a){}}),s(e)}),a.find(".um-datepicker-filter").each(function(){var e=jQuery(this),a=new Date(1e3*e.data("date_min")),t=new Date(1e3*e.data("date_max"));e.pickadate({selectYears:!0,min:a,max:t,formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){e.blur(),e.siblings(".picker").find(".picker__button--close").addClass("button")},onClose:function(){e.blur()},onSet:function(e){}})}),a.find(".um-timepicker-filter").each(function(){var e=jQuery(this),a=e.data("min"),t=e.data("max"),a=a.split(":"),t=t.split(":");e.pickatime({format:e.data("format"),interval:parseInt(e.data("intervals")),min:[a[0],a[1]],max:[t[0],t[1]],formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()},onSet:function(e){}})})},error:function(e){return!1}}))}),jQuery(".um-md-default-filters-add-option").on("click",function(){var e,a,t;i||((e=jQuery(this).siblings("ul.um-md-default-filters-list")).data("field_id"),(a=0)").append(e.siblings(".um-hidden-md-default-filters").clone()).html(),e.append('
  • '+t+''+wp.i18n.__("Remove","ultimate-member")+'
  • '),e.find("li:last .um-hidden-md-default-filters").attr("name",jQuery(this).data("name")).addClass("um-forms-field um-long-field").removeClass("um-hidden-md-default-filters").attr("id",e.data("id_attr")+"-"+a),e.find("li:last .um-field-wrapper select").trigger("change"))}),jQuery(document.body).on("click",".um-text-delete",function(){jQuery(this).parents("li.um-multi-text-option-line").remove()}),jQuery(".um-multi-text-add-option").on("click",function(){var e=jQuery(this).siblings("ul.um-multi-text-list"),a=0,t=(0").append(e.siblings(".um-hidden-multi-text").clone()).html()),i=e.data("item_class");e.append('
  • '+t+''+wp.i18n.__("Remove","ultimate-member")+"
  • "),e.find("li:last .um-hidden-multi-text").attr("name",jQuery(this).data("name")).addClass("um-forms-field um-long-field").removeClass("um-hidden-multi-text").attr("id",e.data("id_attr")+"-"+a)}),jQuery(".um-media-upload").each(function(){var e=jQuery(this).find(".um-forms-field"),a=e.data("default");""!=e.val()&&e.val()!=a?(e.siblings(".um-set-image").hide(),e.siblings(".um-clear-image").show(),e.siblings(".icon_preview").show()):(e.val()==a&&e.siblings(".icon_preview").show(),e.siblings(".um-set-image").show(),e.siblings(".um-clear-image").hide())}),"undefined"!=typeof wp&&wp.media&&wp.media.editor&&(jQuery(".um-set-image").on("click",function(e){var a=jQuery(this);e.preventDefault(),t&&t.remove(),(t=wp.media({title:a.data("upload_frame"),button:{text:wp.i18n.__("Select","ultimate-member")},multiple:!1})).on("select",function(){var e=t.state().get("selection").first().toJSON();a.siblings(".icon_preview").attr("src",e.url).show(),a.siblings(".um-forms-field").val(e.url),a.siblings(".um-media-upload-data-id").val(e.id),a.siblings(".um-media-upload-data-width").val(e.width),a.siblings(".um-media-upload-data-height").val(e.height),a.siblings(".um-media-upload-data-thumbnail").val(e.thumbnail),a.siblings(".um-media-upload-data-url").trigger("change"),a.siblings(".um-media-upload-url").val(e.url),a.siblings(".um-clear-image").show(),a.hide(),jQuery(document).trigger("um_media_upload_select",[a,e])}),t.open()}),jQuery(".icon_preview").on("click",function(e){jQuery(this).siblings(".um-set-image").trigger("click")}),jQuery(".um-clear-image").on("click",function(e){var a=jQuery(this),t=a.siblings(".um-forms-field").data("default");a.siblings(".um-set-image").show(),a.hide(),a.siblings(".icon_preview").attr("src",t),a.siblings(".um-media-upload-data-id").val(""),a.siblings(".um-media-upload-data-width").val(""),a.siblings(".um-media-upload-data-height").val(""),a.siblings(".um-media-upload-data-thumbnail").val(""),a.siblings(".um-forms-field").val(t),a.siblings(".um-media-upload-data-url").trigger("change"),a.siblings(".um-media-upload-url").val(t),jQuery(document).trigger("um_media_upload_clear",a)})),jQuery(document.body).on("change",".um-forms-field",function(){(0 '+a.text+"");else{let e;t=(e=void 0!==a.element&&void 0!==a.element.attributes["data-img"]?a.element.attributes["data-img"].value:e)?jQuery(' '+a.text+""):jQuery(""+a.text+"")}return t}var a,t;jQuery(".um-user-select-field:visible:not(.um-select2-inited)").length&&(a={ajax:{url:wp.ajax.settings.url,dataType:"json",delay:250,data:function(e){var a={action:"um_get_users",search:e.term,page:e.page||1,nonce:um_admin_scripts.nonce};return jQuery.each(jQuery(this)[0].attributes,function(){var e;this.specified&&-1!==this.name.indexOf("data-ajax-args-")&&(e=this.name.replace("data-ajax-args-","").trim(),a[e]=this.value)}),a},processResults:function(e,a){a.page=a.page||1;var t=[];return e.data.users&&jQuery.each(e.data.users,function(e,a){void 0!==a.img?t.push({id:a.ID,text:a.user_login+" (#"+a.ID+")",img:a.img}):t.push({id:a.ID,text:a.user_login+" (#"+a.ID+")"})}),{results:t,pagination:{more:20*a.page")}function um_same_page_wrong_ajax(e){um_add_same_page_log(e,wp.i18n.__("Wrong AJAX response...","ultimate-member")),um_add_same_page_log(e,wp.i18n.__("Your upgrade was crashed, please contact with support","ultimate-member"))}function um_same_page_something_wrong(e){um_add_same_page_log(e,wp.i18n.__("Something went wrong with AJAX request...","ultimate-member")),um_add_same_page_log(e,wp.i18n.__("Your upgrade was crashed, please contact with support","ultimate-member"))}jQuery(document).ready(function(){um_admin_init_users_select(),um_admin_init_pages_select(),jQuery(document.body).on("click",".um-forms-field[data-log-object]",function(){var e=jQuery(this).data("log-object");jQuery(this).is(":checked")?jQuery(this).parents("label").siblings(".um-same-page-update-"+e).show():jQuery(this).parents("label").siblings(".um-same-page-update-"+e).hide()}),jQuery(document.body).on("click",".um-admin-form-same-page-update",function(){var t,a,i,s=jQuery(this).data("upgrade_cb");jQuery(this).prop("disabled",!0),um_add_same_page_log(s,wp.i18n.__("Upgrade Process Started...","ultimate-member")),"sync_metatable"===s?(t=0,a=500,jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_same_page_update",cb_func:"um_usermeta_fields",nonce:um_admin_scripts.nonce},success:function(e){i=1,um_add_same_page_log(s,wp.i18n.__("Getting metadata","ultimate-member")),jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_same_page_update",cb_func:"um_get_metadata",nonce:um_admin_scripts.nonce},success:function(e){void 0!==e.data.count?(um_add_same_page_log(s,wp.i18n.__("There are ","ultimate-member")+e.data.count+wp.i18n.__(" metadata rows...","ultimate-member")),um_add_same_page_log(s,wp.i18n.__("Start metadata upgrading...","ultimate-member")),t=Math.ceil(e.data.count/a),function a(){i<=t?jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_same_page_update",cb_func:"um_update_metadata_per_page",page:i,nonce:um_admin_scripts.nonce},success:function(e){void 0!==e.data?(um_add_same_page_log(s,e.data.message),i++,a()):um_same_page_wrong_ajax(s)},error:function(){um_same_page_something_wrong(s)}}):window.location=um_forms_data.successfully_redirect}()):um_same_page_wrong_ajax(s)},error:function(){um_same_page_something_wrong(s)}})},error:function(){um_same_page_something_wrong(s)}})):wp.hooks.doAction("um_same_page_upgrade",s)}),jQuery(".um-sortable-items-field").sortable({items:".um-sortable-item",connectWith:".um-admin-drag-col,.um-admin-drag-group",forcePlaceholderSize:!0,update:function(e,a){var t=[];jQuery(this).find("li").each(function(){jQuery(this).hasClass("um-hidden-item")||t.push(jQuery(this).data("tab-id"))}),jQuery(this).siblings(".um-sortable-items-value").val(t.join(","))}}),jQuery(".um-multi-selects-list.um-sortable-multi-selects").sortable({items:".um-admin-drag-fld",connectWith:".um-admin-drag-col,.um-admin-drag-group",forcePlaceholderSize:!0}),jQuery('.um-multi-selects-list[data-field_id="_um_sorting_fields"] li').each(function(){"other"===jQuery(this).find(".um-field-wrapper:not(.um-custom-order-fields) select").val()?jQuery(this).find(".um-field-wrapper.um-custom-order-fields").show():jQuery(this).find(".um-field-wrapper.um-custom-order-fields").hide()}),jQuery('.um-forms-line[data-field_type="md_sorting_fields"] .um-multi-selects-add-option').on("click",function(){var e=jQuery(this).siblings("ul.um-multi-selects-list"),a=e.hasClass("um-sortable-multi-selects"),t=(e.data("field_id"),0),i=(0").append(e.siblings(".um-hidden-multi-selects").clone()).html()),s='
  • ';a&&(s+='');let l="";jQuery.each(um_forms_data.md_sorting_data_types,function(e,a){l+='"}),s+=''+i+''+wp.i18n.__("Remove","ultimate-member")+'
  • ',e.append(s),e.find("li:last .um-hidden-multi-selects").attr("name",jQuery(this).data("name")).addClass("um-forms-field um-long-field").removeClass("um-hidden-multi-selects").attr("id",e.data("id_attr")+"-"+t).trigger("change"),jQuery("#"+e.data("id_attr")+"-"+t).parents("li").find('.um-field-wrapper.um-custom-order-fields input[name="meta_key"]').attr("name","um_metadata[_um_sorting_fields][other_data]["+t+"][meta_key]"),jQuery("#"+e.data("id_attr")+"-"+t).parents("li").find('.um-field-wrapper.um-custom-order-fields input[name="label"]').attr("name","um_metadata[_um_sorting_fields][other_data]["+t+"][label]"),jQuery("#"+e.data("id_attr")+"-"+t).parents("li").find('.um-field-wrapper.um-custom-order-fields select[name="data_type"]').attr("name","um_metadata[_um_sorting_fields][other_data]["+t+"][data_type]"),jQuery("#"+e.data("id_attr")+"-"+t).parents("li").find('.um-field-wrapper.um-custom-order-fields select[name="order"]').attr("name","um_metadata[_um_sorting_fields][other_data]["+t+"][order]")}),jQuery(document.body).on("change",'.um-multi-selects-list[data-field_id="_um_sorting_fields"] .um-field-wrapper:not(.um-custom-order-fields) select',function(){"other"===jQuery(this).val()?jQuery(this).parents("li").find(".um-field-wrapper.um-custom-order-fields").show():jQuery(this).parents("li").find(".um-field-wrapper.um-custom-order-fields").hide()}),jQuery(document.body).on("click",".um-multi-selects-option-line .um-select-delete",function(){jQuery(this).parents("li.um-multi-selects-option-line").remove()}),jQuery(document.body).on("click",".um-md-default-filters-option-line .um-select-delete",function(){jQuery(this).parents("li.um-md-default-filters-option-line").remove()}),jQuery(".um-multi-selects-add-option").on("click",function(){var e,a,t,i;jQuery(this).parents('.um-forms-line[data-field_type="md_sorting_fields"]').length||(a=(e=jQuery(this).siblings("ul.um-multi-selects-list")).hasClass("um-sortable-multi-selects"),e.data("field_id"),(t=0)',a&&(i+=''),i+=''+jQuery("
    ").append(e.siblings(".um-hidden-multi-selects").clone()).html()+''+wp.i18n.__("Remove","ultimate-member")+"",e.append(i),e.find("li:last .um-hidden-multi-selects").attr("name",jQuery(this).data("name")).addClass("um-forms-field um-long-field").removeClass("um-hidden-multi-selects").attr("id",e.data("id_attr")+"-"+t))});var t,e=-(new Date).getTimezoneOffset()/60,i=(jQuery('input[name="um-gmt-offset"]').val(e),jQuery(".um-admin-metabox").find(".um-slider").each(function(){var e=jQuery(this),a=parseInt(e.data("min")),t=parseInt(e.data("max")),a=[a=void 0!==jQuery("#"+e.data("field_name")+"_min").val()?jQuery("#"+e.data("field_name")+"_min").val():a,t=void 0!==jQuery("#"+e.data("field_name")+"_max").val()?jQuery("#"+e.data("field_name")+"_max").val():t];e.slider({range:!0,min:parseInt(e.data("min")),max:parseInt(e.data("max")),values:a,create:function(e,a){},step:1,slide:function(e,a){s(jQuery(this),a)},stop:function(e,a){}}),s(e)}),jQuery(".um-admin-metabox").find(".um-datepicker-filter").each(function(){var e=jQuery(this),a=new Date(1e3*e.data("date_min")),t=new Date(1e3*e.data("date_max"));e.pickadate({selectYears:!0,min:a,max:t,formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()},onSet:function(e){}}).pickadate("picker").set("select",1e3*e.data("value"))}),jQuery(".um-admin-metabox").find(".um-timepicker-filter").each(function(){var e=jQuery(this),a=e.data("min"),t=e.data("max"),a=a.split(":"),t=t.split(":");e.pickatime({format:e.data("format"),interval:parseInt(e.data("intervals")),min:[a[0],a[1]],max:[t[0],t[1]],formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()},onSet:function(e){}})}),!1);function s(e,a){var t,i="",s=e.siblings(".um-slider-range").data("placeholder-s"),l=e.siblings(".um-slider-range").data("placeholder-p"),a=a?(i=(a.values[0]===a.values[1]?s.replace("{value}",a.values[0]):l.replace("{min_range}",a.values[0]).replace("{max_range}",a.values[1])).replace("{field_label}",e.siblings(".um-slider-range").data("label")),t=a.values[0],a.values[1]):(i=(e.slider("values",0)===e.slider("values",1)?s.replace("{value}",e.slider("values",0)):l.replace("{min_range}",e.slider("values",0)).replace("{max_range}",e.slider("values",1))).replace("{field_label}",e.siblings(".um-slider-range").data("label")),t=e.slider("values",0),e.slider("values",1));e.siblings(".um-slider-range").html(i),e.siblings(".um_range_min").val(t),e.siblings(".um_range_max").val(a)}function a(){jQuery(".um-forms-line").removeClass("um-forms-line-conditioned").each(function(){void 0===jQuery(this).data("conditional")||jQuery(this).hasClass("um-forms-line-conditioned")||(!function i(e){e.addClass("um-forms-line-conditioned");var a=e.data("conditional");var t=a[1];var s=a[2];var l=e.data("prefix");var n=!0;{var r,u;"="===t||"!="===t?-1===a[0].indexOf("||")&&void 0!==(u=jQuery("#"+l+"_"+a[0])).parents(".um-forms-line").data("conditional")&&(n=i(u.parents(".um-forms-line"))):"~"===t?(m=a[0].split("|"),r=[],jQuery.each(m,function(e){r.push(jQuery("#"+l+"_"+m[e]))}),void 0!==r[0].parents(".um-forms-line").data("conditional")&&(n=i(r[0].parents(".um-forms-line")))):"><"===t&&void 0!==(u=jQuery("#"+l+"_"+a[0]+"_"+a[2])).parents(".um-forms-line").data("conditional")&&(n=i(u.parents(".um-forms-line")))}var d=!1;{var m,o,c,p,f,_,g,h;if("="===t)return-1!==a[0].indexOf("||")?(m=a[0].split("||"),o=!1,jQuery.each(m,function(e){var a,e=jQuery("#"+l+"_"+m[e]),t=(n=!(d=!1),void 0!==e.parents(".um-forms-line").data("conditional")&&(n=i(e.parents(".um-forms-line"))),e.prop("tagName").toLowerCase());"input"===t?(a=e.attr("type"),d="checkbox"===a?"1"==s?e.is(":checked"):!e.is(":checked"):Array.isArray(s)?-1!==s.indexOf(e.val()):e.val()==s):"select"===t&&(d=Array.isArray(s)?-1!==s.indexOf(e.val()):e.val()==s),d&&n&&(o=!0)}),o):("input"==(g=u.prop("tagName").toLowerCase())?(h=u.attr("type"),d="checkbox"==h?"1"==s?u.is(":checked"):!u.is(":checked"):Array.isArray(s)?-1!==s.indexOf(u.val()):u.val()==s):"select"==g&&(d=Array.isArray(s)?-1!==s.indexOf(u.val()):u.val()==s),d&&n);if("!="===t)return-1!==a[0].indexOf("||")?(m=a[0].split("||"),o=!1,jQuery.each(m,function(e){var a,e=jQuery("#"+l+"_"+m[e]),t=(n=!(d=!1),void 0!==e.parents(".um-forms-line").data("conditional")&&(n=i(e.parents(".um-forms-line"))),e.prop("tagName").toLowerCase());"input"===t?(a=e.attr("type"),d="checkbox"===a?"1"==s?!e.is(":checked"):e.is(":checked"):e.val()!=s):"select"===t&&(d=e.val()!=s),d&&n&&(o=!0)}),o):("input"==(g=u.prop("tagName").toLowerCase())?(h=u.attr("type"),d="checkbox"==h?"1"==s?!u.is(":checked"):u.is(":checked"):u.val()!=s):"select"==g&&(d=u.val()!=s),d&&n);if("~"===t)return p=[],"sortable_items"===e.data("field_type")?(c=e.find(".um-sortable-items-value").data("field_id"),jQuery.each(r,function(e){var e=r[e],a=e.prop("tagName").toLowerCase();"input"===a?"checkbox"===e.attr("type")&&"1"==s&&e.is(":checked")&&p.push(e.data("fill_"+c)):"select"==a&&!s&&e.val()&&(p=(p=p.concat(e.val())).filter(y))}),f=jQuery('[data-field_id="'+c+'"]'),p.length?(f.siblings(".um-sortable-items-field").find("li").addClass("um-hidden-item"),jQuery.each(p,function(e){f.siblings(".um-sortable-items-field").find('li[data-tab-id="'+p[e]+'"]').removeClass("um-hidden-item")}),_=[],f.siblings(".um-sortable-items-field").find("li").each(function(){jQuery(this).hasClass("um-hidden-item")||_.push(jQuery(this).data("tab-id"))}),f.val(_.join(",")),f.siblings(".um-sortable-items-field").sortable("refresh"),d=!0):f.val(null)):(c=e.find(e.data("field_type")).data("field_id"),jQuery.each(r,function(e){var e=r[e],a=e.prop("tagName").toLowerCase();"input"===a?"checkbox"===e.attr("type")&&"1"==s&&e.is(":checked")&&p.push(e.data("fill_"+c)):"select"==a&&!s&&e.val()&&(p=(p=p.concat(e.val())).filter(y))}),f=jQuery('[data-field_id="'+c+'"]'),p.length?(f.find("option").hide(),jQuery.each(p,function(e){f.find('option[value="'+p[e]+'"]').show()}),-1===p.indexOf(f.val())&&(f.val(p[0]),f.find("option").attr("selected",!1).prop("selected",!1),f.find('option[value="'+p[0]+'"]').attr("selected",!0).prop("selected",!0)),d=!0):(f.val(null),f.find("option").attr("selected",!1).prop("selected",!1))),d&&n;if("><"===t)return g=u.prop("tagName").toLowerCase(),(d="input"==g&&"checkbox"==(h=u.attr("type"))?u.is(":checked"):d)&&n}return!1}(jQuery(this))?jQuery(this).hide():(jQuery(this).show(),um_admin_init_users_select()))})}function y(e,a,t){return t.indexOf(e)===a}jQuery(document.body).on("change",".um-md-default-filters-option-line .um-field-wrapper select",function(){var t,e,a;i||(e=(t=jQuery(this)).val(),a=t.data("member_directory"),i=!0,wp.ajax.send("um_member_directory_default_filter_settings",{data:{key:e,directory_id:a,nonce:um_admin_scripts.nonce},success:function(e){var a=t.parents(".um-md-default-filters-option-line").find(".um-field-wrapper2");a.html(e.field_html),i=!1,a.find(".um-slider").each(function(){var e=jQuery(this),a=[parseInt(e.data("min")),parseInt(e.data("max"))];e.slider({range:!0,min:parseInt(e.data("min")),max:parseInt(e.data("max")),values:a,create:function(e,a){},step:1,slide:function(e,a){s(jQuery(this),a)},stop:function(e,a){}}),s(e)}),a.find(".um-datepicker-filter").each(function(){var e=jQuery(this),a=new Date(1e3*e.data("date_min")),t=new Date(1e3*e.data("date_max"));e.pickadate({selectYears:!0,min:a,max:t,formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()},onSet:function(e){}})}),a.find(".um-timepicker-filter").each(function(){var e=jQuery(this),a=e.data("min"),t=e.data("max"),a=a.split(":"),t=t.split(":");e.pickatime({format:e.data("format"),interval:parseInt(e.data("intervals")),min:[a[0],a[1]],max:[t[0],t[1]],formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()},onSet:function(e){}})})},error:function(e){return!1}}))}),jQuery(".um-md-default-filters-add-option").on("click",function(){var e,a,t;i||((e=jQuery(this).siblings("ul.um-md-default-filters-list")).data("field_id"),(a=0)").append(e.siblings(".um-hidden-md-default-filters").clone()).html(),e.append('
  • '+t+''+wp.i18n.__("Remove","ultimate-member")+'
  • '),e.find("li:last .um-hidden-md-default-filters").attr("name",jQuery(this).data("name")).addClass("um-forms-field um-long-field").removeClass("um-hidden-md-default-filters").attr("id",e.data("id_attr")+"-"+a),e.find("li:last .um-field-wrapper select").trigger("change"))}),jQuery(document.body).on("click",".um-text-delete",function(){jQuery(this).parents("li.um-multi-text-option-line").remove()}),jQuery(".um-multi-text-add-option").on("click",function(){var e=jQuery(this).siblings("ul.um-multi-text-list"),a=0,t=(0").append(e.siblings(".um-hidden-multi-text").clone()).html()),i=e.data("item_class");e.append('
  • '+t+''+wp.i18n.__("Remove","ultimate-member")+"
  • "),e.find("li:last .um-hidden-multi-text").attr("name",jQuery(this).data("name")).addClass("um-forms-field um-long-field").removeClass("um-hidden-multi-text").attr("id",e.data("id_attr")+"-"+a)}),jQuery(".um-media-upload").each(function(){var e=jQuery(this).find(".um-forms-field"),a=e.data("default");""!=e.val()&&e.val()!=a?(e.siblings(".um-set-image").hide(),e.siblings(".um-clear-image").show(),e.siblings(".icon_preview").show()):(e.val()==a&&e.siblings(".icon_preview").show(),e.siblings(".um-set-image").show(),e.siblings(".um-clear-image").hide())}),"undefined"!=typeof wp&&wp.media&&wp.media.editor&&(jQuery(".um-set-image").on("click",function(e){var a=jQuery(this);e.preventDefault(),t&&t.remove(),(t=wp.media({title:a.data("upload_frame"),button:{text:wp.i18n.__("Select","ultimate-member")},multiple:!1})).on("select",function(){var e=t.state().get("selection").first().toJSON();a.siblings(".icon_preview").attr("src",e.url).show(),a.siblings(".um-forms-field").val(e.url),a.siblings(".um-media-upload-data-id").val(e.id),a.siblings(".um-media-upload-data-width").val(e.width),a.siblings(".um-media-upload-data-height").val(e.height),a.siblings(".um-media-upload-data-thumbnail").val(e.thumbnail),a.siblings(".um-media-upload-data-url").trigger("change"),a.siblings(".um-media-upload-url").val(e.url),a.siblings(".um-clear-image").show(),a.hide(),jQuery(document).trigger("um_media_upload_select",[a,e])}),t.open()}),jQuery(".icon_preview").on("click",function(e){jQuery(this).siblings(".um-set-image").trigger("click")}),jQuery(".um-clear-image").on("click",function(e){var a=jQuery(this),t=a.siblings(".um-forms-field").data("default");a.siblings(".um-set-image").show(),a.hide(),a.siblings(".icon_preview").attr("src",t),a.siblings(".um-media-upload-data-id").val(""),a.siblings(".um-media-upload-data-width").val(""),a.siblings(".um-media-upload-data-height").val(""),a.siblings(".um-media-upload-data-thumbnail").val(""),a.siblings(".um-forms-field").val(t),a.siblings(".um-media-upload-data-url").trigger("change"),a.siblings(".um-media-upload-url").val(t),jQuery(document).trigger("um_media_upload_clear",a)})),jQuery(document.body).on("change",".um-forms-field",function(){(0 'um_options', - 'tab' => 'override_templates', + 'page' => 'um_options', + 'tab' => 'advanced', + 'section' => 'override_templates', ), admin_url( 'admin.php' ) ); diff --git a/includes/admin/class-enqueue.php b/includes/admin/class-enqueue.php index 604933af..dba671c6 100644 --- a/includes/admin/class-enqueue.php +++ b/includes/admin/class-enqueue.php @@ -351,9 +351,10 @@ final class Enqueue extends \um\common\Enqueue { $forms_data = array( 'successfully_redirect' => add_query_arg( array( - 'page' => 'um_options', - 'tab' => 'misc', - 'msg' => 'updated', + 'page' => 'um_options', + 'tab' => 'advanced', + 'section' => 'features', + 'msg' => 'updated', ), admin_url( 'admin.php' ) ), @@ -583,12 +584,18 @@ final class Enqueue extends \um\common\Enqueue { wp_enqueue_style( 'um_admin_roles' ); } elseif ( 'ultimate-member_page_um_options' === $hook ) { // phpcs:ignore WordPress.Security.NonceVerification - if ( isset( $_GET['tab'] ) && 'secure' === $_GET['tab'] ) { + if ( isset( $_GET['tab'], $_GET['section'] ) && 'advanced' === $_GET['tab'] && 'secure' === $_GET['section'] ) { wp_register_script( 'um_admin_secure', $js_url . 'admin/secure' . $suffix . '.js', array( 'jquery', 'wp-i18n' ), UM_VERSION, true ); wp_set_script_translations( 'um_admin_secure', 'ultimate-member' ); wp_enqueue_script( 'um_admin_secure' ); } + // phpcs:ignore WordPress.Security.NonceVerification + if ( isset( $_GET['tab'] ) && 'appearance' === $_GET['tab'] && empty( $_GET['section'] ) ) { + // Init WP Media Uploader on the UM > Settings > Appearance > Profile screen. + wp_enqueue_media(); + } + wp_register_style( 'um_admin_settings', $css_url . 'admin/settings' . $suffix . '.css', array(), UM_VERSION ); wp_enqueue_style( 'um_admin_settings' ); diff --git a/includes/admin/class-secure.php b/includes/admin/class-secure.php index 09a65790..2830bd85 100644 --- a/includes/admin/class-secure.php +++ b/includes/admin/class-secure.php @@ -91,8 +91,7 @@ if ( ! class_exists( 'um\admin\Secure' ) ) { public function admin_init() { global $wpdb; // Dismiss admin notice after the first visit to Secure settings page. - if ( isset( $_REQUEST['page'] ) && isset( $_REQUEST['tab'] ) && - 'um_options' === sanitize_key( $_REQUEST['page'] ) && 'secure' === sanitize_key( $_REQUEST['tab'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification + if ( isset( $_REQUEST['page'], $_REQUEST['tab'], $_REQUEST['section'] ) && 'um_options' === sanitize_key( $_REQUEST['page'] ) && 'advanced' === sanitize_key( $_REQUEST['tab'] ) && 'secure' === sanitize_key( $_REQUEST['section'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification UM()->admin()->notices()->dismiss( 'secure_settings' ); } @@ -236,16 +235,18 @@ if ( ! class_exists( 'um\admin\Secure' ) ) { 'description' => __( 'Scan your site to check for vulnerabilities prior to Ultimate Member version 2.6.7 and get recommendations to secure your site.', 'ultimate-member' ), ), array( - 'id' => 'lock_register_forms', - 'type' => 'checkbox', - 'label' => __( 'Lock All Register Forms', 'ultimate-member' ), - 'description' => __( 'This prevents all users from registering with Ultimate Member on your site.', 'ultimate-member' ), + 'id' => 'lock_register_forms', + 'type' => 'checkbox', + 'label' => __( 'Lock All Register Forms', 'ultimate-member' ), + 'checkbox_label' => __( 'Lock Forms', 'ultimate-member' ), + 'description' => __( 'This prevents all users from registering with Ultimate Member on your site.', 'ultimate-member' ), ), array( - 'id' => 'display_login_form_notice', - 'type' => 'checkbox', - 'label' => __( 'Display Login form notice to reset passwords', 'ultimate-member' ), - 'description' => __( 'Enforces users to reset their passwords( one-time ) and prevent from entering old password.', 'ultimate-member' ), + 'id' => 'display_login_form_notice', + 'type' => 'checkbox', + 'label' => __( 'Display Login form notice to reset passwords', 'ultimate-member' ), + 'checkbox_label' => __( 'Enable Login form notice', 'ultimate-member' ), + 'description' => __( 'Enforces users to reset their passwords (one-time) and prevent from entering old password.', 'ultimate-member' ), ), ); @@ -265,17 +266,19 @@ if ( ! class_exists( 'um\admin\Secure' ) ) { $secure_fields, array( array( - 'id' => 'secure_ban_admins_accounts', - 'type' => 'checkbox', - 'label' => __( 'Enable ban for administrative capabilities', 'ultimate-member' ), - 'description' => __( ' When someone tries to inject capabilities to the Account, Profile & Register forms submission, it will be banned.', 'ultimate-member' ), + 'id' => 'secure_ban_admins_accounts', + 'type' => 'checkbox', + 'label' => __( 'Administrative capabilities ban', 'ultimate-member' ), + 'checkbox_label' => __( 'Enable ban for administrative capabilities', 'ultimate-member' ), + 'description' => __( ' When someone tries to inject capabilities to the Account, Profile & Register forms submission, it will be banned.', 'ultimate-member' ), ), array( - 'id' => 'secure_notify_admins_banned_accounts', - 'type' => 'checkbox', - 'label' => __( 'Notify Administrators', 'ultimate-member' ), - 'description' => __( 'When enabled, All administrators will be notified when someone has suspicious activities in the Account, Profile & Register forms.', 'ultimate-member' ), - 'conditional' => array( 'secure_ban_admins_accounts', '=', 1 ), + 'id' => 'secure_notify_admins_banned_accounts', + 'type' => 'checkbox', + 'label' => __( 'Notify Administrators', 'ultimate-member' ), + 'checkbox_label' => __( 'Enable notification', 'ultimate-member' ), + 'description' => __( 'When enabled, All administrators will be notified when someone has suspicious activities in the Account, Profile & Register forms.', 'ultimate-member' ), + 'conditional' => array( 'secure_ban_admins_accounts', '=', 1 ), ), array( 'id' => 'secure_notify_admins_banned_accounts__interval', @@ -292,14 +295,15 @@ if ( ! class_exists( 'um\admin\Secure' ) ) { 'id' => 'secure_allowed_redirect_hosts', 'type' => 'textarea', 'label' => __( 'Allowed hosts for safe redirect (one host per line)', 'ultimate-member' ), - 'description' => __( 'Extend allowed hosts for frontend pages redirects', 'ultimate-member' ), + 'description' => __( 'Extend allowed hosts for frontend pages redirects.', 'ultimate-member' ), ), ) ); - $settings['secure'] = array( - 'title' => __( 'Secure', 'ultimate-member' ), - 'fields' => $secure_fields, + $settings['advanced']['sections']['secure'] = array( + 'title' => __( 'Secure', 'ultimate-member' ), + 'description' => __( 'This feature scans for suspicious registered accounts, bans the usage of administrative capabilities to site subscribers/members, allows the website administrators to force all users to reset their passwords, preventing users from logging-in using their old passwords that may have been exposed.', 'ultimate-member' ), + 'fields' => $secure_fields, ); return $settings; diff --git a/includes/admin/core/class-admin-forms-settings.php b/includes/admin/core/class-admin-forms-settings.php index ba52b817..37ad481f 100644 --- a/includes/admin/core/class-admin-forms-settings.php +++ b/includes/admin/core/class-admin-forms-settings.php @@ -1,12 +1,12 @@ options()->get_default( $field_data['id' . $i] ); + public function get_field_value( $field_data, $i = '' ) { + $default_key = 'default' . $i; + $value_key = 'value' . $i; + $id_key = 'id' . $i; - if ( $field_data['type'] == 'checkbox' || $field_data['type'] == 'multi_checkbox' ) { - if ( isset( $field_data['value' . $i] ) ) { - return $field_data['value' . $i]; - } else { - $value = UM()->options()->get( $field_data['id' . $i] ); - $value = is_string( $value ) ? stripslashes( $value ) : $value; - return '' !== $value ? $value : $default; - } - } else { - if ( isset( $field_data['value' . $i] ) ) { - return $field_data['value'. $i]; - } else { - $value = UM()->options()->get( $field_data['id' . $i] ); - $value = is_string( $value ) ? stripslashes( $value ) : $value; - return isset( $value ) ? $value : $default; + $default = isset( $field_data[ $default_key ] ) ? $field_data[ $default_key ] : UM()->options()->get_default( $field_data[ $id_key ] ); + + if ( in_array( $field_data['type'], array( 'checkbox', 'multi_checkbox' ), true ) ) { + if ( isset( $field_data[ $value_key ] ) ) { + return $field_data[ $value_key ]; } + + $value = UM()->options()->get( $field_data[ $id_key ] ); + $value = is_string( $value ) ? stripslashes( $value ) : $value; + return '' !== $value ? $value : $default; } - } + if ( isset( $field_data[ $value_key ] ) ) { + return $field_data[ $value_key ]; + } + + $value = UM()->options()->get( $field_data[ $id_key ] ); + $value = is_string( $value ) ? stripslashes( $value ) : $value; + return isset( $value ) ? $value : $default; + } } } diff --git a/includes/admin/core/class-admin-forms.php b/includes/admin/core/class-admin-forms.php index f2194200..10def99d 100644 --- a/includes/admin/core/class-admin-forms.php +++ b/includes/admin/core/class-admin-forms.php @@ -52,7 +52,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { * @param bool $echo * @return string */ - function render_form( $echo = true ) { + public function render_form( $echo = true ) { if ( empty( $this->form_data['fields'] ) ) { return ''; @@ -64,7 +64,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { ob_start(); foreach ( $this->form_data['fields'] as $field_data ) { - if ( isset( $field_data['type'] ) && 'hidden' == $field_data['type'] ) { + if ( isset( $field_data['type'] ) && 'hidden' === $field_data['type'] ) { echo $this->render_form_row( $field_data ); } } @@ -97,19 +97,18 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { } } - /** * @param array $data * * @return string */ - function render_form_row( $data ) { + public function render_form_row( $data ) { if ( empty( $data['type'] ) ) { return ''; } - if ( !empty( $data['value'] ) && $data['type'] != 'email_template' ) { + if ( ! empty( $data['value'] ) && $data['type'] != 'email_template' ) { $data['value'] = wp_unslash( $data['value'] ); /*for multi_text*/ @@ -169,8 +168,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { } - if ( ! empty( $data['description'] ) ) + if ( ! empty( $data['description'] ) ) { $html .= '

    ' . $data['description'] . '

    '; + } $html .= '
    '; @@ -190,8 +190,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { } - if ( ! empty( $data['description'] ) ) + if ( ! empty( $data['description'] ) ) { $html .= '

    ' . $data['description'] . '

    '; + } $html .= '
    '; @@ -209,8 +210,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { } - if ( ! empty( $data['description'] ) ) + if ( ! empty( $data['description'] ) ) { $html .= '

    ' . $data['description'] . '

    '; + } $html .= ''; @@ -233,8 +235,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { } - if ( ! empty( $data['description'] ) ) + if ( ! empty( $data['description'] ) ) { $html .= '

    ' . $data['description'] . '

    '; + } $html .= ''; @@ -255,8 +258,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { } - if ( ! empty( $data['description'] ) ) + if ( ! empty( $data['description'] ) ) { $html .= '

    ' . $data['description'] . '

    '; + } $html .= ''; @@ -276,15 +280,14 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { } - if ( ! empty( $data['description'] ) ) + if ( ! empty( $data['description'] ) ) { $html .= '

    ' . $data['description'] . '

    '; + } $html .= ''; - } } } - } else { $html .= $this->render_hidden( $data ); } @@ -927,10 +930,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { * * @return bool|string */ - function render_checkbox( $field_data ) { + public function render_checkbox( $field_data ) { - if ( empty( $field_data['id'] ) ) + if ( empty( $field_data['id'] ) ) { return false; + } $id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id']; $id_attr = ' id="' . esc_attr( $id ) . '" '; @@ -941,7 +945,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { $class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" '; $data = array( - 'field_id' => $field_data['id'] + 'field_id' => $field_data['id'], ); if ( ! empty( $field_data['data'] ) ) { @@ -959,20 +963,22 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { $value = $this->get_field_value( $field_data ); - $html = " - "; + $checkbox_label = ! empty( $field_data['checkbox_label'] ) ? $field_data['checkbox_label'] : ''; - - return $html; + $field_html = ""; + if ( '' !== $checkbox_label ) { + $field_html = ""; + } + $html = "{$field_html}"; + return apply_filters( 'um_admin_render_checkbox_field_html', $html, $field_data ); } - /** * @param $field_data * * @return bool|string */ - function render_same_page_update( $field_data ) { + public function render_same_page_update( $field_data ) { if ( empty( $field_data['id'] ) ) { return false; @@ -987,7 +993,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { $class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" '; $data = array( - 'field_id' => $field_data['id'] + 'field_id' => $field_data['id'], ); if ( ! empty( $field_data['data'] ) ) { @@ -1009,8 +1015,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { $value = $this->get_field_value( $field_data ); - $html = " - "; + $checkbox_label = ! empty( $field_data['checkbox_label'] ) ? $field_data['checkbox_label'] : ''; + + $field_html = ""; + if ( '' !== $checkbox_label ) { + $field_html = ""; + } + $html = "{$field_html}"; if ( ! empty( $field_data['upgrade_cb'] ) ) { $html .= '
    ' . $field_data['upgrade_description'] . '
    @@ -1020,7 +1031,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { return $html; } - /** * @param $field_data * @@ -1083,6 +1093,79 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { return $html; } + /** + * @param $field_data + * + * @since 2.8.3 + * + * @return bool|string + */ + public function render_page_select( $field_data ) { + if ( empty( $field_data['id'] ) ) { + return false; + } + + $multiple = ! empty( $field_data['multi'] ) ? 'multiple' : ''; + + $id = ( ! empty( $this->form_data['prefix_id'] ) ? sanitize_title( $this->form_data['prefix_id'] ) : '' ) . '_' . $field_data['id']; + $id_attr = ' id="' . esc_attr( $id ) . '" '; + + $class = ! empty( $field_data['class'] ) ? $field_data['class'] . ' ' : ' '; + $class .= ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field'; + $class_attr = ' class="um-forms-field um-pages-select2 ' . esc_attr( $class ) . '" '; + + $data = array( + 'field_id' => $field_data['id'], + ); + + if ( ! empty( $field_data['placeholder'] ) ) { + $data['placeholder'] = $field_data['placeholder']; + } + + $data_attr = ''; + foreach ( $data as $key => $value ) { + $data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" '; + } + + $name = $field_data['id']; + $name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name; + $hidden_name_attr = ' name="' . $name . '" '; + $name = $name . ( ! empty( $field_data['multi'] ) ? '[]' : '' ); + $name_attr = ' name="' . $name . '" '; + + $value = $this->get_field_value( $field_data ); + + $options = ''; + if ( ! empty( $field_data['options'] ) ) { + foreach ( $field_data['options'] as $key => $option ) { + if ( ! empty( $field_data['multi'] ) ) { + + if ( ! is_array( $value ) || empty( $value ) ) { + $value = array(); + } + + $options .= ''; + } else { + $options .= ''; + } + } + } + + $hidden = ''; + if ( ! empty( $multiple ) ) { + $hidden = ""; + } + + $button = ''; + $slug = str_replace( 'core_', '', $field_data['id'] ); + if ( ! um_get_predefined_page_id( $slug ) || 'publish' !== get_post_status( um_get_predefined_page_id( $slug ) ) ) { + $button = ' ' . esc_html__( 'Create Default', 'ultimate-member' ) . ''; + } + + $html = "$hidden$button"; + + return $html; + } /** * @param $field_data @@ -1739,7 +1822,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { return $html; } - /** * Get field value * diff --git a/includes/admin/core/class-admin-menu.php b/includes/admin/core/class-admin-menu.php index d7bb773f..e0a018b1 100644 --- a/includes/admin/core/class-admin-menu.php +++ b/includes/admin/core/class-admin-menu.php @@ -16,18 +16,16 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) { */ class Admin_Menu { - /** * @var string */ var $pagehook; var $slug = 'ultimatemember'; - /** * Admin_Menu constructor. */ - function __construct() { + public function __construct() { add_action( 'admin_menu', array( &$this, 'primary_admin_menu' ), 0 ); add_action( 'admin_menu', array( &$this, 'secondary_menu_items' ), 1000 ); add_action( 'admin_menu', array( &$this, 'extension_menu' ), 9999 ); @@ -35,8 +33,46 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) { add_action( 'admin_head', array( $this, 'menu_order_count' ) ); add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1000 ); + + add_action( 'load-ultimate-member_page_um_options', array( &$this, 'maybe_settings_redirect' ) ); } + /** + * Trigger redirect on the Settings screen if there is a wrong tab or section. + * + * @since 2.8.2 + */ + public function maybe_settings_redirect() { + $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] ); + $current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] ); + + $settings_struct = UM()->admin_settings()->settings_structure[ $current_tab ]; + + // Remove not option hidden fields. + if ( ! empty( $settings_struct['fields'] ) ) { + foreach ( $settings_struct['fields'] as $field_key => $field_options ) { + if ( isset( $field_options['is_option'] ) && false === $field_options['is_option'] ) { + unset( $settings_struct['fields'][ $field_key ] ); + } + } + } + + if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) && empty( $settings_struct['form_sections'] ) ) { + wp_safe_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) ); + exit; + } + + if ( ! empty( $settings_struct['sections'] ) ) { + if ( empty( $settings_struct['sections'][ $current_subtab ] ) ) { + $args = array( 'page' => 'um_options' ); + if ( ! empty( $current_tab ) ) { + $args['tab'] = $current_tab; + } + wp_safe_redirect( add_query_arg( $args, admin_url( 'admin.php' ) ) ); + exit; + } + } + } /** * Change the admin footer text on UM admin pages @@ -143,8 +179,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) { /** * Setup admin menu */ - function primary_admin_menu() { - $this->pagehook = add_menu_page( __( 'Ultimate Member', 'ultimate-member' ), __( 'Ultimate Member', 'ultimate-member' ), 'manage_options', $this->slug, array( &$this, 'admin_page' ), 'dashicons-admin-users', '42.78578'); + public function primary_admin_menu() { + $this->pagehook = add_menu_page( __( 'Ultimate Member', 'ultimate-member' ), __( 'Ultimate Member', 'ultimate-member' ), 'manage_options', $this->slug, array( &$this, 'admin_page' ), 'dashicons-admin-users', '42.78578' ); add_action( 'load-' . $this->pagehook, array( &$this, 'on_load_page' ) ); @@ -155,7 +191,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) { /** * Secondary admin menu (after settings) */ - function secondary_menu_items() { + public function secondary_menu_items() { + add_submenu_page( $this->slug, __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( UM()->admin_settings(), 'settings_page' ) ); + add_submenu_page( $this->slug, __( 'Forms', 'ultimate-member' ), __( 'Forms', 'ultimate-member' ), 'manage_options', 'edit.php?post_type=um_form', '' ); add_submenu_page( $this->slug, __( 'User Roles', 'ultimate-member' ), __( 'User Roles', 'ultimate-member' ), 'manage_options', 'um_roles', array( &$this, 'um_roles_pages' ) ); diff --git a/includes/admin/core/class-admin-notices.php b/includes/admin/core/class-admin-notices.php index dde627d1..9a251f81 100644 --- a/includes/admin/core/class-admin-notices.php +++ b/includes/admin/core/class-admin-notices.php @@ -780,7 +780,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) { */ public function template_version() { if ( true === (bool) get_option( 'um_override_templates_outdated' ) ) { - $link = admin_url( 'admin.php?page=um_options&tab=override_templates' ); + $link = admin_url( 'admin.php?page=um_options&tab=advanced§ion=override_templates' ); ob_start(); ?> @@ -849,7 +849,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {

    - +

    admin()->check_ajax_nonce(); @@ -260,37 +253,131 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { ), ); - $core_pages = UM()->config()->core_pages; - - foreach ( $core_pages as $page_s => $page ) { - $have_pages = UM()->query()->wp_pages(); - $page_id = UM()->options()->get_core_page_id( $page_s ); +// $core_pages = UM()->config()->core_pages; +// +// foreach ( $core_pages as $page_s => $page ) { +// $have_pages = UM()->query()->wp_pages(); +// $page_id = UM()->options()->get_core_page_id( $page_s ); +// +// $page_title = ! empty( $page['title'] ) ? $page['title'] : ''; +// +// if ( 'reached_maximum_limit' === $have_pages ) { +// $general_pages_fields[] = array( +// 'id' => $page_id, +// 'type' => 'text', +// // translators: %s: Page title +// 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ), +// 'placeholder' => __( 'Add page ID', 'ultimate-member' ), +// 'compiler' => true, +// 'size' => 'small', +// ); +// } else { +// $general_pages_fields[] = array( +// 'id' => $page_id, +// 'type' => 'select', +// // translators: %s: Page title +// 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ), +// 'options' => UM()->query()->wp_pages(), +// 'placeholder' => __( 'Choose a page...', 'ultimate-member' ), +// 'compiler' => true, +// 'size' => 'small', +// ); +// } +// +// $settings_map[ $page_id ] = array( +// 'sanitize' => 'absint', +// ); +// } + foreach ( UM()->config()->get( 'predefined_pages' ) as $slug => $page ) { + $page_id = UM()->options()->get_predefined_page_option_key( $slug ); $page_title = ! empty( $page['title'] ) ? $page['title'] : ''; - if ( 'reached_maximum_limit' === $have_pages ) { - $general_pages_fields[] = array( - 'id' => $page_id, - 'type' => 'text', - // translators: %s: Page title - 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ), - 'placeholder' => __( 'Add page ID', 'ultimate-member' ), - 'compiler' => true, - 'size' => 'small', - ); + $options = array(); + $page_value = ''; + + $pre_result = apply_filters( 'um_admin_settings_pages_list_value', false, $page_id ); + if ( false === $pre_result ) { + if ( ! empty( $opt_value = UM()->options()->get( $page_id ) ) ) { + if ( 'publish' === get_post_status( $opt_value ) ) { + $title = get_the_title( $opt_value ); + $title = ( mb_strlen( $title ) > 50 ) ? mb_substr( $title, 0, 49 ) . '...' : $title; + $title = sprintf( __( '%s (ID: %s)', 'ultimate-member' ), $title, $opt_value ); + + $options = array( $opt_value => $title ); + $page_value = $opt_value; + } + } } else { - $general_pages_fields[] = array( - 'id' => $page_id, - 'type' => 'select', - // translators: %s: Page title - 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ), - 'options' => UM()->query()->wp_pages(), - 'placeholder' => __( 'Choose a page...', 'ultimate-member' ), - 'compiler' => true, - 'size' => 'small', - ); + // `page_value` variable that we transfer from 3rd-party hook for getting filtered option value also + $page_value = $pre_result['page_value']; + unset( $pre_result['page_value'] ); + + $options = $pre_result; } + $page_setting_description = ''; + if ( ! empty( $page_value ) ) { + $content = get_the_content( null, false, $page_value ); + switch ( $slug ) { + case 'account': + if ( $page_value === um_get_predefined_page_id( 'user' ) ) { + $page_setting_description = __( 'Warning: Account page and User page must be separate pages.', 'ultimate-member' ); + } elseif ( ! has_shortcode( $content, 'ultimatemember_account' ) ) { + $page_setting_description = __( 'Warning: Account page must contain shortcode [ultimatemember_account].', 'ultimate-member' ); + } elseif ( function_exists( 'wc_get_page_id' ) && wc_get_page_id( 'myaccount' ) === um_get_predefined_page_id( 'account' ) ) { + $page_setting_description = __( 'Warning: Account page and WooCommerce "My account" page should be separate pages.', 'ultimate-member' ); + } + break; + case 'login': + if ( $page_value === um_get_predefined_page_id( 'logout' ) ) { + $page_setting_description = __( 'Warning: Login page and Logout page must be separate pages.', 'ultimate-member' ); + } elseif ( ! has_shortcode( $content, 'ultimatemember' ) ) { + $page_setting_description = __( 'Warning: Login page must contain a login form shortcode. You can get existing shortcode or create a new one here.', 'ultimate-member' ); + } + break; + case 'logout': + if ( $page_value === (int) get_option( 'page_on_front' ) ) { + $page_setting_description = __( 'Warning: Home page and Logout page must be separate pages.', 'ultimate-member' ); + } elseif ( $page_value === um_get_predefined_page_id( 'login' ) ) { + $page_setting_description = __( 'Warning: Login page and Logout page must be separate pages.', 'ultimate-member' ); + } + break; + case 'password-reset': + if ( ! has_shortcode( $content, 'ultimatemember_password' ) ) { + $page_setting_description = __( 'Warning: Password Reset page must contain shortcode [ultimatemember_password].', 'ultimate-member' ); + } + break; + case 'register': + if ( ! has_shortcode( $content, 'ultimatemember' ) ) { + $page_setting_description = __( 'Warning: Register page must contain a registration form shortcode. You can get existing shortcode or create a new one here.', 'ultimate-member' ); + } + break; + case 'user': + if ( $page_value === um_get_predefined_page_id( 'account' ) ) { + $description = __( 'Warning: Account page and User page must be separate pages.', 'ultimate-member' ); + } elseif ( ! has_shortcode( $content, 'ultimatemember' ) ) { + $page_setting_description = __( 'Warning: User page must contain a profile form shortcode. You can get existing shortcode or create a new one here.', 'ultimate-member' ); + } + break; + default: + $page_setting_description = apply_filters( 'um_pages_settings_description', $page_setting_description, $content, $slug ); + break; + } + } + + $general_pages_fields[] = array( + 'id' => $page_id, + 'type' => 'page_select', + // translators: %s: Page title + 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ), + 'options' => $options, + 'value' => $page_value, + 'placeholder' => __( 'Choose a page...', 'ultimate-member' ), + 'size' => 'small', + 'description' => $page_setting_description, + ); + $settings_map[ $page_id ] = array( 'sanitize' => 'absint', ); @@ -431,7 +518,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $duplicates = array(); $taxonomies_options = array(); $exclude_taxonomies = UM()->excluded_taxonomies(); - $all_taxonomies = get_taxonomies( array( 'public' => true, 'show_ui' => true ), 'objects' ); + $all_taxonomies = get_taxonomies( + array( + 'public' => true, + 'show_ui' => true, + ), + 'objects' + ); foreach ( $all_taxonomies as $key => $taxonomy ) { if ( in_array( $key, $exclude_taxonomies, true ) ) { continue; @@ -457,7 +550,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } } - $restricted_access_taxonomy_metabox_value = array(); $restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' ); if ( ! empty( $restricted_access_taxonomy_metabox ) && is_array( $restricted_access_taxonomy_metabox ) ) { @@ -639,10 +731,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $latest_truncate = get_option( 'um_member_directory_truncated', false ); $same_page_update = array( - 'id' => 'member_directory_own_table', - 'type' => 'same_page_update', - 'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ), - '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' ), + 'id' => 'member_directory_own_table', + 'type' => 'same_page_update', + 'label' => __( 'Custom usermeta table', 'ultimate-member' ), + 'checkbox_label' => __( 'Enable custom table for usermeta', 'ultimate-member' ), + 'description' => __( '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' ), ); if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) { @@ -1103,135 +1196,178 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'fields' => $general_pages_fields, ), 'users' => array( - 'title' => __( 'Users', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'permalink_base', - 'type' => 'select', - 'size' => 'small', - 'label' => __( 'Profile Permalink Base', 'ultimate-member' ), - // translators: %s: Profile page URL - 'tooltip' => sprintf( __( 'Here you can control the permalink structure of the user profile URL globally e.g. %susername/', 'ultimate-member' ), trailingslashit( um_get_core_page( 'user' ) ) ), - 'options' => UM()->config()->permalink_base_options, - 'placeholder' => __( 'Select...', 'ultimate-member' ), - ), - array( - 'id' => 'permalink_base_custom_meta', - 'type' => 'text', - 'label' => __( 'Profile Permalink Base Custom Meta Key', 'ultimate-member' ), - 'tooltip' => __( 'Specify the custom field meta key that you want to use as profile permalink base. Meta value should be unique.', 'ultimate-member' ), - 'conditional' => array( 'permalink_base', '=', 'custom_meta' ), - 'size' => 'medium', - ), - array( - 'id' => 'display_name', - 'type' => 'select', - 'size' => 'medium', - 'label' => __( 'User Display Name', 'ultimate-member' ), - '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' ), - 'options' => UM()->config()->display_name_options, - 'placeholder' => __( 'Select...', 'ultimate-member' ), - ), - array( - 'id' => 'display_name_field', - 'type' => 'text', - 'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ), - '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' ), - 'conditional' => array( 'display_name', '=', 'field' ), - 'size' => 'medium', - ), - array( - 'id' => 'author_redirect', - 'type' => 'checkbox', - 'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ), - 'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ), - ), - array( - 'id' => 'members_page', - 'type' => 'checkbox', - 'label' => __( 'Enable Members Directory', 'ultimate-member' ), - 'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ), - ), - array( - 'id' => 'use_gravatars', - 'type' => 'checkbox', - 'label' => __( 'Use Gravatars?', 'ultimate-member' ), - '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' ), - ), - array( - 'id' => 'use_um_gravatar_default_builtin_image', - 'type' => 'select', - 'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ), - 'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ), - 'options' => array( - 'default' => __( 'Default', 'ultimate-member' ), - '404' => __( '404 ( File Not Found response )', 'ultimate-member' ), - 'mm' => __( 'Mystery Man', 'ultimate-member' ), - 'identicon' => __( 'Identicon', 'ultimate-member' ), - 'monsterid' => __( 'Monsterid', 'ultimate-member' ), - 'wavatar' => __( 'Wavatar', 'ultimate-member' ), - 'retro' => __( 'Retro', 'ultimate-member' ), - 'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ), - ), - 'conditional' => array( 'use_gravatars', '=', 1 ), - 'size' => 'medium', - ), - array( - 'id' => 'use_um_gravatar_default_image', - 'type' => 'checkbox', - 'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ), - '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' ), - 'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ), - ), - array( - 'id' => 'toggle_password', - 'type' => 'checkbox', - 'label' => __( 'Show/hide password button', 'ultimate-member' ), - 'tooltip' => __( 'Enable visibility for show/hide password button for the password field-type.', 'ultimate-member' ), - ), - array( - 'id' => 'require_strongpass', - 'type' => 'checkbox', - 'label' => __( 'Require a strong password?', 'ultimate-member' ), - 'tooltip' => __( 'Enable or disable a strong password rules common for all Ultimate Member forms.', 'ultimate-member' ), - ), - array( - 'id' => 'password_min_chars', - 'type' => 'number', - 'label' => __( 'Password minimum length', 'ultimate-member' ), - 'tooltip' => __( 'If you want to enable a minimum number of characters to be in password. User password field in the UM forms has own settings for that. Leave empty to use default value 8', 'ultimate-member' ), - 'size' => 'small', - ), - array( - 'id' => 'password_max_chars', - 'type' => 'number', - 'label' => __( 'Password maximum length', 'ultimate-member' ), - 'tooltip' => __( 'If you want to enable a maximum number of characters to be in password. User password field in the UM forms has own settings for that. Leave empty to use default value 30', 'ultimate-member' ), - 'size' => 'small', - ), - array( - 'id' => 'profile_noindex', - 'type' => 'select', - 'size' => 'small', - 'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ), - 'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ), - 'options' => array( - '0' => __( 'No', 'ultimate-member' ), - '1' => __( 'Yes', 'ultimate-member' ), + 'title' => __( 'Users', 'ultimate-member' ), + 'form_sections' => array( + 'users' => array( + 'title' => __( 'Users', 'ultimate-member' ), + 'description' => __( 'General users settings.', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'permalink_base', + 'type' => 'select', + 'size' => 'small', + 'label' => __( 'Profile Permalink Base', 'ultimate-member' ), + // translators: %s: Profile page URL + 'description' => sprintf( __( 'Here you can control the permalink structure of the user profile URL globally e.g. %susername/.', 'ultimate-member' ), trailingslashit( um_get_core_page( 'user' ) ) ), + 'options' => UM()->config()->permalink_base_options, + 'placeholder' => __( 'Select...', 'ultimate-member' ), + ), + array( + 'id' => 'permalink_base_custom_meta', + 'type' => 'text', + 'label' => __( 'Profile Permalink Base Custom Meta Key', 'ultimate-member' ), + 'description' => __( 'Specify the custom field meta key that you want to use as profile permalink base. Meta value should be unique.', 'ultimate-member' ), + 'conditional' => array( 'permalink_base', '=', 'custom_meta' ), + 'size' => 'medium', + ), + array( + 'id' => 'display_name', + 'type' => 'select', + 'size' => 'medium', + 'label' => __( 'User Display Name', 'ultimate-member' ), + 'description' => __( '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' ), + 'options' => UM()->config()->display_name_options, + 'placeholder' => __( 'Select...', 'ultimate-member' ), + ), + array( + 'id' => 'display_name_field', + 'type' => 'text', + 'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ), + 'description' => __( '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' ), + 'conditional' => array( 'display_name', '=', 'field' ), + 'size' => 'medium', + ), + array( + 'id' => 'author_redirect', + 'type' => 'checkbox', + 'label' => __( 'Hide author pages', 'ultimate-member' ), + 'checkbox_label' => __( 'Enable automatically redirect author page to their profile', 'ultimate-member' ), + 'description' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ), + ), + array( + 'id' => 'members_page', + 'type' => 'checkbox', + 'label' => __( 'Members Directory', 'ultimate-member' ), + 'checkbox_label' => __( 'Enable Members Directory', 'ultimate-member' ), + 'description' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ), + ), + array( + 'id' => 'use_gravatars', + 'type' => 'checkbox', + 'label' => __( 'Use Gravatar', 'ultimate-member' ), + 'checkbox_label' => __( 'Enable Gravatar', 'ultimate-member' ), + 'description' => __( 'Do you want to use Gravatar instead of the default plugin profile photo (If the user did not upload a custom profile photo/avatar)?', 'ultimate-member' ), + ), + array( + 'id' => 'use_um_gravatar_default_builtin_image', + 'type' => 'select', + 'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ), + 'description' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ), + 'options' => array( + 'default' => __( 'Default', 'ultimate-member' ), + '404' => __( '404 ( File Not Found response )', 'ultimate-member' ), + 'mm' => __( 'Mystery Man', 'ultimate-member' ), + 'identicon' => __( 'Identicon', 'ultimate-member' ), + 'monsterid' => __( 'Monsterid', 'ultimate-member' ), + 'wavatar' => __( 'Wavatar', 'ultimate-member' ), + 'retro' => __( 'Retro', 'ultimate-member' ), + 'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ), + ), + 'conditional' => array( 'use_gravatars', '=', 1 ), + 'size' => 'medium', + ), + array( + 'id' => 'use_um_gravatar_default_image', + 'type' => 'checkbox', + 'label' => __( 'Replace Gravatar\'s Default avatar', 'ultimate-member' ), + 'checkbox_label' => __( 'Set Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ), + 'description' => __( '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' ), + 'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ), + ), + array( + 'id' => 'delete_comments', + 'type' => 'checkbox', + 'label' => __( 'Delete user comments', 'ultimate-member' ), + 'checkbox_label' => __( 'Enable deleting user comments after deleting a user', 'ultimate-member' ), + 'description' => __( 'Do you want to delete a user\'s comments when that user deletes themself or is removed from the admin dashboard from the site?', 'ultimate-member' ), + ), ), ), - array( - 'id' => 'activation_link_expiry_time', - 'type' => 'number', - 'label' => __( 'Activation link lifetime', 'ultimate-member' ), - 'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ), - 'size' => 'small', + 'password' => array( + 'title' => __( 'Password', 'ultimate-member' ), + 'description' => __( 'Password & Security settings.', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'toggle_password', + 'type' => 'checkbox', + 'label' => __( 'Toggle Password Visibility', 'ultimate-member' ), + 'checkbox_label' => __( 'Enable password show/hide button', 'ultimate-member' ), + 'description' => __( 'Enable visibility for show/hide password button for the password field-type.', 'ultimate-member' ), + ), + array( + 'id' => 'require_strongpass', + 'type' => 'checkbox', + 'label' => __( 'Require Strong Passwords', 'ultimate-member' ), + 'checkbox_label' => __( 'Enable strong passwords', 'ultimate-member' ), + 'description' => __( 'Enable this option to apply strong password rules to all password fields (user registration, password reset and password change).', 'ultimate-member' ), + ), + array( + 'id' => 'password_min_chars', + 'type' => 'number', + 'label' => __( 'Password minimum length', 'ultimate-member' ), + 'description' => __( 'Enter the minimum number of characters a user must use for their password. The default minimum characters is 8.', 'ultimate-member' ), + 'size' => 'small', + 'conditional' => array( 'require_strongpass', '=', '1' ), + ), + array( + 'id' => 'password_max_chars', + 'type' => 'number', + 'label' => __( 'Password maximum length', 'ultimate-member' ), + 'description' => __( 'Enter the maximum number of characters a user can use for their password. The default maximum characters is 30.', 'ultimate-member' ), + 'size' => 'small', + 'conditional' => array( 'require_strongpass', '=', '1' ), + ), + array( + 'id' => 'activation_link_expiry_time', + 'type' => 'number', + 'label' => __( 'Email activation link expiration (days)', 'ultimate-member' ), + 'description' => __( 'For user registrations that require an email link to be clicked to confirm account. How long would you like the activation link to be active for before it expires? If this field is left blank the activation link will not expire.', 'ultimate-member' ), + 'size' => 'small', + ), + ), ), - array( - 'id' => 'delete_comments', - 'type' => 'checkbox', - 'label' => __( 'Deleting user comments after deleting a user', 'ultimate-member' ), - 'tooltip' => __( 'Do you want to delete a user\'s comments when that user deletes themself or is removed from the admin dashboard from the site?', 'ultimate-member' ), + 'seo' => array( + 'title' => __( 'SEO', 'ultimate-member' ), + 'description' => __( 'SEO settings for the User Profiles.', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'profile_noindex', + 'type' => 'select', + 'size' => 'small', + 'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ), + 'description' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ), + 'options' => array( + '0' => __( 'No', 'ultimate-member' ), + '1' => __( 'Yes', 'ultimate-member' ), + ), + ), + array( + 'id' => 'profile_title', + 'type' => 'text', + 'label' => __( 'User Profile Title', 'ultimate-member' ), + 'description' => __( 'This is the title that is displayed on a specific user profile.', 'ultimate-member' ), + 'size' => 'medium', + ), + array( + 'id' => 'profile_desc', + 'type' => 'textarea', + 'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ), + 'description' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ), + 'args' => array( + 'textarea_rows' => 6, + ), + ), + ), ), ), ), @@ -1368,31 +1504,44 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { ), ), 'email' => array( - 'title' => __( 'Email', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'admin_email', - 'type' => 'text', - 'label' => __( 'Admin E-mail Address', 'ultimate-member' ), - 'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ), + 'title' => __( 'Emails', 'ultimate-member' ), + 'form_sections' => array( + 'email_sender' => array( + 'title' => __( 'Email sender options', 'ultimate-member' ), + 'description' => __( 'How the sender appears in outgoing Ultimate Member emails.', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'admin_email', + 'type' => 'text', + 'label' => __( 'Admin E-mail Address', 'ultimate-member' ), + 'description' => __( 'e.g. admin@companyname.com', 'ultimate-member' ), + ), + array( + 'id' => 'mail_from', + 'type' => 'text', + 'label' => __( 'Mail appears from', 'ultimate-member' ), + 'description' => __( 'e.g. Site Name', 'ultimate-member' ), + ), + array( + 'id' => 'mail_from_addr', + 'type' => 'text', + 'label' => __( 'Mail appears from address', 'ultimate-member' ), + 'description' => __( 'e.g. admin@companyname.com', 'ultimate-member' ), + ), + ), ), - array( - 'id' => 'mail_from', - 'type' => 'text', - 'label' => __( 'Mail appears from', 'ultimate-member' ), - 'tooltip' => __( 'e.g. Site Name', 'ultimate-member' ), - ), - array( - 'id' => 'mail_from_addr', - 'type' => 'text', - 'label' => __( 'Mail appears from address', 'ultimate-member' ), - 'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ), - ), - array( - 'id' => 'email_html', - 'type' => 'checkbox', - 'label' => __( 'Use HTML for E-mails?', 'ultimate-member' ), - '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' ), + 'email_template' => array( + 'title' => __( 'Email template', 'ultimate-member' ), + 'description' => __( 'Section to customize email templates settings.', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'email_html', + 'type' => 'checkbox', + 'label' => __( 'Content type', 'ultimate-member' ), + 'checkbox_label' => __( 'Enable HTML for E-mails', 'ultimate-member' ), + 'description' => __( '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' ), + ), + ), ), ), ), @@ -1800,66 +1949,106 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'licenses' => array( 'title' => __( 'Licenses', 'ultimate-member' ), ), - 'misc' => array( - 'title' => __( 'Misc', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'form_asterisk', - 'type' => 'checkbox', - 'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ), - ), - array( - 'id' => 'profile_title', - 'type' => 'text', - 'label' => __( 'User Profile Title', 'ultimate-member' ), - 'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ), - 'size' => 'medium', - ), - array( - 'id' => 'profile_desc', - 'type' => 'textarea', - 'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ), - 'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ), - 'args' => array( - 'textarea_rows' => 6, + 'advanced' => array( + 'title' => __( 'Advanced', 'ultimate-member' ), + 'sections' => array( + '' => array( + 'title' => __( 'General', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'form_asterisk', + 'type' => 'checkbox', + 'label' => __( 'Required fields\' asterisk', 'ultimate-member' ), + 'checkbox_label' => __( 'Show an asterisk for required fields', 'ultimate-member' ), + ), + array( + 'id' => 'um_profile_object_cache_stop', + 'type' => 'checkbox', + 'label' => __( 'Cache User Profile', 'ultimate-member' ), + 'checkbox_label' => __( 'Disable user data cache', 'ultimate-member' ), + 'description' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ), + ), + array( + 'id' => 'rest_api_version', + 'type' => 'select', + 'label' => __( 'REST API version', 'ultimate-member' ), + 'description' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ), + 'options' => array( + '1.0' => __( '1.0 version', 'ultimate-member' ), + '2.0' => __( '2.0 version', 'ultimate-member' ), + ), + ), + array( + 'id' => 'uninstall_on_delete', + 'type' => 'checkbox', + 'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ), + 'checkbox_label' => __( 'Enable flushing data', 'ultimate-member' ), + 'description' => __( 'Check this box if you would like Ultimate Member to completely remove all of its data when the plugin/extensions are deleted.', 'ultimate-member' ), + ), ), ), - array( - 'id' => 'um_profile_object_cache_stop', - 'type' => 'checkbox', - 'label' => __( 'Disable Cache User Profile', 'ultimate-member' ), - 'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ), - ), - array( - 'id' => 'enable_blocks', - 'type' => 'checkbox', - 'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ), - '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' ), - ), - array( - 'id' => 'rest_api_version', - 'type' => 'select', - 'label' => __( 'REST API version', 'ultimate-member' ), - 'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ), - 'options' => array( - '1.0' => __( '1.0 version', 'ultimate-member' ), - '2.0' => __( '2.0 version', 'ultimate-member' ), + 'override_templates' => array( + 'title' => __( 'Override templates', 'ultimate-member' ), + 'form_sections' => array( + 'override_templates' => array( + 'title' => __( 'Override templates', 'ultimate-member' ), + // translators: %s: Link to the docs article. + 'description' => sprintf( __( 'You can find a list of template file changes with each release. You can check the latest templates and their statuses, and see if they\'re outdated or updated. You may get more details about overriding templates here.', 'ultimate-member' ), 'https://docs.ultimatemember.com/article/1516-templates-map' ), /** @noinspection HtmlUnknownTarget */ + 'fields' => array( + array( + 'id' => 'override_templates_list_table', + 'type' => 'override_templates_list_table', + ), + ), + ), ), ), - // backward compatibility option leave it disabled for better security and ability to exclude posts/terms pre-query - // otherwise we filtering only results and restricted posts/terms can be visible - array( - 'id' => 'disable_restriction_pre_queries', - 'type' => 'checkbox', - 'label' => __( 'Disable pre-queries for restriction content logic (advanced)', 'ultimate-member' ), - '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' ), - ), - $same_page_update, - array( - 'id' => 'uninstall_on_delete', - 'type' => 'checkbox', - 'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ), - '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' ), + 'features' => array( + 'title' => __( 'Features', 'ultimate-member' ), + 'form_sections' => array( + 'features' => array( + 'title' => __( 'Features', 'ultimate-member' ), + 'description' => __( 'Start using new features that are being progressively rolled out to improve the users management experience.', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'enable_blocks', + 'type' => 'checkbox', + 'label' => __( 'Gutenberg Blocks', 'ultimate-member' ), + 'checkbox_label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ), + 'description' => __( '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' ), + ), + $same_page_update, + ), + ), + 'beta_features' => array( + 'title' => __( 'Experimental features', 'ultimate-member' ), + 'description' => __( 'These features are either experimental or incomplete, enable them at your own risk!', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'disable_legacy_fonicons', + 'type' => 'checkbox', + 'label' => __( 'Legacy fonticons', 'ultimate-member' ), + 'checkbox_label' => __( 'Disable legacy fonticons', 'ultimate-member' ), + 'description' => __( 'Check this box if you would like to disable legacy Ultimate Member fonticons used outdated versions of FontAwesome and Ionicons libraries.', 'ultimate-member' ), + ), + ), + ), + 'legacy_features' => array( + 'title' => __( 'Legacy features', 'ultimate-member' ), + 'description' => __( 'These features are related to the legacy logic or functionality. Please enable them only for the backward compatibility.', 'ultimate-member' ), + 'fields' => array( + // backward compatibility option leave it disabled for better security and ability to exclude posts/terms pre-query + // otherwise we're filtering only results and restricted posts/terms can be visible + array( + 'id' => 'disable_restriction_pre_queries', + 'type' => 'checkbox', + 'label' => __( 'Restriction content pre-queries', 'ultimate-member' ), + 'checkbox_label' => __( 'Disable pre-queries for restriction content logic', 'ultimate-member' ), + 'description' => __( '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' ), + ), + ), + ), + ), ), ), ), @@ -1870,21 +2059,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'type' => 'install_info', ), ), - ), - 'override_templates' => array( - 'title' => __( 'Override templates', 'ultimate-member' ), - 'fields' => array( - array( - 'type' => 'override_templates', - ), - ), - ), + ), // @todo remove since 2.9.0 ) ); - } - /** * @param array $settings * @@ -1922,71 +2101,66 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { return $settings; } - /** * @param $tab * @param $section * * @return array */ - function get_section_fields( $tab, $section ) { + public function get_section_fields( $tab, $section ) { + $custom_section_fields = apply_filters( 'um_settings_section_custom_fields', false, $tab, $section ); + if ( false !== $custom_section_fields ) { + return $custom_section_fields; + } if ( empty( $this->settings_structure[ $tab ] ) ) { return array(); } + if ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['form_sections'] ) ) { + return array( 'form_sections' => $this->settings_structure[ $tab ]['sections'][ $section ]['form_sections'] ); + } + if ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) { return $this->settings_structure[ $tab ]['sections'][ $section ]['fields']; - } elseif ( ! empty( $this->settings_structure[ $tab ]['fields'] ) ) { + } + + if ( ! empty( $this->settings_structure[ $tab ]['form_sections'] ) ) { + return array( 'form_sections' => $this->settings_structure[ $tab ]['form_sections'] ); + } + + if ( ! empty( $this->settings_structure[ $tab ]['fields'] ) ) { return $this->settings_structure[ $tab ]['fields']; } return array(); } - /** - * Setup admin menu + * Settings page callback. */ - function primary_admin_menu() { - add_submenu_page( 'ultimatemember', __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( &$this, 'settings_page' ) ); - } - - - /** - * Settings page callback - */ - function settings_page() { - $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] ); + public function settings_page() { + $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] ); $current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] ); - $settings_struct = $this->settings_structure[ $current_tab ]; + $temp_structure = $this->settings_structure; // Don't remove this temp variable. Internal workaround for Email Tab integration. - //remove not option hidden fields - if ( ! empty( $settings_struct['fields'] ) ) { - foreach ( $settings_struct['fields'] as $field_key => $field_options ) { + $custom_content = apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_custom_content', false, $current_tab, $current_subtab ); - if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) { - unset( $settings_struct['fields'][ $field_key ] ); - } - - } + if ( false === $custom_content ) { + $section_fields = $this->get_section_fields( $current_tab, $current_subtab ); + $settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab ); + } else { + $settings_section = $custom_content; } - if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) ) { - um_js_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) ); - } + $this->settings_structure = $temp_structure; // Don't remove this temp variable. Internal workaround for Email Tab integration. - if ( ! empty( $settings_struct['sections'] ) ) { - if ( empty( $settings_struct['sections'][ $current_subtab ] ) ) { - um_js_redirect( add_query_arg( array( 'page' => 'um_options', 'tab' => $current_tab ), admin_url( 'admin.php' ) ) ); - } - } - - echo '

    ' . __( 'Ultimate Member - Settings', 'ultimate-member' ) . '

    '; + echo '

    ' . esc_html__( 'Ultimate Member - Settings', 'ultimate-member' ) . '

    '; echo $this->generate_tabs_menu() . $this->generate_subtabs_menu( $current_tab ); + echo '
    '; /** * UM hook * @@ -2004,158 +2178,93 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { * } * ?> */ - do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" ); - - if ( in_array( $current_tab, apply_filters('um_settings_custom_tabs', array( 'licenses', 'install_info', 'override_templates' ) ) ) || in_array( $current_subtab, apply_filters( 'um_settings_custom_subtabs', array(), $current_tab ) ) ) { - - /** - * UM hook - * - * @type action - * @title um_settings_page_{$current_tab}_{$current_subtab}_before_section - * @description Show some content before section content at settings page - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 ); - * @example - * - */ - do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" ); - - $section_fields = $this->get_section_fields( $current_tab, $current_subtab ); - $settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab ); - - /** - * UM hook - * - * @type filter - * @title um_settings_section_{$current_tab}_{$current_subtab}_content - * - * @description Render settings section - * @input_vars - * [{"var":"$content","type":"string","desc":"Section content"}, - * {"var":"$section_fields","type":"array","desc":"Section Fields"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 ); - * @example - * - */ - echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content', - $settings_section, - $section_fields - ); - - } else { ?> + do_action( "um_settings_page_before_{$current_tab}_{$current_subtab}_content" ); + $form_wrapper = true; + if ( in_array( $current_tab, array( 'licenses', 'install_info' ), true ) ) { + $form_wrapper = false; + } + if ( 'advanced' === $current_tab && 'override_templates' === $current_subtab ) { + $form_wrapper = false; + } + $form_wrapper = apply_filters( 'um_settings_default_form_wrapper', $form_wrapper, $current_tab, $current_subtab ); + if ( $form_wrapper ) { + ?>
    - */ - do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" ); + } - $section_fields = $this->get_section_fields( $current_tab, $current_subtab ); - $settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab ); - - /** - * UM hook - * - * @type filter - * @title um_settings_section_{$current_tab}_{$current_subtab}_content - * @description Render settings section - * @input_vars - * [{"var":"$content","type":"string","desc":"Section content"}, - * {"var":"$section_fields","type":"array","desc":"Section Fields"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 ); - * @example - * - */ - echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content', - $settings_section, - $section_fields - ); ?> + /** + * UM hook + * + * @type action + * @title um_settings_page_{$current_tab}_{$current_subtab}_before_section + * @description Show some content before section content at settings page + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 ); + * @example + * + */ + do_action( "um_settings_page_{$current_tab}_{$current_subtab}_before_section" ); + echo $settings_section; + if ( $form_wrapper ) { + $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); + ?>

    - - +

    - - '; - $tabs = ''; + return $tabs . ''; } - /** * @param string $tab * * @return string */ - function generate_subtabs_menu( $tab = '' ) { + private function generate_subtabs_menu( $tab = '' ) { if ( empty( $this->settings_structure[ $tab ]['sections'] ) ) { return ''; } + $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] ); + $current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] ); + $menu_subtabs = array(); foreach ( $this->settings_structure[ $tab ]['sections'] as $slug => $subtab ) { $menu_subtabs[ $slug ] = $subtab['title']; } - $subtabs = '
      '; - - $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] ); - $current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] ); + $subtabs = array(); foreach ( $menu_subtabs as $name => $label ) { - $active = ( $current_subtab == $name ) ? 'current' : ''; - $subtabs .= '' - . $label . - ' | '; + $active = $current_subtab === $name ? 'current' : ''; + + $args = array( 'page' => 'um_options' ); + if ( ! empty( $current_tab ) ) { + $args['tab'] = $current_tab; + } + if ( ! empty( $name ) ) { + $args['section'] = $name; + } + $tab_url = add_query_arg( $args, admin_url( 'admin.php' ) ); + + $subtabs[] = '' . esc_html( $label ) . ''; } - return substr( $subtabs, 0, -3 ) . '
    '; - } + if ( empty( $subtabs ) ) { + return ''; + } + return '
    • ' . implode( ' |
    • ', $subtabs ) . '
    '; + } /** * Handler for settings forms @@ -2318,8 +2437,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } } - - function set_default_if_empty( $settings ) { + public function set_default_if_empty( $settings ) { $tab = ''; if ( ! empty( $_GET['tab'] ) ) { $tab = sanitize_key( $_GET['tab'] ); @@ -2330,7 +2448,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $section = sanitize_key( $_GET['section'] ); } - if ( 'access' === $tab && empty( $section ) ) { if ( ! array_key_exists( 'access_exclude_uris', $settings ) ) { $settings['access_exclude_uris'] = array(); @@ -2340,14 +2457,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { return $settings; } - /** - * Remove empty values from multi text fields + * Remove empty values from multi text fields. * - * @param $settings + * @param array $settings * @return array */ - function remove_empty_values( $settings ) { + public function remove_empty_values( $settings ) { $tab = ''; if ( ! empty( $_GET['tab'] ) ) { $tab = sanitize_key( $_GET['tab'] ); @@ -2358,9 +2474,25 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $section = sanitize_key( $_GET['section'] ); } - if ( isset( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) { + if ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['form_sections'] ) ) { + $fields = array(); + foreach ( $this->settings_structure[ $tab ]['sections'][ $section ]['form_sections'] as $section_key => $section_data ) { + if ( ! empty( $section_data['fields'] ) ) { + $fields[] = $section_data['fields']; + } + } + $fields = array_merge( ...$fields ); + } elseif ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) { $fields = $this->settings_structure[ $tab ]['sections'][ $section ]['fields']; - } else { + } elseif ( ! empty( $this->settings_structure[ $tab ]['form_sections'] ) ) { + $fields = array(); + foreach ( $this->settings_structure[ $tab ]['form_sections'] as $section_key => $section_data ) { + if ( ! empty( $section_data['fields'] ) ) { + $fields[] = $section_data['fields']; + } + } + $fields = array_merge( ...$fields ); + } elseif ( ! empty( $this->settings_structure[ $tab ]['fields'] ) ) { $fields = $this->settings_structure[ $tab ]['fields']; } @@ -2368,15 +2500,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { return $settings; } - $filtered_settings = array(); foreach ( $settings as $key => $value ) { - $filtered_settings[ $key ] = $value; foreach ( $fields as $field ) { - if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) { - $filtered_settings[ $key ] = array_filter( $settings[ $key ] ); + if ( $field['id'] === $key && array_key_exists( 'type', $field ) && 'multi_text' === $field['type'] ) { + $filtered_settings[ $key ] = array_filter( $value ); } } } @@ -2384,7 +2514,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { return $filtered_settings; } - /** * */ @@ -2541,12 +2670,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } } } - } } } - /** * */ @@ -2560,7 +2687,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } } - /** * */ @@ -2591,13 +2717,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } $item_name = false; - $version = false; - $author = false; + $version = false; + $author = false; foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) { if ( $field_data['id'] == $key ) { $item_name = ! empty( $field_data['item_name'] ) ? $field_data['item_name'] : false; - $version = ! empty( $field_data['version'] ) ? $field_data['version'] : false; - $author = ! empty( $field_data['author'] ) ? $field_data['author'] : false; + $version = ! empty( $field_data['version'] ) ? $field_data['version'] : false; + $author = ! empty( $field_data['author'] ) ? $field_data['author'] : false; } } @@ -2615,7 +2741,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { array( 'timeout' => UM()->request_timeout, 'sslverify' => false, - 'body' => $api_params + 'body' => $api_params, ) ); @@ -2627,7 +2753,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { array( 'timeout' => UM()->request_timeout, 'sslverify' => true, - 'body' => $api_params + 'body' => $api_params, ) ); @@ -2638,44 +2764,86 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $request = ( $request ) ? maybe_unserialize( $request ) : false; - if ( $edd_action == 'activate_license' || $edd_action == 'check_license' ) { + if ( in_array( $edd_action, array( 'activate_license', 'check_license' ), true ) ) { update_option( "{$key}_edd_answer", $request ); } else { delete_option( "{$key}_edd_answer" ); } - } } - /** - * + * Adds email notifications list table before the email options list. */ - function settings_before_email_tab() { + public function settings_before_email_tab() { $email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] ); - $emails = UM()->config()->email_notifications; + $emails = UM()->config()->email_notifications; if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) { include_once UM_PATH . 'includes/admin/core/list-tables/emails-list-table.php'; } } - /** - * @param $section + * Set settings field per email notification. * - * @return string + * @param bool|array $section_fields + * @param string $tab + * + * @return bool|array */ - function settings_email_tab( $section ) { + public function email_section_custom_fields( $section_fields, $tab ) { + if ( 'email' !== $tab ) { + return $section_fields; + } + $email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] ); - $emails = UM()->config()->email_notifications; + $emails = UM()->config()->email_notifications; if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) { - return $section; + return $section_fields; } $in_theme = UM()->mail()->template_in_theme( $email_key ); + $back_link = add_query_arg( + array( + 'page' => 'um_options', + 'tab' => 'email', + ), + admin_url( 'admin.php' ) + ); + + $this->settings_structure['email']['title'] = '' . $emails[ $email_key ]['title']; + $this->settings_structure['email']['description'] = $emails[ $email_key ]['description']; + + $section_fields = array( + array( + 'id' => 'um_email_template', + 'type' => 'hidden', + 'value' => $email_key, + ), + array( + 'id' => $email_key . '_on', + 'type' => 'checkbox', + 'label' => __( 'Enable/Disable', 'ultimate-member' ), + 'checkbox_label' => __( 'Enable this email notification', 'ultimate-member' ), + ), + array( + 'id' => $email_key . '_sub', + 'type' => 'text', + 'label' => __( 'Subject', 'ultimate-member' ), + 'conditional' => array( $email_key . '_on', '=', 1 ), + ), + array( + 'id' => $email_key, + 'type' => 'email_template', + 'label' => __( 'Email Content', 'ultimate-member' ), + 'conditional' => array( $email_key . '_on', '=', 1 ), + 'value' => UM()->mail()->get_email_template( $email_key ), + 'in_theme' => $in_theme, + ), + ); /** * UM hook * @@ -2697,67 +2865,32 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { * } * ?> */ - $section_fields = apply_filters( 'um_admin_settings_email_section_fields', array( - array( - 'id' => 'um_email_template', - 'type' => 'hidden', - 'value' => $email_key, - ), - array( - 'id' => $email_key . '_on', - 'type' => 'checkbox', - 'label' => $emails[ $email_key ]['title'], - 'tooltip' => $emails[ $email_key ]['description'], - ), - array( - 'id' => $email_key . '_sub', - 'type' => 'text', - 'label' => __( 'Subject Line', 'ultimate-member' ), - 'conditional' => array( $email_key . '_on', '=', 1 ), - 'tooltip' => __( 'This is the subject line of the e-mail', 'ultimate-member' ), - ), - array( - 'id' => $email_key, - 'type' => 'email_template', - 'label' => __( 'Message Body', 'ultimate-member' ), - 'conditional' => array( $email_key . '_on', '=', 1 ), - 'tooltip' => __( 'This is the content of the e-mail', 'ultimate-member' ), - 'value' => UM()->mail()->get_email_template( $email_key ), - 'in_theme' => $in_theme - ), - ), $email_key ); - - return $this->render_settings_section( $section_fields, 'email', $email_key ); + return apply_filters( 'um_admin_settings_email_section_fields', $section_fields, $email_key ); } - /** + * @param bool $html + * @param string $current_tab + * @param string $current_subtab * + * @return bool|string */ - function settings_appearance_profile_tab() { - wp_enqueue_media(); - } - - - /** - * @param $html - * @param $section_fields - * - * @return string - */ - function settings_licenses_tab( $html, $section_fields ) { - ob_start(); ?> + public function settings_licenses_tab( $html, $current_tab, $current_subtab ) { + $section_fields = $this->get_section_fields( $current_tab, $current_subtab ); + if ( empty( $section_fields ) ) { + return $html; + } + $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); + ob_start(); + ?>
    - - - options()->get( $field_data['id'] ); - $value = isset( $option_value ) && ! empty( $option_value ) ? $option_value : ( isset( $field_data['default'] ) ? $field_data['default'] : '' ); + $value = isset( $option_value ) && ! empty( $option_value ) ? $option_value : ( isset( $field_data['default'] ) ? $field_data['default'] : '' ); $license = get_option( "{$field_data['id']}_edd_answer" ); @@ -2984,7 +3117,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { - Override Templates tab. - * @return void + * HTML for Settings > Advanced > Override Templates tab. + * + * @return string */ - public function settings_override_templates_tab() { + public function settings_override_templates_tab( $content ) { $um_check_version = get_transient( 'um_check_template_versions' ); $check_url = add_query_arg( @@ -3058,9 +3190,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { '_wpnonce' => wp_create_nonce( 'check_templates_version' ), ) ); + ob_start(); ?> -

    +

    @@ -3073,19 +3206,45 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } ?>

    -

    +

    + + Install Info tab. + * + * @todo remove since 2.9.0 + * + * @return string + */ + public function settings_install_info() { + ob_start(); + ?> +

    +

    here.', 'ultimate-member' ), 'https://docs.ultimatemember.com/article/1516-templates-map' ), UM()->get_allowed_html( 'admin_notice' ) ); + // translators: %s: Link to the Site Health > Info. + echo wp_kses( sprintf( __( 'This settings tab is deprecated. And it will be fully removed since 2.9.0 version. Please get the installation info from there.', 'ultimate-member' ), add_query_arg( 'tab', 'debug', admin_url( 'site-health.php' ) ) ), UM()->get_allowed_html( 'admin_notice' ) ); + ?> +

    +

    + here.', 'ultimate-member' ), 'https://docs.ultimatemember.com/article/1879-ultimate-member-site-health' ), UM()->get_allowed_html( 'admin_notice' ) ); ?>

    Name . ' ' . $theme_data->Version; - - // Identify Hosting Provider - $host = um_get_host(); - - um_fetch_user( get_current_user_id() ); - - if ( isset( $this->content ) ) { - echo $this->content; - } else { ?> - -

    Install Info

    - - - -

    - - - -

    - - - admin_forms_settings( array( - 'class' => 'um_options-' . $current_tab . '-' . $current_subtab . ' um-third-column', - 'prefix_id' => 'um_options', - 'fields' => $section_fields - ) )->render_form(); ?> + if ( ! empty( $section_fields['form_sections'] ) ) { + foreach ( $section_fields['form_sections'] as $section_key => $form_section_fields ) { + if ( empty( $form_section_fields['fields'] ) ) { + continue; + } - +

    get_allowed_html( 'admin_notice' ) ); ?>

    + +

    get_allowed_html( 'admin_notice' ) ); ?>

    + admin_forms_settings( + array( + 'class' => 'um_options-' . $current_tab . '-' . $current_subtab . '-' . $section_key . ' um-third-column', + 'prefix_id' => 'um_options', + 'fields' => $form_section_fields['fields'], + ) + )->render_form(); + } else { + echo $custom_form_section_content; + } + + $settings_section .= ob_get_clean(); + } + } else { + $settings_structure = $this->settings_structure[ $current_tab ]; + if ( ! empty( $settings_structure['sections'] ) ) { + if ( ! empty( $settings_structure['sections'][ $current_subtab ] ) ) { + $settings_subtab_structure = $settings_structure['sections'][ $current_subtab ]; + + $section_title = array_key_exists( 'title', $settings_subtab_structure ) ? $settings_subtab_structure['title'] : ''; + $section_description = array_key_exists( 'description', $settings_subtab_structure ) ? $settings_subtab_structure['description'] : ''; + } + } else { + $section_title = array_key_exists( 'title', $settings_structure ) ? $settings_structure['title'] : ''; + $section_description = array_key_exists( 'description', $settings_structure ) ? $settings_structure['description'] : ''; + } + + ob_start(); + + if ( ! empty( $section_title ) ) { + ?> +

    get_allowed_html( 'admin_notice' ) ); ?>

    + +

    get_allowed_html( 'admin_notice' ) ); ?>

    + admin_forms_settings( + array( + 'class' => 'um_options-' . $current_tab . '-' . $current_subtab . ' um-third-column', + 'prefix_id' => 'um_options', + 'fields' => $section_fields, + ) + )->render_form(); + + $settings_section .= ob_get_clean(); + } + + return $settings_section; } /** diff --git a/includes/admin/core/list-tables/emails-list-table.php b/includes/admin/core/list-tables/emails-list-table.php index cbfcf3f3..0ebd6798 100644 --- a/includes/admin/core/list-tables/emails-list-table.php +++ b/includes/admin/core/list-tables/emails-list-table.php @@ -99,6 +99,15 @@ class UM_Emails_List_Table extends WP_List_Table { $this->_column_headers = array( $columns, $hidden, $sortable ); } + /** + * Generates the table navigation above or below the table + * + * @since 3.1.0 + * @param string $which + */ + protected function display_tablenav( $which ) { + // Stop displaying tablenav. + } /** * @param object $item @@ -221,12 +230,14 @@ class UM_Emails_List_Table extends WP_List_Table { function column_email( $item ) { $active = UM()->options()->get( $item['key'] . '_on' ); - $icon = ! empty( $active ) ? 'um-notification-is-active dashicons-yes' : 'dashicons-no-alt'; - $link = add_query_arg( array( 'email' => $item['key'] ) ); - $text = '' . $item['title'] . ''; + $icon = ! empty( $active ) ? 'um-notification-is-active dashicons-yes' : 'dashicons-no-alt'; + $icon_title = ! empty( $active ) ? __( 'Enabled', 'ultimate-member' ) : __( 'Disabled', 'ultimate-member' ); + + $link = add_query_arg( array( 'email' => $item['key'] ), remove_query_arg( 'paged' ) ); + $text = '' . esc_html( $item['title'] ) . ''; if ( ! empty( $item['description'] ) ) { - $text .= ' '; + $text .= ' '; } return $text; @@ -239,11 +250,11 @@ class UM_Emails_List_Table extends WP_List_Table { * @return string */ function column_recipients( $item ) { - if ( $item['recipient'] == 'admin' ) { + if ( 'admin' === $item['recipient'] ) { return UM()->options()->get( 'admin_email' ); - } else { - return __( 'Member', 'ultimate-member' ); } + + return __( 'Member', 'ultimate-member' ); } @@ -253,7 +264,8 @@ class UM_Emails_List_Table extends WP_List_Table { * @return string */ function column_configure( $item ) { - return ''; + $edit_link = add_query_arg( array( 'email' => $item['key'] ), remove_query_arg( 'paged' ) ); + return ''; } @@ -276,13 +288,13 @@ class UM_Emails_List_Table extends WP_List_Table { } $ListTable = new UM_Emails_List_Table( array( - 'singular' => __( 'Email Notification', 'ultimate-member' ), - 'plural' => __( 'Email Notifications', 'ultimate-member' ), - 'ajax' => false + 'singular' => __( 'Email Notification', 'ultimate-member' ), + 'plural' => __( 'Email Notifications', 'ultimate-member' ), + 'ajax' => false, )); -$per_page = 20; -$paged = $ListTable->get_pagenum(); +$per_page = 999; +$paged = $ListTable->get_pagenum(); /** * UM hook @@ -306,9 +318,9 @@ $paged = $ListTable->get_pagenum(); * ?> */ $columns = apply_filters( 'um_email_templates_columns', array( - 'email' => __( 'Email', 'ultimate-member' ), - 'recipients' => __( 'Recipient(s)', 'ultimate-member' ), - 'configure' => '', + 'email' => __( 'Email', 'ultimate-member' ), + 'recipients' => __( 'Recipient(s)', 'ultimate-member' ), + 'configure' => '', ) ); $ListTable->set_columns( $columns ); @@ -317,18 +329,21 @@ $emails = UM()->config()->email_notifications; $ListTable->prepare_items(); $ListTable->items = array_slice( $emails, ( $paged - 1 ) * $per_page, $per_page ); -$ListTable->wpc_set_pagination_args( array( 'total_items' => count( $emails ), 'per_page' => $per_page ) ); ?> +$ListTable->wpc_set_pagination_args( array( 'total_items' => count( $emails ), 'per_page' => $per_page ) ); +?> -

    - here', 'ultimate-member' ), 'https://docs.ultimatemember.com/article/1335-email-templates' ), UM()->get_allowed_html( 'admin_notice' ) ); - ?> +

    +

    + +
    + + here.', 'ultimate-member' ), 'https://docs.ultimatemember.com/article/1335-email-templates' ), UM()->get_allowed_html( 'admin_notice' ) ); ?>

    - +
    display(); ?> +
    diff --git a/includes/admin/core/list-tables/version-template-list-table.php b/includes/admin/core/list-tables/version-template-list-table.php index 940ba523..bf1360fe 100644 --- a/includes/admin/core/list-tables/version-template-list-table.php +++ b/includes/admin/core/list-tables/version-template-list-table.php @@ -163,6 +163,16 @@ class UM_Versions_List_Table extends WP_List_Table { $icon = 1 === $item['status_code'] ? 'um-notification-is-active dashicons-yes' : 'dashicons-no-alt'; return $item['status'] . ' '; } + + /** + * Generates the table navigation above or below the table + * + * @since 3.1.0 + * @param string $which + */ + protected function display_tablenav( $which ) { + // Stop displaying tablenav. + } } $list_table = new UM_Versions_List_Table( @@ -210,6 +220,7 @@ $list_table->prepare_items(); - + + display(); ?> diff --git a/includes/ajax/class-init.php b/includes/ajax/class-init.php index 4772a48c..45ae7e2c 100644 --- a/includes/ajax/class-init.php +++ b/includes/ajax/class-init.php @@ -20,9 +20,22 @@ if ( ! class_exists( 'um\ajax\Init' ) ) { * @used-by \UM::includes() */ public function includes() { + $this->pages(); $this->secure(); } + /** + * @since 2.8.3 + * + * @return Pages + */ + public function pages() { + if ( empty( UM()->classes['um\ajax\pages'] ) ) { + UM()->classes['um\ajax\pages'] = new Pages(); + } + return UM()->classes['um\ajax\pages']; + } + /** * @since 2.6.8 * diff --git a/includes/ajax/class-pages.php b/includes/ajax/class-pages.php new file mode 100644 index 00000000..60bd674b --- /dev/null +++ b/includes/ajax/class-pages.php @@ -0,0 +1,69 @@ +admin()->check_ajax_nonce(); + + // we will pass post IDs and titles to this array + $return = array(); + + $pre_result = apply_filters( 'um_admin_settings_get_pages_list', false ); + + if ( false === $pre_result ) { + $query_args = array( + 'post_type' => 'page', + 'post_status' => 'publish', // if you don't want drafts to be returned + 'ignore_sticky_posts' => 1, + 'posts_per_page' => 10, // how much to show at once + 'paged' => absint( $_GET['page'] ), + 'orderby' => 'title', + 'order' => 'asc', + ); + + if ( ! empty( $_GET['search'] ) ) { + $query_args['s'] = sanitize_text_field( $_GET['search'] ); // the search query + } + + $search_results = new \WP_Query( $query_args ); + + if ( $search_results->have_posts() ) { + while ( $search_results->have_posts() ) { + $search_results->the_post(); + + // shorten the title a little + $title = ( mb_strlen( $search_results->post->post_title ) > 50 ) ? mb_substr( $search_results->post->post_title, 0, 49 ) . '...' : $search_results->post->post_title; + $title = sprintf( __( '%s (ID: %s)', 'ultimate-member' ), $title, $search_results->post->ID ); + $return[] = array( $search_results->post->ID, $title ); // array( Post ID, Post Title ) + } + } + + $return['total_count'] = $search_results->found_posts; + } else { + // got already calculated posts array from 3rd-party integrations (e.g. WPML, Polylang) + $return = $pre_result; + } + + wp_send_json( $return ); + } +} diff --git a/includes/ajax/class-secure.php b/includes/ajax/class-secure.php index b761bfff..c432ea7f 100644 --- a/includes/ajax/class-secure.php +++ b/includes/ajax/class-secure.php @@ -282,7 +282,7 @@ class Secure { $content .= $br . '
    ' . wp_kses( __( 'WARNING: Ensure that you\'ve created a full backup of your site as your restoration point before changing anything on your site with our recommendations.', 'ultimate-member' ), UM()->get_allowed_html( 'admin_notice' ) ) . '
    '; if ( $suspicious_accounts_count > 0 ) { - $lock_register_forms_url = admin_url( 'admin.php?page=um_options&tab=secure&um_secure_lock_register_forms=1&_wpnonce=' . wp_create_nonce( 'um_secure_lock_register_forms' ) ); + $lock_register_forms_url = admin_url( 'admin.php?page=um_options&tab=advanced§ion=secure&um_secure_lock_register_forms=1&_wpnonce=' . wp_create_nonce( 'um_secure_lock_register_forms' ) ); $content .= $br . esc_html__( '1. Please temporarily lock all your active Register forms.', 'ultimate-member' ); $content .= ' ' . esc_html__( 'Click here to lock them now.', 'ultimate-member' ) . ''; $content .= ' ' . esc_html__( 'You can unblock the Register forms later. Just go to Ultimate Member > Settings > Secure > uncheck the option "Lock All Register Forms".', 'ultimate-member' ); diff --git a/includes/class-config.php b/includes/class-config.php index 27e2f6e6..1a4c7a1e 100644 --- a/includes/class-config.php +++ b/includes/class-config.php @@ -31,6 +31,13 @@ if ( ! class_exists( 'um\Config' ) ) { */ public $core_pages; + /** + * @since 2.8.3 + * + * @var array + */ + public $predefined_pages; + /** * @var array */ @@ -841,6 +848,90 @@ if ( ! class_exists( 'um\Config' ) ) { 'password-reset' => array( 'title' => __( 'Password Reset', 'ultimate-member' ) ), ) ); } - //end class + + /** + * Get variable from config + * + * @param string $key + * + * @return mixed + * + * @since 2.8.3 + */ + public function get( $key ) { + if ( empty( $this->$key ) ) { + $this->{'init_' . $key}(); + } + return apply_filters( 'um_config_get', $this->$key, $key ); + } + + /** + * Init plugin core pages. + * + * @since 2.8.3 + */ + public function init_predefined_pages() { + $core_forms = get_option( 'um_core_forms', array() ); + $setup_shortcodes = array_merge( + array( + 'profile' => '', + 'login' => '', + 'register' => '', + ), + $core_forms + ); + + $this->predefined_pages = array( + 'user' => array( + 'title' => __( 'User', 'ultimate-member' ), + 'content' => ! empty( $setup_shortcodes['profile'] ) ? '[ultimatemember form_id="' . $setup_shortcodes['profile'] . '"]' : '', + ), + 'login' => array( + 'title' => __( 'Login', 'ultimate-member' ), + 'content' => ! empty( $setup_shortcodes['login'] ) ? '[ultimatemember form_id="' . $setup_shortcodes['login'] . '"]' : '', + ), + 'register' => array( + 'title' => __( 'Register', 'ultimate-member' ), + 'content' => ! empty( $setup_shortcodes['register'] ) ? '[ultimatemember form_id="' . $setup_shortcodes['register'] . '"]' : '', + ), + 'logout' => array( + 'title' => __( 'Logout', 'ultimate-member' ), + 'content' => '', + ), + 'account' => array( + 'title' => __( 'Account', 'ultimate-member' ), + 'content' => '[ultimatemember_account]', + ), + 'password-reset' => array( + 'title' => __( 'Password Reset', 'ultimate-member' ), + 'content' => '[ultimatemember_password]', + ), + ); + + /** + * Filters Ultimate Member predefined pages. + * + * @param {array} $pages Predefined pages. + * + * @return {array} Predefined pages. + * + * @since 2.8.3 + * @hook um_predefined_pages + * + * @example + * function my_predefined_pages( $pages ) { + * // your code here + * $pages['my_page_key'] = array( 'title' => __( 'My Page Title', 'my-translate-key' ) ); + * return $pages; + * } + * add_filter( 'um_predefined_pages', 'my_predefined_pages' ); + */ + $this->predefined_pages = apply_filters( 'um_predefined_pages', $this->predefined_pages ); + + // since 2.8.3 legacy hook + // @todo remove in 3.0 version + $this->predefined_pages = apply_filters( 'um_core_pages', $this->predefined_pages ); + $this->core_pages = $this->predefined_pages; + } } } diff --git a/includes/class-init.php b/includes/class-init.php index 210caebf..0a7d33b4 100644 --- a/includes/class-init.php +++ b/includes/class-init.php @@ -228,7 +228,8 @@ if ( ! class_exists( 'UM' ) ) { // init widgets add_action( 'widgets_init', array( &$this, 'widgets_init' ) ); - //include short non class functions + // Include short non-class functions + require_once 'um-core-functions.php'; require_once 'um-short-functions.php'; require_once 'um-deprecated-functions.php'; } @@ -585,8 +586,6 @@ if ( ! class_exists( 'UM' ) ) { $this->theme_updater(); } elseif ( $this->is_request( 'frontend' ) ) { $this->frontend()->includes(); - $this->account(); - $this->password(); $this->login(); $this->register(); $this->user_posts(); @@ -594,6 +593,8 @@ if ( ! class_exists( 'UM' ) ) { } //common includes + $this->account(); + $this->password(); $this->rewrite(); $this->mail(); $this->rest_api(); diff --git a/includes/core/class-options.php b/includes/core/class-options.php index a453e1f9..66a0ca97 100644 --- a/includes/core/class-options.php +++ b/includes/core/class-options.php @@ -1,8 +1,9 @@ getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) { - * echo 'You have FireFox version 2 or greater'; - * } - * - * User Agents Sampled from: http://www.useragentstring.com/ - * - * This implementation is based on the original work from Gary White - * http://apptools.com/phptools/browser/ - * - * UPDATES: - * - * 2010-08-20 (v1.9): - * + Added MSN Explorer Browser (legacy) - * + Added Bing/MSN Robot (Thanks Rob MacDonald) - * + Added the Android Platform (PLATFORM_ANDROID) - * + Fixed issue with Android 1.6/2.2 (Thanks Tom Hirashima) - * - * 2010-04-27 (v1.8): - * + Added iPad Support - * - * 2010-03-07 (v1.7): - * + *MAJOR* Rebuild (preg_match and other "slow" routine removal(s)) - * + Almost allof Gary's original code has been replaced - * + Large PHPUNIT testing environment created to validate new releases and additions - * + Added FreeBSD Platform - * + Added OpenBSD Platform - * + Added NetBSD Platform - * + Added SunOS Platform - * + Added OpenSolaris Platform - * + Added support of the Iceweazel Browser - * + Added isChromeFrame() call to check if chromeframe is in use - * + Moved the Opera check in front of the Firefox check due to legacy Opera User Agents - * + Added the __toString() method (Thanks Deano) - * - * 2009-11-15: - * + Updated the checkes for Firefox - * + Added the NOKIA platform - * + Added Checks for the NOKIA brower(s) - * - * 2009-11-08: - * + PHP 5.3 Support - * + Added support for BlackBerry OS and BlackBerry browser - * + Added support for the Opera Mini browser - * + Added additional documenation - * + Added support for isRobot() and isMobile() - * + Added support for Opera version 10 - * + Added support for deprecated Netscape Navigator version 9 - * + Added support for IceCat - * + Added support for Shiretoko - * - * 2010-04-27 (v1.8): - * + Added iPad Support - * - * 2009-08-18: - * + Updated to support PHP 5.3 - removed all deprecated function calls - * + Updated to remove all double quotes (") -- converted to single quotes (') - * - * 2009-04-27: - * + Updated the IE check to remove a typo and bug (thanks John) - * - * 2009-04-22: - * + Added detection for GoogleBot - * + Added detection for the W3C Validator. - * + Added detection for Yahoo! Slurp - * - * 2009-03-14: - * + Added detection for iPods. - * + Added Platform detection for iPhones - * + Added Platform detection for iPods - * - * 2009-02-16: (Rick Hale) - * + Added version detection for Android phones. - * - * 2008-12-09: - * + Removed unused constant - * - * 2008-11-07: - * + Added Google's Chrome to the detection list - * + Added isBrowser(string) to the list of functions special thanks to - * Daniel 'mavrick' Lang for the function concept (http://mavrick.id.au) - * - * - * Gary White noted: "Since browser detection is so unreliable, I am - * no longer maintaining this script. You are free to use and or - * modify/update it as you want, however the author assumes no - * responsibility for the accuracy of the detected values." - * - * Anyone experienced with Gary's script might be interested in these notes: - * - * Added class constants - * Added detection and version detection for Google's Chrome - * Updated the version detection for Amaya - * Updated the version detection for Firefox - * Updated the version detection for Lynx - * Updated the version detection for WebTV - * Updated the version detection for NetPositive - * Updated the version detection for IE - * Updated the version detection for OmniWeb - * Updated the version detection for iCab - * Updated the version detection for Safari - * Updated Safari to remove mobile devices (iPhone) - * Added detection for iPhone - * Added detection for robots - * Added detection for mobile devices - * Added detection for BlackBerry - * Removed Netscape checks (matches heavily with firefox & mozilla) - * - */ - -class Browser { - public $_agent = ''; - public $_browser_name = ''; - public $_version = ''; - public $_platform = ''; - public $_os = ''; - public $_is_aol = false; - public $_is_mobile = false; - public $_is_robot = false; - public $_aol_version = ''; - - public $BROWSER_UNKNOWN = 'unknown'; - public $VERSION_UNKNOWN = 'unknown'; - - public $BROWSER_OPERA = 'Opera'; // Http://www.opera.com/ - public $BROWSER_OPERA_MINI = 'Opera Mini'; // Http://www.opera.com/mini/ - public $BROWSER_WEBTV = 'WebTV'; // Http://www.webtv.net/pc/ - public $BROWSER_IE = 'Internet Explorer'; // Http://www.microsoft.com/ie/ - public $BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // Http://en.wikipedia.org/wiki/Internet_Explorer_Mobile - public $BROWSER_KONQUEROR = 'Konqueror'; // Http://www.konqueror.org/ - public $BROWSER_ICAB = 'iCab'; // Http://www.icab.de/ - public $BROWSER_OMNIWEB = 'OmniWeb'; // Http://www.omnigroup.com/applications/omniweb/ - public $BROWSER_FIREBIRD = 'Firebird'; // Http://www.ibphoenix.com/ - public $BROWSER_FIREFOX = 'Firefox'; // Http://www.mozilla.com/en-US/firefox/firefox.html - public $BROWSER_ICEWEASEL = 'Iceweasel'; // Http://www.geticeweasel.org/ - public $BROWSER_SHIRETOKO = 'Shiretoko'; // Http://wiki.mozilla.org/Projects/shiretoko - public $BROWSER_MOZILLA = 'Mozilla'; // Http://www.mozilla.com/en-US/ - public $BROWSER_AMAYA = 'Amaya'; // Http://www.w3.org/Amaya/ - public $BROWSER_LYNX = 'Lynx'; // Http://en.wikipedia.org/wiki/Lynx - public $BROWSER_SAFARI = 'Safari'; // Http://apple.com - public $BROWSER_IPHONE = 'iPhone'; // Http://apple.com - public $BROWSER_IPOD = 'iPod'; // Http://apple.com - public $BROWSER_IPAD = 'iPad'; // Http://apple.com - public $BROWSER_CHROME = 'Chrome'; // Http://www.google.com/chrome - public $BROWSER_ANDROID = 'Android'; // Http://www.android.com/ - public $BROWSER_GOOGLEBOT = 'GoogleBot'; // Http://en.wikipedia.org/wiki/Googlebot - public $BROWSER_SLURP = 'Yahoo! Slurp'; // Http://en.wikipedia.org/wiki/Yahoo!_Slurp - public $BROWSER_W3CVALIDATOR = 'W3C Validator'; // Http://validator.w3.org/ - public $BROWSER_BLACKBERRY = 'BlackBerry'; // Http://www.blackberry.com/ - public $BROWSER_ICECAT = 'IceCat'; // Http://en.wikipedia.org/wiki/GNU_IceCat - public $BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // Http://en.wikipedia.org/wiki/Web_Browser_for_S60 - public $BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform - public $BROWSER_MSN = 'MSN Browser'; // Http://explorer.msn.com/ - public $BROWSER_MSNBOT = 'MSN Bot'; // Http://search.msn.com/msnbot.htm - // Http://en.wikipedia.org/wiki/Msnbot (used for Bing as well) - - public $BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // Http://browser.netscape.com/ (DEPRECATED) - public $BROWSER_GALEON = 'Galeon'; // Http://galeon.sourceforge.net/ (DEPRECATED) - public $BROWSER_NETPOSITIVE = 'NetPositive'; // Http://en.wikipedia.org/wiki/NetPositive (DEPRECATED) - public $BROWSER_PHOENIX = 'Phoenix'; // Http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED) - - public $PLATFORM_UNKNOWN = 'unknown'; - public $PLATFORM_WINDOWS = 'Windows'; - public $PLATFORM_WINDOWS_CE = 'Windows CE'; - public $PLATFORM_APPLE = 'Apple'; - public $PLATFORM_LINUX = 'Linux'; - public $PLATFORM_OS2 = 'OS/2'; - public $PLATFORM_BEOS = 'BeOS'; - public $PLATFORM_IPHONE = 'iPhone'; - public $PLATFORM_IPOD = 'iPod'; - public $PLATFORM_IPAD = 'iPad'; - public $PLATFORM_BLACKBERRY = 'BlackBerry'; - public $PLATFORM_NOKIA = 'Nokia'; - public $PLATFORM_FREEBSD = 'FreeBSD'; - public $PLATFORM_OPENBSD = 'OpenBSD'; - public $PLATFORM_NETBSD = 'NetBSD'; - public $PLATFORM_SUNOS = 'SunOS'; - public $PLATFORM_OPENSOLARIS = 'OpenSolaris'; - public $PLATFORM_ANDROID = 'Android'; - - public $OPERATING_SYSTEM_UNKNOWN = 'unknown'; - - function __construct( $useragent="" ) { - $this->reset(); - if ( $useragent != "" ) { - $this->setUserAgent( $useragent ); - } else { - $this->determine(); - } - } - - /** - * Reset all properties - */ - function reset() { - $this->_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ""; - $this->_browser_name = $this->BROWSER_UNKNOWN; - $this->_version = $this->VERSION_UNKNOWN; - $this->_platform = $this->PLATFORM_UNKNOWN; - $this->_os = $this->OPERATING_SYSTEM_UNKNOWN; - $this->_is_aol = false; - $this->_is_mobile = false; - $this->_is_robot = false; - $this->_aol_version = $this->VERSION_UNKNOWN; - } - - /** - * Check to see if the specific browser is valid - * - * @param string $browserName - * @return True if the browser is the specified browser - */ - function isBrowser( $browserName ) { return 0 == strcasecmp( $this->_browser_name, trim( $browserName ) ); } - - /** - * The name of the browser. All return types are from the class contants - * - * @return string Name of the browser - */ - function getBrowser() { return $this->_browser_name; } - /** - * Set the name of the browser - * - * @param unknown $browser The name of the Browser - */ - function setBrowser( $browser ) { return $this->_browser_name = $browser; } - /** - * The name of the platform. All return types are from the class contants - * - * @return string Name of the browser - */ - function getPlatform() { return $this->_platform; } - /** - * Set the name of the platform - * - * @param unknown $platform The name of the Platform - */ - function setPlatform( $platform ) { return $this->_platform = $platform; } - /** - * The version of the browser. - * - * @return string Version of the browser (will only contain alpha-numeric characters and a period) - */ - function getVersion() { return $this->_version; } - /** - * Set the version of the browser - * - * @param unknown $version The version of the Browser - */ - function setVersion( $version ) { $this->_version = preg_replace( '/[^0-9,.,a-z,A-Z-]/', '', $version ); } - /** - * The version of AOL. - * - * @return string Version of AOL (will only contain alpha-numeric characters and a period) - */ - function getAolVersion() { return $this->_aol_version; } - /** - * Set the version of AOL - * - * @param unknown $version The version of AOL - */ - function setAolVersion( $version ) { $this->_aol_version = preg_replace( '/[^0-9,.,a-z,A-Z]/', '', $version ); } - /** - * Is the browser from AOL? - * - * @return boolean True if the browser is from AOL otherwise false - */ - function isAol() { return $this->_is_aol; } - /** - * Is the browser from a mobile device? - * - * @return boolean True if the browser is from a mobile device otherwise false - */ - function isMobile() { return $this->_is_mobile; } - /** - * Is the browser from a robot (ex Slurp,GoogleBot)? - * - * @return boolean True if the browser is from a robot otherwise false - */ - function isRobot() { return $this->_is_robot; } - /** - * Set the browser to be from AOL - * - * @param unknown $isAol - */ - function setAol( $isAol ) { $this->_is_aol = $isAol; } - /** - * Set the Browser to be mobile - * - * @param boolean $value is the browser a mobile brower or not - */ - function setMobile( $value=true ) { $this->_is_mobile = $value; } - /** - * Set the Browser to be a robot - * - * @param boolean $value is the browser a robot or not - */ - function setRobot( $value=true ) { $this->_is_robot = $value; } - /** - * Get the user agent value in use to determine the browser - * - * @return string The user agent from the HTTP header - */ - function getUserAgent() { return $this->_agent; } - /** - * Set the user agent value (the construction will use the HTTP header value - this will overwrite it) - * - * @param unknown $agent_string The value for the User Agent - */ - function setUserAgent( $agent_string ) { - $this->reset(); - $this->_agent = $agent_string; - $this->determine(); - } - /** - * Used to determine if the browser is actually "chromeframe" - * - * @since 1.7 - * @return boolean True if the browser is using chromeframe - */ - function isChromeFrame() { - return strpos( $this->_agent, "chromeframe" ) !== false; - } - /** - * Returns a formatted string with a summary of the details of the browser. - * - * @return string formatted string with a summary of the browser - */ - function __toString() { - $text1 = $this->getUserAgent(); //grabs the UA (user agent) string - $UAline1 = substr( $text1, 0, 32 ); //the first line we print should only be the first 32 characters of the UA string - $text2 = $this->getUserAgent();//now we grab it again and save it to a string - $towrapUA = str_replace( $UAline1, '', $text2 );//the rest of the printoff (other than first line) is equivolent - // To the whole string minus the part we printed off. IE - // User Agent: thefirst32charactersfromUAline1 - // the rest of it is now stored in - // $text2 to be printed off - // But we need to add spaces before each line that is split other than line 1 - $space = ''; - for ( $i = 0; $i < 25; $i++ ) { - $space .= ' '; - } - // Now we split the remaining string of UA ($text2) into lines that are prefixed by spaces for formatting - $wordwrapped = chunk_split( $towrapUA, 32, "\n $space" ); - return "Platform: {$this->getPlatform()} \n". - "Browser Name: {$this->getBrowser()} \n" . - "Browser Version: {$this->getVersion()} \n" . - "User Agent String: $UAline1 \n\t\t\t " . - "$wordwrapped"; - } - /** - * Protected routine to calculate and determine what the browser is in use (including platform) - */ - function determine() { - $this->checkPlatform(); - $this->checkBrowsers(); - $this->checkForAol(); - } - /** - * Protected routine to determine the browser type - * - * @return boolean True if the browser was detected otherwise false - */ - function checkBrowsers() { - return ( - // Well-known, well-used - // Special Notes: - // (1) Opera must be checked before FireFox due to the odd - // user agents used in some older versions of Opera - // (2) WebTV is strapped onto Internet Explorer so we must - // check for WebTV before IE - // (3) (deprecated) Galeon is based on Firefox and needs to be - // tested before Firefox is tested - // (4) OmniWeb is based on Safari so OmniWeb check must occur - // before Safari - // (5) Netscape 9+ is based on Firefox so Netscape checks - // before FireFox are necessary - $this->checkBrowserWebTv() || - $this->checkBrowserInternetExplorer() || - $this->checkBrowserOpera() || - $this->checkBrowserGaleon() || - $this->checkBrowserNetscapeNavigator9Plus() || - $this->checkBrowserFirefox() || - $this->checkBrowserChrome() || - $this->checkBrowserOmniWeb() || - - // Common mobile - $this->checkBrowserAndroid() || - $this->checkBrowseriPad() || - $this->checkBrowseriPod() || - $this->checkBrowseriPhone() || - $this->checkBrowserBlackBerry() || - $this->checkBrowserNokia() || - - // Common bots - $this->checkBrowserGoogleBot() || - $this->checkBrowserMSNBot() || - $this->checkBrowserSlurp() || - - // WebKit base check (post mobile and others) - $this->checkBrowserSafari() || - - // Everyone else - $this->checkBrowserNetPositive() || - $this->checkBrowserFirebird() || - $this->checkBrowserKonqueror() || - $this->checkBrowserIcab() || - $this->checkBrowserPhoenix() || - $this->checkBrowserAmaya() || - $this->checkBrowserLynx() || - - $this->checkBrowserShiretoko() || - $this->checkBrowserIceCat() || - $this->checkBrowserW3CValidator() || - $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */ - ); - } - - /** - * Determine if the user is using a BlackBerry (last updated 1.7) - * - * @return boolean True if the browser is the BlackBerry browser otherwise false - */ - function checkBrowserBlackBerry() { - if ( stripos( $this->_agent, 'blackberry' ) !== false ) { - $aresult = explode( "/", stristr( $this->_agent, "BlackBerry" ) ); - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - $this->_browser_name = $this->BROWSER_BLACKBERRY; - $this->setMobile( true ); - return true; - } - return false; - } - - /** - * Determine if the user is using an AOL User Agent (last updated 1.7) - * - * @return boolean True if the browser is from AOL otherwise false - */ - function checkForAol() { - $this->setAol( false ); - $this->setAolVersion( $this->VERSION_UNKNOWN ); - - if ( stripos( $this->_agent, 'aol' ) !== false ) { - $aversion = explode( ' ', stristr( $this->_agent, 'AOL' ) ); - $this->setAol( true ); - $this->setAolVersion( preg_replace( '/[^0-9\.a-z]/i', '', $aversion[1] ) ); - return true; - } - return false; - } - - /** - * Determine if the browser is the GoogleBot or not (last updated 1.7) - * - * @return boolean True if the browser is the GoogletBot otherwise false - */ - function checkBrowserGoogleBot() { - if ( stripos( $this->_agent, 'googlebot' ) !== false ) { - $aresult = explode( '/', stristr( $this->_agent, 'googlebot' ) ); - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( str_replace( ';', '', $aversion[0] ) ); - $this->_browser_name = $this->BROWSER_GOOGLEBOT; - $this->setRobot( true ); - return true; - } - return false; - } - - /** - * Determine if the browser is the MSNBot or not (last updated 1.9) - * - * @return boolean True if the browser is the MSNBot otherwise false - */ - function checkBrowserMSNBot() { - if ( stripos( $this->_agent, "msnbot" ) !== false ) { - $aresult = explode( "/", stristr( $this->_agent, "msnbot" ) ); - $aversion = explode( " ", $aresult[1] ); - $this->setVersion( str_replace( ";", "", $aversion[0] ) ); - $this->_browser_name = $this->BROWSER_MSNBOT; - $this->setRobot( true ); - return true; - } - return false; - } - - /** - * Determine if the browser is the W3C Validator or not (last updated 1.7) - * - * @return boolean True if the browser is the W3C Validator otherwise false - */ - function checkBrowserW3CValidator() { - if ( stripos( $this->_agent, 'W3C-checklink' ) !== false ) { - $aresult = explode( '/', stristr( $this->_agent, 'W3C-checklink' ) ); - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - $this->_browser_name = $this->BROWSER_W3CVALIDATOR; - return true; - } else if ( stripos( $this->_agent, 'W3C_Validator' ) !== false ) { - // Some of the Validator versions do not delineate w/ a slash - add it back in - $ua = str_replace( "W3C_Validator ", "W3C_Validator/", $this->_agent ); - $aresult = explode( '/', stristr( $ua, 'W3C_Validator' ) ); - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - $this->_browser_name = $this->BROWSER_W3CVALIDATOR; - return true; - } - return false; - } - - /** - * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7) - * - * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false - */ - function checkBrowserSlurp() { - if ( stripos( $this->_agent, 'slurp' ) !== false ) { - $aresult = explode( '/', stristr( $this->_agent, 'Slurp' ) ); - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - $this->_browser_name = $this->BROWSER_SLURP; - $this->setRobot( true ); - $this->setMobile( false ); - return true; - } - return false; - } - - /** - * Determine if the browser is Internet Explorer or not (last updated 1.7) - * - * @return boolean True if the browser is Internet Explorer otherwise false - */ - function checkBrowserInternetExplorer() { - - // Test for v1 - v1.5 IE - if ( stripos( $this->_agent, 'microsoft internet explorer' ) !== false ) { - $this->setBrowser( $this->BROWSER_IE ); - $this->setVersion( '1.0' ); - $aresult = stristr( $this->_agent, '/' ); - if ( preg_match( '/308|425|426|474|0b1/i', $aresult ) ) { - $this->setVersion( '1.5' ); - } - return true; - } - // Test for versions > 1.5 - else if ( stripos( $this->_agent, 'msie' ) !== false && stripos( $this->_agent, 'opera' ) === false ) { - // See if the browser is the odd MSN Explorer - if ( stripos( $this->_agent, 'msnb' ) !== false ) { - $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'MSN' ) ); - $this->setBrowser( $this->BROWSER_MSN ); - $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) ); - return true; - } - $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'msie' ) ); - $this->setBrowser( $this->BROWSER_IE ); - $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) ); - return true; - } - // Test for Pocket IE - else if ( stripos( $this->_agent, 'mspie' ) !== false || stripos( $this->_agent, 'pocket' ) !== false ) { - $aresult = explode( ' ', stristr( $this->_agent, 'mspie' ) ); - $this->setPlatform( $this->PLATFORM_WINDOWS_CE ); - $this->setBrowser( $this->BROWSER_POCKET_IE ); - $this->setMobile( true ); - - if ( stripos( $this->_agent, 'mspie' ) !== false ) { - $this->setVersion( $aresult[1] ); - } else { - $aversion = explode( '/', $this->_agent ); - $this->setVersion( $aversion[1] ); - } - return true; - } - return false; - } - - /** - * Determine if the browser is Opera or not (last updated 1.7) - * - * @return boolean True if the browser is Opera otherwise false - */ - function checkBrowserOpera() { - if ( stripos( $this->_agent, 'opera mini' ) !== false ) { - $resultant = stristr( $this->_agent, 'opera mini' ); - if ( preg_match( '/\//', $resultant ) ) { - $aresult = explode( '/', $resultant ); - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - } else { - $aversion = explode( ' ', stristr( $resultant, 'opera mini' ) ); - $this->setVersion( $aversion[1] ); - } - $this->_browser_name = $this->BROWSER_OPERA_MINI; - $this->setMobile( true ); - return true; - } else if ( stripos( $this->_agent, 'opera' ) !== false ) { - $resultant = stristr( $this->_agent, 'opera' ); - if ( preg_match( '/Version\/(10.*)$/', $resultant, $matches ) ) { - $this->setVersion( $matches[1] ); - } else if ( preg_match( '/\//', $resultant ) ) { - $aresult = explode( '/', str_replace( "(", " ", $resultant ) ); - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - } else { - $aversion = explode( ' ', stristr( $resultant, 'opera' ) ); - $this->setVersion( isset( $aversion[1] )?$aversion[1]:"" ); - } - $this->_browser_name = $this->BROWSER_OPERA; - return true; - } - return false; - } - - /** - * Determine if the browser is Chrome or not (last updated 1.7) - * - * @return boolean True if the browser is Chrome otherwise false - */ - function checkBrowserChrome() { - if ( stripos( $this->_agent, 'Chrome' ) !== false ) { - $aresult = explode( '/', stristr( $this->_agent, 'Chrome' ) ); - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - $this->setBrowser( $this->BROWSER_CHROME ); - return true; - } - return false; - } - - - /** - * Determine if the browser is WebTv or not (last updated 1.7) - * - * @return boolean True if the browser is WebTv otherwise false - */ - function checkBrowserWebTv() { - if ( stripos( $this->_agent, 'webtv' ) !== false ) { - $aresult = explode( '/', stristr( $this->_agent, 'webtv' ) ); - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - $this->setBrowser( $this->BROWSER_WEBTV ); - return true; - } - return false; - } - - /** - * Determine if the browser is NetPositive or not (last updated 1.7) - * - * @return boolean True if the browser is NetPositive otherwise false - */ - function checkBrowserNetPositive() { - if ( stripos( $this->_agent, 'NetPositive' ) !== false ) { - $aresult = explode( '/', stristr( $this->_agent, 'NetPositive' ) ); - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aversion[0] ) ); - $this->setBrowser( $this->BROWSER_NETPOSITIVE ); - return true; - } - return false; - } - - /** - * Determine if the browser is Galeon or not (last updated 1.7) - * - * @return boolean True if the browser is Galeon otherwise false - */ - function checkBrowserGaleon() { - if ( stripos( $this->_agent, 'galeon' ) !== false ) { - $aresult = explode( ' ', stristr( $this->_agent, 'galeon' ) ); - $aversion = explode( '/', $aresult[0] ); - $this->setVersion( $aversion[1] ); - $this->setBrowser( $this->BROWSER_GALEON ); - return true; - } - return false; - } - - /** - * Determine if the browser is Konqueror or not (last updated 1.7) - * - * @return boolean True if the browser is Konqueror otherwise false - */ - function checkBrowserKonqueror() { - if ( stripos( $this->_agent, 'Konqueror' ) !== false ) { - $aresult = explode( ' ', stristr( $this->_agent, 'Konqueror' ) ); - $aversion = explode( '/', $aresult[0] ); - $this->setVersion( $aversion[1] ); - $this->setBrowser( $this->BROWSER_KONQUEROR ); - return true; - } - return false; - } - - /** - * Determine if the browser is iCab or not (last updated 1.7) - * - * @return boolean True if the browser is iCab otherwise false - */ - function checkBrowserIcab() { - if ( stripos( $this->_agent, 'icab' ) !== false ) { - $aversion = explode( ' ', stristr( str_replace( '/', ' ', $this->_agent ), 'icab' ) ); - $this->setVersion( $aversion[1] ); - $this->setBrowser( $this->BROWSER_ICAB ); - return true; - } - return false; - } - - /** - * Determine if the browser is OmniWeb or not (last updated 1.7) - * - * @return boolean True if the browser is OmniWeb otherwise false - */ - function checkBrowserOmniWeb() { - if ( stripos( $this->_agent, 'omniweb' ) !== false ) { - $aresult = explode( '/', stristr( $this->_agent, 'omniweb' ) ); - $aversion = explode( ' ', isset( $aresult[1] )?$aresult[1]:"" ); - $this->setVersion( $aversion[0] ); - $this->setBrowser( $this->BROWSER_OMNIWEB ); - return true; - } - return false; - } - - /** - * Determine if the browser is Phoenix or not (last updated 1.7) - * - * @return boolean True if the browser is Phoenix otherwise false - */ - function checkBrowserPhoenix() { - if ( stripos( $this->_agent, 'Phoenix' ) !== false ) { - $aversion = explode( '/', stristr( $this->_agent, 'Phoenix' ) ); - $this->setVersion( $aversion[1] ); - $this->setBrowser( $this->BROWSER_PHOENIX ); - return true; - } - return false; - } - - /** - * Determine if the browser is Firebird or not (last updated 1.7) - * - * @return boolean True if the browser is Firebird otherwise false - */ - function checkBrowserFirebird() { - if ( stripos( $this->_agent, 'Firebird' ) !== false ) { - $aversion = explode( '/', stristr( $this->_agent, 'Firebird' ) ); - $this->setVersion( $aversion[1] ); - $this->setBrowser( $this->BROWSER_FIREBIRD ); - return true; - } - return false; - } - - /** - * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7) - * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008) - * - * @return boolean True if the browser is Netscape Navigator 9+ otherwise false - */ - function checkBrowserNetscapeNavigator9Plus() { - if ( stripos( $this->_agent, 'Firefox' ) !== false && preg_match( '/Navigator\/([^ ]*)/i', $this->_agent, $matches ) ) { - $this->setVersion( $matches[1] ); - $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR ); - return true; - } else if ( stripos( $this->_agent, 'Firefox' ) === false && preg_match( '/Netscape6?\/([^ ]*)/i', $this->_agent, $matches ) ) { - $this->setVersion( $matches[1] ); - $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR ); - return true; - } - return false; - } - - /** - * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7) - * - * @return boolean True if the browser is Shiretoko otherwise false - */ - function checkBrowserShiretoko() { - if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/Shiretoko\/([^ ]*)/i', $this->_agent, $matches ) ) { - $this->setVersion( $matches[1] ); - $this->setBrowser( $this->BROWSER_SHIRETOKO ); - return true; - } - return false; - } - - /** - * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7) - * - * @return boolean True if the browser is Ice Cat otherwise false - */ - function checkBrowserIceCat() { - if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/IceCat\/([^ ]*)/i', $this->_agent, $matches ) ) { - $this->setVersion( $matches[1] ); - $this->setBrowser( $this->BROWSER_ICECAT ); - return true; - } - return false; - } - - /** - * Determine if the browser is Nokia or not (last updated 1.7) - * - * @return boolean True if the browser is Nokia otherwise false - */ - function checkBrowserNokia() { - if ( preg_match( "/Nokia([^\/]+)\/([^ SP]+)/i", $this->_agent, $matches ) ) { - $this->setVersion( $matches[2] ); - if ( stripos( $this->_agent, 'Series60' ) !== false || strpos( $this->_agent, 'S60' ) !== false ) { - $this->setBrowser( $this->BROWSER_NOKIA_S60 ); - } else { - $this->setBrowser( $this->BROWSER_NOKIA ); - } - $this->setMobile( true ); - return true; - } - return false; - } - - /** - * Determine if the browser is Firefox or not (last updated 1.7) - * - * @return boolean True if the browser is Firefox otherwise false - */ - function checkBrowserFirefox() { - if ( stripos( $this->_agent, 'safari' ) === false ) { - if ( preg_match( "/Firefox[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches ) ) { - $this->setVersion( $matches[1] ); - $this->setBrowser( $this->BROWSER_FIREFOX ); - return true; - } else if ( preg_match( "/Firefox$/i", $this->_agent, $matches ) ) { - $this->setVersion( "" ); - $this->setBrowser( $this->BROWSER_FIREFOX ); - return true; - } - } - return false; - } - - /** - * Determine if the browser is Firefox or not (last updated 1.7) - * - * @return boolean True if the browser is Firefox otherwise false - */ - function checkBrowserIceweasel() { - if ( stripos( $this->_agent, 'Iceweasel' ) !== false ) { - $aresult = explode( '/', stristr( $this->_agent, 'Iceweasel' ) ); - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - $this->setBrowser( $this->BROWSER_ICEWEASEL ); - return true; - } - return false; - } - /** - * Determine if the browser is Mozilla or not (last updated 1.7) - * - * @return boolean True if the browser is Mozilla otherwise false - */ - function checkBrowserMozilla() { - if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) { - $aversion = explode( ' ', stristr( $this->_agent, 'rv:' ) ); - preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion ); - $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) ); - $this->setBrowser( $this->BROWSER_MOZILLA ); - return true; - } else if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9]\.[0-9]/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) { - $aversion = explode( '', stristr( $this->_agent, 'rv:' ) ); - $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) ); - $this->setBrowser( $this->BROWSER_MOZILLA ); - return true; - } else if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/mozilla\/([^ ]*)/i', $this->_agent, $matches ) && stripos( $this->_agent, 'netscape' ) === false ) { - $this->setVersion( $matches[1] ); - $this->setBrowser( $this->BROWSER_MOZILLA ); - return true; - } - return false; - } - - /** - * Determine if the browser is Lynx or not (last updated 1.7) - * - * @return boolean True if the browser is Lynx otherwise false - */ - function checkBrowserLynx() { - if ( stripos( $this->_agent, 'lynx' ) !== false ) { - $aresult = explode( '/', stristr( $this->_agent, 'Lynx' ) ); - $aversion = explode( ' ', ( isset( $aresult[1] )?$aresult[1]:"" ) ); - $this->setVersion( $aversion[0] ); - $this->setBrowser( $this->BROWSER_LYNX ); - return true; - } - return false; - } - - /** - * Determine if the browser is Amaya or not (last updated 1.7) - * - * @return boolean True if the browser is Amaya otherwise false - */ - function checkBrowserAmaya() { - if ( stripos( $this->_agent, 'amaya' ) !== false ) { - $aresult = explode( '/', stristr( $this->_agent, 'Amaya' ) ); - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - $this->setBrowser( $this->BROWSER_AMAYA ); - return true; - } - return false; - } - - /** - * Determine if the browser is Safari or not (last updated 1.7) - * - * @return boolean True if the browser is Safari otherwise false - */ - function checkBrowserSafari() { - if ( stripos( $this->_agent, 'Safari' ) !== false && stripos( $this->_agent, 'iPhone' ) === false && stripos( $this->_agent, 'iPod' ) === false ) { - $aresult = explode( '/', stristr( $this->_agent, 'Version' ) ); - if ( isset( $aresult[1] ) ) { - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - } else { - $this->setVersion( $this->VERSION_UNKNOWN ); - } - $this->setBrowser( $this->BROWSER_SAFARI ); - return true; - } - return false; - } - - /** - * Determine if the browser is iPhone or not (last updated 1.7) - * - * @return boolean True if the browser is iPhone otherwise false - */ - function checkBrowseriPhone() { - if ( stripos( $this->_agent, 'iPhone' ) !== false ) { - $aresult = explode( '/', stristr( $this->_agent, 'Version' ) ); - if ( isset( $aresult[1] ) ) { - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - } else { - $this->setVersion( $this->VERSION_UNKNOWN ); - } - $this->setMobile( true ); - $this->setBrowser( $this->BROWSER_IPHONE ); - return true; - } - return false; - } - - /** - * Determine if the browser is iPod or not (last updated 1.7) - * - * @return boolean True if the browser is iPod otherwise false - */ - function checkBrowseriPad() { - if ( stripos( $this->_agent, 'iPad' ) !== false ) { - $aresult = explode( '/', stristr( $this->_agent, 'Version' ) ); - if ( isset( $aresult[1] ) ) { - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - } else { - $this->setVersion( $this->VERSION_UNKNOWN ); - } - $this->setMobile( true ); - $this->setBrowser( $this->BROWSER_IPAD ); - return true; - } - return false; - } - - /** - * Determine if the browser is iPod or not (last updated 1.7) - * - * @return boolean True if the browser is iPod otherwise false - */ - function checkBrowseriPod() { - if ( stripos( $this->_agent, 'iPod' ) !== false ) { - $aresult = explode( '/', stristr( $this->_agent, 'Version' ) ); - if ( isset( $aresult[1] ) ) { - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - } else { - $this->setVersion( $this->VERSION_UNKNOWN ); - } - $this->setMobile( true ); - $this->setBrowser( $this->BROWSER_IPOD ); - return true; - } - return false; - } - - /** - * Determine if the browser is Android or not (last updated 1.7) - * - * @return boolean True if the browser is Android otherwise false - */ - function checkBrowserAndroid() { - if ( stripos( $this->_agent, 'Android' ) !== false ) { - $aresult = explode( ' ', stristr( $this->_agent, 'Android' ) ); - if ( isset( $aresult[1] ) ) { - $aversion = explode( ' ', $aresult[1] ); - $this->setVersion( $aversion[0] ); - } else { - $this->setVersion( $this->VERSION_UNKNOWN ); - } - $this->setMobile( true ); - $this->setBrowser( $this->BROWSER_ANDROID ); - return true; - } - return false; - } - - /** - * Determine the user's platform (last updated 1.7) - */ - function checkPlatform() { - if ( stripos( $this->_agent, 'windows' ) !== false ) { - $this->_platform = $this->PLATFORM_WINDOWS; - } else if ( stripos( $this->_agent, 'iPad' ) !== false ) { - $this->_platform = $this->PLATFORM_IPAD; - } else if ( stripos( $this->_agent, 'iPod' ) !== false ) { - $this->_platform = $this->PLATFORM_IPOD; - } else if ( stripos( $this->_agent, 'iPhone' ) !== false ) { - $this->_platform = $this->PLATFORM_IPHONE; - } elseif ( stripos( $this->_agent, 'mac' ) !== false ) { - $this->_platform = $this->PLATFORM_APPLE; - } elseif ( stripos( $this->_agent, 'android' ) !== false ) { - $this->_platform = $this->PLATFORM_ANDROID; - } elseif ( stripos( $this->_agent, 'linux' ) !== false ) { - $this->_platform = $this->PLATFORM_LINUX; - } else if ( stripos( $this->_agent, 'Nokia' ) !== false ) { - $this->_platform = $this->PLATFORM_NOKIA; - } else if ( stripos( $this->_agent, 'BlackBerry' ) !== false ) { - $this->_platform = $this->PLATFORM_BLACKBERRY; - } elseif ( stripos( $this->_agent, 'FreeBSD' ) !== false ) { - $this->_platform = $this->PLATFORM_FREEBSD; - } elseif ( stripos( $this->_agent, 'OpenBSD' ) !== false ) { - $this->_platform = $this->PLATFORM_OPENBSD; - } elseif ( stripos( $this->_agent, 'NetBSD' ) !== false ) { - $this->_platform = $this->PLATFORM_NETBSD; - } elseif ( stripos( $this->_agent, 'OpenSolaris' ) !== false ) { - $this->_platform = $this->PLATFORM_OPENSOLARIS; - } elseif ( stripos( $this->_agent, 'SunOS' ) !== false ) { - $this->_platform = $this->PLATFORM_SUNOS; - } elseif ( stripos( $this->_agent, 'OS\/2' ) !== false ) { - $this->_platform = $this->PLATFORM_OS2; - } elseif ( stripos( $this->_agent, 'BeOS' ) !== false ) { - $this->_platform = $this->PLATFORM_BEOS; - } elseif ( stripos( $this->_agent, 'win' ) !== false ) { - $this->_platform = $this->PLATFORM_WINDOWS; - } - - } -} \ No newline at end of file diff --git a/includes/um-core-functions.php b/includes/um-core-functions.php new file mode 100755 index 00000000..d2d7c397 --- /dev/null +++ b/includes/um-core-functions.php @@ -0,0 +1,84 @@ +config()->get( 'predefined_pages' ); + return array_key_exists( $slug, $predefined_pages ); +} + +/** + * @param string $slug + * + * @return false|int + */ +function um_get_predefined_page_id( $slug ) { + if ( ! um_predefined_page_slug_exists( $slug ) ) { + return false; + } + + $option_key = UM()->options()->get_predefined_page_option_key( $slug ); + return apply_filters( 'um_get_predefined_page_id', UM()->options()->get( $option_key ), $slug ); +} + +/** + * + * @param string $slug + * @param null|int|\WP_Post $post + * + * @return bool + */ +function um_is_predefined_page( $slug, $post = null ) { + // handle $post inside, just we need make $post as \WP_Post. Otherwise something is wrong and return false + if ( ! $post ) { + global $post; + + if ( empty( $post ) ) { + return false; + } + } else { + if ( is_numeric( $post ) ) { + $post = get_post( $post ); + + if ( empty( $post ) ) { + return false; + } + } + } + + if ( empty( $post->ID ) ) { + return false; + } + + return um_get_predefined_page_id( $slug ) === $post->ID; +} + +/** + * Get predefined page URL + * + * @param string $slug + * + * @return false|string + */ +function um_get_predefined_page_url( $slug ) { + $url = false; + + if ( $page_id = um_get_predefined_page_id( $slug ) ) { + $url = get_permalink( $page_id ); + } + + return $url; +}
    Extend UM core pages.