PluginProbe
Friends / 4.3.0
Friends v4.3.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 / main-feed-header.php

main-feed-header.php in Friends 4.3.0, at templates/frontend/main-feed-header.php

161 lines 5.9 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 header for the main feed on /friends/.
4 *
5 * @package Friends
6 */
7
8 $data = $args['friends']->get_main_header_data();
9 $hidden_post_count = 0;
10 if ( isset( $data['post_count_by_post_status']->trash ) ) {
11 $hidden_post_count = $data['post_count_by_post_status']->trash;
12 }
13 ?><div id="main-header" class="mb-2">
14 <h2 id="page-title"><a href="<?php echo esc_url( home_url( '/friends/' ) ); ?>">
15 <?php
16 $_title = __( 'Main Feed', 'friends' );
17 switch ( $args['friends']->frontend->post_format ) {
18 case 'standard':
19 $_title = _x( 'Post feed', 'Post format', 'friends' );
20 break;
21 case 'aside':
22 $_title = _x( 'Aside feed', 'Post format', 'friends' );
23 break;
24 case 'chat':
25 $_title = _x( 'Chat feed', 'Post format', 'friends' );
26 break;
27 case 'gallery':
28 $_title = _x( 'Gallery feed', 'Post format', 'friends' );
29 break;
30 case 'link':
31 $_title = _x( 'Link feed', 'Post format', 'friends' );
32 break;
33 case 'image':
34 $_title = _x( 'Image feed', 'Post format', 'friends' );
35 break;
36 case 'quote':
37 $_title = _x( 'Quote feed', 'Post format', 'friends' );
38 break;
39 case 'status':
40 $_title = _x( 'Status feed', 'Post format', 'friends' );
41 break;
42 case 'video':
43 $_title = _x( 'Video feed', 'Post format', 'friends' );
44 break;
45 case 'audio':
46 $_title = _x( 'Audio feed', 'Post format', 'friends' );
47 break;
48 }
49 $_search_term = '';
50 if ( isset( $_GET['s'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
51 $_search_term = sanitize_text_field( wp_unslash( $_GET['s'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
52 $_title = sprintf(
53 // translators: %s is a search term.
54 __( 'Search for "%s"', 'friends' ),
55 esc_html( $_search_term )
56 );
57 }
58
59 if ( $args['friends']->frontend->reaction ) {
60 echo esc_html(
61 sprintf(
62 // translators: %1$s is an emoji reaction, %2$s is a type of feed, e.g. "Main Feed".
63 __( 'My %1$s reactions on %2$s', 'friends' ),
64 $args['friends']->frontend->reaction,
65 $_title
66 )
67 );
68 } elseif ( $args['friends']->frontend->tag ) {
69 echo esc_html(
70 sprintf(
71 // translators: %1$s is a hash tag, %2$s is a type of feed, e.g. "Main Feed".
72 _x( '#%1$s on %2$s', '#tag on feed', 'friends' ),
73 $args['friends']->frontend->tag,
74 $_title
75 )
76 );
77 } else {
78 echo esc_html( $_title );
79 }
80
81 ?>
82 </a></h2>
83
84 <?php if ( $data['description'] ) : ?>
85 <p>
86 <?php
87 echo wp_kses( $data['description'], array( 'a' => array( 'href' => array() ) ) );
88 ?>
89 </p>
90 <?php endif; ?>
91
92 <?php if ( $_search_term ) : ?>
93 <?php
94 $_current_order = isset( $_GET['order'] ) ? strtoupper( sanitize_text_field( wp_unslash( $_GET['order'] ) ) ) : 'DESC'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
95 ?>
96 <a class="chip" href="<?php echo esc_url( remove_query_arg( 's' ) ); ?>">
97 <?php
98 echo esc_html(
99 sprintf(
100 /* translators: %s is the search term */
101 __( 'Clear search for "%s"', 'friends' ),
102 $_search_term
103 )
104 );
105 ?>
106 </a>
107 <?php if ( 'DESC' === $_current_order ) : ?>
108 <a class="chip" href="<?php echo esc_url( add_query_arg( 'order', 'ASC' ) ); ?>">
109 <?php esc_html_e( 'Oldest first', 'friends' ); ?>
110 </a>
111 <?php else : ?>
112 <a class="chip active" href="<?php echo esc_url( add_query_arg( 'order', 'ASC' ) ); ?>">
113 <?php esc_html_e( 'Oldest first', 'friends' ); ?>
114 </a>
115 <a class="chip" href="<?php echo esc_url( remove_query_arg( 'order' ) ); ?>">
116 <?php esc_html_e( 'Newest first', 'friends' ); ?>
117 </a>
118 <?php endif; ?>
119 <a class="chip" href="<?php echo esc_url( home_url( '/friends/add-friend/' ) ); ?>"><?php echo esc_html__( 'Add Friend', 'friends' ); ?></a>
120 <a class="chip toggle-compact" href=""><?php echo esc_html( 'collapsed' === $args['frontend_default_view'] ? __( 'Expanded mode', 'friends' ) : __( 'Compact mode', 'friends' ) ); ?></a>
121 <?php else : ?>
122 <?php foreach ( $data['post_count_by_post_format'] as $post_format => $count ) : ?>
123 <a class="chip post-count-<?php echo esc_attr( $post_format ); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'friends_post_counts' ) ); ?>" href="<?php echo esc_url( home_url( '/friends/type/' . $post_format . '/' ) ); ?>"><?php echo esc_html( $args['friends']->get_post_format_plural_string( $post_format, $count ) ); ?></a>
124 <?php endforeach; ?>
125
126 <?php if ( isset( $_GET['show-hidden'] ) ) : // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>
127 <a class="chip" href="<?php echo esc_attr( remove_query_arg( 'show-hidden' ) ); ?>">
128 <?php echo esc_html__( 'Hide hidden items', 'friends' ); ?>
129 </a>
130 <?php elseif ( $hidden_post_count > 0 ) : ?>
131 <a class="chip" href="<?php echo esc_attr( add_query_arg( 'show-hidden', 1 ) ); ?>">
132 <?php echo esc_html( sprintf( /* translators: %s is the number of hidden posts */_n( '%s hidden items', '%s hidden items', $hidden_post_count, 'friends' ), number_format_i18n( $hidden_post_count ) ) ); ?>
133 </a>
134 <?php elseif ( $hidden_post_count ) : ?>
135 <a class="chip post-count-trash" href="<?php echo esc_attr( add_query_arg( 'show-hidden', 1 ) ); ?>">
136 <?php echo esc_html( sprintf( /* translators: %s is the number of hidden posts */_n( '%s hidden items', '%s hidden items', $hidden_post_count, 'friends' ), $hidden_post_count ) ); ?>
137 </a>
138 <?php endif; ?>
139
140
141 <?php foreach ( Friends\Reactions::get_available_emojis() as $slug => $reaction ) : ?>
142 <a class="chip" href="<?php echo esc_url( home_url( '/friends/reaction' . $slug . '/' ) ); ?>">
143 <?php
144 echo esc_html(
145 sprintf(
146 // translators: %s is an emoji.
147 __( 'Reacted with %s', 'friends' ),
148 $reaction->char
149 )
150 );
151 ?>
152 </a>
153 <?php endforeach; ?>
154
155 <a class="chip" href="<?php echo esc_url( home_url( '/friends/add-friend/' ) ); ?>"><?php echo esc_html__( 'Add Friend', 'friends' ); ?></a>
156 <a class="chip toggle-compact" href=""><?php echo esc_html( 'collapsed' === $args['frontend_default_view'] ? __( 'Expanded mode', 'friends' ) : __( 'Compact mode', 'friends' ) ); ?></a>
157 <?php endif; ?>
158
159 <?php do_action( 'friends_main_feed_header', $args ); ?>
160 </div>
161