post_parent ) && (int) $image->post_parent !== (int) $id ) { $url .= '#main'; } return $url; } add_filter( 'attachment_link', __NAMESPACE__ . '\enhanced_image_navigation', 10, 2 ); /** * Filters wp_title to print a neat tag based on what is being viewed. */ function wp_title( string $title, string $sep ): string { global $page, $paged; $title = apply_filters( 'o2_page_title', $title ); if ( is_feed() ) { return $title; } // Normalize to avoid double-hashed tags. if ( is_tag() ) { $title = '#' . ltrim( $title, '#' ); } // Add separator if needed. $title = rtrim( $title ); if ( $title && strcmp( mb_substr( $title, -1 ), $sep ) ) { $title .= " $sep"; } $title .= ' '; // Add the blog name. $title .= get_bloginfo( 'name' ); // Add a page number if necessary: if ( $paged >= 2 || $page >= 2 ) { /* translators: %s is replaced with the page number */ $title .= " $sep " . sprintf( __( 'Page %s', 'p2020' ), max( $paged, $page ) ); } return $title; } add_filter( 'wp_title', __NAMESPACE__ . '\wp_title', 10, 2 ); /** * Auto subscribe author to their post/comments (check the hidden o2 checkbox) */ add_filter( 'subscribe_author_to_comments_override', '__return_true' ); add_filter( 'subscribe_to_comments_override', '__return_true' ); /** * Get post thumbnail if it exists. * * @return string */ function page_cover_image() { $featured_image = get_the_post_thumbnail(); if ( $featured_image ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo Shared\html_output( "<figure class='p2020-page-cover'>$featured_image</figure>" ); } } /** * Hide inherited app controls */ function filter_app_controls() { // hide not used app controls. return array(); } add_filter( 'o2_app_controls', __NAMESPACE__ . '\filter_app_controls' ); function update_search_o2_options( $o2_options ) { global $wp_query; if ( ! is_search() ) { return $o2_options; } // translators: number of posts. $o2_options['options']['pageTitle'] = sprintf( _x( '%d results', 'number of found search results', 'p2020' ), $wp_query->found_posts ); $o2_options['options']['showAvatars'] = false; return $o2_options; } add_filter( 'o2_options', __NAMESPACE__ . '\update_search_o2_options' ); function add_search_post_date( $fragment, $post_id ) { if ( ! is_search() ) { return $fragment; } $post = get_post( $post_id ); $timestamp = strtotime( $post->post_date_gmt ); $fragment['dateString'] = sprintf( '%d › %d › %d › %s', gmdate( 'Y', $timestamp ), gmdate( 'm', $timestamp ), gmdate( 'd', $timestamp ), $post->post_name ); return $fragment; } add_filter( 'o2_post_fragment', __NAMESPACE__ . '\add_search_post_date', 10, 2 );