mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
- member directory code merge;
This commit is contained in:
@@ -186,6 +186,11 @@ jQuery(document).ready( function() {
|
||||
}
|
||||
|
||||
|
||||
function um_distinct( value, index, self ) {
|
||||
return self.indexOf( value ) === index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Conditional logic
|
||||
*
|
||||
@@ -206,10 +211,12 @@ jQuery(document).ready( function() {
|
||||
var parent_condition = true;
|
||||
|
||||
if ( condition === '=' || condition === '!=' ) {
|
||||
var condition_field = jQuery( '#' + prefix + '_' + conditional[0] );
|
||||
if ( conditional[0].indexOf( '||' ) === -1 ) {
|
||||
var condition_field = jQuery( '#' + prefix + '_' + conditional[0] );
|
||||
|
||||
if ( typeof condition_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) {
|
||||
parent_condition = check_condition( condition_field.parents('.um-forms-line') );
|
||||
if ( typeof condition_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) {
|
||||
parent_condition = check_condition( condition_field.parents('.um-forms-line') );
|
||||
}
|
||||
}
|
||||
} else if ( condition === '~' ) {
|
||||
var selectors = conditional[0].split('|');
|
||||
@@ -224,31 +231,106 @@ jQuery(document).ready( function() {
|
||||
|
||||
var own_condition = false;
|
||||
if ( condition === '=' ) {
|
||||
var tagName = condition_field.prop("tagName").toLowerCase();
|
||||
if ( conditional[0].indexOf( '||' ) !== -1 ) {
|
||||
var selectors = conditional[0].split('||');
|
||||
var complete_condition = false;
|
||||
|
||||
if ( tagName == 'input' ) {
|
||||
var input_type = condition_field.attr('type');
|
||||
if ( input_type == 'checkbox' ) {
|
||||
own_condition = ( value == '1' ) ? condition_field.is(':checked') : ! condition_field.is(':checked');
|
||||
} else {
|
||||
jQuery.each( selectors, function(i) {
|
||||
var cond_field = jQuery( '#' + prefix + '_' + selectors[i] );
|
||||
|
||||
own_condition = false;
|
||||
parent_condition = true;
|
||||
|
||||
if ( typeof cond_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) {
|
||||
parent_condition = check_condition( cond_field.parents('.um-forms-line') );
|
||||
}
|
||||
|
||||
var tagName = cond_field.prop("tagName").toLowerCase();
|
||||
|
||||
if ( tagName === 'input' ) {
|
||||
var input_type = cond_field.attr('type');
|
||||
if ( input_type === 'checkbox' ) {
|
||||
own_condition = ( value == '1' ) ? cond_field.is(':checked') : ! cond_field.is(':checked');
|
||||
} else {
|
||||
own_condition = ( cond_field.val() == value );
|
||||
}
|
||||
} else if ( tagName === 'select' ) {
|
||||
own_condition = ( cond_field.val() == value );
|
||||
}
|
||||
|
||||
if ( own_condition && parent_condition ) {
|
||||
complete_condition = true;
|
||||
}
|
||||
});
|
||||
|
||||
return complete_condition;
|
||||
} else {
|
||||
var tagName = condition_field.prop("tagName").toLowerCase();
|
||||
|
||||
if ( tagName == 'input' ) {
|
||||
var input_type = condition_field.attr('type');
|
||||
if ( input_type == 'checkbox' ) {
|
||||
own_condition = ( value == '1' ) ? condition_field.is(':checked') : ! condition_field.is(':checked');
|
||||
} else {
|
||||
own_condition = ( condition_field.val() == value );
|
||||
}
|
||||
} else if ( tagName == 'select' ) {
|
||||
own_condition = ( condition_field.val() == value );
|
||||
}
|
||||
} else if ( tagName == 'select' ) {
|
||||
own_condition = ( condition_field.val() == value );
|
||||
}
|
||||
} else if ( condition === '!=' ) {
|
||||
var tagName = condition_field.prop("tagName").toLowerCase();
|
||||
|
||||
if ( tagName == 'input' ) {
|
||||
var input_type = condition_field.attr('type');
|
||||
if ( input_type == 'checkbox' ) {
|
||||
own_condition = ( value == '1' ) ? ! condition_field.is(':checked') : condition_field.is(':checked');
|
||||
} else {
|
||||
return ( own_condition && parent_condition );
|
||||
}
|
||||
|
||||
} else if ( condition === '!=' ) {
|
||||
if ( conditional[0].indexOf( '||' ) !== -1 ) {
|
||||
var selectors = conditional[0].split('||');
|
||||
var complete_condition = false;
|
||||
|
||||
jQuery.each( selectors, function(i) {
|
||||
var cond_field = jQuery( '#' + prefix + '_' + selectors[i] );
|
||||
|
||||
own_condition = false;
|
||||
parent_condition = true;
|
||||
if ( typeof cond_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) {
|
||||
parent_condition = check_condition( cond_field.parents('.um-forms-line') );
|
||||
}
|
||||
|
||||
var tagName = cond_field.prop("tagName").toLowerCase();
|
||||
|
||||
if ( tagName === 'input' ) {
|
||||
var input_type = cond_field.attr('type');
|
||||
if ( input_type === 'checkbox' ) {
|
||||
own_condition = ( value == '1' ) ? ! cond_field.is(':checked') : cond_field.is(':checked');
|
||||
} else {
|
||||
own_condition = ( cond_field.val() != value );
|
||||
}
|
||||
} else if ( tagName === 'select' ) {
|
||||
own_condition = ( cond_field.val() != value );
|
||||
}
|
||||
|
||||
if ( own_condition && parent_condition ) {
|
||||
complete_condition = true;
|
||||
}
|
||||
});
|
||||
|
||||
return complete_condition;
|
||||
} else {
|
||||
var tagName = condition_field.prop("tagName").toLowerCase();
|
||||
|
||||
if ( tagName == 'input' ) {
|
||||
var input_type = condition_field.attr('type');
|
||||
if ( input_type == 'checkbox' ) {
|
||||
own_condition = ( value == '1' ) ? ! condition_field.is(':checked') : condition_field.is(':checked');
|
||||
} else {
|
||||
own_condition = ( condition_field.val() != value );
|
||||
}
|
||||
} else if ( tagName == 'select' ) {
|
||||
own_condition = ( condition_field.val() != value );
|
||||
}
|
||||
} else if ( tagName == 'select' ) {
|
||||
own_condition = ( condition_field.val() != value );
|
||||
|
||||
return ( own_condition && parent_condition );
|
||||
}
|
||||
|
||||
} else if ( condition === '~' ) {
|
||||
|
||||
var field_id = form_line.find( form_line.data('field_type') ).data('field_id');
|
||||
@@ -265,6 +347,11 @@ jQuery(document).ready( function() {
|
||||
visible_options.push( condition_field.data( 'fill_' + field_id ) );
|
||||
}
|
||||
}
|
||||
} else if ( tagName == 'select' ) {
|
||||
if ( ! value && condition_field.val() ) {
|
||||
visible_options = visible_options.concat( condition_field.val() );
|
||||
visible_options = visible_options.filter( um_distinct );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -285,9 +372,11 @@ jQuery(document).ready( function() {
|
||||
lines_field.val( null );
|
||||
lines_field.find( 'option' ).attr( 'selected', false ).prop( 'selected', false );
|
||||
}
|
||||
|
||||
return ( own_condition && parent_condition );
|
||||
}
|
||||
|
||||
return ( own_condition && parent_condition );
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -411,6 +411,54 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render text field
|
||||
*
|
||||
* @param $field_data
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
function render_number( $field_data ) {
|
||||
|
||||
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 ) . '" ';
|
||||
|
||||
$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 ' . esc_attr( $class ) . '" ';
|
||||
|
||||
$data = array(
|
||||
'field_id' => $field_data['id']
|
||||
);
|
||||
|
||||
if ( ! empty( $field_data['attr'] ) && is_array( $field_data['attr'] ) ){
|
||||
$data = array_merge( $data, $field_data['attr'] );
|
||||
}
|
||||
|
||||
$data_attr = '';
|
||||
foreach ( $data as $key => $value ) {
|
||||
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
|
||||
$placeholder_attr = ! empty( $field_data['placeholder'] ) ? ' placeholder="' . esc_attr( $field_data['placeholder'] ) . '"' : '';
|
||||
|
||||
$name = $field_data['id'];
|
||||
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
||||
$name_attr = ' name="' . $name . '" ';
|
||||
|
||||
$value = $this->get_field_value( $field_data );
|
||||
$value_attr = ' value="' . esc_attr( $value ) . '" ';
|
||||
|
||||
$html = "<input type=\"number\" $id_attr $class_attr $name_attr $data_attr $value_attr $placeholder_attr />";
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $field_data
|
||||
*
|
||||
@@ -908,8 +956,24 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
|
||||
$for_attr = ' for="' . esc_attr( $id . '_' . $k ) . '" ';
|
||||
$name_attr = ' name="' . $name . '[' . $k . ']" ';
|
||||
|
||||
$data = array(
|
||||
'field_id' => $field_data['id'] . '_' . $k,
|
||||
);
|
||||
|
||||
if ( ! empty( $field_data['data'] ) ) {
|
||||
$data = array_merge( $data, $field_data['data'] );
|
||||
}
|
||||
|
||||
$data_attr = '';
|
||||
foreach ( $data as $key => $value ) {
|
||||
if ( $value == 'checkbox_key' ) {
|
||||
$value = $k;
|
||||
}
|
||||
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
|
||||
$html .= "<label $for_attr>
|
||||
<input type=\"checkbox\" " . checked( in_array( $k, $values ), true, false ) . "$id_attr $name_attr value=\"1\" $class_attr>
|
||||
<input type=\"checkbox\" " . checked( in_array( $k, $values ), true, false ) . "$id_attr $name_attr $data_attr value=\"1\" $class_attr>
|
||||
<span>$title</span>
|
||||
</label>";
|
||||
}
|
||||
|
||||
@@ -776,6 +776,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
*/
|
||||
function add_metabox_directory() {
|
||||
add_meta_box( 'um-admin-form-general', __( 'General Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
||||
add_meta_box( 'um-admin-form-sorting', __( 'Sorting', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
||||
add_meta_box( 'um-admin-form-profile', __( 'Profile Card', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
||||
add_meta_box( 'um-admin-form-search', __( 'Search Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
||||
add_meta_box( 'um-admin-form-pagination', __( 'Results & Pagination', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
||||
@@ -1014,26 +1015,31 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
*
|
||||
* @param $post_id
|
||||
* @param $post
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function save_metabox_directory( $post_id, $post ) {
|
||||
global $wpdb;
|
||||
|
||||
// validate nonce
|
||||
if ( !isset( $_POST['um_admin_save_metabox_directory_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_directory_nonce'], basename( __FILE__ ) ) ) return $post_id;
|
||||
if ( ! isset( $_POST['um_admin_save_metabox_directory_nonce'] ) || ! wp_verify_nonce( $_POST['um_admin_save_metabox_directory_nonce'], basename( __FILE__ ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// validate post type
|
||||
if ( $post->post_type != 'um_directory' ) return $post_id;
|
||||
if ( $post->post_type != 'um_directory' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// validate user
|
||||
$post_type = get_post_type_object( $post->post_type );
|
||||
if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) return $post_id;
|
||||
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$where = array( 'ID' => $post_id );
|
||||
|
||||
if ( empty( $_POST['post_title'] ) )
|
||||
if ( empty( $_POST['post_title'] ) ) {
|
||||
$_POST['post_title'] = 'Directory #'.$post_id;
|
||||
}
|
||||
|
||||
$wpdb->update( $wpdb->posts, array( 'post_title' => $_POST['post_title'] ), $where );
|
||||
|
||||
@@ -1043,30 +1049,43 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
delete_post_meta( $post_id, '_um_reveal_fields' );
|
||||
delete_post_meta( $post_id, '_um_search_fields' );
|
||||
delete_post_meta( $post_id, '_um_roles_can_search' );
|
||||
delete_post_meta( $post_id, '_um_roles_can_filter' );
|
||||
delete_post_meta( $post_id, '_um_show_these_users' );
|
||||
|
||||
//save metadata
|
||||
foreach ( $_POST['um_metadata'] as $k => $v ) {
|
||||
|
||||
if ( $k == '_um_show_these_users' && trim( $_POST['um_metadata'][ $k ] ) ) {
|
||||
$v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
|
||||
}
|
||||
|
||||
if ( strstr( $k, '_um_' ) ) {
|
||||
|
||||
if ( $k === '_um_is_default' ) {
|
||||
|
||||
$mode = UM()->query()->get_attr( 'mode', $post_id );
|
||||
|
||||
if ( ! empty( $mode ) ) {
|
||||
|
||||
$posts = $wpdb->get_col(
|
||||
"SELECT post_id
|
||||
FROM {$wpdb->postmeta}
|
||||
WHERE meta_key = '_um_mode' AND
|
||||
meta_value = 'directory'"
|
||||
);
|
||||
|
||||
foreach ( $posts as $p_id ) {
|
||||
delete_post_meta( $p_id, '_um_is_default' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$v = apply_filters( 'um_member_directory_meta_value_before_save', $v, $k, $post_id );
|
||||
|
||||
update_post_meta( $post_id, $k, $v );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
global $post_id;
|
||||
|
||||
$meta = get_post_custom( get_the_ID() );
|
||||
foreach( $meta as $k => $v ) {
|
||||
@@ -8,67 +9,63 @@ foreach( $meta as $k => $v ) {
|
||||
}
|
||||
}
|
||||
|
||||
$roles_array = array();
|
||||
|
||||
foreach ( UM()->roles()->get_roles() as $key => $value ) {
|
||||
$_um_roles = UM()->query()->get_meta_value( '_um_roles', $key );
|
||||
if ( ! empty( $_um_roles ) )
|
||||
$roles_array[] = $_um_roles;
|
||||
}
|
||||
$_um_roles_value = get_post_meta( $post_id, '_um_roles', true );
|
||||
$_um_roles_value = empty( $_um_roles_value ) ? array() : $_um_roles_value;
|
||||
|
||||
$show_these_users = get_post_meta( get_the_ID(), '_um_show_these_users', true );
|
||||
if ( $show_these_users ) {
|
||||
$show_these_users = implode( "\n", str_replace( "\r", "", $show_these_users ) );
|
||||
} ?>
|
||||
}
|
||||
|
||||
$_um_view_types_value = get_post_meta( $post_id, '_um_view_types', true );
|
||||
$_um_view_types_value = empty( $_um_view_types_value ) ? array( 'grid' ) : $_um_view_types_value;
|
||||
|
||||
$view_types_options = array_map( function( $item ) {
|
||||
return $item['title'];
|
||||
}, UM()->member_directory()->view_types );
|
||||
|
||||
$conditional = array();
|
||||
foreach ( $view_types_options as $key => $value ) {
|
||||
$conditional[] = '_um_view_types_' . $key;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
|
||||
<?php
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_admin_directory_sort_users_select
|
||||
* @description Extend Sort Types for Member Directory
|
||||
* @input_vars
|
||||
* [{"var":"$sort_types","type":"array","desc":"Sort Types"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
|
||||
* function my_directory_sort_users_select( $sort_types ) {
|
||||
* // your code here
|
||||
* return $sort_types;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$sort_options = apply_filters( 'um_admin_directory_sort_users_select', array(
|
||||
'user_registered_desc' => __( 'New users first', 'ultimate-member' ),
|
||||
'user_registered_asc' => __( 'Old users first', 'ultimate-member' ),
|
||||
'last_login' => __( 'Last login', 'ultimate-member' ),
|
||||
'display_name' => __( 'Display Name', 'ultimate-member' ),
|
||||
'first_name' => __( 'First Name', 'ultimate-member' ),
|
||||
'last_name' => __( 'Last Name', 'ultimate-member' ),
|
||||
'random' => __( 'Random', 'ultimate-member' ),
|
||||
'other' => __( 'Other (custom field)', 'ultimate-member' ),
|
||||
) );
|
||||
|
||||
$fields = array(
|
||||
<?php $fields = array(
|
||||
array(
|
||||
'id' => '_um_mode',
|
||||
'type' => 'hidden',
|
||||
'value' => 'directory',
|
||||
'id' => '_um_mode',
|
||||
'type' => 'hidden',
|
||||
'value' => 'directory',
|
||||
),
|
||||
array(
|
||||
'id' => '_um_view_types',
|
||||
'type' => 'multi_checkbox',
|
||||
'label' => __( 'View type(s)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'View type a specific parameter in the directory', 'ultimate-member' ),
|
||||
'options' => $view_types_options,
|
||||
'columns' => 3,
|
||||
'value' => $_um_view_types_value,
|
||||
'data' => array( 'fill__um_default_view' => 'checkbox_key' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_default_view',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Default view type', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Default directory view type', 'ultimate-member' ),
|
||||
'options' => $view_types_options,
|
||||
'value' => UM()->query()->get_meta_value( '_um_default_view', null, '' ),
|
||||
'conditional' => array( implode( '|', $conditional ), '~', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_roles',
|
||||
'type' => 'select',
|
||||
'type' => 'multi_checkbox',
|
||||
'label' => __( 'User Roles to Display', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If you do not want to show all members, select only user roles to appear in this directory', 'ultimate-member' ),
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'multi' => true,
|
||||
'value' => $roles_array,
|
||||
'columns' => 3,
|
||||
'value' => $_um_roles_value,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_has_profile_photo',
|
||||
@@ -83,22 +80,6 @@ if ( $show_these_users ) {
|
||||
'label' => __( 'Only show members who have uploaded a cover photo', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_has_cover_photo' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_sortby',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Sort users by', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Sort users by a specific parameter in the directory', 'ultimate-member' ),
|
||||
'options' => $sort_options,
|
||||
'value' => UM()->query()->get_meta_value( '_um_sortby' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_sortby_custom',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Meta key', 'ultimate-member' ),
|
||||
'tooltip' => __( 'To sort by a custom field, enter the meta key of field here', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_sortby_custom', null, 'na' ),
|
||||
'conditional' => array( '_um_sortby', '=', 'other' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_these_users',
|
||||
'type' => 'textarea',
|
||||
|
||||
@@ -3,33 +3,62 @@
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
<?php UM()->admin_forms( array(
|
||||
'class' => 'um-member-directory-pagination um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => array(
|
||||
'class' => 'um-member-directory-pagination um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_profiles_per_page',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Number of profiles per page', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Number of profiles to appear on page for standard users', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profiles_per_page', null, 12 ),
|
||||
'size' => 'small'
|
||||
'id' => '_um_must_search',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show results only after search/filtration', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, member results will only appear after search/filter is performed', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_must_search' ),
|
||||
'conditional' => array( '_um_search||_um_filters', '=', 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profiles_per_page_mobile',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Number of profiles per page (for Mobiles & Tablets)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Number of profiles to appear on page for mobile users', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profiles_per_page_mobile', null, 8 ),
|
||||
'size' => 'small'
|
||||
'id' => '_um_max_users',
|
||||
'type' => 'number',
|
||||
'label' => __( 'Maximum number of profiles', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Use this setting to control the maximum number of profiles to appear in this directory. Leave blank to disable this limit', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_max_users', null, 'na' ),
|
||||
'size' => 'small'
|
||||
),
|
||||
array(
|
||||
'id' => '_um_max_users',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Maximum number of profiles', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Use this setting to control the maximum number of profiles to appear in this directory. Leave blank to disable this limit', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_max_users', null, 'na' ),
|
||||
'size' => 'small'
|
||||
)
|
||||
'id' => '_um_profiles_per_page',
|
||||
'type' => 'number',
|
||||
'label' => __( 'Number of profiles per page', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Number of profiles to appear on page for standard users', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profiles_per_page', null, 12 ),
|
||||
'size' => 'small'
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profiles_per_page_mobile',
|
||||
'type' => 'number',
|
||||
'label' => __( 'Number of profiles per page (for Mobiles & Tablets)', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Number of profiles to appear on page for mobile users', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profiles_per_page_mobile', null, 8 ),
|
||||
'size' => 'small'
|
||||
),
|
||||
array(
|
||||
'id' => '_um_directory_header',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Results Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the search result text . e.g. Found 3,000 Members. Leave this blank to not show result text', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_directory_header', null, __( '{total_users} Members', 'ultimate-member' ) ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_directory_header_single',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Single Result Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Same as above but in case of 1 user found only', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_directory_header_single', null, __( '{total_users} Member', 'ultimate-member' ) ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_directory_no_users',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Custom text if no users were found', 'ultimate-member' ),
|
||||
'tooltip' => __( 'This is the text that is displayed if no users are found during a search', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_directory_no_users', null, __( 'We are sorry. We cannot find any users who match your search criteria.', 'ultimate-member' ) ),
|
||||
),
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
|
||||
|
||||
@@ -12,77 +12,103 @@
|
||||
$_um_tagline_fields = get_post_meta( $post_id, '_um_tagline_fields', true );
|
||||
$_um_reveal_fields = get_post_meta( $post_id, '_um_reveal_fields', true );
|
||||
|
||||
|
||||
$fields = array(
|
||||
array(
|
||||
'id' => '_um_profile_photo',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Profile Photo', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_photo', null, 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_cover_photos',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Cover Photo', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, the users cover photo will appear in the directory', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_cover_photos', null, 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_name',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show display name', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_name', null, 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_tagline',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show tagline below profile name', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_tagline' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_tagline_fields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Choose field(s) to display in tagline', 'ultimate-member' ),
|
||||
'value' => $_um_tagline_fields,
|
||||
'conditional' => array( '_um_show_tagline', '=', 1 ),
|
||||
'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
|
||||
'options' => $user_fields,
|
||||
'show_default_number' => 1,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_userinfo',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show extra user information below tagline?', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_userinfo' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_reveal_fields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Choose field(s) to display in reveal section', 'ultimate-member' ),
|
||||
'value' => $_um_reveal_fields,
|
||||
'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
|
||||
'conditional' => array( '_um_show_userinfo', '=', 1 ),
|
||||
'options' => $user_fields,
|
||||
'show_default_number' => 1,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_social',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show social connect icons', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_social' ),
|
||||
'conditional' => array( '_um_show_userinfo', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_userinfo_animate',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable reveal section transition by default', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_userinfo_animate' ),
|
||||
'conditional' => array( '_um_show_userinfo', '=', 1 )
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_admin_extend_directory_options_general
|
||||
* @description Extend Directory options fields
|
||||
* @input_vars
|
||||
* [{"var":"$fields","type":"array","desc":"Directory options fields"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
|
||||
* function my_directory_sort_users_select( $sort_types ) {
|
||||
* // your code here
|
||||
* return $sort_types;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$fields = apply_filters( 'um_admin_extend_directory_options_profile', $fields );
|
||||
|
||||
UM()->admin_forms( array(
|
||||
'class' => 'um-member-directory-profile um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_profile_photo',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Profile Photo', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_profile_photo', null, 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_cover_photos',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Cover Photo', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, the users cover photo will appear in the directory', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_cover_photos', null, 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_name',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show display name', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_name', null, 1 ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_tagline',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show tagline below profile name', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_tagline' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_tagline_fields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Choose field(s) to display in tagline', 'ultimate-member' ),
|
||||
'value' => $_um_tagline_fields,
|
||||
'conditional' => array( '_um_show_tagline', '=', 1 ),
|
||||
'add_text' => __( 'Add New Custom Field','ultimate-member' ),
|
||||
'options' => $user_fields,
|
||||
'show_default_number' => 1,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_userinfo',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show extra user information below tagline?', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_userinfo' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_userinfo_animate',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable reveal section transition by default', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_userinfo_animate' ),
|
||||
'conditional' => array( '_um_show_userinfo', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_reveal_fields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Choose field(s) to display in reveal section', 'ultimate-member' ),
|
||||
'value' => $_um_reveal_fields,
|
||||
'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
|
||||
'conditional' => array( '_um_show_userinfo', '=', 1 ),
|
||||
'options' => $user_fields,
|
||||
'show_default_number' => 1,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_show_social',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show social connect icons', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_show_social' ),
|
||||
'conditional' => array( '_um_show_userinfo', '=', 1 )
|
||||
)
|
||||
)
|
||||
'class' => 'um-member-directory-profile um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => $fields,
|
||||
) )->render_form(); ?>
|
||||
|
||||
|
||||
<div class="um-admin-clear"></div>
|
||||
</div>
|
||||
@@ -1,14 +1,35 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
global $post_id; ?>
|
||||
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
<?php
|
||||
$can_search_array = array();
|
||||
foreach ( UM()->roles()->get_roles() as $key => $value ) {
|
||||
$_um_roles_can_search = UM()->query()->get_meta_value( '_um_roles_can_search', $key );
|
||||
if ( ! empty( $_um_roles_can_search ) )
|
||||
$can_search_array[] = $_um_roles_can_search;
|
||||
}
|
||||
/*$_um_roles_search_value = array();
|
||||
$_um_roles_search = get_post_meta( $post_id, '_um_roles_can_search', true );
|
||||
if ( ! empty( $_um_roles_search ) ) {
|
||||
foreach ( UM()->roles()->get_roles() as $key => $value ) {
|
||||
if ( in_array( $key, array_keys( $_um_roles_search ) ) ) {
|
||||
$_um_roles_search_value[] = $key;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
$_um_roles_search_value = get_post_meta( $post_id, '_um_roles_can_search', true );
|
||||
$_um_roles_search_value = empty( $_um_roles_search_value ) ? array() : $_um_roles_search_value;
|
||||
|
||||
/*$_um_roles_filter_value = array();
|
||||
$_um_roles_filter = get_post_meta( $post_id, '_um_roles_can_filter', true );
|
||||
if ( ! empty( $_um_roles_filter ) ) {
|
||||
foreach ( UM()->roles()->get_roles() as $key => $value ) {
|
||||
if ( in_array( $key, array_keys( $_um_roles_filter ) ) ) {
|
||||
$_um_roles_filter_value[] = $key;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
$_um_roles_filter_value = get_post_meta( $post_id, '_um_roles_can_filter', true );
|
||||
$_um_roles_filter_value = empty( $_um_roles_filter_value ) ? array() : $_um_roles_filter_value;
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
@@ -36,84 +57,68 @@
|
||||
$searchable_fields = $searchable_fields + $custom_search;
|
||||
$user_fields = array();
|
||||
foreach ( $searchable_fields as $key => $arr ) {
|
||||
$user_fields[$key] = isset( $arr['title'] ) ? $arr['title'] : '';
|
||||
$user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : '';
|
||||
}
|
||||
|
||||
$post_id = get_the_ID();
|
||||
$_um_search_fields = get_post_meta( $post_id, '_um_search_fields', true );
|
||||
//$post_id = get_the_ID();
|
||||
$_um_search_fields = get_post_meta( $post_id, '_um_search_fields', true );
|
||||
|
||||
UM()->admin_forms( array(
|
||||
'class' => 'um-member-directory-search um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => array(
|
||||
'class' => 'um-member-directory-search um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_search',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Search feature', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, users will be able to search members in this directory', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_search' ),
|
||||
'id' => '_um_search',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Search feature', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, users will be able to search members in this directory', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_search' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_must_search',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Show results only after search', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, member results will only appear after search is performed', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_must_search' ),
|
||||
'id' => '_um_roles_can_search',
|
||||
'type' => 'multi_checkbox',
|
||||
'label' => __( 'User Roles that can use search', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If you want to allow specific user roles to be able to search only', 'ultimate-member' ),
|
||||
'value' => $_um_roles_search_value,
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'columns' => 3,
|
||||
'conditional' => array( '_um_search', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_roles_can_search',
|
||||
'type' => 'select',
|
||||
'multi' => true,
|
||||
'label' => __( 'User Roles that can use search', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If you want to allow specific user roles to be able to search only', 'ultimate-member' ),
|
||||
'value' => $can_search_array,
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'conditional' => array( '_um_search', '=', 1 )
|
||||
'id' => '_um_filters',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Filters feature', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If turned on, users will be able to filter members in this directory', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_filters' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_search_fields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Choose field(s) to enable in search', 'ultimate-member' ),
|
||||
'value' => $_um_search_fields,
|
||||
'conditional' => array( '_um_search', '=', 1 ),
|
||||
'options' => $user_fields,
|
||||
'add_text' => __( 'Add New Custom Field','ultimate-member' ),
|
||||
'show_default_number' => 1,
|
||||
'id' => '_um_roles_can_filter',
|
||||
'type' => 'multi_checkbox',
|
||||
'label' => __( 'User Roles that can use filters', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If you want to allow specific user roles to be able to filter only', 'ultimate-member' ),
|
||||
'value' => $_um_roles_filter_value,
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'columns' => 3,
|
||||
'conditional' => array( '_um_filters', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_search_filters',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Additional search filters', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Additional search filters like URL parameters' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_search_filters', null, '' ),
|
||||
'conditional' => array( '_um_search', '=', 1 ),
|
||||
'placeholder' => 'field1=val1&field2=val2'
|
||||
'id' => '_um_search_fields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Choose filter(s) meta to enable', 'ultimate-member' ),
|
||||
'value' => $_um_search_fields,
|
||||
'conditional' => array( '_um_filters', '=', 1 ),
|
||||
'options' => UM()->member_directory()->filter_fields,
|
||||
'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
|
||||
'show_default_number' => 1,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_directory_header',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Results Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Customize the search result text . e.g. Found 3,000 Members. Leave this blank to not show result text', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_directory_header', null, __('{total_users} Members','ultimate-member') ),
|
||||
'conditional' => array( '_um_search', '=', 1 )
|
||||
'id' => '_um_search_filters',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Default filters', 'ultimate-member' ),
|
||||
'tooltip' => __( 'You can set default filters like URL parameters', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_search_filters', null, 'na' ),
|
||||
'placeholder' => 'field1=val1&field2=val2'
|
||||
),
|
||||
array(
|
||||
'id' => '_um_directory_header_single',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Single Result Text', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Same as above but in case of 1 user found only', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_directory_header_single', null, __('{total_users} Member','ultimate-member') ),
|
||||
'conditional' => array( '_um_search', '=', 1 )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_directory_no_users',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Custom text if no users were found', 'ultimate-member' ),
|
||||
'tooltip' => __( 'This is the text that is displayed if no users are found during a search', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value('_um_directory_no_users', null, __('We are sorry. We cannot find any users who match your search criteria.','ultimate-member') ),
|
||||
'conditional' => array( '_um_search', '=', 1 )
|
||||
)
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
global $post_id;
|
||||
|
||||
|
||||
$_um_sorting_fields = get_post_meta( $post_id, '_um_sorting_fields', true );
|
||||
$_um_sorting_fields = empty( $_um_sorting_fields ) ? array() : $_um_sorting_fields; ?>
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
|
||||
<?php $fields = array(
|
||||
array(
|
||||
'id' => '_um_sortby',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Default sort users by', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Default sorting users by a specific parameter in the directory', 'ultimate-member' ),
|
||||
'options' => UM()->member_directory()->default_sorting,
|
||||
'value' => UM()->query()->get_meta_value( '_um_sortby' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_sortby_custom',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Meta key', 'ultimate-member' ),
|
||||
'tooltip' => __( 'To sort by a custom field, enter the meta key of field here', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_sortby_custom', null, 'na' ),
|
||||
'conditional' => array( '_um_sortby', '=', 'other' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_enable_sorting',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable custom sorting', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Whether to provide an ability to change the sorting on the directory page', 'ultimate-member' ),
|
||||
'value' => UM()->query()->get_meta_value( '_um_enable_sorting' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_sorting_fields',
|
||||
'type' => 'multi_selects',
|
||||
'label' => __( 'Choose field(s) to enable in sorting', 'ultimate-member' ),
|
||||
'value' => $_um_sorting_fields,
|
||||
'options' => UM()->member_directory()->sort_fields,
|
||||
'add_text' => __( 'Add New Field', 'ultimate-member' ),
|
||||
'show_default_number' => 1,
|
||||
'conditional' => array( '_um_enable_sorting', '=', 1 )
|
||||
)
|
||||
);
|
||||
|
||||
UM()->admin_forms( array(
|
||||
'class' => 'um-member-directory-sorting um-half-column',
|
||||
'prefix_id' => 'um_metadata',
|
||||
'fields' => $fields
|
||||
) )->render_form(); ?>
|
||||
|
||||
<div class="um-admin-clear"></div>
|
||||
</div>
|
||||
@@ -563,6 +563,7 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
$this->mobile();
|
||||
$this->external_integrations();
|
||||
$this->gdpr();
|
||||
$this->member_directory();
|
||||
|
||||
//if multisite networks active
|
||||
if ( is_multisite() ) {
|
||||
@@ -572,6 +573,19 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @return um\core\Member_Directory()
|
||||
*/
|
||||
function member_directory() {
|
||||
if ( empty( $this->classes['member_directory'] ) ) {
|
||||
$this->classes['member_directory'] = new um\core\Member_Directory();
|
||||
}
|
||||
return $this->classes['member_directory'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get extension API
|
||||
*
|
||||
|
||||
@@ -135,7 +135,7 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
||||
) );
|
||||
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_members', $this->js_baseurl . 'um-members' . $this->suffix . '.js', array( 'jquery', 'wp-util', 'jquery-ui-slider' ), 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 );
|
||||
|
||||
@@ -166,7 +166,10 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
||||
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_ui', $this->css_baseurl . 'jquery-ui.css', array(), ultimatemember_version );
|
||||
|
||||
wp_register_style( 'um_members', $this->css_baseurl . 'um-members.css', array( 'um_ui' ), 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 );
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
namespace um\core;
|
||||
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* Class Member_Directory
|
||||
* @package um\core
|
||||
*/
|
||||
class Member_Directory {
|
||||
|
||||
|
||||
/**
|
||||
* Member Directory Views
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $view_types = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
var $sort_fields = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
var $default_sorting = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
var $filter_fields = array();
|
||||
|
||||
|
||||
|
||||
var $filter_supported_fields = array();
|
||||
|
||||
|
||||
var $filter_types = array(
|
||||
'select',
|
||||
'slider',
|
||||
'datepicker',
|
||||
'timepicker',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Member_Directory constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
add_filter( 'plugins_loaded', array( &$this, 'init_variables' ), 99999 );
|
||||
add_filter( 'um_member_directory_meta_value_before_save', array( &$this, 'before_save_data' ), 10, 3 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $key
|
||||
* @param $post_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function before_save_data( $value, $key, $post_id ) {
|
||||
|
||||
$post = get_post( $post_id );
|
||||
|
||||
if ( $post->post_type == 'um_directory' ) {
|
||||
|
||||
if ( ! empty( $value ) && in_array( $key, array( '_um_view_types', '_um_roles', '_um_roles_can_search', '_um_roles_can_filter' ) ) ) {
|
||||
$value = array_keys( $value );
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function init_variables() {
|
||||
|
||||
// Types
|
||||
$this->view_types = apply_filters( 'um_member_directory_views', array(
|
||||
'grid' => array( 'title' => __( 'Grid', 'ultimate-member' ), 'icon' => 'um-faicon-th' ),
|
||||
'list' => array( 'title' => __( 'List', 'ultimate-member' ), 'icon' => 'um-faicon-list' ),
|
||||
) );
|
||||
|
||||
// Sort
|
||||
$this->sort_fields = apply_filters( 'um_members_directory_sort_fields', array(
|
||||
'user_registered_desc' => __( 'New Users First', 'ultimate-member' ),
|
||||
'user_registered_asc' => __( 'Old Users First', 'ultimate-member' ),
|
||||
'username' => __( 'Username', 'ultimate-member' ),
|
||||
'first_name' => __( 'First Name', 'ultimate-member' ),
|
||||
'last_name' => __( 'Last Name', 'ultimate-member' ),
|
||||
'display_name' => __( 'Display Name', 'ultimate-member' ),
|
||||
'last_login' => __( 'Last Login', 'ultimate-member' ),
|
||||
) );
|
||||
|
||||
asort( $this->sort_fields );
|
||||
|
||||
$this->default_sorting = apply_filters( 'um_members_directory_default_sort', array_merge( $this->sort_fields, array(
|
||||
'random' => __( 'Random', 'ultimate-member' ),
|
||||
'other' => __( 'Other (Custom Field)', 'ultimate-member' ),
|
||||
) ) );
|
||||
|
||||
asort( $this->default_sorting );
|
||||
|
||||
|
||||
|
||||
// <!-- <option value="description">Biography</option> to Search-->
|
||||
//<!-- <option value="user_email">E-mail Address</option> to Search-->
|
||||
//<!-- <option value="first_name">First Name</option> to Search-->
|
||||
//<!-- <option value="last_name">Last Name</option> to Search-->
|
||||
//<!-- <option value="mobile_number">Mobile Number</option> to Search-->
|
||||
//<!-- <option value="nickname">Nickname</option> to Search-->
|
||||
//<!-- <option value="phone_number">Phone Number</option> to Search-->
|
||||
//<!-- <option value="secondary_user_email">Secondary E-mail Address</option> to Search-->
|
||||
//<!-- <option value="user_login">Username</option> to Search-->
|
||||
//<!-- <option value="username">Username or E-mail</option> - username to Search-->
|
||||
//<!-- <option value="gm">gm</option> - google maps field to Search-->
|
||||
//<!-- <option value="numberr">number</option> - number field to Search-->
|
||||
//<!-- <option value="scm">scm</option> - Soundcloud field to Search-->
|
||||
//<!-- <option value="test">test</option> - text box field to Search-->
|
||||
//<!-- <option value="textareaa">textareaa</option> - textarea field to Search-->
|
||||
//<!-- <option value="vimeov">vimeov</option> - Vimeo field to Search-->
|
||||
//<!-- <option value="youtubev">youtubev</option> - Youtube field to Search-->
|
||||
//<!-- URL fields to Search-->
|
||||
//<!-- Password skip-->
|
||||
//<!-- File, Image Upload maybe search by file,image name-->
|
||||
//<!---->
|
||||
//<!---->
|
||||
//<!-- DatePicker, TimePicker to Filter-->
|
||||
//<!-- Rating field to Filter-->
|
||||
//<!-- needs to be added 'birth_date' - Age to Filter-->
|
||||
//<!-- <option value="checkboxx">checkbox</option> - checkbox field to Filter-->
|
||||
//<!-- <option value="drop">drop</option> - select field to Filter-->
|
||||
//<!-- <option value="radi">radi</option> - radio field to Filter-->
|
||||
//<!-- <option value="multidrop">multidrop</option> - multiselect field to Filter-->
|
||||
//<!-- <option value="role_radio">Roles (Radio)</option> - roles merge to Filter-->
|
||||
//<!-- <option value="user_registered">Registration Date</option> - to Filter-->
|
||||
//<!-- <option value="gender">Gender</option> to Filter-->
|
||||
//<!-- <option value="languages">Languages</option> to Filter-->
|
||||
//<!-- <option value="_um_last_login">Last Login</option> to Filter-->
|
||||
//<!-- <option value="country">Country</option> to Filter-->
|
||||
//<!---->
|
||||
//<!-- So there are next filters:-->
|
||||
//<!---->
|
||||
//<!-- Predefined Fields:-->
|
||||
//<!-- Country, Gender, Age(Birth Date field), Last Login, User Registered-->
|
||||
//<!-- Languages, Roles (merge dropdown+radio)-->
|
||||
//<!---->
|
||||
//<!-- Custom Fields:-->
|
||||
//<!-- all TimePicker, Datepicker,-->
|
||||
//<!-- Rating field(by stars), Checkbox, Radio, Select, Multi-select custom fields-->
|
||||
|
||||
|
||||
// Filters
|
||||
$this->filter_fields = array(
|
||||
'country' => __( 'Country', 'ultimate-member' ),
|
||||
'gender' => __( 'Gender', 'ultimate-member' ),
|
||||
'languages' => __( 'Languages', 'ultimate-member' ),
|
||||
'role' => __( 'Roles', 'ultimate-member' ),
|
||||
'birth_date' => __( 'Age', 'ultimate-member' ),
|
||||
'last_login' => __( 'Last Login', 'ultimate-member' ),
|
||||
'user_registered' => __( 'User Registered', 'ultimate-member' ),
|
||||
);
|
||||
|
||||
$this->filter_supported_fields = apply_filters( 'um_members_directory_custom_field_types_supported_filter', array( 'date', 'time', 'select', 'multiselect', 'radio', 'checkbox', 'rating' ) );
|
||||
|
||||
foreach ( UM()->builtin()->saved_fields as $key => $data ) {
|
||||
if ( isset( $data['type'] ) && in_array( $data['type'], $this->filter_supported_fields ) ) {
|
||||
if ( array_search( $data['title'], $this->filter_fields ) !== false ) {
|
||||
$data['title'] = $data['title'] . ' (' . $key . ')';
|
||||
}
|
||||
$this->filter_fields[ $key ] = $data['title'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->filter_fields = apply_filters( 'um_members_directory_filter_fields', $this->filter_fields );
|
||||
|
||||
ksort( $this->filter_fields );
|
||||
}
|
||||
}
|
||||
}
|
||||
+1158
-68
File diff suppressed because it is too large
Load Diff
@@ -261,6 +261,99 @@ function um_submit_form_errors_hook( $args ) {
|
||||
add_action( 'um_submit_form_errors_hook', 'um_submit_form_errors_hook', 10 );
|
||||
|
||||
|
||||
function um_check_conditions_on_submit( $condition, $fields, $args ) {
|
||||
$continue = false;
|
||||
|
||||
list( $visibility, $parent_key, $op, $parent_value ) = $condition;
|
||||
|
||||
if ( ! isset( $args[ $parent_key ] ) ) {
|
||||
$continue = true;
|
||||
return $continue;
|
||||
}
|
||||
|
||||
if ( ! empty( $fields[ $parent_key ]['conditions'] ) ) {
|
||||
foreach ( $fields[ $parent_key ]['conditions'] as $parent_condition ) {
|
||||
$continue = um_check_conditions_on_submit( $parent_condition, $fields, $args );
|
||||
if ( ! empty( $continue ) ) {
|
||||
return $continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$cond_value = ( $fields[ $parent_key ]['type'] == 'radio' ) ? $args[ $parent_key ][0] : $args[ $parent_key ];
|
||||
|
||||
if ( $visibility == 'hide' ) {
|
||||
if ( $op == 'empty' ) {
|
||||
if ( empty( $cond_value ) ) {
|
||||
$continue = true;
|
||||
}
|
||||
} elseif ( $op == 'not empty' ) {
|
||||
if ( ! empty( $cond_value ) ) {
|
||||
$continue = true;
|
||||
}
|
||||
} elseif ( $op == 'equals to' ) {
|
||||
if ( $cond_value == $parent_value ) {
|
||||
$continue = true;
|
||||
}
|
||||
} elseif ( $op == 'not equals' ) {
|
||||
if ( $cond_value != $parent_value ) {
|
||||
$continue = true;
|
||||
}
|
||||
} elseif ( $op == 'greater than' ) {
|
||||
if ( $cond_value > $parent_value ) {
|
||||
$continue = true;
|
||||
}
|
||||
} elseif ( $op == 'less than' ) {
|
||||
if ( $cond_value < $parent_value ) {
|
||||
$continue = true;
|
||||
}
|
||||
} elseif ( $op == 'contains' ) {
|
||||
if ( is_string( $cond_value ) && strstr( $cond_value, $parent_value ) ) {
|
||||
$continue = true;
|
||||
}
|
||||
if( is_array( $cond_value ) && in_array( $parent_value, $cond_value ) ) {
|
||||
$continue = true;
|
||||
}
|
||||
}
|
||||
} elseif ( $visibility == 'show' ) {
|
||||
if ( $op == 'empty' ) {
|
||||
if ( ! empty( $cond_value ) ) {
|
||||
$continue = true;
|
||||
}
|
||||
} elseif ( $op == 'not empty' ) {
|
||||
if ( empty( $cond_value ) ) {
|
||||
$continue = true;
|
||||
}
|
||||
} elseif ( $op == 'equals to' ) {
|
||||
if ( $cond_value != $parent_value ) {
|
||||
$continue = true;
|
||||
}
|
||||
} elseif ( $op == 'not equals' ) {
|
||||
if ( $cond_value == $parent_value ) {
|
||||
$continue = true;
|
||||
}
|
||||
} elseif ( $op == 'greater than' ) {
|
||||
if ( $cond_value <= $parent_value ) {
|
||||
$continue = true;
|
||||
}
|
||||
} elseif ( $op == 'less than' ) {
|
||||
if ( $cond_value >= $parent_value ) {
|
||||
$continue = true;
|
||||
}
|
||||
} elseif ( $op == 'contains' ) {
|
||||
if ( is_string( $cond_value ) && ! strstr( $cond_value, $parent_value ) ) {
|
||||
$continue = true;
|
||||
}
|
||||
if( is_array( $cond_value ) && !in_array( $parent_value, $cond_value ) ) {
|
||||
$continue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $continue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Error processing hook : standard
|
||||
*
|
||||
@@ -312,80 +405,9 @@ function um_submit_form_errors_hook_( $args ) {
|
||||
|
||||
if ( ! empty( $array['conditions'] ) ) {
|
||||
foreach ( $array['conditions'] as $condition ) {
|
||||
list( $visibility, $parent_key, $op, $parent_value ) = $condition;
|
||||
|
||||
if ( ! isset( $args[ $parent_key ] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$cond_value = ( $fields[ $parent_key ]['type'] == 'radio' ) ? $args[ $parent_key ][0] : $args[ $parent_key ];
|
||||
|
||||
if ( $visibility == 'hide' ) {
|
||||
if ( $op == 'empty' ) {
|
||||
if ( empty( $cond_value ) ) {
|
||||
continue 2;
|
||||
}
|
||||
} elseif ( $op == 'not empty' ) {
|
||||
if ( ! empty( $cond_value ) ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $op == 'equals to' ) {
|
||||
if ( $cond_value == $parent_value ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $op == 'not equals' ) {
|
||||
if ( $cond_value != $parent_value ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $op == 'greater than' ) {
|
||||
if ( $cond_value > $parent_value ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $op == 'less than' ) {
|
||||
if ( $cond_value < $parent_value ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $op == 'contains' ) {
|
||||
if ( is_string( $cond_value ) && strstr( $cond_value, $parent_value ) ) {
|
||||
continue;
|
||||
}
|
||||
if( is_array( $cond_value ) && in_array( $parent_value, $cond_value ) ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} elseif ( $visibility == 'show' ) {
|
||||
if ( $op == 'empty' ) {
|
||||
if ( ! empty( $cond_value ) ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $op == 'not empty' ) {
|
||||
if ( empty( $cond_value ) ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $op == 'equals to' ) {
|
||||
if ( $cond_value != $parent_value ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $op == 'not equals' ) {
|
||||
if ( $cond_value == $parent_value ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $op == 'greater than' ) {
|
||||
if ( $cond_value <= $parent_value ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $op == 'less than' ) {
|
||||
if ( $cond_value >= $parent_value ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $op == 'contains' ) {
|
||||
if ( is_string( $cond_value ) && ! strstr( $cond_value, $parent_value ) ) {
|
||||
continue;
|
||||
}
|
||||
if( is_array( $cond_value ) && !in_array( $parent_value, $cond_value ) ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$continue = um_check_conditions_on_submit( $condition, $fields, $args );
|
||||
if ( $continue === true ) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ function um_members_directory_search( $args ) {
|
||||
|
||||
}
|
||||
}
|
||||
add_action( 'um_members_directory_search', 'um_members_directory_search' );
|
||||
//add_action( 'um_members_directory_search', 'um_members_directory_search' );
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user