display. * @param string $type The type of the content template. * @param array $args Additional arguments passed to the template. */ return apply_filters( 'tripp_content_template', $content, $name, $type, $args ); } /** * Retrieves the first URL in the post content. * * @param string $content A string which might contain HTML element. * @return string The first URL found in the content. */ function tripp_get_url_in_content( $content = '' ) { if ( empty( $content ) ) { $content = get_the_content(); } $url = ''; if ( preg_match( '#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $content, $matches ) ) { $url = $matches[0]; } return $url; } /** * Retrieves the first HTML element matched a given tag name in the post content. * * @param string $content A string which might contain HTML element. * @param string $tagname A tag's name to find. * @return string The first HTML element matched a given tag name. */ function tripp_get_html_element( $content = '', $tagname = '' ) { if ( empty( $content ) ) { $content = get_the_content(); } $element = ''; if ( preg_match( '#<(?P' . $tagname . ')[^<]*?(?:>[\s\S]*?<\/(?P=tag)>|\s*\/>)#', $content, $matches ) ) { $element = $matches[0]; } return $element; } /** * 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_post_quote( $post = 0 ) { $block_content = ''; $post = get_post( $post ); if ( ! $post ) { return $block_content; } if ( function_exists( 'flextension_get_featured_block' ) ) { if ( has_block( 'core/quote', $post->post_content ) ) { $quote_block = flextension_get_featured_block( 'core/quote', $post->post_content ); $block_content = render_block( $quote_block ); } elseif ( has_block( 'core/pullquote', $post->post_content ) ) { $quote_block = flextension_get_featured_block( 'core/pullquote', $post->post_content ); $block_content = render_block( $quote_block ); } } if ( empty( $block_content ) ) { $block_content = tripp_get_html_element( $post->post_content, 'blockquote' ); } echo '
' . sprintf( '', 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 '

'; } /** * 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 '
'; dynamic_sidebar( $name ); echo '
'; } } /** * Displays footer widgets. */ function tripp_footer_widgets() { $columns = get_theme_mod( 'footer_widgets', 0 ); if ( absint( $columns ) > 0 ) { get_template_part( 'template-parts/footer/footer', 'widgets', array( 'columns' => $columns ) ); } } /** * Displays footer info. */ function tripp_footer_info() { get_template_part( 'template-parts/footer/footer', 'info' ); } /** * Displays Footer Logo. */ function tripp_footer_logo() { $html = ''; $footer_logo_id = absint( get_theme_mod( 'footer_logo', 0 ) ); // We have a logo. Logo is go. if ( $footer_logo_id ) { $footer_logo_attr = array(); $footer_logo_retina_id = absint( get_theme_mod( 'footer_logo_retina', 0 ) ); if ( $footer_logo_retina_id ) { $srcsets = array(); $srcsets[] = wp_get_attachment_image_url( $footer_logo_id, 'full' ) . ' 1x'; $srcsets[] = wp_get_attachment_image_url( $footer_logo_retina_id, 'full' ) . ' 2x'; $footer_logo_attr['srcset'] = implode( ', ', $srcsets ); unset( $footer_logo_attr['sizes'] ); } /* * If the logo alt attribute is empty, get the site title and explicitly * pass it to the attributes used by wp_get_attachment_image(). */ $image_alt = get_post_meta( $footer_logo_id, '_wp_attachment_image_alt', true ); if ( empty( $image_alt ) ) { $footer_logo_attr['alt'] = get_bloginfo( 'name', 'display' ); } /* * If the alt attribute is not empty, there's no need to explicitly pass * it because wp_get_attachment_image() already adds the alt attribute. */ echo sprintf( '%2$s', esc_url( tripp_logo_url() ), wp_get_attachment_image( $footer_logo_id, 'full', false, $footer_logo_attr ) ); } elseif ( is_customize_preview() ) { // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview). echo sprintf( '', esc_url( tripp_logo_url() ) ); } } /** * Displays footer menu. */ function tripp_footer_menu() { if ( ( 'show' === get_theme_mod( 'footer_menu', '' ) || is_customize_preview() ) && has_nav_menu( 'footer' ) ) { echo ''; } } /** * Displays footer social links. */ function tripp_footer_social_links() { $footer_links = get_theme_mod( 'footer_links', '' ); if ( function_exists( 'flextension_social_icons_widget' ) && ( ! empty( $footer_links ) || is_customize_preview() ) ) { echo ''; } } /** * Displays language switcher in the footer. * * @since 1.2.2 */ function tripp_footer_language_switcher() { if ( function_exists( 'wpml_footer_language_selector_action' ) && class_exists( 'WPML_Language_Switcher', false ) ) { global $wpml_language_switcher; if ( $wpml_language_switcher instanceof WPML_Language_Switcher ) { $footer_slot = $wpml_language_switcher->get_slot( 'statics', 'footer' ); if ( true === (bool) $footer_slot->get( 'show' ) ) { wpml_footer_language_selector_action(); } } } } /** * Returns default Site Info. * * @return string Default site info. */ function tripp_default_site_info() { $site_title = get_bloginfo( 'name' ); if ( empty( $site_title ) ) { $site_title = 'Tripp'; } return '© ' . gmdate( 'Y' ) . ' ' . $site_title . '. Proudly powered by WordPress.'; } /** * Displays Site Info in the footer. */ function tripp_footer_text() { $html = get_theme_mod( 'footer_text', tripp_default_site_info() ); if ( ! empty( $html ) || is_customize_preview() ) { echo '' . wp_kses_data( $html ) . ''; } } walking – Nos Dushi Bida