- fixed getting posts count at the Posts tab;

- UM metatable queries changed;
This commit is contained in:
nikitasinelnikov
2020-01-10 12:53:30 +02:00
parent 2496825590
commit 731506be2b
4 changed files with 24 additions and 11 deletions
@@ -121,6 +121,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
//member directory data
$metakeys[] = 'um_member_directory_data';
$metakeys[] = '_um_verified';
$metakeys[] = '_money_spent';
$metakeys[] = '_completed';
$metakeys[] = '_reviews_avg';
$skip_fields = UM()->builtin()->get_fields_without_metakey();
$skip_fields = array_merge( $skip_fields, UM()->member_directory()->core_search_fields );
@@ -531,7 +531,9 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_search ON umm_search.user_id = u.ID";
$this->where_clauses[] = $wpdb->prepare( "( umm_search.um_value = %s OR umm_search.um_value LIKE %s OR umm_search.um_value LIKE %s OR {$core_search})", $search_line, '%' . $search_line . '%', '%' . serialize( strval( $search_line ) ) . '%' );
$additional_search = apply_filters( 'um_member_directory_meta_general_search_meta_query', '', stripslashes( $_POST['search'] ) );
$this->where_clauses[] = $wpdb->prepare( "( umm_search.um_value = %s OR umm_search.um_value LIKE %s OR umm_search.um_value LIKE %s OR {$core_search}{$additional_search})", $search_line, '%' . $search_line . '%', '%' . serialize( strval( $search_line ) ) . '%' );
$this->is_search = true;
}
@@ -623,7 +625,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '_um_last_login' )";
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS NUMERIC ) {$order} ";
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS SIGNED ) {$order} ";
} elseif ( $sortby == 'last_first_name' ) {
@@ -703,7 +705,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
$sql_join = implode( ' ', $this->joins );
$sql_where = implode( ' AND ', $this->where_clauses );
$sql_where = ! empty( $sql_where ) ? ' AND ' . $sql_where : '';
$sql_where = ! empty( $sql_where ) ? 'AND ' . $sql_where : '';
global $wpdb;
+9 -7
View File
@@ -503,7 +503,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
$values_array = array_unique( $temp_values );
}
if ( empty( $values_array ) ) {
if ( $attrs['metakey'] != 'online_status' && empty( $values_array ) ) {
ob_get_clean();
return '';
}
@@ -550,12 +550,14 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
$attrs['options'] = UM()->fields()->get_options_from_callback( $attrs, $attrs['type'] );
}
if ( $attrs['metakey'] != 'role_select' && empty( $custom_dropdown ) ) {
$attrs['options'] = array_intersect( array_map( 'stripslashes', $attrs['options'] ), $values_array );
} elseif ( ! empty( $custom_dropdown ) ) {
$attrs['options'] = array_intersect_key( $attrs['options'], array_flip( $values_array ) );
} else {
$attrs['options'] = array_intersect_key( $attrs['options'], array_flip( $values_array ) );
if ( $attrs['metakey'] != 'online_status' ) {
if ( $attrs['metakey'] != 'role_select' && $attrs['metakey'] != 'mycred_rank' && empty( $custom_dropdown ) ) {
$attrs['options'] = array_intersect( array_map( 'stripslashes', $attrs['options'] ), $values_array );
} elseif ( ! empty( $custom_dropdown ) ) {
$attrs['options'] = array_intersect_key( $attrs['options'], array_flip( $values_array ) );
} else {
$attrs['options'] = array_intersect_key( $attrs['options'], array_flip( $values_array ) );
}
}
$attrs['options'] = apply_filters( 'um_member_directory_filter_select_options', $attrs['options'], $values_array, $attrs );
+7 -1
View File
@@ -60,7 +60,13 @@ if ( ! class_exists( 'um\core\User_posts' ) ) {
$args = apply_filters( 'um_profile_query_make_posts', $args );
$posts = get_posts( $args );
$count_posts = (int) count_user_posts( um_get_requested_user(), 'post', true );
$args['posts_per_page'] = -1;
$args['fields'] = 'ids';
unset( $args['offset'] );
$count_posts = get_posts( $args );
if ( ! empty( $count_posts ) && ! is_wp_error( $count_posts ) ) {
$count_posts = count( $count_posts );
}
UM()->get_template( 'profile/posts.php', '', array( 'posts' => $posts, 'count_posts' => $count_posts ), true );
}