-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsingle-profile.php
169 lines (148 loc) · 5.4 KB
/
single-profile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php
/**
* The template for displaying all single posts.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package shiro
*/
use WMF\Images\Credits;
get_header();
while ( have_posts() ) :
the_post();
?>
<?php
$roles = get_the_terms( get_the_ID(), 'role' );
$default_heading = get_theme_mod( 'wmf_related_profiles_heading', __( 'Other members of ', 'shiro-admin' ) );
$team_name = '';
$parent_name = $roles[0]->name;
$parent_link = get_term_link( $roles[0] );
$connected_user = get_post_meta( get_the_ID(), 'connected_user', true );
if ( ! empty( $roles ) && ! is_wp_error( $roles ) ) {
$team_name = $roles;
$ancestors = get_ancestors( $roles[0]->term_id, 'role' );
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$referer_id = isset( $_GET['referer'] ) ? absint( $_GET['referer'] ) : null;
$referer_link = get_term_link( $referer_id );
// Check if referer query parameter is set to determine $parent_id before lookup for ancestors.
if ( ! empty( $referer_link ) && ! is_wp_error( $referer_link ) ) {
$parent_id = $referer_id;
} else {
$parent_id = is_array( $ancestors ) ? end( $ancestors ) : false;
}
if ( $parent_id ) {
$parent_term = get_term( $parent_id );
$parent_name = $parent_term->name;
$parent_link = get_term_link( $parent_id );
}
}
get_template_part(
'template-parts/header/profile',
'single',
array(
'back_to_link' => $parent_link,
'back_to_label' => $parent_name,
'role' => get_post_meta( get_the_ID(), 'profile_role', true ),
'team_name' => $team_name,
'share_links' => get_post_meta( get_the_ID(), 'contact_links', true ),
)
);
$share_links = get_post_meta( get_the_ID(), 'contact_links', true );
?>
<div class="mw-980 mar-bottom">
<div class="flex flex-medium flex-space-between mar-bottom_lg">
<div class="w-48p">
<?php
get_template_part(
'template-parts/thumbnail',
'framed',
array(
'inner_image' => get_post_thumbnail_id( get_the_ID() ),
'container_class' => '',
)
);
?>
<?php if ( ! empty( $share_links ) || ! empty( $connected_user ) ) : ?>
<div class="rise-up side-list">
<?php if ( ! empty( $share_links ) ) : ?>
<?php
foreach ( $share_links as $link ) :
if ( empty( $link['link'] ) ) {
continue;
}
?>
<div class="link-list mar-right">
<?php
// Avoid undefined array index warnings.
$link['link'] = $link['link'] ?? '';
$link['title'] = $link['title'] ?? '';
$img = '';
if ( is_int( strpos( $link['link'], 'meta.wikimedia.org' ) ) ) {
$img = get_template_directory_uri() . '/assets/src/svg/globe.svg';
}
if ( is_int( strpos( $link['link'], 'mailto' ) ) ) {
$img = get_template_directory_uri() . '/assets/src/svg/email.svg';
}
if ( is_int( strpos( $link['link'], 'wikipedia.org' ) ) ) {
$img = get_template_directory_uri() . '/assets/src/svg/individual/wikipedia.svg';
}
if ( is_int( strpos( $link['link'], '/news/' ) ) ) {
$img = get_template_directory_uri() . '/assets/src/svg/individual/wikimedia-blue.svg';
}
?>
<div class="bold profile-contacts">
<?php if ( isset( $link['link'] ) ) : ?>
<a href="<?php echo strpos( $link['link'], 'mailto' ) !== false ? esc_url( 'mailto:' . antispambot( str_replace( 'mailto:', '', $link['link'] ) ) ) : esc_url( $link['link'] ); ?>">
<?php endif; ?>
<img src="<?php echo esc_url( $img ); ?>" alt="">
<?php echo esc_html( $link['title'] ); ?>
<?php if ( isset( $link['link'] ) ) : ?>
</a>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
<?php if ( ! empty( $connected_user ) ) : ?>
<?php
$authorimg = get_template_directory_uri() . '/assets/src/svg/edit-ltr.svg';
if ( is_rtl() ) {
$authorimg = get_template_directory_uri() . '/assets/src/svg/edit-rtl.svg';
}
$authorlink = wmf_get_author_link( $connected_user );
$authorlinkcopy = sprintf( /* translators: 1. post title */ __( 'Posts by %s', 'shiro' ), get_the_title() );
?>
<div class="link-list mar-right">
<div class="bold profile-contacts">
<a href="/news/author/<?php echo esc_attr( $authorlink ); ?>">
<img src="<?php echo esc_url( $authorimg ); ?>" alt="">
<?php echo esc_html( $authorlinkcopy ); ?>
</a>
</div>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<div class="w-50p">
<div class="article-main mod-margin-bottom wysiwyg">
<?php the_content(); ?>
</div>
</div>
</div>
</div>
<?php
get_template_part( 'template-parts/page/page', 'offsite-links' );
Credits::get_instance()->pause();
$template_args = get_post_meta( get_the_ID(), 'profiles', true );
if ( ! is_array( $template_args ) ) {
$template_args = [];
}
$template_args['profiles_list'] = wmf_get_related_profiles( get_the_ID() );
$template_args['headline'] = ! empty( $template_args['headline'] ) ? $template_args['headline'] : $default_heading . $roles[0]->name;
get_template_part( 'template-parts/modules/profiles/list', null, $template_args );
endwhile;
Credits::get_instance()->resume();
get_template_part( 'template-parts/page/page', 'listings' );
get_template_part( 'template-parts/profiles/related-posts' );
get_footer();