- fix make()

This commit is contained in:
ashubawork
2023-06-22 16:11:32 +03:00
parent 9f8767b3c8
commit a027cfcd70
+21 -26
View File
@@ -146,51 +146,46 @@ if ( ! class_exists( 'um\core\Query' ) ) {
* *
* @return array|bool|int|\WP_Query * @return array|bool|int|\WP_Query
*/ */
function make( $args ) { public function make( $args ) {
$defaults = array( $defaults = array(
'post_type' => 'post', 'post_type' => 'post',
'post_status' => array('publish') 'post_status' => array( 'publish' ),
); );
$args = wp_parse_args( $args, $defaults ); $args = wp_parse_args( $args, $defaults );
if ( isset( $args['post__in'] ) && empty( $args['post__in'] ) ) if ( isset( $args['post__in'] ) && empty( $args['post__in'] ) ) {
return false; return false;
}
extract( $args ); if ( 'comment' === $args['post_type'] ) { // comments
if ( $post_type == 'comment' ) { // comments
unset( $args['post_type'] ); unset( $args['post_type'] );
/** /**
* UM hook * Filters extend excluded comment types
* *
* @type filter * @since 2.0
* @title um_excluded_comment_types * @hook um_excluded_comment_types
* @description Extend excluded comment types *
* @input_vars * @param {array} $types Comment Types.
* [{"var":"$types","type":"array","desc":"Comment Types"}] *
* @change_log * @return {array} $types Comment Types.
* ["Since: 2.0"] *
* @usage * @example <caption>Extend excluded comment types.</caption>
* <?php add_filter( 'um_excluded_comment_types', 'function_name', 10, 1 ); ?> * function my_excluded_comment_types( $types ) {
* @example
* <?php
* add_filter( 'um_excluded_comment_types', 'my_excluded_comment_types', 10, 1 );
* function my_profile_active_tab( $types ) {
* // your code here * // your code here
* return $types; * return $types;
* } * }
* ?> * add_filter( 'um_excluded_comment_types', 'my_excluded_comment_types', 10, 1 );
*/ */
$args['type__not_in'] = apply_filters( 'um_excluded_comment_types', array('') ); $args['type__not_in'] = apply_filters( 'um_excluded_comment_types', array( '' ) );
$comments = get_comments($args); $comments = get_comments( $args );
return $comments; return $comments;
} else { } else {
$custom_posts = new \WP_Query(); $custom_posts = new \WP_Query();
$args['post_status'] = is_array( $args['post_status'] ) ? $args['post_status'] : explode( ',', $args['post_status'] ); $args['post_status'] = is_array( $args['post_status'] ) ? $args['post_status'] : explode( ',', $args['post_status'] );
$custom_posts->query( $args ); $custom_posts->query( $args );