'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 '' . esc_html__( 'Load more', 'tripp' ) . '
'; } /** * Returns the next and previous posts pagination. * * @param int $total Total pages. * @param int $current The current page. * @return string The HTML output for the posts pagination. */ function tripp_next_previous_pagination( $total = 0, $current = 0 ) { if ( ! $current ) { $current = max( 1, get_query_var( 'paged' ) ); } $pagination = ''; // Previous link. if ( $current > 1 ) { $label = '' . esc_html__( 'Newer', 'tripp' ) . ''; $pagination = get_previous_posts_link( $label ); } // Current link. if ( $total > 1 ) { $pagination .= '' . esc_html( $current ) . ''; } // Next link. $nextpage = absint( $current ) + 1; if ( $nextpage <= $total ) { $label = '' . esc_html__( 'Older', 'tripp' ) . ''; $pagination .= get_next_posts_link( $label, $total ); } return $pagination; } /** * Retrieves a numbered pagination. * * @param array $args { * Optional. Default pagination arguments, see paginate_links(). * * @type string $screen_reader_text Screen reader text for navigation element. * Default 'Posts navigation'. * @type string $aria_label ARIA label text for the nav element. Default 'Posts'. * @type string $class Custom class for the nav element. Default 'pagination'. * } * @return string Markup for pagination links. */ function tripp_numbered_pagination( $args = array() ) { // Make sure the nav element has an aria-label attribute: fallback to the screen reader text. if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) { $args['aria_label'] = $args['screen_reader_text']; } $args = wp_parse_args( $args, array( 'end_size' => 0, 'mid_size' => 1, 'prev_text' => sprintf( '%s', esc_html__( 'Newer', 'tripp' ) ), 'next_text' => sprintf( '%s', esc_html__( 'Older', 'tripp' ) ), ) ); // Make sure we get a string back. Plain is the next best thing. if ( isset( $args['type'] ) && 'array' === $args['type'] ) { $args['type'] = 'plain'; } // Set up paginated links. return paginate_links( $args ); } /** * Gets the pagination navigation. * * @param string $page_links The page links. * @param string $class The pagination class name. * @return string The HTML output for the posts pagination. */ function tripp_get_pagination( $page_links = '', $class = '' ) { if ( empty( $page_links ) ) { return ''; } $output = sprintf( '', $class, $page_links ); return $output; } /** * Returns the URL of the post page. * * @global WP_Rewrite $wp_rewrite * * @param int $i Page number. * @return string URL of the post page. */ function tripp_link_page_url( $i ) { global $wp_rewrite; $post = get_post(); $query_args = array(); if ( 1 === $i ) { $url = get_permalink(); } else { $permalink = get_option( 'permalink_structure' ); if ( empty( $permalink ) || in_array( $post->post_status, array( 'draft', 'pending' ), true ) ) { $url = add_query_arg( 'page', $i, get_permalink() ); } elseif ( 'page' === get_option( 'show_on_front' ) && absint( get_option( 'page_on_front' ) ) === $post->ID ) { $url = trailingslashit( get_permalink() ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $i, 'single_paged' ); } else { $url = trailingslashit( get_permalink() ) . user_trailingslashit( $i, 'single_paged' ); } } if ( is_preview() ) { if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $query_args['preview_id'] = absint( wp_unslash( $_GET['preview_id'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended $query_args['preview_nonce'] = sanitize_key( $_GET['preview_nonce'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended } $url = get_preview_post_link( $post, $query_args, $url ); } return $url; } /** * Returns whether the footer can be displayed. * * @param int $id The post ID. * @return bool Whether the footer can be displayed. */ function tripp_has_footer( $id = 0 ) { if ( empty( $id ) ) { $id = tripp_get_page_id(); } return false === (bool) get_post_meta( $id, '_tripp_hide_footer', true ); } /** * Return whether the footer gap is visible. * * @param int $id The post ID. * @return bool Whether the footer gap is visible. */ function tripp_has_footer_gap( $id = 0 ) { if ( ( is_archive() && ! is_post_type_archive() ) ) { return true; } if ( empty( $id ) ) { $id = tripp_get_page_id(); } return false === (bool) get_post_meta( $id, '_tripp_hide_footer_gap', true ); } /** * Determines if the Footer Logo can be displayed. * * @return bool Whether the Footer Logo can be displayed. */ function tripp_has_footer_logo() { return (bool) get_theme_mod( 'footer_logo', 0 ); } /** * Prints out the footer widgets class. * * @param string $class Space-separated string. * @param int $columns Number of columns. */ function tripp_footer_widgets_class( $class = '', $columns = 1 ) { $classes = array( $class ); if ( absint( $columns ) > 1 ) { $classes[] = "tripp-grid has-{$columns}-columns"; } else { $classes[] = 'has-one-column'; } echo esc_attr( implode( ' ', $classes ) ); } /** * Prints out the footer columns and widgets. * * @param int $columns Number of columns. */ function tripp_footer_columns( $columns = 1 ) { $is_preview = is_customize_preview(); $max = $is_preview ? 4 : $columns; for ( $i = 1; $i <= $max; $i++ ) { $name = 'footer-' . $i; $class = 'footer-col-' . esc_attr( $i ); if ( $is_preview && $i > $columns ) { $class .= ' is-hidden'; } echo '