add_filter( 'previous_posts_link_attributes', 'tripp_previous_posts_link_attribute' ); /** * Gets the anchor tag attributes for the next posts page link. * * @param string $attributes Attributes for the anchor tag. * @return string Attributes for the anchor tag. */ function tripp_next_posts_link_attribute( $attributes = '' ) { $attributes = 'class="next"'; return $attributes; } add_filter( 'next_posts_link_attributes', 'tripp_next_posts_link_attribute' ); /** * Adds Next and Previous links to paginated posts. * * @global int $page * @global int $numpages * * @param array $args An array of arguments for page links for paginated posts. * @return array An array of arguments for page links for paginated posts. */ function tripp_link_pages_args( $args = array() ) { global $page, $numpages; $prev_link = ''; $prev = $page - 1; if ( $prev > 0 ) { $url = tripp_link_page_url( $prev ); $prev_link = sprintf( '%2$s ', esc_url( $url ), esc_html__( 'Prev.', 'tripp' ) ); } $args['before'] = ''; return $args; } add_filter( 'wp_link_pages_args', 'tripp_link_pages_args' ); /** * Sets the arguments used in retrieving the comment list. * * @see wp_list_comments() * * @param string|array $args { * Optional. Formatting options. * * @type object $walker Instance of a Walker class to list comments. Default null. * @type int $max_depth The maximum comments depth. Default empty. * @type string $style The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'. * @type string $callback Callback function to use. Default null. * @type string $end-callback Callback function to use at the end. Default null. * @type string $type Type of comments to list. * Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'. * @type int $page Page ID to list comments for. Default empty. * @type int $per_page Number of comments to list per page. Default empty. * @type int $avatar_size Height and width dimensions of the avatar size. Default 32. * @type bool $reverse_top_level Ordering of the listed comments. If true, will display newest comments first. * @type bool $reverse_children Whether to reverse child comments in the list. Default null. * @type string $format How to format the comments list. * Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'. * @type bool $short_ping Whether to output short pings. Default false. * @type bool $echo Whether to echo the output or return it. Default true. * } */ function tripp_list_comments_args( $args ) { $args['avatar_size'] = 32; if ( empty( $args['callback'] ) ) { $args['callback'] = 'tripp_comment'; } $args['style'] = 'ol'; $args['short_ping'] = true; return $args; } add_filter( 'wp_list_comments_args', 'tripp_list_comments_args' ); /** * Adds the anchor tag attributes for the next comments page link. * * @param string $attributes Attributes for the anchor tag. * @return string Attributes for the anchor tag. */ function tripp_next_comments_link_attributes( $attributes ) { $attributes .= ' class="next"'; return $attributes; } add_filter( 'next_comments_link_attributes', 'tripp_next_comments_link_attributes' ); /** * Adds the anchor tag attributes for the previous comments page link. * * @param string $attributes Attributes for the anchor tag. * @return string Attributes for the anchor tag. */ function tripp_previous_comments_link_attributes( $attributes ) { $attributes .= ' class="prev"'; return $attributes; } add_filter( 'previous_comments_link_attributes', 'tripp_previous_comments_link_attributes' ); /** * Sets the comments link title attributes for display. * * @param string $attributes The comments link attributes. Default empty. * @return string The comments link attributes. */ function tripp_comments_popup_link_attributes( $attributes = '' ) { $attributes = ' title="' . esc_attr( esc_html__( 'Leave a comment', 'tripp' ) ) . '"'; return $attributes; } add_filter( 'comments_popup_link_attributes', 'tripp_comments_popup_link_attributes' ); /** * Sets the comment form default arguments. * * @param array $args The comment form arguments. * @return array The comment form arguments. */ function tripp_comment_form_args( $args = array() ) { $args['title_reply'] = esc_html__( 'Leave a Comment', 'tripp' ); $args['comment_field'] = '
'; return $args; } add_filter( 'comment_form_defaults', 'tripp_comment_form_args' ); /** * Defines the default comment form fields. * * @param array $fields The default comment fields. * @return array The default comment fields. */ function tripp_comment_form_fields( $fields = array() ) { $commenter = wp_get_current_commenter(); $req = get_option( 'require_name_email' ); $aria_req = ( $req ? " aria-required='true'" : '' ); $html_req = ( $req ? " required='required'" : '' ); $fields['author'] = ' '; $fields['email'] = '
'; $fields['url'] = '
'; return $fields; } add_filter( 'comment_form_default_fields', 'tripp_comment_form_fields' ); /** * Returns the arguments for the Navigation Menu widget. * * @param array $nav_menu_args { * An array of arguments passed to wp_nav_menu() to retrieve a navigation menu. * * @type callable|bool $fallback_cb Callback to fire if the menu doesn't exist. Default empty. * @type mixed $menu Menu ID, slug, or name. * } * @return array An array of arguments for the Navigation Menu widget. */ function tripp_widget_nav_menu_vertical( $nav_menu_args = array() ) { $nav_menu_args['menu_class'] = 'vertical-menu'; $nav_menu_args['container'] = is_customize_preview() ? 'div' : false; $nav_menu_args['after'] = ''; return $nav_menu_args; } add_filter( 'widget_nav_menu_args', 'tripp_widget_nav_menu_vertical' ); /** * Disable requests to wp.org repository for this theme. * * @since 1.0.1 * * @param array $request An array of HTTP request arguments. * @param string $url The request URL. * @return array Amended request arguments. */ function tripp_update_check( $request, $url ) { if ( false !== strpos( $url, '//api.wordpress.org/themes/update-check/1.1/' ) ) { $data = json_decode( $request['body']['themes'] ); $slug = get_template(); unset( $data->themes->$slug ); $request['body']['themes'] = wp_json_encode( $data ); } return $request; } add_filter( 'http_request_args', 'tripp_update_check', 5, 2 ); /** * Disables the Block Editor on Widgets Editing screen. */ add_filter( 'gutenberg_use_widgets_block_editor', '__return_false' ); add_filter( 'use_widgets_block_editor', '__return_false' ); /** * Tripp Theme actions & filters. */ /** * Filters the Custom Fonts available for this theme. * * @param array $fonts An array list of fonts available for this theme. * @return array An array list of fonts available for this theme. */ function tripp_custom_fonts( $fonts = array() ) { if ( function_exists( 'flextension_fonts' ) ) { $custom_fonts = flextension_fonts(); if ( ! empty( $custom_fonts ) ) { $fonts = array_merge( $fonts, $custom_fonts ); } } return $fonts; } add_filter( 'tripp_fonts', 'tripp_custom_fonts' ); /** * Sets the list of custom logo image attributes for the Light version. * * @param array $custom_logo_attr Custom logo image attributes. * @param int $custom_logo_id Custom logo attachment ID. * @return array Custom logo image attributes. */ function tripp_light_logo_image_attributes( $custom_logo_attr = array(), $custom_logo_id = 0 ) { $custom_logo_retina_id = absint( get_theme_mod( 'light_logo_retina', 0 ) ); if ( 0 !== $custom_logo_retina_id ) { $srcsets = array(); $srcsets[] = wp_get_attachment_image_url( $custom_logo_id, 'full' ) . ' 1x'; $srcsets[] = wp_get_attachment_image_url( $custom_logo_retina_id, 'full' ) . ' 2x'; $custom_logo_attr['srcset'] = implode( ', ', $srcsets ); } $custom_logo_attr['data-lazyload'] = 'disabled'; return $custom_logo_attr; } add_filter( 'tripp_get_light_logo_image_attributes', 'tripp_light_logo_image_attributes', 10, 2 ); /** * Adds a Dark Mode toggle button to the list of extra menu items. * * @param array $items An array of the extra menu items. * @return array An array of the extra menu items. */ function tripp_dark_mode_menu_button( $items = array() ) { // Only when the site allows users to change their preferences, or currently in Customize mode. if ( tripp_has_user_color_support() || is_customize_preview() ) { $items['dark-mode'] = ''; } return $items; } add_filter( 'tripp_extra_menu_items', 'tripp_dark_mode_menu_button' ); /** * Sets the author cover background image to the author's page header. * * @param array $args An array of the arguments for the header. * @return array An array of the arguments for the header. */ function tripp_author_page_header( $args = array() ) { if ( 'archive' === $args['layout'] ) { // Author page and Author Cover Image is available. if ( function_exists( 'flextension_author_cover_image_id' ) && is_author() && get_query_var( 'author' ) ) { $author_id = get_query_var( 'author' ); $image_id = flextension_author_cover_image_id( $author_id ); if ( $image_id > 0 ) { $image_url = wp_get_attachment_image_url( $image_id, 'fullwidth' ); if ( ! empty( $image_url ) ) { $args['background'] = 'image'; $args['background_image'] = $image_url; if ( function_exists( 'flextension_author_cover_image_styles' ) ) { $styles = flextension_author_cover_image_styles( $author_id ); if ( ! empty( $styles['background-position'] ) ) { $args['background_position'] = $styles['background-position']; } } } } } elseif ( function_exists( 'flextension_get_term_thumbnail_id' ) && ( is_category() || is_tag() || is_tax() ) ) { $term_id = get_queried_object_id(); $image_id = flextension_get_term_thumbnail_id( $term_id ); if ( $image_id > 0 ) { $image_url = wp_get_attachment_image_url( $image_id, 'fullwidth' ); if ( ! empty( $image_url ) ) { $args['background'] = 'image'; $args['background_image'] = $image_url; if ( function_exists( 'tripp_xt_term_image_styles' ) ) { $styles = tripp_xt_term_image_styles( $term_id ); if ( ! empty( $styles['background-position'] ) ) { $args['background_position'] = $styles['background-position']; } } } } } } return $args; } add_filter( 'tripp_page_header_args', 'tripp_author_page_header' ); /** * Filters the posts arguments for a search page. * * @param array $args An array of posts arguments. * @return array New array of posts arguments. */ function tripp_search_posts_args( $args ) { if ( is_search() || ( isset( $args['query'] ) && $args['query']->is_search() ) ) { $args['layout'] = 'search'; } return $args; } add_filter( 'tripp_posts_args', 'tripp_search_posts_args' ); /** * Adds the container (paragraph) the author description. * * @since 1.0.6 * * @param string $value The value of the metadata. * @return string The author description with the container. */ function tripp_add_author_description_container( $value = '' ) { if ( ! empty( $value ) ) { $value = ' '; } return $value; } add_filter( 'tripp_author_description', 'tripp_add_author_description_container', 10 ); /** * Inserts author location before the author description. * * @param string $value The value of the metadata. * @param int $user_id The user ID for the value. * @return string The author description with author location. */ function tripp_add_author_location( $value = '', $user_id = 0 ) { if ( function_exists( 'flextension_author_location' ) ) { $value = flextension_author_location( $user_id ) . $value; } return $value; } add_filter( 'tripp_author_description', 'tripp_add_author_location', 10, 2 ); /** * Adds the contact links to the author description. * * @param string $value The value of the metadata. * @param int $user_id The user ID for the value. * @return string The author description with the contact links. */ function tripp_add_author_social_links( $value = '', $user_id = 0 ) { if ( function_exists( 'flextension_get_user_social_links' ) ) { $value = $value . flextension_get_user_social_links( $user_id ); } return $value; } add_filter( 'tripp_author_description', 'tripp_add_author_social_links', 10, 2 ); /** * Prints out the filter options for the list of posts. * * @param array $options An array of options. */ function tripp_posts_filter_options( $options = array() ) { $taxonomies = get_object_taxonomies( $options['post_type'], 'objects' ); $taxonomies = wp_filter_object_list( $taxonomies, array( 'publicly_queryable' => true, ) ); /** * Filters the array list of taxonomies. * * @param array $taxonomies An array list of taxonomies. */ $taxonomies = apply_filters( 'tripp_posts_filter_taxonomies', $taxonomies ); if ( ! empty( $taxonomies ) ) { if ( ! empty( $options['taxonomy'] ) && isset( $taxonomies[ $options['taxonomy'] ] ) ) { unset( $taxonomies[ $options['taxonomy'] ] ); } if ( isset( $taxonomies['destination'] ) ) { unset( $taxonomies['destination'] ); } if ( ! is_search() ) { $taxonomies = wp_list_sort( $taxonomies, 'label' ); } $link_base = tripp_get_link_base(); $columns = 0; $output = ''; $selected_items = 0; foreach ( $taxonomies as $taxonomy ) { if ( empty( $taxonomy ) ) { continue; } $terms = get_terms( array( 'taxonomy' => $taxonomy->name, ) ); if ( is_wp_error( $terms ) ) { $terms = array(); } if ( ! empty( $terms ) ) { $columns++; $output .= '
\s*
#', '', $content ); /** This filter is documented in wp-includes/post-template.php */ $content = apply_filters( 'the_content', $content ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound, WPThemeReview.CoreFunctionality.PrefixAllGlobals.NonPrefixedHooknameFound $content = trim( $content ); if ( ! empty( $content ) ) { echo '