true ]; } elseif ( 'comments' === $active_filter ) { $query_args = [ 'p2filter_comments' => true ]; } $query_args['ts'] = P2_Core\Unread\Unread::get_content_cutoff_timestamp( $active_filter ); $ajax_url = add_query_arg( $query_args, $ajax_url ); return $ajax_url; } /** * Callback for 'infinite_scroll_query_args' filter hook. * (https://opengrok.a8c.com/source/xref/jetpack/modules/infinite-scroll/infinity.php#1310) * Add query args for making filter views work. */ function infinite_scroll_query_args( $query_args ) { if ( ! is_array( $query_args ) ) { return $query_args; } $active_filter = P2_Core\Filtering\View::get_active_filter(); if ( empty( $active_filter ) ) { return $query_args; } if ( 'posts' === $active_filter ) { $query_args['p2filter_posts'] = true; } elseif ( 'comments' === $active_filter ) { $query_args['p2filter_comments'] = true; } $query_args['ts'] = P2_Core\Unread\Unread::get_content_cutoff_timestamp( $active_filter ); return $query_args; } function filter_o2_post_fragment( $fragment ) { $active_filter = P2_Core\Filtering\View::get_active_filter(); // If we are not on a filter page, there is nothing more to do here. if ( empty( $active_filter ) ) { return $fragment; } if ( P2_Core\Filtering\View::FILTERING_COMMENTS === $active_filter ) { // Convert to array for easier manipulation. $css_classes = explode( ' ', $fragment['cssClasses'] ); // If a post appears in the recent comments filter view, // automatically add "trim post" class $css_classes[] = 'p2020-post-read-more'; if ( $fragment['isProjectThread'] ) { $fragment['isProjectThread'] = false; $css_classes = array_filter( $css_classes, function( $classname ) { return 'tag-project-thread' !== $classname; } ); } if ( $fragment['postMeta']['isSticky'] ) { $fragment['postMeta']['isSticky'] = false; } // Convert back to string. $fragment['cssClasses'] = implode( ' ', $css_classes ); } return $fragment; } function filter_o2_comment_fragment( $fragment ) { $active_filter = P2_Core\Filtering\View::get_active_filter(); // If we are not on a filter page, there is nothing more to do here. if ( empty( $active_filter ) ) { return $fragment; } if ( ! empty( $fragment['isUnread'] ) ) { $fragment['cssClasses'] .= ' p2020-unread-comment'; } // Flag unread comments, trim everything else. if ( P2_Core\Filtering\View::FILTERING_COMMENTS === $active_filter ) { if ( ! $fragment['isUnread'] ) { $fragment['cssClasses'] .= ' p2020-comment-read-more'; } } return $fragment; }