PluginProbe
Friends / 2.8.0
Friends v2.8.0
4.3.2 4.3.1 4.3.0 4.2.2 4.2.1 4.2.0 4.1.0 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.0 2.9.1 All 88 releases
friends / templates / frontend / parts / header.php

header.php in Friends 2.8.0, at templates/frontend/parts/header.php

113 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * This template contains the content header part for an article on /friends/.
4 *
5 * @version 1.0
6 * @package Friends
7 */
8
9 $friend_user = $args['friend_user'];
10 $avatar = $args['avatar'];
11 $author_name = $args['friend_user']->display_name;
12
13 /**
14 * Allows overriding the authorname for a post.
15 *
16 * @param string $override_author_name The author name to override with.
17 * @param string $author_name The author name.
18 * @param int $post_id The post ID.
19 *
20 * Example:
21 * ```php
22 * add_filter( 'friends_override_author_name', function( $override_author_name, $author_name, $post_id ) {
23 * if ( ! $override_author_name ) { // Only override if not already overridden.
24 * $override_author_name = get_post_meta( $post_id, 'author', true );
25 * }
26 * return $override_author_name;
27 * }, 10, 3 );
28 * ```
29 */
30 $override_author_name = apply_filters( 'friends_override_author_name', '', $author_name, get_the_id() );
31 ?><header class="entry-header card-header columns">
32 <div class="avatar col-auto mr-2">
33 <?php if ( in_array( get_post_type(), apply_filters( 'friends_frontend_post_types', array() ), true ) ) : ?>
34 <a href="<?php echo esc_attr( $friend_user->get_local_friends_page_url() ); ?>" class="author-avatar">
35 <?php echo get_avatar( $args['friend_user']->user_login, 36 ); ?>
36 </a>
37 <?php else : ?>
38 <a href="<?php echo esc_url( get_the_author_meta( 'url' ) ); ?>" class="author-avatar">
39 <img src="<?php echo esc_url( $avatar ? $avatar : get_avatar_url( get_the_author_meta( 'ID' ) ) ); ?>" width="36" height="36" class="avatar" />
40 </a>
41 <?php endif; ?>
42 </div>
43 <div class="post-meta">
44 <div class="author">
45 <?php if ( in_array( get_post_type(), apply_filters( 'friends_frontend_post_types', array() ), true ) ) : ?>
46 <a href="<?php echo esc_attr( $friend_user->get_local_friends_page_url() ); ?>">
47 <strong><?php echo esc_html( $friend_user->display_name ); ?></strong>
48 <?php if ( $override_author_name && trim( str_replace( $override_author_name, '', $author_name ) ) === $author_name ) : ?>
49 <?php echo esc_html( $override_author_name ); ?>
50 <?php endif; ?>
51 </a>
52 <?php else : ?>
53 <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>">
54 <strong><?php the_author(); ?></strong>
55 </a>
56 <?php endif; ?>
57 </div>
58 <div class="permalink">
59 <?php
60 echo wp_kses(
61 sprintf(
62 // translators: %1$s is a date or relative time, %2$s is a site name or domain.
63 _x( '%1$s on %2$s', 'at-date-on-post', 'friends' ),
64 '<a href="' . esc_attr( $friend_user->get_local_friends_page_url() . get_the_ID() . '/' ) . '" title="' . get_the_time( 'r' ) . '">' .
65 /* translators: %s is a time span */ sprintf( __( '%s ago' ), human_time_diff( get_post_time( 'U', true ) ) ) . // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
66 '</a>',
67 '<a href="' . esc_url( get_the_permalink() ) . '" rel="noopener noreferrer" target="_blank">' . esc_html( parse_url( get_the_permalink(), PHP_URL_HOST ) ) . '</a>'
68 ),
69 array(
70 'a' => array(
71 'href' => array(),
72 'rel' => array(),
73 'target' => array(),
74 'title' => array(),
75 ),
76 )
77 );
78
79 if ( isset( $args['read_time'] ) ) {
80 echo ' <span class="reading-time" title="', esc_html__( 'Estimated reading time', 'friends' ), '">', esc_html(
81 sprintf(
82 // translators: %s is a timeframe, e.g. < 1 min or 2min.
83 __( '%s read', 'friends' ),
84 $args['read_time']
85 )
86 ), '</span>';
87 }
88 ?>
89 </div>
90 </div>
91 <div class="overflow col-ml-auto">
92 <a class="btn btn-link collapse-post" tabindex="0" title="<?php esc_html_e( 'Double or meta/shift/cmd click to toggle all', 'friends' ); ?>">
93 <i class="dashicons dashicons-fullscreen-exit-alt"></i>
94 </a>
95
96 <div class="friends-dropdown friends-dropdown-right">
97 <a class="btn btn-link friends-dropdown-toggle" tabindex="0">
98 <i class="dashicons dashicons-menu-alt2"></i>
99 </a>
100 <ul class="menu" style="min-width: <?php echo esc_attr( intval( _x( '250', 'dropdown-menu-width', 'friends' ) ) ); ?>px">
101 <?php
102 Friends\Friends::template_loader()->get_template_part(
103 'frontend/parts/header-menu',
104 null,
105 $args
106 );
107 ?>
108 </ul>
109 </div>
110
111 </div>
112 </header>
113