PATH:
home
/
lab2454c
/
nfsin.com
/
wp-content
/
plugins
/
ultimate-member
/
includes
/
core
<?php namespace um\core; if ( ! defined( 'ABSPATH' ) ) exit; if ( ! class_exists( 'um\core\User_posts' ) ) { /** * Class User_posts * @package um\core */ class User_posts { /** * User_posts constructor. */ function __construct() { add_action( 'um_profile_content_posts', array( &$this, 'add_posts' ) ); add_action( 'um_profile_content_comments', array( &$this, 'add_comments' ) ); } /** * Add posts */ function add_posts() { $args = array( 'post_type' => 'post', 'posts_per_page' => 10, 'offset' => 0, 'author' => um_get_requested_user(), 'post_status' => array( 'publish' ), 'um_main_query' => true, 'suppress_filters' => false, ); /** * UM hook * * @type filter * @title um_profile_query_make_posts * @description Some changes of WP_Query Posts Tab * @input_vars * [{"var":"$query_posts","type":"WP_Query","desc":"UM Posts Tab query"}] * @change_log * ["Since: 2.0"] * @usage * <?php add_filter( 'um_profile_query_make_posts', 'function_name', 10, 1 ); ?> * @example * <?php * add_filter( 'um_profile_query_make_posts', 'my_profile_query_make_posts', 10, 1 ); * function my_profile_query_make_posts( $query_posts ) { * // your code here * return $query_posts; * } * ?> */ $args = apply_filters( 'um_profile_query_make_posts', $args ); $posts = get_posts( $args ); $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 ); } /** * Add comments */ function add_comments() { $comments = get_comments( array( 'number' => 10, 'offset' => 0, 'user_id' => um_user( 'ID' ), 'post_status' => array( 'publish' ), 'type__not_in' => apply_filters( 'um_excluded_comment_types', array('') ), ) ); $comments_count = get_comments( array( 'user_id' => um_user( 'ID' ), 'post_status' => array( 'publish' ), 'type__not_in' => apply_filters( 'um_excluded_comment_types', array('') ), 'count' => 1, ) ); UM()->get_template( 'profile/comments.php', '', array( 'comments' => $comments, 'count_comments' => $comments_count ), true ); } /** * Dynamic load of posts * */ function load_posts() { UM()->check_ajax_nonce(); $author = ! empty( $_POST['author'] ) ? absint( $_POST['author'] ) : get_current_user_id(); $page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 0; $args = array( 'post_type' => 'post', 'posts_per_page' => 10, 'offset' => ( $page - 1 ) * 10, 'author' => $author, 'post_status' => array( 'publish' ), 'um_main_query' => true, 'suppress_filters' => false, ); /** * UM hook * * @type filter * @title um_profile_query_make_posts * @description Some changes of WP_Query Posts Tab * @input_vars * [{"var":"$query_posts","type":"WP_Query","desc":"UM Posts Tab query"}] * @change_log * ["Since: 2.0"] * @usage * <?php add_filter( 'um_profile_query_make_posts', 'function_name', 10, 1 ); ?> * @example * <?php * add_filter( 'um_profile_query_make_posts', 'my_profile_query_make_posts', 10, 1 ); * function my_profile_query_make_posts( $query_posts ) { * // your code here * return $query_posts; * } * ?> */ $args = apply_filters( 'um_profile_query_make_posts', $args ); $posts = get_posts( $args ); UM()->get_template( 'profile/posts.php', '', array( 'posts' => $posts ), true ); wp_die(); } /** * Dynamic load of comments */ function load_comments() { UM()->check_ajax_nonce(); $user_id = ! empty( $_POST['user_id'] ) ? absint( $_POST['user_id'] ) : get_current_user_id(); $page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 0; $comments = get_comments( array( 'number' => 10, 'offset' => ( $page - 1 ) * 10, 'user_id' => $user_id, 'post_status' => array('publish'), 'type__not_in' => apply_filters( 'um_excluded_comment_types', array('') ), ) ); UM()->get_template( 'profile/comments.php', '', array( 'comments' => $comments ), true ); wp_die(); } /** * Count posts by type * * @param string $user_id * @param string $post_type * * @return int|string */ function count_user_posts_by_type( $user_id = '', $post_type = 'post' ) { global $wpdb; if ( ! $user_id ) { $user_id = um_user( 'ID' ); } if ( ! $user_id ) { return 0; } $where = get_posts_by_author_sql( $post_type, true, $user_id ); $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" ); return $this->pretty_number_formatting( $count ); } /** * Count comments * * @param int|null $user_id * * @return int|string */ function count_user_comments( $user_id = null ) { global $wpdb; if ( ! $user_id ) { $user_id = um_user( 'ID' ); } if ( ! $user_id ) { return 0; } $count = $wpdb->get_var("SELECT COUNT(comment_ID) FROM " . $wpdb->comments. " WHERE user_id = " . $user_id . " AND comment_approved = '1'"); return $this->pretty_number_formatting( $count ); } /** * @param int $count * * @return string */ function pretty_number_formatting( $count ) { /** * UM hook * * @type filter * @title um_pretty_number_formatting * @description Change User Posts count value * @input_vars * [{"var":"$count","type":"int","desc":"Posts Count"}] * @change_log * ["Since: 2.0"] * @usage * <?php add_filter( 'um_pretty_number_formatting', 'function_name', 10, 1 ); ?> * @example * <?php * add_filter( 'um_pretty_number_formatting', 'my_pretty_number_formatting', 10, 1 ); * function my_pretty_number_formatting( $count ) { * // your code here * return $count; * } * ?> */ return apply_filters( 'um_pretty_number_formatting', $count ); } } }
[-] um-filters-account.php
[edit]
[-] um-actions-login.php
[edit]
[-] um-actions-misc.php
[edit]
[-] class-access.php
[edit]
[-] class-plugin-updater.php
[edit]
[-] class-modal.php
[edit]
[-] um-filters-fields.php
[edit]
[-] class-common.php
[edit]
[-] class-options.php
[edit]
[-] um-filters-profile.php
[edit]
[-] class-profile.php
[edit]
[-] class-fonticons.php
[edit]
[-] class-member-directory-meta.php
[edit]
[+]
..
[-] um-filters-commenting.php
[edit]
[-] class-permalinks.php
[edit]
[-] class-member-directory.php
[edit]
[-] class-templates.php
[edit]
[-] class-setup.php
[edit]
[-] class-rewrite.php
[edit]
[-] um-filters-navmenu.php
[edit]
[-] class-date-time.php
[edit]
[-] class-blocks.php
[edit]
[-] um-actions-account.php
[edit]
[-] um-filters-avatars.php
[edit]
[-] class-external-integrations.php
[edit]
[-] um-actions-register.php
[edit]
[-] um-actions-save-profile.php
[edit]
[-] class-builtin.php
[edit]
[-] um-actions-access.php
[edit]
[-] um-filters-files.php
[edit]
[-] class-user-posts.php
[edit]
[-] um-filters-user.php
[edit]
[-] class-multisite.php
[edit]
[-] class-gdpr.php
[edit]
[-] class-account.php
[edit]
[-] class-roles-capabilities.php
[edit]
[-] um-actions-profile.php
[edit]
[-] class-files.php
[edit]
[-] um-actions-ajax.php
[edit]
[-] um-actions-wpadmin.php
[edit]
[-] class-form.php
[edit]
[-] class-enqueue.php
[edit]
[-] class-ajax-common.php
[edit]
[-] um-filters-login.php
[edit]
[-] class-register.php
[edit]
[-] class-fields.php
[edit]
[-] class-user.php
[edit]
[-] class-password.php
[edit]
[-] um-actions-core.php
[edit]
[-] um-actions-global.php
[edit]
[-] class-mail.php
[edit]
[-] class-cron.php
[edit]
[-] class-validation.php
[edit]
[-] .htaccess
[edit]
[-] class-logout.php
[edit]
[-] class-shortcodes.php
[edit]
[-] um-actions-user.php
[edit]
[-] class-login.php
[edit]
[+]
rest
[-] class-uploader.php
[edit]
[-] um-actions-form.php
[edit]
[-] class-query.php
[edit]
[-] um-filters-misc.php
[edit]