' .
sprintf(
'
%2$s',
esc_url( tripp_get_post_link( $post ) ),
wp_kses(
$block_content,
array(
'blockquote' => array(),
'p' => array(),
'cite' => array(),
)
)
)
. '
';
}
/**
* Returns HTML content for the featured quote.
*
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`.
* @return string The HTML content for the featured audio.
*/
function tripp_get_post_link( $post = 0 ) {
$link = '';
$post = get_post( $post );
if ( ! $post ) {
return $link;
}
if ( 'link' === get_post_format( $post ) ) {
$link = tripp_get_url_in_content( $post->post_content );
} else {
$link = get_permalink( $post );
if ( true === get_theme_mod( 'blog_quick_view_link', false ) ) {
$link .= '#tripp-quick-view-' . $post->ID;
}
}
return $link;
}
/**
* Retrieves the post excerpt.
*
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`.
* @return string Post excerpt.
*/
function tripp_get_post_excerpt( $post = 0 ) {
$post = get_post( $post );
if ( ! $post ) {
return '';
}
$excerpt = $post->post_excerpt;
/**
* Filters the retrieved post excerpt.
*
* @param string $excerpt The post excerpt.
* @param WP_Post $post Post object.
*/
return apply_filters( 'tripp_post_excerpt', $excerpt, $post );
}
/**
* Returns whether the post can display given post property.
*
* @param string $prop The post property name.
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`.
* @return bool Whether the post can display given post property.
*/
function tripp_post_can_show( $prop, $post = 0 ) {
$show = true;
switch ( $prop ) {
case 'title':
$post = get_post( $post );
if ( $post ) {
$post_format = get_post_format( $post );
if ( 'aside' === $post_format || 'status' === $post_format ) {
$show = false;
}
}
break;
default:
if ( post_password_required( $post ) ) {
$show = tripp_protected_post_can_show( $prop, $post );
}
break;
}
/**
* Filters whether the post can display given post property.
*
* @param bool $show Whether the post can display given post property.
* @param string $prop The post property name.
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`.
*/
return apply_filters( 'tripp_post_can_show', $show, $prop, $post );
}
/**
* Returns whether the protected post can display given post property.
*
* @param string $prop The post property name.
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`.
* @return bool Whether the protected post can display given post property.
*/
function tripp_protected_post_can_show( $prop, $post = 0 ) {
$post_type = get_post_type( $post );
$default = ( 'metadata' === $prop );
return (bool) get_theme_mod( "protected_{$post_type}_{$prop}", $default );
}
/**
* Returns whether the post can display content footer.
*
* @param array $args The post property name.
* @return bool Whether the post can display content footer.
*/
function tripp_post_can_show_content_footer( $args = array() ) {
return tripp_post_can_show( 'metadata' ) && ( true === $args['show_author'] || true === $args['show_meta'] || true === $args['show_buttons'] || is_customize_preview() );
}
/**
* Gets the link base URL.
*
* @return string The link base URL.
*/
function tripp_get_link_base() {
$base = false;
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
$base = wp_get_referer();
if ( empty( $base ) ) {
// If front page is set to display a static page, get the URL of the posts page.
if ( 'page' === get_option( 'show_on_front' ) ) {
$base = get_permalink( get_option( 'page_for_posts' ) );
} else {
$base = get_home_url();
}
}
}
return $base;
}
/**
* Retrieves a paginated navigation to next/previous set of posts, when applicable.
*
* @global WP_Query $wp_query
*
* @param string $type The pagination type.
* @param int $total Total pages.
* @param int $current Current page.
* @return string The HTML output for the next/previous page link.
*/
function tripp_posts_pagination( $type, $total = 0, $current = 0 ) {
global $wp_query;
if ( 'none' === $type ) {
return;
}
$class = '';
$page_links = '';
if ( ! $total ) {
$total = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
}
if ( ! $current ) {
$current = max( 1, get_query_var( 'paged' ) );
}
$current = absint( $current );
switch ( $type ) {
case 'next_previous':
$class = 'next-previous-pagination';
$page_links = tripp_next_previous_pagination( $total, $current );
break;
case 'numbered':
$class = 'numbered-pagination';
$args = array(
'total' => $total,
'current' => $current,
);
$page_links = tripp_numbered_pagination( $args );
break;
default:
$page_link = '';
$class = 'loadmore-pagination';
if ( 'scroll' === $type ) {
$class .= ' infinite-scroll';
}
if ( 1 !== $total && $current < $total ) {
$page_link = get_pagenum_link( $current + 1 );
}
if ( ! empty( $page_link ) ) {
$page_links = tripp_posts_pagination_link( $page_link );
}
break;
}
echo tripp_get_pagination( $page_links, $class ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* Gets the posts pagination link.
*
* @param string $page_link The page link.
* @return string The HTML output for the posts pagination link.
*/
function tripp_posts_pagination_link( $page_link = '' ) {
return '