GLOBALS['tripp_is_signup_page'] ) && $GLOBALS['tripp_is_signup_page']; } /** * Sets whether the current page is the registration page. */ function tripp_signup_page() { $GLOBALS['tripp_is_signup_page'] = true; } add_action( 'signup_header', 'tripp_signup_page' ); /** * Removes Block editor assets from Classic editor then add Classic editor assets instead. * * @param string[] $stylesheets Array of URLs of stylesheets to be applied to the editor. */ function tripp_classic_editor_stylesheets( $stylesheets = array() ) { $index = array_search( get_theme_file_uri( 'assets/css/editor.css' ), $stylesheets, true ); if ( false !== $index ) { unset( $stylesheets[ $index ] ); } $stylesheets[] = get_theme_file_uri( 'assets/css/classic-editor.css' ); return $stylesheets; } add_filter( 'editor_stylesheets', 'tripp_classic_editor_stylesheets' ); /** * Removes hentry class from the page and adds custom class 'entry' to the array of posts classes. * * @param string[] $classes An array of post class names. * @param string[] $class An array of additional class names added to the post. * @param int $post_id The post ID. * @return string[] $classes An array of post class names. */ function tripp_get_post_classes( $classes, $class, $post_id ) { $classes[] = 'entry'; if ( 'page' === get_post_type( $post_id ) ) { $classes = array_diff( $classes, array( 'hentry' ) ); } /** * If the post thumbnail is enabled for the password protected post, * Add a 'has-post-thumbnail' class to the post to make it work correctly. */ if ( post_password_required( $post_id ) && tripp_protected_post_can_show( 'thumbnail', $post_id ) && has_post_thumbnail( $post_id ) ) { $classes[] = 'has-post-thumbnail'; } return $classes; } add_filter( 'post_class', 'tripp_get_post_classes', 10, 3 ); /** * Adds a title to posts and pages that are missing titles. * * @param string $title The title. * @return string New title. */ function tripp_no_post_title( $title ) { return '' === $title ? esc_html_x( 'Untitled', 'Added to posts and pages that are missing titles', 'tripp' ) : $title; } add_filter( 'the_title', 'tripp_no_post_title' ); /** * Removes 'Protected:' from the post title format for protected posts. * * @param string $format The post title format for protected posts. * Default 'Protected: %s'. * @return string The post title format for protected posts. */ function tripp_protected_title_format( $format ) { $format = '%s'; return $format; } add_filter( 'protected_title_format', 'tripp_protected_title_format', 10 ); /** * Adds a custom query var, filter into WordPress public query variables. * * @since 1.0.2 Adds 'tag' to public query variables. * * @param array $query_vars An array of allowed query variable names. * @return array An array of allowed query variable names. */ function tripp_add_query_vars( $query_vars = array() ) { $query_vars[] = 'tag'; $query_vars[] = 'filter'; return $query_vars; } add_filter( 'query_vars', 'tripp_add_query_vars' ); /** * Overrides WP query on the Author page. * * @since 1.0.2 Adds tags to the query when filtering with tags. * * @param WP_Query $query The WP_Query instance (passed by reference). */ function tripp_parse_query( $query ) { if ( ! is_admin() && $query->is_main_query() ) { if ( true === $query->is_author() ) { $query->is_category = false; $query->is_tag = false; $query->is_tax = false; } if ( $query->get( 'tag' ) ) { $tag_query = $query->get( 'tag' ); if ( is_array( $tag_query ) ) { $tag_query = implode( ',', $tag_query ); } if ( '' !== $tag_query && ! $query->is_singular ) { if ( strpos( $tag_query, ',' ) !== false ) { $tags = preg_split( '/[,\r\n\t ]+/', $tag_query ); $slugs = array(); foreach ( (array) $tags as $tag ) { $tag = sanitize_term_field( 'slug', $tag, 0, 'post_tag', 'db' ); $slugs[] = $tag; } $query->set( 'tag_slug__in', $slugs ); } elseif ( preg_match( '/[+\r\n\t ]+/', $tag_query ) || ! empty( $query->get( 'cat' ) ) ) { $tags = preg_split( '/[+\r\n\t ]+/', $tag_query ); $slugs = array(); foreach ( (array) $tags as $tag ) { $tag = sanitize_term_field( 'slug', $tag, 0, 'post_tag', 'db' ); $slugs[] = $tag; } $query->set( 'tag_slug__and', $slugs ); } else { $tag_query = sanitize_term_field( 'slug', $tag_query, 0, 'post_tag', 'db' ); $slugs = $query->get( 'tag_slug__in', array() ); $slugs[] = $tag_query; $query->set( 'tag_slug__in', $slugs ); } } } } } add_action( 'parse_query', 'tripp_parse_query' ); /** * Filters the posts for logged in user by following. * * @param WP_Query $query The WP_Query instance (passed by reference). */ function tripp_filter_posts( $query ) { if ( ! is_admin() && $query->is_main_query() ) { if ( 'following' === $query->get( 'filter' ) && function_exists( 'flextension_author_get_following' ) ) { // Display only posts from authors current user follow. $authors = flextension_author_get_following(); if ( empty( $authors ) ) { $authors = array( 0 ); } $query->set( 'author__in', $authors ); } } } add_action( 'pre_get_posts', 'tripp_filter_posts' ); /** * Sets the list of custom logo image attributes. * * @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_custom_logo_image_attributes( $custom_logo_attr = array(), $custom_logo_id = 0 ) { $custom_logo_retina_id = absint( get_theme_mod( 'custom_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( 'get_custom_logo_image_attributes', 'tripp_custom_logo_image_attributes', 10, 2 ); /** * Filters the arguments for a single nav menu item. * * @param stdClass $args An object of wp_nav_menu() arguments. * @param WP_Post $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. */ function tripp_nav_menu_item_args( $args, $item, $depth ) { if ( 0 === $depth && 'split-menu with-counters' === $args->menu_class ) { $args->link_after = ''; } return $args; } add_filter( 'nav_menu_item_args', 'tripp_nav_menu_item_args', 10, 3 ); /** * Adds custom image size names. * * @param array $sizes An array list of the image sizes. * @return array An array list of the image sizes. */ function tripp_add_image_size_names( $sizes ) { return array_merge( $sizes, array( 'tripp-large' => esc_html__( 'Square', 'tripp' ), 'tripp-wide' => esc_html__( 'Wide', 'tripp' ), 'tripp-fullwidth' => esc_html__( 'Full Width', 'tripp' ), ) ); } add_filter( 'image_size_names_choose', 'tripp_add_image_size_names' ); /** * Sets the excerpt lenght. * * @param int $length The lenght of post excerpt. * @return int The new value of the excerpt lenght. */ function tripp_excerpt_length( $length ) { return get_option( 'blog_excerpt_length', $length ); } add_filter( 'excerpt_length', 'tripp_excerpt_length' ); /** * Replaces "[...]" (appended to automatically generated excerpts) with ... * * @param string $more_string Default 'more' string. * @return string 'Continue reading' link prepended with an ellipsis. */ function tripp_get_excerpt_more( $more_string = '' ) { $more_string = ' … '; return $more_string; } add_filter( 'excerpt_more', 'tripp_get_excerpt_more' ); /** * Gets the anchor tag attributes for the previous posts page link. * * @param string $attributes Attributes for the anchor tag. * @return string Attributes for the anchor tag. */ function tripp_previous_posts_link_attribute( $attributes = '' ) { $attributes = 'class="prev"'; return $attributes; } 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 '