mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Merge branch 'master' of https://github.com/ultimatemember/ultimatemember
# Conflicts: # assets/js/um-conditional.js # assets/js/um-conditional.min.js # assets/js/um-scripts.min.js # includes/core/class-enqueue.php
This commit is contained in:
@@ -34,9 +34,11 @@ matrix:
|
|||||||
- php: "5.6"
|
- php: "5.6"
|
||||||
- php: "7.0"
|
- php: "7.0"
|
||||||
- php: "7.1"
|
- php: "7.1"
|
||||||
|
- php: "7.2"
|
||||||
|
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- php: "7.1"
|
- php: "7.1"
|
||||||
|
- php: "7.2"
|
||||||
# - php: "nightly"
|
# - php: "nightly"
|
||||||
|
|
||||||
# whitelist branches for the "push" build check.
|
# whitelist branches for the "push" build check.
|
||||||
|
|||||||
+581
-372
@@ -1,387 +1,596 @@
|
|||||||
function condition_fields() {
|
var arr_all_conditions = []; //raw
|
||||||
var first_group = 0,
|
var um_field_conditions = {}; // filtered
|
||||||
state_array = [],
|
var um_field_default_values = {};
|
||||||
count = state_array.length,
|
|
||||||
state = 'show';
|
|
||||||
|
|
||||||
jQuery('.um-profile-body .um-field, .um-profile-body .um-field').each(function () {
|
/**
|
||||||
var conds = jQuery(this).attr('data-conds');
|
* Get field default value
|
||||||
|
* @param object $dom
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function um_get_field_default_value( $dom ) {
|
||||||
|
var default_value = '';
|
||||||
|
var type = um_get_field_type($dom);
|
||||||
|
switch ( type ) {
|
||||||
|
|
||||||
if ( conds ){
|
case 'text':
|
||||||
var array = JSON.parse(conds);
|
case 'number':
|
||||||
|
case 'date':
|
||||||
|
case 'textarea':
|
||||||
|
case 'select':
|
||||||
|
default_value = $dom.find('input:text,input[type=number],textarea,select').val();
|
||||||
|
break;
|
||||||
|
|
||||||
jQuery.each(array, function() {
|
case 'multiselect':
|
||||||
var action = this[0],
|
default_value = $dom.find('select').val();
|
||||||
field = this[1],
|
break;
|
||||||
op = this[2],
|
|
||||||
val = this[3],
|
|
||||||
group = this[5],
|
|
||||||
depend_field;
|
|
||||||
|
|
||||||
var input = jQuery('.um-profile-body .um-field[data-key="'+field+'"] .um-field-area input'),
|
case 'radio':
|
||||||
select = jQuery('.um-profile-body .um-field[data-key="'+field+'"] .um-field-area>select'),
|
if ($dom.find('input[type=radio]:checked').length >= 1) {
|
||||||
textarea = jQuery('.um-profile-body .um-field[data-key="'+field+'"] .um-field-area>textarea'),
|
default_value = $dom.find('input[type=radio]:checked').val();
|
||||||
content_block = jQuery('.um-profile-body .um-field[data-key="'+field+'"] .um-field-block');
|
}
|
||||||
|
|
||||||
if( input.length > 0 && select.length === 0 ){
|
break;
|
||||||
|
case 'checkbox':
|
||||||
|
|
||||||
if( input.is(':checkbox') ){
|
if ($dom.find('input[type=checkbox]:checked').length >= 1) {
|
||||||
var checked = jQuery('.um-profile-body .um-field[data-key="'+field+'"] input:checked');
|
|
||||||
checked.each(function () {
|
|
||||||
var checked_vals = jQuery(this).val();
|
|
||||||
|
|
||||||
if( checked_vals === val ){
|
if ($dom.find('input[type=checkbox]:checked').length > 1) {
|
||||||
depend_field = val;
|
$dom.find('input[type=checkbox]:checked').each(function () {
|
||||||
}
|
default_value = default_value + jQuery(this).val() + ' ';
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
default_value = $dom.find('input[type=checkbox]:checked').val();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
}
|
||||||
} else if( input.is(':radio')) {
|
break;
|
||||||
depend_field = jQuery('.um-profile-body .um-field[data-key="'+field+'"] input:checked').val();
|
}
|
||||||
} else {
|
|
||||||
depend_field = input.val();
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if( select.length > 0 ){
|
return {type: type, value: default_value};
|
||||||
|
|
||||||
if( jQuery.inArray( val, select.val() ) > 0 ){
|
|
||||||
depend_field = val;
|
|
||||||
} else {
|
|
||||||
depend_field = select.val()
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if( textarea.length > 0 ){
|
|
||||||
|
|
||||||
depend_field = textarea.val();
|
|
||||||
|
|
||||||
} else if( content_block.length > 0 ){
|
|
||||||
|
|
||||||
depend_field = content_block.text();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if( parseInt(group) !== first_group ){
|
|
||||||
|
|
||||||
if ( action === 'show') {
|
|
||||||
|
|
||||||
switch (op) {
|
|
||||||
case 'equals to':
|
|
||||||
if( depend_field == val ){
|
|
||||||
state = 'show';
|
|
||||||
} else {
|
|
||||||
state = 'hide';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'not equals':
|
|
||||||
if( depend_field != val ){
|
|
||||||
state = 'show';
|
|
||||||
} else {
|
|
||||||
state = 'hide';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'empty':
|
|
||||||
if( !depend_field || depend_field === '' ){
|
|
||||||
state = 'show';
|
|
||||||
} else {
|
|
||||||
state = 'hide';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'not empty':
|
|
||||||
if( depend_field && depend_field !== '' ){
|
|
||||||
state = 'show';
|
|
||||||
} else {
|
|
||||||
state = 'hide';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'greater than':
|
|
||||||
if( jQuery.isNumeric(val) && jQuery.isNumeric(depend_field) ){
|
|
||||||
if( val > depend_field ){
|
|
||||||
state = 'show'
|
|
||||||
} else {
|
|
||||||
state = 'hide'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
state = 'hide';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'less than':
|
|
||||||
if( jQuery.isNumeric(val) && jQuery.isNumeric(depend_field) ){
|
|
||||||
if( val < depend_field ){
|
|
||||||
state = 'show'
|
|
||||||
} else {
|
|
||||||
state = 'hide'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
state = 'hide';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'contains':
|
|
||||||
if( depend_field.search(val) >= 0 ){
|
|
||||||
state = 'show';
|
|
||||||
} else {
|
|
||||||
state = 'hide';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else { // if hide
|
|
||||||
|
|
||||||
switch (op) {
|
|
||||||
case 'equals to':
|
|
||||||
if (depend_field == val) {
|
|
||||||
state = 'hide';
|
|
||||||
} else {
|
|
||||||
state = 'show';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'not equals':
|
|
||||||
if (depend_field != val) {
|
|
||||||
state = 'hide';
|
|
||||||
} else {
|
|
||||||
state = 'show';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'empty':
|
|
||||||
if (!depend_field || depend_field === '') {
|
|
||||||
state = 'hide';
|
|
||||||
} else {
|
|
||||||
state = 'show';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'not empty':
|
|
||||||
if (depend_field && depend_field !== '') {
|
|
||||||
state = 'hide';
|
|
||||||
} else {
|
|
||||||
state = 'show';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'greater than':
|
|
||||||
if (jQuery.isNumeric(val) && jQuery.isNumeric(depend_field)) {
|
|
||||||
if (val > depend_field) {
|
|
||||||
state = 'hide'
|
|
||||||
} else {
|
|
||||||
state = 'show'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
state = 'show';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'less than':
|
|
||||||
if (jQuery.isNumeric(val) && jQuery.isNumeric(depend_field)) {
|
|
||||||
if (val < depend_field) {
|
|
||||||
state = 'hide'
|
|
||||||
} else {
|
|
||||||
state = 'show'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
state = 'show';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'contains':
|
|
||||||
if (depend_field.search(val) >= 0) {
|
|
||||||
state = 'hide';
|
|
||||||
} else {
|
|
||||||
state = 'show';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
first_group++;
|
|
||||||
state_array.push(state);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if ( action === 'show') {
|
|
||||||
|
|
||||||
switch (op) {
|
|
||||||
case 'equals to':
|
|
||||||
if( depend_field == val ){
|
|
||||||
state = 'show';
|
|
||||||
} else {
|
|
||||||
state = 'not_show';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'not equals':
|
|
||||||
if( depend_field != val ){
|
|
||||||
state = 'show';
|
|
||||||
} else {
|
|
||||||
state = 'not_show';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'empty':
|
|
||||||
if( !depend_field || depend_field === '' ){
|
|
||||||
state = 'show';
|
|
||||||
} else {
|
|
||||||
state = 'not_show';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'not empty':
|
|
||||||
if( depend_field && depend_field !== '' ){
|
|
||||||
state = 'show';
|
|
||||||
} else {
|
|
||||||
state = 'not_show';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'greater than':
|
|
||||||
if( jQuery.isNumeric(val) && jQuery.isNumeric(depend_field) ){
|
|
||||||
if( val > depend_field ){
|
|
||||||
state = 'show'
|
|
||||||
} else {
|
|
||||||
state = 'not_show'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
state = 'not_show';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'less than':
|
|
||||||
if( jQuery.isNumeric(val) && jQuery.isNumeric(depend_field) ){
|
|
||||||
if( val < depend_field ){
|
|
||||||
state = 'show'
|
|
||||||
} else {
|
|
||||||
state = 'not_show'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
state = 'not_show';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'contains':
|
|
||||||
if( depend_field.search(val) >= 0 ){
|
|
||||||
state = 'show';
|
|
||||||
} else {
|
|
||||||
state = 'not_show';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else { // if hide
|
|
||||||
|
|
||||||
switch (op) {
|
|
||||||
case 'equals to':
|
|
||||||
if (depend_field == val) {
|
|
||||||
state = 'hide';
|
|
||||||
} else {
|
|
||||||
state = 'not_hide';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'not equals':
|
|
||||||
if (depend_field != val) {
|
|
||||||
state = 'hide';
|
|
||||||
} else {
|
|
||||||
state = 'not_hide';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'empty':
|
|
||||||
if (!depend_field || depend_field === '') {
|
|
||||||
state = 'hide';
|
|
||||||
} else {
|
|
||||||
state = 'not_hide';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'not empty':
|
|
||||||
if (depend_field && depend_field !== '') {
|
|
||||||
state = 'hide';
|
|
||||||
} else {
|
|
||||||
state = 'not_hide';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'greater than':
|
|
||||||
if (jQuery.isNumeric(val) && jQuery.isNumeric(depend_field)) {
|
|
||||||
if (val > depend_field) {
|
|
||||||
state = 'hide'
|
|
||||||
} else {
|
|
||||||
state = 'not_hide'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
state = 'not_hide';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'less than':
|
|
||||||
if (jQuery.isNumeric(val) && jQuery.isNumeric(depend_field)) {
|
|
||||||
if (val < depend_field) {
|
|
||||||
state = 'hide'
|
|
||||||
} else {
|
|
||||||
state = 'not_hide'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
state = 'not_hide';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'contains':
|
|
||||||
if (depend_field.search(val) >= 0) {
|
|
||||||
state = 'hide';
|
|
||||||
} else {
|
|
||||||
state = 'not_hide';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if( state_array[count] ){
|
|
||||||
if( state_array[count] === 'show' || state_array[count] === 'not_hide' ){
|
|
||||||
if ( state === 'show' || state === 'not_hide' ){
|
|
||||||
state_array[count] = 'show';
|
|
||||||
} else {
|
|
||||||
state_array[count] = 'hide';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
state_array[count] = 'hide';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ( state === 'show' || state === 'not_hide' ){
|
|
||||||
state_array[count] = 'show';
|
|
||||||
} else {
|
|
||||||
state_array[count] = 'hide';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
if( jQuery.inArray( 'show', state_array ) < 0 ){
|
|
||||||
jQuery(this).hide();
|
|
||||||
} else {
|
|
||||||
jQuery(this).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get field element by field wrapper
|
||||||
|
* @param object $dom
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
function um_get_field_element( $dom ) {
|
||||||
|
var default_value = '';
|
||||||
|
var type = um_get_field_type($dom);
|
||||||
|
|
||||||
|
switch ( type ) {
|
||||||
|
|
||||||
|
case 'text':
|
||||||
|
case 'number':
|
||||||
|
case 'date':
|
||||||
|
case 'textarea':
|
||||||
|
case 'select':
|
||||||
|
case 'multiselect':
|
||||||
|
case 'radio':
|
||||||
|
case 'checkbox':
|
||||||
|
return $dom.find('input,textarea,select');
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get field type
|
||||||
|
* @param object $dom
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function um_get_field_type($dom) {
|
||||||
|
var type = '';
|
||||||
|
var classes = $dom.attr( 'class' );
|
||||||
|
jQuery.each( classes.split(' '), function (i, d) {
|
||||||
|
if (d.indexOf('um-field-type') != -1) {
|
||||||
|
type = d.split('_')[1];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return type;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get field siblings/chidren conditions
|
||||||
|
* @param string field_key
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function um_get_field_children(field_key) {
|
||||||
|
var arr_conditions = [];
|
||||||
|
jQuery.each(arr_all_conditions, function (ii, condition) {
|
||||||
|
if (condition.field.parent == field_key) {
|
||||||
|
arr_conditions.push(condition.field.condition);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return arr_conditions;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Split single array to multi-dimensional array
|
||||||
|
* @param array arr
|
||||||
|
* @param integer n
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function um_splitup_array(arr, n) {
|
||||||
|
var rest = arr.length % n,
|
||||||
|
restUsed = rest,
|
||||||
|
partLength = Math.floor(arr.length / n),
|
||||||
|
result = [];
|
||||||
|
|
||||||
|
for (var i = 0; i < arr.length; i += partLength) {
|
||||||
|
var end = partLength + i,
|
||||||
|
add = false;
|
||||||
|
|
||||||
|
if (rest !== 0 && restUsed) {
|
||||||
|
end++;
|
||||||
|
restUsed--;
|
||||||
|
add = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.push(arr.slice(i, end));
|
||||||
|
|
||||||
|
if (add) {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var obj_result = [];
|
||||||
|
jQuery.each(result, function (ii, dd) {
|
||||||
|
obj_result.push({
|
||||||
|
action: dd[0],
|
||||||
|
if_field: dd[1],
|
||||||
|
operator: dd[2],
|
||||||
|
value: dd[3]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
return obj_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get field live value
|
||||||
|
* @param object $dom
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function um_get_field_data($dom) {
|
||||||
|
um_live_field = $dom.parents('.um-field').data('key');
|
||||||
|
um_live_value = $dom.val();
|
||||||
|
|
||||||
|
if ($dom.is(':checkbox')) {
|
||||||
|
|
||||||
|
um_live_value = '';
|
||||||
|
|
||||||
|
if ($dom.parents('.um-field').find('input:checked').length > 1) {
|
||||||
|
$dom.parents('.um-field').find('input:checked').each(function () {
|
||||||
|
um_live_value = um_live_value + jQuery(this).val() + ' ';
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if ($dom.parents('.um-field').find('input:checked').length >= 1) {
|
||||||
|
um_live_value = $dom.parents('.um-field').find('input:checked').val();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($dom.is(':radio')) {
|
||||||
|
um_live_value = $dom.parents('.um-field').find('input[type=radio]:checked').val();
|
||||||
|
}
|
||||||
|
|
||||||
|
return um_live_value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function um_in_array(needle, haystack, strict){
|
||||||
|
var found = false, key, strict = !!strict;
|
||||||
|
for (key in haystack) {
|
||||||
|
if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply field conditions
|
||||||
|
* @param object $dom
|
||||||
|
* @param boolean is_single_update
|
||||||
|
*/
|
||||||
|
function um_apply_conditions($dom, is_single_update) {
|
||||||
|
var operators = ['empty', 'not empty', 'equals to', 'not equals', 'greater than', 'less than', 'contains'];
|
||||||
|
var key = $dom.parents('.um-field[data-key]').data('key');
|
||||||
|
var conditions = um_field_conditions[key];
|
||||||
|
|
||||||
|
var live_field_value = um_get_field_data($dom);
|
||||||
|
|
||||||
|
var $owners = {};
|
||||||
|
var $owners_values = {};
|
||||||
|
var $owner_conditions = {};
|
||||||
|
|
||||||
|
jQuery.each(conditions, function (index, condition) {
|
||||||
|
if (typeof $owners_values[condition.owner] == 'undefined') {
|
||||||
|
$owners_values[condition.owner] = [];
|
||||||
|
$owner_conditions[condition.owner] = {}
|
||||||
|
}
|
||||||
|
$owners_values[condition.owner].push(condition.value);
|
||||||
|
$owner_conditions[condition.owner] = condition;
|
||||||
|
});
|
||||||
|
|
||||||
|
jQuery.each(conditions, function (index, condition) {
|
||||||
|
if (typeof $owners[condition.owner] == 'undefined') {
|
||||||
|
$owners[condition.owner] = {};
|
||||||
|
}
|
||||||
|
if (condition.operator == 'empty') {
|
||||||
|
if (!live_field_value || live_field_value == '' && um_in_array(live_field_value, $owners_values[condition.owner])) {
|
||||||
|
$owners[condition.owner][index] = true;
|
||||||
|
} else {
|
||||||
|
$owners[condition.owner][index] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (condition.operator == 'not empty') {
|
||||||
|
if (live_field_value && live_field_value != '' && !um_in_array(live_field_value, $owners_values[condition.owner])) {
|
||||||
|
$owners[condition.owner][index] = true;
|
||||||
|
} else {
|
||||||
|
$owners[condition.owner][index] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (condition.operator == 'equals to') {
|
||||||
|
if (condition.value == live_field_value && um_in_array(live_field_value, $owners_values[condition.owner])) {
|
||||||
|
$owners[condition.owner][index] = true;
|
||||||
|
} else {
|
||||||
|
$owners[condition.owner][index] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (condition.operator == 'not equals') {
|
||||||
|
if (jQuery.isNumeric(condition.value) && parseInt(live_field_value) != parseInt(condition.value) && live_field_value && !um_in_array(live_field_value, $owners_values[condition.owner])) {
|
||||||
|
$owners[condition.owner][index] = true;
|
||||||
|
} else if (condition.value != live_field_value && !um_in_array(live_field_value, $owners_values[condition.owner])) {
|
||||||
|
$owners[condition.owner][index] = true;
|
||||||
|
} else {
|
||||||
|
$owners[condition.owner][index] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (condition.operator == 'greater than') {
|
||||||
|
if (jQuery.isNumeric(condition.value) && parseInt(live_field_value) > parseInt(condition.value)) {
|
||||||
|
$owners[condition.owner][index] = true;
|
||||||
|
} else {
|
||||||
|
$owners[condition.owner][index] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (condition.operator == 'less than') {
|
||||||
|
if (jQuery.isNumeric(condition.value) && parseInt(live_field_value) < parseInt(condition.value)) {
|
||||||
|
$owners[condition.owner][index] = true;
|
||||||
|
} else {
|
||||||
|
$owners[condition.owner][index] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( condition.operator == 'contains' ) {
|
||||||
|
if ( 'multiselect' == um_get_field_type( $dom.parents('.um-field[data-key]') ) ) {
|
||||||
|
if ( live_field_value && live_field_value.indexOf( condition.value ) >= 0 && um_in_array( condition.value, live_field_value ) ) {
|
||||||
|
$owners[condition.owner][index] = true;
|
||||||
|
} else {
|
||||||
|
$owners[condition.owner][index] = false;
|
||||||
|
}
|
||||||
|
} else if ( 'checkbox' == um_get_field_type( $dom.parents('.um-field[data-key]') ) ) {
|
||||||
|
if ( live_field_value && live_field_value.indexOf( condition.value ) >= 0 ) {
|
||||||
|
$owners[condition.owner][index] = true;
|
||||||
|
} else {
|
||||||
|
$owners[condition.owner][index] = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( live_field_value && live_field_value.indexOf( condition.value ) >= 0 && um_in_array( live_field_value, $owners_values[ condition.owner ] ) ) {
|
||||||
|
$owners[condition.owner][index] = true;
|
||||||
|
} else {
|
||||||
|
$owners[condition.owner][index] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}); // end foreach `conditions`
|
||||||
|
jQuery.each($owners, function (index, field) {
|
||||||
|
if (um_in_array(true, field)) {
|
||||||
|
um_field_apply_action($dom, $owner_conditions[index], true);
|
||||||
|
} else {
|
||||||
|
um_field_apply_action($dom, $owner_conditions[index], false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$dom.trigger('um_fields_change');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply condition's action
|
||||||
|
* @param object $dom
|
||||||
|
* @param string condition
|
||||||
|
* @param boolean is_true
|
||||||
|
*/
|
||||||
|
function um_field_apply_action($dom, condition, is_true) {
|
||||||
|
var child_dom = jQuery('div.um-field[data-key="' + condition.owner + '"]');
|
||||||
|
|
||||||
|
if (condition.action == 'show' && is_true /*&& child_dom.is(':hidden')*/) {
|
||||||
|
child_dom.show();
|
||||||
|
_show_in_ie( child_dom );
|
||||||
|
um_field_restore_default_value(child_dom);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (condition.action == 'show' && !is_true /*&& child_dom.is(':visible') */) {
|
||||||
|
child_dom.hide();
|
||||||
|
_hide_in_ie( child_dom );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (condition.action == 'hide' && is_true /*&& child_dom.is(':visible')*/) {
|
||||||
|
child_dom.hide();
|
||||||
|
_hide_in_ie( child_dom );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (condition.action == 'hide' && !is_true /*&& child_dom.is(':hidden')*/) {
|
||||||
|
child_dom.show();
|
||||||
|
_show_in_ie( child_dom );
|
||||||
|
um_field_restore_default_value( child_dom );
|
||||||
|
|
||||||
|
}
|
||||||
|
$dom.removeClass('um-field-has-changed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restores default field value
|
||||||
|
* @param object $dom
|
||||||
|
*/
|
||||||
|
function um_field_restore_default_value( $dom ) {
|
||||||
|
//um_field_default_values
|
||||||
|
|
||||||
|
var type = um_get_field_type( $dom );
|
||||||
|
var key = $dom.data('key');
|
||||||
|
var field = um_field_default_values[key];
|
||||||
|
switch ( type ) {
|
||||||
|
|
||||||
|
case 'text':
|
||||||
|
case 'number':
|
||||||
|
case 'date':
|
||||||
|
case 'textarea':
|
||||||
|
$dom.find('input:text,input[type=number],textareas').val(field.value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'select':
|
||||||
|
$dom.find('select').find('option').prop('selected', false);
|
||||||
|
$dom.find('select').val(field.value);
|
||||||
|
$dom.find('select').trigger('change');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'multiselect':
|
||||||
|
$dom.find('select').find('option').prop('selected', false);
|
||||||
|
jQuery.each(field.value, function (i, value) {
|
||||||
|
$dom.find('select').find('option[value="' + value + '"]').attr('selected', true);
|
||||||
|
});
|
||||||
|
$dom.find('select').trigger('change');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'checkbox':
|
||||||
|
|
||||||
|
if ( $dom.find('input[type=checkbox]:checked').length >= 1 ) {
|
||||||
|
|
||||||
|
$dom.find('input[type=checkbox]:checked').removeAttr('checked');
|
||||||
|
$dom.find('span.um-field-checkbox-state i').removeClass('um-icon-android-checkbox-outline');
|
||||||
|
$dom.find('span.um-field-checkbox-state i').addClass('um-icon-android-checkbox-outline-blank');
|
||||||
|
$dom.find('.um-field-checkbox.active').removeClass('active');
|
||||||
|
|
||||||
|
if (jQuery.isArray(field.value)) {
|
||||||
|
jQuery.each(field.value, function (i, value) {
|
||||||
|
var cbox_elem = $dom.find('input[type=checkbox][value="' + value + '"]');
|
||||||
|
cbox_elem.attr('checked', true);
|
||||||
|
cbox_elem.closest('.um-field-checkbox').find('i').removeClass('um-icon-android-checkbox-outline-blank');
|
||||||
|
cbox_elem.closest('.um-field-checkbox').find('i').addClass('um-icon-android-checkbox-outline');
|
||||||
|
cbox_elem.closest('.um-field-checkbox').addClass('active');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
var cbox_elem = $dom.find('input[type=checkbox][value="' + field.value + '"]');
|
||||||
|
cbox_elem.attr('checked', true);
|
||||||
|
cbox_elem.closest('.um-field-checkbox').find('i').removeClass('um-icon-android-checkbox-outline-blank');
|
||||||
|
cbox_elem.closest('.um-field-checkbox').find('i').addClass('um-icon-android-checkbox-outline');
|
||||||
|
cbox_elem.closest('.um-field-checkbox').addClass('active');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'radio':
|
||||||
|
|
||||||
|
if ( $dom.find('input[type=radio]:checked').length >= 1 ) {
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
|
||||||
|
$dom.find('input[type=radio]:checked').removeAttr('checked');
|
||||||
|
|
||||||
|
$dom.find('span.um-field-radio-state i').removeClass('um-icon-android-radio-button-on');
|
||||||
|
$dom.find('span.um-field-radio-state i').addClass('um-icon-android-radio-button-off');
|
||||||
|
$dom.find('.um-field-radio.active').removeClass('active');
|
||||||
|
|
||||||
|
var radio_elem = $dom.find("input[type=radio][value='" + field.value + "']");
|
||||||
|
radio_elem.attr('checked', true);
|
||||||
|
radio_elem.closest('.um-field-radio').find('i').removeClass('um-icon-android-radio-button-off');
|
||||||
|
radio_elem.closest('.um-field-radio').find('i').addClass('um-icon-android-radio-button-on');
|
||||||
|
radio_elem.closest('.um-field-radio').addClass('active');
|
||||||
|
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
} // end switch type
|
||||||
|
|
||||||
|
|
||||||
|
if ( ! $dom.hasClass( 'um-field-has-changed' ) ) {
|
||||||
|
var me = um_get_field_element( $dom );
|
||||||
|
|
||||||
|
if ( type == 'radio' || type == 'checkbox' ) {
|
||||||
|
me = me.find( ':checked' );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( me ) {
|
||||||
|
me.trigger( 'change' );
|
||||||
|
$dom.addClass( 'um-field-has-changed' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
maybe future fix
|
||||||
|
if ( me ) {
|
||||||
|
if ( type == 'radio' || type == 'checkbox' ) {
|
||||||
|
me.each( function() {
|
||||||
|
if ( jQuery(this).is(':checked') ) {
|
||||||
|
jQuery(this).trigger('change');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
me.trigger( 'change' );
|
||||||
|
}
|
||||||
|
|
||||||
|
$dom.addClass( 'um-field-has-changed' );
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hides sibling/child field when parent field is hidden
|
||||||
|
*/
|
||||||
|
function um_field_hide_siblings() {
|
||||||
|
|
||||||
|
jQuery.each(um_field_conditions, function (index, conditions) {
|
||||||
|
if (jQuery('.um-field[data-key="' + index + '"]:hidden').length >= 1 || jQuery('.um-field[data-key="' + index + '"]').css('display') == 'none') {
|
||||||
|
jQuery.each(conditions, function (key, condition) {
|
||||||
|
jQuery('.um-field[data-key="' + condition.owner + '"]').hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hides div for IE browser
|
||||||
|
* @param object $dom
|
||||||
|
*/
|
||||||
|
function _hide_in_ie( $dom ){
|
||||||
|
if ( typeof( jQuery.browser ) != 'undefined' && jQuery.browser.msie ) {
|
||||||
|
$dom.css({"visibility":"hidden"});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows div for IE browser
|
||||||
|
* @param object $dom
|
||||||
|
*/
|
||||||
|
function _show_in_ie( $dom ){
|
||||||
|
if ( typeof( jQuery.browser ) != 'undefined' && jQuery.browser.msie ) {
|
||||||
|
$dom.css({"visibility":"visible"});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UM Conditional fields Init
|
||||||
|
*/
|
||||||
|
function um_init_field_conditions() {
|
||||||
|
var arr_field_keys = [];
|
||||||
|
|
||||||
|
jQuery( '.um-field[data-key]' ).each( function() {
|
||||||
|
|
||||||
|
var key = jQuery(this).data( 'key' );
|
||||||
|
|
||||||
|
arr_field_keys.push( key );
|
||||||
|
|
||||||
|
var parse_attrs = {};
|
||||||
|
jQuery.each( jQuery(this)[0].attributes, function ( index, attribute ) {
|
||||||
|
if ( attribute.name.indexOf( 'data-cond' ) != -1 ) {
|
||||||
|
// replace "data-cond-"
|
||||||
|
var cond_field_id_and_attr = attribute.name.slice( 10 );
|
||||||
|
// return "n"
|
||||||
|
var cond_field_id = cond_field_id_and_attr.substring( 1, 0 );
|
||||||
|
//replace "n-"
|
||||||
|
var cond_field_attr = cond_field_id_and_attr.slice( 2 );
|
||||||
|
|
||||||
|
if ( typeof parse_attrs[cond_field_id] == 'undefined' )
|
||||||
|
parse_attrs[cond_field_id] = {};
|
||||||
|
|
||||||
|
parse_attrs[cond_field_id][cond_field_attr] = attribute.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jQuery.each( parse_attrs, function ( ii, dd ) {
|
||||||
|
var obj = {'field' :{
|
||||||
|
owner: key,
|
||||||
|
action: dd.action,
|
||||||
|
parent: dd.field,
|
||||||
|
operator: dd.operator,
|
||||||
|
value: dd.value,
|
||||||
|
condition: {
|
||||||
|
owner: key,
|
||||||
|
action: dd.action,
|
||||||
|
operator: dd.operator,
|
||||||
|
value: dd.value
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
|
||||||
|
arr_all_conditions.push(obj);
|
||||||
|
});
|
||||||
|
|
||||||
|
um_field_default_values[jQuery(this).data('key')] = um_get_field_default_value( jQuery(this) );
|
||||||
|
});
|
||||||
|
|
||||||
|
jQuery.each( arr_field_keys, function ( i, field_key ) {
|
||||||
|
um_field_conditions[field_key] = um_get_field_children( field_key );
|
||||||
|
});
|
||||||
|
|
||||||
|
jQuery( '.um-field[data-key]:visible' ).each( function() {
|
||||||
|
var $wrap_dom = jQuery(this);
|
||||||
|
var me = um_get_field_element( $wrap_dom );
|
||||||
|
if ( typeof me.trigger !== 'undefined' ) {
|
||||||
|
me.trigger( 'change' );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
jQuery(document).ready( function (){
|
jQuery(document).ready( function (){
|
||||||
|
|
||||||
condition_fields();
|
jQuery(document).on('change', '.um-field select, .um-field input[type="radio"], .um-field input[type="checkbox"]', function () {
|
||||||
|
var me = jQuery(this);
|
||||||
jQuery('.um-profile-body .um-field input, .um-profile-body .um-field textarea').on('change keyup', function () {
|
um_apply_conditions(me, false);
|
||||||
condition_fields();
|
|
||||||
});
|
|
||||||
jQuery('.um-profile-body .um-field select').on('change', function () {
|
|
||||||
condition_fields();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jQuery(document).on('input change', '.um-field input[type="text"]', function () {
|
||||||
|
var me = jQuery(this);
|
||||||
|
um_apply_conditions(me, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
jQuery(document).on('input change', '.um-field input[type="number"]', function () {
|
||||||
|
var me = jQuery(this);
|
||||||
|
um_apply_conditions(me, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
jQuery(document).on('input change', '.um-field input[type="password"]', function () {
|
||||||
|
var me = jQuery(this);
|
||||||
|
um_apply_conditions(me, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
jQuery(document).on('um_fields_change', function () {
|
||||||
|
um_field_hide_siblings();
|
||||||
|
um_field_hide_siblings(); // dupes, issue with false field wrapper's visiblity validations. requires optimization.
|
||||||
|
});
|
||||||
|
|
||||||
|
um_init_field_conditions();
|
||||||
});
|
});
|
||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -124,10 +124,10 @@ jQuery(document).ready(function() {
|
|||||||
score: function() {return jQuery(this).attr('data-score');},
|
score: function() {return jQuery(this).attr('data-score');},
|
||||||
scoreName: function(){return jQuery(this).attr('data-key');},
|
scoreName: function(){return jQuery(this).attr('data-key');},
|
||||||
hints: false,
|
hints: false,
|
||||||
click: function(score, evt) {
|
click: function( score, evt ) {
|
||||||
live_field = this.id;
|
live_field = this.id;
|
||||||
live_value = score;
|
live_value = score;
|
||||||
um_conditional();
|
um_apply_conditions( jQuery(this), false );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -123,10 +123,13 @@ jQuery(document).ready( function() {
|
|||||||
button.siblings('.um-media-upload-data-width').val(attachment.width);
|
button.siblings('.um-media-upload-data-width').val(attachment.width);
|
||||||
button.siblings('.um-media-upload-data-height').val(attachment.height);
|
button.siblings('.um-media-upload-data-height').val(attachment.height);
|
||||||
button.siblings('.um-media-upload-data-thumbnail').val(attachment.thumbnail);
|
button.siblings('.um-media-upload-data-thumbnail').val(attachment.thumbnail);
|
||||||
|
button.siblings('.um-media-upload-data-url').trigger('change');
|
||||||
button.siblings('.um-media-upload-url').val(attachment.url);
|
button.siblings('.um-media-upload-url').val(attachment.url);
|
||||||
|
|
||||||
button.siblings('.um-clear-image').show();
|
button.siblings('.um-clear-image').show();
|
||||||
button.hide();
|
button.hide();
|
||||||
|
|
||||||
|
jQuery( document ).trigger( 'um_media_upload_select', [button, attachment] );
|
||||||
});
|
});
|
||||||
|
|
||||||
frame.open();
|
frame.open();
|
||||||
@@ -137,16 +140,20 @@ jQuery(document).ready( function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
jQuery('.um-clear-image').click( function(e) {
|
jQuery('.um-clear-image').click( function(e) {
|
||||||
var default_image_url = jQuery(this).siblings('.um-forms-field').data('default');
|
var clear_button = jQuery(this);
|
||||||
jQuery(this).siblings('.um-set-image').show();
|
var default_image_url = clear_button.siblings('.um-forms-field').data('default');
|
||||||
jQuery(this).hide();
|
clear_button.siblings('.um-set-image').show();
|
||||||
jQuery(this).siblings('.icon_preview').attr( 'src', default_image_url );
|
clear_button.hide();
|
||||||
jQuery(this).siblings('.um-media-upload-data-id').val('');
|
clear_button.siblings('.icon_preview').attr( 'src', default_image_url );
|
||||||
jQuery(this).siblings('.um-media-upload-data-width').val('');
|
clear_button.siblings('.um-media-upload-data-id').val('');
|
||||||
jQuery(this).siblings('.um-media-upload-data-height').val('');
|
clear_button.siblings('.um-media-upload-data-width').val('');
|
||||||
jQuery(this).siblings('.um-media-upload-data-thumbnail').val('');
|
clear_button.siblings('.um-media-upload-data-height').val('');
|
||||||
jQuery(this).siblings('.um-forms-field').val( default_image_url );
|
clear_button.siblings('.um-media-upload-data-thumbnail').val('');
|
||||||
jQuery(this).siblings('.um-media-upload-url').val( default_image_url );
|
clear_button.siblings('.um-forms-field').val( default_image_url );
|
||||||
|
clear_button.siblings('.um-media-upload-data-url').trigger('change');
|
||||||
|
clear_button.siblings('.um-media-upload-url').val( default_image_url );
|
||||||
|
|
||||||
|
jQuery( document ).trigger( 'um_media_upload_clear', clear_button );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +161,7 @@ jQuery(document).ready( function() {
|
|||||||
/**
|
/**
|
||||||
* On option fields change
|
* On option fields change
|
||||||
*/
|
*/
|
||||||
jQuery('body').on('change', '.um-forms-field', function() {
|
jQuery( document.body ).on('change', '.um-forms-field', function() {
|
||||||
if ( jQuery('.um-forms-line[data-conditional*=\'"' + jQuery(this).data('field_id') + '",\']').length > 0 ) {
|
if ( jQuery('.um-forms-line[data-conditional*=\'"' + jQuery(this).data('field_id') + '",\']').length > 0 ) {
|
||||||
run_check_conditions();
|
run_check_conditions();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -975,7 +975,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
|
|||||||
$class_attr = ' class="um-forms-field um-media-upload-data-url ' . $class . '"';
|
$class_attr = ' class="um-forms-field um-media-upload-data-url ' . $class . '"';
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'field_id' => $field_data['id'],
|
'field_id' => $field_data['id'] . '_url',
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( ! empty( $field_data['default']['url'] ) )
|
if ( ! empty( $field_data['default']['url'] ) )
|
||||||
|
|||||||
@@ -1170,7 +1170,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
|||||||
*/
|
*/
|
||||||
do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" );
|
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' ) ) ) || in_array( $current_subtab, apply_filters('um_settings_custom_subtabs', array() ) ) ) {
|
if ( in_array( $current_tab, apply_filters('um_settings_custom_tabs', array( 'licenses', 'install_info' ) ) ) || in_array( $current_subtab, apply_filters( 'um_settings_custom_subtabs', array(), $current_tab ) ) ) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UM hook
|
* UM hook
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ if ( ! class_exists( 'um\core\AJAX_Common' ) ) {
|
|||||||
|
|
||||||
add_action( 'wp_ajax_um_ajax_paginate', array( UM()->query(), 'ajax_paginate' ) );
|
add_action( 'wp_ajax_um_ajax_paginate', array( UM()->query(), 'ajax_paginate' ) );
|
||||||
add_action( 'wp_ajax_um_ajax_paginate_posts', array( UM()->user_posts(), 'load_posts' ) );
|
add_action( 'wp_ajax_um_ajax_paginate_posts', array( UM()->user_posts(), 'load_posts' ) );
|
||||||
|
add_action( 'wp_ajax_nopriv_um_ajax_paginate_posts', array( UM()->user_posts(), 'load_posts' ) );
|
||||||
|
|
||||||
add_action( 'wp_ajax_um_muted_action', array( UM()->form(), 'ajax_muted_action' ) );
|
add_action( 'wp_ajax_um_muted_action', array( UM()->form(), 'ajax_muted_action' ) );
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ if ( ! class_exists( 'um\core\Date_Time' ) ) {
|
|||||||
/**
|
/**
|
||||||
* Show a cool time difference between 2 timestamps
|
* Show a cool time difference between 2 timestamps
|
||||||
*
|
*
|
||||||
* @param $from
|
* @param int $from
|
||||||
* @param string $to
|
* @param int $to
|
||||||
*
|
*
|
||||||
* @return mixed|void
|
* @return string
|
||||||
*/
|
*/
|
||||||
function time_diff( $from, $to = '' ) {
|
function time_diff( $from, $to = '' ) {
|
||||||
$since = '';
|
$since = '';
|
||||||
@@ -51,52 +51,50 @@ if ( ! class_exists( 'um\core\Date_Time' ) ) {
|
|||||||
$diff = (int) abs( $to - $from );
|
$diff = (int) abs( $to - $from );
|
||||||
if ( $diff < 60 ) {
|
if ( $diff < 60 ) {
|
||||||
|
|
||||||
$since = __('just now','ultimate-member');
|
$since = __( 'just now', 'ultimate-member' );
|
||||||
|
|
||||||
} elseif ( $diff < HOUR_IN_SECONDS ) {
|
} elseif ( $diff < HOUR_IN_SECONDS ) {
|
||||||
|
|
||||||
$mins = round( $diff / MINUTE_IN_SECONDS );
|
$mins = round( $diff / MINUTE_IN_SECONDS );
|
||||||
if ( $mins <= 1 )
|
if ( $mins <= 1 ) {
|
||||||
$mins = 1;
|
$mins = 1;
|
||||||
if ( $mins == 1 ) {
|
|
||||||
$since = sprintf( __('%s min','ultimate-member'), $mins );
|
|
||||||
} else {
|
|
||||||
$since = sprintf( __('%s mins','ultimate-member'), $mins );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$since = sprintf( _n( '%s min', '%s mins', $mins, 'ultimate-member' ), $mins );
|
||||||
|
|
||||||
} elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) {
|
} elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) {
|
||||||
|
|
||||||
$hours = round( $diff / HOUR_IN_SECONDS );
|
$hours = round( $diff / HOUR_IN_SECONDS );
|
||||||
if ( $hours <= 1 )
|
if ( $hours <= 1 ) {
|
||||||
$hours = 1;
|
$hours = 1;
|
||||||
if ( $hours == 1 ) {
|
|
||||||
$since = sprintf( __('%s hr','ultimate-member'), $hours );
|
|
||||||
} else {
|
|
||||||
$since = sprintf( __('%s hrs','ultimate-member'), $hours );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$since = sprintf( _n( '%s hr', '%s hrs', $hours, 'ultimate-member' ), $hours );
|
||||||
|
|
||||||
} elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) {
|
} elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) {
|
||||||
|
|
||||||
$days = round( $diff / DAY_IN_SECONDS );
|
$days = round( $diff / DAY_IN_SECONDS );
|
||||||
if ( $days <= 1 )
|
if ( $days <= 1 ) {
|
||||||
$days = 1;
|
$days = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ( $days == 1 ) {
|
if ( $days == 1 ) {
|
||||||
$since = sprintf( __('Yesterday at %s','ultimate-member'), date('g:ia', $from ) );
|
$since = sprintf( __( 'Yesterday at %s', 'ultimate-member' ), date_i18n( 'g:ia', $from ) );
|
||||||
} else {
|
} else {
|
||||||
$since = sprintf(__('%s at %s','ultimate-member'), date('F d', $from ), date('g:ia', $from ) );
|
$since = sprintf( __( '%s at %s', 'ultimate-member' ), date_i18n( 'F d', $from ), date_i18n( 'g:ia', $from ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ( $diff < 30 * DAY_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) {
|
} elseif ( $diff < 30 * DAY_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) {
|
||||||
|
|
||||||
$since = sprintf(__('%s at %s','ultimate-member'), date('F d', $from ), date('g:ia', $from ) );
|
$since = sprintf( __( '%s at %s', 'ultimate-member' ), date_i18n( 'F d', $from ), date_i18n( 'g:ia', $from ) );
|
||||||
|
|
||||||
} elseif ( $diff < YEAR_IN_SECONDS && $diff >= 30 * DAY_IN_SECONDS ) {
|
} elseif ( $diff < YEAR_IN_SECONDS && $diff >= 30 * DAY_IN_SECONDS ) {
|
||||||
|
|
||||||
$since = sprintf(__('%s at %s','ultimate-member'), date('F d', $from ), date('g:ia', $from ) );
|
$since = sprintf( __( '%s at %s','ultimate-member'), date_i18n( 'F d', $from ), date_i18n( 'g:ia', $from ) );
|
||||||
|
|
||||||
} elseif ( $diff >= YEAR_IN_SECONDS ) {
|
} elseif ( $diff >= YEAR_IN_SECONDS ) {
|
||||||
|
|
||||||
$since = sprintf(__('%s at %s','ultimate-member'), date( 'F d, Y', $from ), date('g:ia', $from ) );
|
$since = sprintf( __( '%s at %s', 'ultimate-member' ), date_i18n( 'F d, Y', $from ), date_i18n( 'g:ia', $from ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+100
-155
@@ -1,9 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace um\core;
|
namespace um\core;
|
||||||
|
|
||||||
|
|
||||||
// Exit if accessed directly
|
// Exit if accessed directly
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||||
|
|
||||||
|
|
||||||
if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
||||||
|
|
||||||
|
|
||||||
@@ -67,10 +69,9 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enqueue scripts and styles
|
*
|
||||||
*/
|
*/
|
||||||
function wp_enqueue_scripts() {
|
function register_scripts() {
|
||||||
|
|
||||||
$dequeue_select2 = apply_filters( 'um_dequeue_select2_scripts', false );
|
$dequeue_select2 = apply_filters( 'um_dequeue_select2_scripts', false );
|
||||||
if ( class_exists( 'WooCommerce' ) || $dequeue_select2 ) {
|
if ( class_exists( 'WooCommerce' ) || $dequeue_select2 ) {
|
||||||
wp_dequeue_style( 'select2' );
|
wp_dequeue_style( 'select2' );
|
||||||
@@ -81,7 +82,6 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
|||||||
}
|
}
|
||||||
wp_register_script( 'select2', $this->js_baseurl . 'select2/select2.full.min.js', array( 'jquery', 'jquery-masonry' ), ultimatemember_version, true );
|
wp_register_script( 'select2', $this->js_baseurl . 'select2/select2.full.min.js', array( 'jquery', 'jquery-masonry' ), ultimatemember_version, true );
|
||||||
|
|
||||||
|
|
||||||
wp_register_script( 'um_scrollbar', $this->js_baseurl . 'um-scrollbar' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
wp_register_script( 'um_scrollbar', $this->js_baseurl . 'um-scrollbar' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
||||||
|
|
||||||
wp_register_script( 'um_jquery_form', $this->js_baseurl . 'um-jquery-form' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
wp_register_script( 'um_jquery_form', $this->js_baseurl . 'um-jquery-form' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
||||||
@@ -96,16 +96,56 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
|||||||
$datetime_deps[] = 'um_datetime_locale';
|
$datetime_deps[] = 'um_datetime_locale';
|
||||||
}
|
}
|
||||||
wp_register_script( 'um_datetime', $this->js_baseurl . 'pickadate/picker.js', $datetime_deps, ultimatemember_version, true );
|
wp_register_script( 'um_datetime', $this->js_baseurl . 'pickadate/picker.js', $datetime_deps, ultimatemember_version, true );
|
||||||
wp_register_script( 'um_datetime_date', $this->js_baseurl . 'pickadate/picker.date.js', array( 'jquery' ), ultimatemember_version, true );
|
wp_register_script( 'um_datetime_date', $this->js_baseurl . 'pickadate/picker.date.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
||||||
wp_register_script( 'um_datetime_time', $this->js_baseurl . 'pickadate/picker.time.js', array( 'jquery' ), ultimatemember_version, true );
|
wp_register_script( 'um_datetime_time', $this->js_baseurl . 'pickadate/picker.time.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
||||||
wp_register_script( 'um_datetime_legacy', $this->js_baseurl . 'pickadate/legacy.js', array( 'jquery' ), ultimatemember_version, true );
|
wp_register_script( 'um_datetime_legacy', $this->js_baseurl . 'pickadate/legacy.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
|
||||||
|
|
||||||
|
|
||||||
wp_register_script( 'um_tipsy', $this->js_baseurl . 'um-tipsy' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
wp_register_script( 'um_tipsy', $this->js_baseurl . 'um-tipsy' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
||||||
wp_register_script( 'um_raty', $this->js_baseurl . 'um-raty' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
wp_register_script( 'um_raty', $this->js_baseurl . 'um-raty' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
||||||
wp_register_script( 'um_crop', $this->js_baseurl . 'um-crop' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
wp_register_script( 'um_crop', $this->js_baseurl . 'um-crop' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
||||||
|
|
||||||
|
wp_register_script( 'um_modal', $this->js_baseurl . 'um-modal' . $this->suffix . '.js', array( 'jquery', 'wp-util', 'um_crop' ), ultimatemember_version, true );
|
||||||
|
wp_register_script( 'um_responsive', $this->js_baseurl . 'um-responsive' . $this->suffix . '.js', array( 'jquery', 'um_functions', 'um_crop' ), ultimatemember_version, true );
|
||||||
|
|
||||||
|
wp_register_script('um_functions', $this->js_baseurl . 'um-functions' . $this->suffix . '.js', array( 'jquery', 'jquery-masonry', 'wp-util', 'um_scrollbar' ), ultimatemember_version, true );
|
||||||
|
wp_register_script( 'um-gdpr', $this->js_baseurl . 'um-gdpr' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, false );
|
||||||
|
wp_register_script('um_conditional', $this->js_baseurl . 'um-conditional' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
||||||
|
wp_register_script('um_scripts', $this->js_baseurl . 'um-scripts' . $this->suffix . '.js', array( 'jquery', 'wp-util', 'um_conditional' ), ultimatemember_version, true );
|
||||||
|
/**
|
||||||
|
* UM hook
|
||||||
|
*
|
||||||
|
* @type filter
|
||||||
|
* @title um_enqueue_localize_data
|
||||||
|
* @description Extend UM localized data
|
||||||
|
* @input_vars
|
||||||
|
* [{"var":"$data","type":"array","desc":"Localize Array"}]
|
||||||
|
* @change_log
|
||||||
|
* ["Since: 2.0"]
|
||||||
|
* @usage add_filter( 'um_enqueue_localize_data', 'function_name', 10, 1 );
|
||||||
|
* @example
|
||||||
|
* <?php
|
||||||
|
* add_filter( 'um_enqueue_localize_data', 'my_enqueue_localize_data', 10, 1 );
|
||||||
|
* function my_enqueue_localize_data( $data ) {
|
||||||
|
* // your code here
|
||||||
|
* return $data;
|
||||||
|
* }
|
||||||
|
* ?>
|
||||||
|
*/
|
||||||
|
$localize_data = apply_filters( 'um_enqueue_localize_data', array() );
|
||||||
|
wp_localize_script( 'um_scripts', 'um_scripts', $localize_data );
|
||||||
|
|
||||||
|
wp_register_script('um_members', $this->js_baseurl . 'um-members' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
||||||
|
wp_register_script('um_profile', $this->js_baseurl . 'um-profile' . $this->suffix . '.js', array( 'jquery', 'wp-util' ), ultimatemember_version, true );
|
||||||
|
wp_register_script('um_account', $this->js_baseurl . 'um-account' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
|
||||||
|
|
||||||
|
wp_register_script( 'um_gchart', 'https://www.google.com/jsapi', array(), ultimatemember_version, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function register_styles() {
|
||||||
//FontAwesome and FontIcons styles
|
//FontAwesome and FontIcons styles
|
||||||
wp_register_style( 'um_fonticons_ii', $this->css_baseurl . 'um-fonticons-ii.css', array(), ultimatemember_version );
|
wp_register_style( 'um_fonticons_ii', $this->css_baseurl . 'um-fonticons-ii.css', array(), ultimatemember_version );
|
||||||
wp_register_style( 'um_fonticons_fa', $this->css_baseurl . 'um-fonticons-fa.css', array(), ultimatemember_version );
|
wp_register_style( 'um_fonticons_fa', $this->css_baseurl . 'um-fonticons-fa.css', array(), ultimatemember_version );
|
||||||
@@ -115,70 +155,45 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
|||||||
wp_register_style( 'select2', $this->css_baseurl . 'select2/select2.min.css', array(), ultimatemember_version );
|
wp_register_style( 'select2', $this->css_baseurl . 'select2/select2.min.css', array(), ultimatemember_version );
|
||||||
wp_register_style( 'um_fileupload', $this->css_baseurl . 'um-fileupload.css', array(), ultimatemember_version );
|
wp_register_style( 'um_fileupload', $this->css_baseurl . 'um-fileupload.css', array(), ultimatemember_version );
|
||||||
wp_register_style( 'um_datetime', $this->css_baseurl . 'pickadate/default.css', array(), ultimatemember_version );
|
wp_register_style( 'um_datetime', $this->css_baseurl . 'pickadate/default.css', array(), ultimatemember_version );
|
||||||
wp_register_style( 'um_datetime_date', $this->css_baseurl . 'pickadate/default.date.css', array( 'um-datetime' ), ultimatemember_version );
|
wp_register_style( 'um_datetime_date', $this->css_baseurl . 'pickadate/default.date.css', array( 'um_datetime' ), ultimatemember_version );
|
||||||
wp_register_style( 'um_datetime_time', $this->css_baseurl . 'pickadate/default.time.css', array( 'um-datetime' ), ultimatemember_version );
|
wp_register_style( 'um_datetime_time', $this->css_baseurl . 'pickadate/default.time.css', array( 'um_datetime' ), ultimatemember_version );
|
||||||
wp_register_style( 'um_scrollbar', $this->css_baseurl . 'um-scrollbar.css', array(), ultimatemember_version );
|
wp_register_style( 'um_scrollbar', $this->css_baseurl . 'um-scrollbar.css', array(), ultimatemember_version );
|
||||||
//ui slider for filters
|
|
||||||
//wp_enqueue_script( 'jquery-ui-slider' );
|
wp_register_style( 'um_rtl', $this->css_baseurl . 'um.rtl.css', array(), ultimatemember_version );
|
||||||
|
wp_register_style( 'um_default_css', $this->css_baseurl . 'um-old-default.css', array(), ultimatemember_version );
|
||||||
|
wp_register_style( 'um_modal', $this->css_baseurl . 'um-modal.css', array( 'um_crop' ), ultimatemember_version );
|
||||||
|
wp_register_style( 'um_responsive', $this->css_baseurl . 'um-responsive.css', array( 'um_profile', 'um_crop' ), ultimatemember_version );
|
||||||
|
|
||||||
|
wp_register_style( 'um_styles', $this->css_baseurl . 'um-styles.css', array(), ultimatemember_version );
|
||||||
|
wp_register_style( 'um_members', $this->css_baseurl . 'um-members.css', array(), ultimatemember_version );
|
||||||
|
wp_register_style( 'um_profile', $this->css_baseurl . 'um-profile.css', array(), ultimatemember_version );
|
||||||
|
wp_register_style( 'um_account', $this->css_baseurl . 'um-account.css', array(), ultimatemember_version );
|
||||||
|
wp_register_style( 'um_misc', $this->css_baseurl . 'um-misc.css', array(), ultimatemember_version );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
global $post;
|
/**
|
||||||
|
* Enqueue scripts and styles
|
||||||
|
*/
|
||||||
|
function wp_enqueue_scripts() {
|
||||||
|
|
||||||
if ( ! is_admin() ) {
|
$this->register_scripts();
|
||||||
$c_url = UM()->permalinks()->get_current_url( get_option( 'permalink_structure' ) );
|
$this->register_styles();
|
||||||
|
|
||||||
$exclude = UM()->options()->get( 'js_css_exclude' );
|
|
||||||
if ( is_array( $exclude ) ) {
|
|
||||||
array_filter( $exclude );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $exclude && is_array( $exclude ) ) {
|
|
||||||
foreach ( $exclude as $match ) {
|
|
||||||
$sub_match = untrailingslashit( $match );
|
|
||||||
if ( ! empty( $c_url ) && ! empty( $sub_match ) && strstr( $c_url, $sub_match ) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$include = UM()->options()->get( 'js_css_include' );
|
|
||||||
if ( is_array( $include ) ) {
|
|
||||||
array_filter( $include );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $include && is_array( $include ) ) {
|
|
||||||
foreach ( $include as $match ) {
|
|
||||||
$sub_match = untrailingslashit( $match );
|
|
||||||
if ( ! empty( $c_url ) && ! empty( $sub_match ) && strstr( $c_url, $sub_match ) ) {
|
|
||||||
$force_load = true;
|
|
||||||
} else {
|
|
||||||
if ( ! isset( $force_load ) ) {
|
|
||||||
$force_load = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( isset( $force_load ) && $force_load == false ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->load_original();
|
$this->load_original();
|
||||||
|
|
||||||
// rtl style
|
// rtl style
|
||||||
if ( is_rtl() ) {
|
if ( is_rtl() ) {
|
||||||
wp_register_style('um_rtl', um_url . 'assets/css/um.rtl.css', array(), ultimatemember_version );
|
wp_enqueue_style( 'um_rtl' );
|
||||||
wp_enqueue_style('um_rtl');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_object($post) && has_shortcode($post->post_content,'ultimate-member')) {
|
global $post;
|
||||||
wp_dequeue_script('jquery-form');
|
if ( is_object( $post ) && has_shortcode( $post->post_content,'ultimatemember' ) ) {
|
||||||
|
wp_dequeue_script( 'jquery-form' );
|
||||||
}
|
}
|
||||||
|
|
||||||
//old settings before UM 2.0 CSS
|
//old settings before UM 2.0 CSS
|
||||||
wp_register_style('um_default_css', um_url . 'assets/css/um-old-default.css', array(), ultimatemember_version );
|
wp_enqueue_style( 'um_default_css' );
|
||||||
wp_enqueue_style('um_default_css');
|
|
||||||
|
|
||||||
$this->old_css_settings();
|
$this->old_css_settings();
|
||||||
}
|
}
|
||||||
@@ -191,11 +206,8 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
|||||||
$uploads = wp_upload_dir();
|
$uploads = wp_upload_dir();
|
||||||
$upload_dir = $uploads['basedir'] . DIRECTORY_SEPARATOR . 'ultimatemember' . DIRECTORY_SEPARATOR;
|
$upload_dir = $uploads['basedir'] . DIRECTORY_SEPARATOR . 'ultimatemember' . DIRECTORY_SEPARATOR;
|
||||||
if ( file_exists( $upload_dir . 'um_old_settings.css' ) ) {
|
if ( file_exists( $upload_dir . 'um_old_settings.css' ) ) {
|
||||||
//was the issues with HTTPS
|
wp_register_style( 'um_old_css', um_url . '../../uploads/ultimatemember/um_old_settings.css' );
|
||||||
//wp_register_style('um_old_css', $uploads['baseurl'] . '/ultimatemember/um_old_settings.css' );
|
wp_enqueue_style( 'um_old_css' );
|
||||||
//fixed using "../../"
|
|
||||||
wp_register_style('um_old_css', um_url . '../../uploads/ultimatemember/um_old_settings.css' );
|
|
||||||
wp_enqueue_style('um_old_css');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,10 +255,7 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
|||||||
* Include Google charts
|
* Include Google charts
|
||||||
*/
|
*/
|
||||||
function load_google_charts() {
|
function load_google_charts() {
|
||||||
|
wp_enqueue_script( 'um_gchart' );
|
||||||
wp_register_script('um_gchart', 'https://www.google.com/jsapi' );
|
|
||||||
wp_enqueue_script('um_gchart');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -254,22 +263,11 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
|||||||
* Load plugin css
|
* Load plugin css
|
||||||
*/
|
*/
|
||||||
function load_css() {
|
function load_css() {
|
||||||
|
wp_enqueue_style( 'um_styles' );
|
||||||
wp_register_style('um_styles', um_url . 'assets/css/um-styles.css' );
|
wp_enqueue_style( 'um_members' );
|
||||||
wp_enqueue_style('um_styles');
|
wp_enqueue_style( 'um_profile' );
|
||||||
|
wp_enqueue_style( 'um_account' );
|
||||||
wp_register_style('um_members', um_url . 'assets/css/um-members.css' );
|
wp_enqueue_style( 'um_misc' );
|
||||||
wp_enqueue_style('um_members');
|
|
||||||
|
|
||||||
wp_register_style('um_profile', um_url . 'assets/css/um-profile.css' );
|
|
||||||
wp_enqueue_style('um_profile');
|
|
||||||
|
|
||||||
wp_register_style('um_account', um_url . 'assets/css/um-account.css' );
|
|
||||||
wp_enqueue_style('um_account');
|
|
||||||
|
|
||||||
wp_register_style('um_misc', um_url . 'assets/css/um-misc.css' );
|
|
||||||
wp_enqueue_style('um_misc');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -277,19 +275,17 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
|||||||
* Load select-dropdowns JS
|
* Load select-dropdowns JS
|
||||||
*/
|
*/
|
||||||
function load_selectjs() {
|
function load_selectjs() {
|
||||||
|
wp_enqueue_script( 'select2' );
|
||||||
wp_enqueue_script('select2');
|
wp_enqueue_style( 'select2' );
|
||||||
wp_enqueue_style('select2');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Fonticons
|
* Load Fonticons
|
||||||
*/
|
*/
|
||||||
function load_fonticons(){
|
function load_fonticons() {
|
||||||
wp_enqueue_style('um_fonticons_ii');
|
wp_enqueue_style( 'um_fonticons_ii' );
|
||||||
wp_enqueue_style('um_fonticons_fa');
|
wp_enqueue_style( 'um_fonticons_fa' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -297,9 +293,8 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
|||||||
* Load fileupload JS
|
* Load fileupload JS
|
||||||
*/
|
*/
|
||||||
function load_fileupload() {
|
function load_fileupload() {
|
||||||
wp_enqueue_script('um_jquery_form');
|
wp_enqueue_script( 'um_fileupload' );
|
||||||
wp_enqueue_script('um_fileupload');
|
wp_enqueue_style( 'um_fileupload' );
|
||||||
wp_enqueue_style('um_fileupload');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -307,12 +302,8 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
|||||||
* Load JS functions
|
* Load JS functions
|
||||||
*/
|
*/
|
||||||
function load_functions() {
|
function load_functions() {
|
||||||
|
wp_enqueue_script('um_functions' );
|
||||||
wp_register_script('um_functions', um_url . 'assets/js/um-functions' . $this->suffix . '.js', array('jquery', 'jquery-masonry', 'wp-util', 'um_scrollbar') );
|
wp_enqueue_script( 'um-gdpr' );
|
||||||
wp_enqueue_script('um_functions');
|
|
||||||
|
|
||||||
wp_enqueue_script( 'um-gdpr', um_url . 'assets/js/um-gdpr' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, false );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -320,47 +311,11 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
|||||||
* Load custom JS
|
* Load custom JS
|
||||||
*/
|
*/
|
||||||
function load_customjs() {
|
function load_customjs() {
|
||||||
|
|
||||||
wp_register_script('um_conditional', um_url . 'assets/js/um-conditional' . $this->suffix . '.js' );
|
|
||||||
wp_enqueue_script('um_conditional');
|
wp_enqueue_script('um_conditional');
|
||||||
|
|
||||||
wp_register_script('um_scripts', um_url . 'assets/js/um-scripts' . $this->suffix . '.js', array('jquery','wp-util') );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UM hook
|
|
||||||
*
|
|
||||||
* @type filter
|
|
||||||
* @title um_enqueue_localize_data
|
|
||||||
* @description Extend UM localized data
|
|
||||||
* @input_vars
|
|
||||||
* [{"var":"$data","type":"array","desc":"Localize Array"}]
|
|
||||||
* @change_log
|
|
||||||
* ["Since: 2.0"]
|
|
||||||
* @usage add_filter( 'um_enqueue_localize_data', 'function_name', 10, 1 );
|
|
||||||
* @example
|
|
||||||
* <?php
|
|
||||||
* add_filter( 'um_enqueue_localize_data', 'my_enqueue_localize_data', 10, 1 );
|
|
||||||
* function my_enqueue_localize_data( $data ) {
|
|
||||||
* // your code here
|
|
||||||
* return $data;
|
|
||||||
* }
|
|
||||||
* ?>
|
|
||||||
*/
|
|
||||||
$localize_data = apply_filters( 'um_enqueue_localize_data', array() );
|
|
||||||
|
|
||||||
wp_localize_script( 'um_scripts', 'um_scripts', $localize_data );
|
|
||||||
|
|
||||||
wp_enqueue_script('um_scripts');
|
wp_enqueue_script('um_scripts');
|
||||||
|
|
||||||
wp_register_script('um_members', um_url . 'assets/js/um-members' . $this->suffix . '.js' );
|
|
||||||
wp_enqueue_script('um_members');
|
wp_enqueue_script('um_members');
|
||||||
|
|
||||||
wp_register_script('um_profile', um_url . 'assets/js/um-profile' . $this->suffix . '.js', array('jquery','wp-util') );
|
|
||||||
wp_enqueue_script('um_profile');
|
wp_enqueue_script('um_profile');
|
||||||
|
|
||||||
wp_register_script('um_account', um_url . 'assets/js/um-account' . $this->suffix . '.js' );
|
|
||||||
wp_enqueue_script('um_account');
|
wp_enqueue_script('um_account');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -398,32 +353,27 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
|||||||
/**
|
/**
|
||||||
* Load crop script
|
* Load crop script
|
||||||
*/
|
*/
|
||||||
function load_imagecrop(){
|
function load_imagecrop() {
|
||||||
wp_enqueue_script('um_crop');
|
wp_enqueue_script( 'um_crop' );
|
||||||
wp_enqueue_style('um_crop');
|
wp_enqueue_style( 'um_crop' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load tipsy
|
* Load tipsy
|
||||||
*/
|
*/
|
||||||
function load_tipsy(){
|
function load_tipsy() {
|
||||||
wp_enqueue_script('um_tipsy');
|
wp_enqueue_script( 'um_tipsy' );
|
||||||
wp_enqueue_style('um_tipsy');
|
wp_enqueue_style( 'um_tipsy' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load modal
|
* Load modal
|
||||||
*/
|
*/
|
||||||
function load_modal(){
|
function load_modal() {
|
||||||
|
wp_enqueue_script( 'um_modal' );
|
||||||
wp_register_style('um_modal', um_url . 'assets/css/um-modal.css' );
|
wp_enqueue_style( 'um_modal' );
|
||||||
wp_enqueue_style('um_modal');
|
|
||||||
|
|
||||||
wp_register_script('um_modal', um_url . 'assets/js/um-modal' . $this->suffix . '.js', array('jquery','wp-util') );
|
|
||||||
wp_enqueue_script('um_modal');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -431,13 +381,8 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
|||||||
* Load responsive styles
|
* Load responsive styles
|
||||||
*/
|
*/
|
||||||
function load_responsive() {
|
function load_responsive() {
|
||||||
|
|
||||||
wp_register_script( 'um_responsive', um_url . 'assets/js/um-responsive' . $this->suffix . '.js', array( 'um_crop' ), ultimatemember_version, true );
|
|
||||||
wp_enqueue_script( 'um_responsive' );
|
wp_enqueue_script( 'um_responsive' );
|
||||||
|
wp_enqueue_style( 'um_responsive' );
|
||||||
wp_register_style('um_responsive', um_url . 'assets/css/um-responsive.css', array( 'um_profile' ) );
|
|
||||||
wp_enqueue_style('um_responsive');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -530,8 +530,11 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
|
|||||||
|
|
||||||
$temp = array();
|
$temp = array();
|
||||||
foreach ( $role_data as $key=>$value ) {
|
foreach ( $role_data as $key=>$value ) {
|
||||||
if ( strpos( $key, '_um_' ) === 0 )
|
if ( strpos( $key, '_um_' ) === 0 ) {
|
||||||
$key = str_replace( '_um_', '', $key );
|
$key = preg_replace('/_um_/', '', $key, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//$key = str_replace( '_um_', '', $key, $count );
|
||||||
$temp[ $key ] = $value;
|
$temp[ $key ] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,8 @@ add_filter( 'um_profile_field_filter_hook__user_registered', 'um_profile_field_f
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function um_profile_field_filter_hook__last_login( $value, $data ) {
|
function um_profile_field_filter_hook__last_login( $value, $data ) {
|
||||||
$value = sprintf( __('Last login: %s','ultimate-member'), um_user_last_login( um_user('ID') ) );
|
//$value = sprintf( __('Last login: %s','ultimate-member'), um_user_last_login( um_user('ID') ) );
|
||||||
|
$value = um_user_last_login( um_user( 'ID' ) );
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
add_filter( 'um_profile_field_filter_hook__last_login', 'um_profile_field_filter_hook__last_login', 99, 2 );
|
add_filter( 'um_profile_field_filter_hook__last_login', 'um_profile_field_filter_hook__last_login', 99, 2 );
|
||||||
|
|||||||
@@ -399,4 +399,22 @@ function um_requesting_password_change() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get core page url
|
||||||
|
*
|
||||||
|
* @deprecated 2.0.30
|
||||||
|
*
|
||||||
|
* @param $time1
|
||||||
|
* @param $time2
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function um_time_diff( $time1, $time2 ) {
|
||||||
|
//um_deprecated_function( 'um_time_diff', '2.0.30', 'UM()->datetime()->time_diff' );
|
||||||
|
|
||||||
|
return UM()->datetime()->time_diff( $time1, $time2 );
|
||||||
}
|
}
|
||||||
@@ -981,19 +981,6 @@ function um_is_temp_file( $filename ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get core page url
|
|
||||||
*
|
|
||||||
* @param $time1
|
|
||||||
* @param $time2
|
|
||||||
*
|
|
||||||
* @return mixed|void
|
|
||||||
*/
|
|
||||||
function um_time_diff( $time1, $time2 ) {
|
|
||||||
return UM()->datetime()->time_diff( $time1, $time2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get user's last login timestamp
|
* Get user's last login timestamp
|
||||||
*
|
*
|
||||||
@@ -1013,19 +1000,13 @@ function um_user_last_login_timestamp( $user_id ) {
|
|||||||
/**
|
/**
|
||||||
* Get user's last login (time diff)
|
* Get user's last login (time diff)
|
||||||
*
|
*
|
||||||
* @param $user_id
|
* @param int $user_id
|
||||||
*
|
*
|
||||||
* @return mixed|string|void
|
* @return string
|
||||||
*/
|
*/
|
||||||
function um_user_last_login( $user_id ) {
|
function um_user_last_login( $user_id ) {
|
||||||
$value = get_user_meta( $user_id, '_um_last_login', true );
|
$value = get_user_meta( $user_id, '_um_last_login', true );
|
||||||
if ( $value ) {
|
return ! empty( $value ) ? UM()->datetime()->time_diff( $value, current_time( 'timestamp' ) ) : '';
|
||||||
$value = um_time_diff( $value, current_time( 'timestamp' ) );
|
|
||||||
} else {
|
|
||||||
$value = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Ultimate Member\n"
|
"Project-Id-Version: Ultimate Member\n"
|
||||||
"POT-Creation-Date: 2018-10-26 14:45+0300\n"
|
"POT-Creation-Date: 2018-11-12 17:51+0200\n"
|
||||||
"PO-Revision-Date: 2018-10-26 14:46+0300\n"
|
"PO-Revision-Date: 2018-11-12 17:52+0200\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"Language: en_US\n"
|
"Language: en_US\n"
|
||||||
@@ -6195,48 +6195,42 @@ msgstr ""
|
|||||||
msgid "just now"
|
msgid "just now"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/class-date-time.php:62
|
#: includes/core/class-date-time.php:63
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "%s min"
|
msgid "%s min"
|
||||||
msgstr ""
|
msgid_plural "%s mins"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
#: includes/core/class-date-time.php:64
|
#: includes/core/class-date-time.php:72
|
||||||
#, php-format
|
|
||||||
msgid "%s mins"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: includes/core/class-date-time.php:73
|
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "%s hr"
|
msgid "%s hr"
|
||||||
msgstr ""
|
msgid_plural "%s hrs"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
#: includes/core/class-date-time.php:75
|
#: includes/core/class-date-time.php:82
|
||||||
#, php-format
|
|
||||||
msgid "%s hrs"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: includes/core/class-date-time.php:84
|
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "Yesterday at %s"
|
msgid "Yesterday at %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/class-date-time.php:86 includes/core/class-date-time.php:91
|
#: includes/core/class-date-time.php:84 includes/core/class-date-time.php:89
|
||||||
#: includes/core/class-date-time.php:95 includes/core/class-date-time.php:99
|
#: includes/core/class-date-time.php:93 includes/core/class-date-time.php:97
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "%s at %s"
|
msgid "%s at %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/class-date-time.php:148
|
#: includes/core/class-date-time.php:146
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "%s year old"
|
msgid "%s year old"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/class-date-time.php:151
|
#: includes/core/class-date-time.php:149
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "%s years old"
|
msgid "%s years old"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/class-date-time.php:154
|
#: includes/core/class-date-time.php:152
|
||||||
msgid "Less than 1 year old"
|
msgid "Less than 1 year old"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -6313,7 +6307,7 @@ msgstr ""
|
|||||||
msgid "Upload File"
|
msgid "Upload File"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/class-fields.php:2364 includes/core/um-filters-fields.php:243
|
#: includes/core/class-fields.php:2364 includes/core/um-filters-fields.php:244
|
||||||
msgid "This file has been removed."
|
msgid "This file has been removed."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -6530,36 +6524,36 @@ msgid ""
|
|||||||
"\"{login_referrer}\">login</a> to view this content."
|
"\"{login_referrer}\">login</a> to view this content."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/class-shortcodes.php:644
|
#: includes/core/class-shortcodes.php:645
|
||||||
msgid "You are already registered"
|
msgid "You are already registered"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/class-shortcodes.php:886
|
#: includes/core/class-shortcodes.php:887
|
||||||
msgid "Default Template"
|
msgid "Default Template"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/class-uploader.php:648
|
#: includes/core/class-uploader.php:654
|
||||||
msgid "Your image is invalid!"
|
msgid "Your image is invalid!"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/class-uploader.php:690
|
#: includes/core/class-uploader.php:696
|
||||||
msgid "This media type is not recognized."
|
msgid "This media type is not recognized."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/class-uploader.php:738
|
#: includes/core/class-uploader.php:744
|
||||||
msgid "Your image is invalid or too large!"
|
msgid "Your image is invalid or too large!"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/class-uploader.php:744 includes/core/class-uploader.php:746
|
#: includes/core/class-uploader.php:750 includes/core/class-uploader.php:752
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "Your photo is too small. It must be at least %spx wide."
|
msgid "Your photo is too small. It must be at least %spx wide."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/class-uploader.php:799
|
#: includes/core/class-uploader.php:805
|
||||||
msgid "This file type is not recognized."
|
msgid "This file type is not recognized."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/class-uploader.php:1065
|
#: includes/core/class-uploader.php:1071
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "Maximum file size allowed: %s"
|
msgid "Maximum file size allowed: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -6950,12 +6944,7 @@ msgstr ""
|
|||||||
msgid "Joined %s"
|
msgid "Joined %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/core/um-filters-fields.php:133
|
#: includes/core/um-filters-fields.php:275
|
||||||
#, php-format
|
|
||||||
msgid "Last login: %s"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: includes/core/um-filters-fields.php:274
|
|
||||||
msgid "Untitled photo"
|
msgid "Untitled photo"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|||||||
+8
-2
@@ -137,7 +137,7 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
|
|||||||
|
|
||||||
= Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin =
|
= Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin =
|
||||||
|
|
||||||
= 2.0.30: October 29, 2018 =
|
= 2.0.30: November 12, 2018 =
|
||||||
|
|
||||||
* Bugfixes:
|
* Bugfixes:
|
||||||
- Fixed crop settings of the big images
|
- Fixed crop settings of the big images
|
||||||
@@ -145,7 +145,13 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
|
|||||||
- Fixed uppercase symbols using at profile page slug
|
- Fixed uppercase symbols using at profile page slug
|
||||||
- Fixed download files/images with cache
|
- Fixed download files/images with cache
|
||||||
- Fixed download files/images with not closed buffers
|
- Fixed download files/images with not closed buffers
|
||||||
- Added bookmarks compatibility
|
- Fixed looping in case if set 'display_name' as custom fields for display name setting
|
||||||
|
- Fixed cover photo size
|
||||||
|
- Fixed date time internalization
|
||||||
|
- Fixed posts pagination for un-logged users
|
||||||
|
- Fixed conditional JS
|
||||||
|
- Fixed "um_" prefix for role data
|
||||||
|
- Added compatibility for upcoming User Bookmarks extension
|
||||||
|
|
||||||
= 2.0.29: October 8, 2018 =
|
= 2.0.29: October 8, 2018 =
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user