/** * 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 ) . ''; } } snow – Nos Dushi Bida