| 1 |
<?php |
| 2 |
/** |
| 3 |
* Mastodon theme: page header with 3-column layout. |
| 4 |
* |
| 5 |
* @package Friends |
| 6 |
*/ |
| 7 |
|
| 8 |
$_search = ''; |
| 9 |
if ( isset( $_GET['s'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 10 |
$_search = sanitize_text_field( wp_unslash( $_GET['s'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 11 |
} |
| 12 |
|
| 13 |
add_filter( |
| 14 |
'document_title_parts', |
| 15 |
function ( $title ) use ( $args ) { |
| 16 |
if ( isset( $args['title'] ) ) { |
| 17 |
$title['title'] = $args['title']; |
| 18 |
} |
| 19 |
return $title; |
| 20 |
} |
| 21 |
); |
| 22 |
|
| 23 |
$mastodon_current_user = wp_get_current_user(); |
| 24 |
|
| 25 |
?><!DOCTYPE html> |
| 26 |
<html <?php language_attributes(); ?> class="no-js no-svg"> |
| 27 |
<head> |
| 28 |
<meta charset="<?php bloginfo( 'charset' ); ?>"> |
| 29 |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
| 30 |
<meta name="color-scheme" content="light dark"> |
| 31 |
<?php wp_head(); ?> |
| 32 |
</head> |
| 33 |
|
| 34 |
<body <?php body_class(); ?>> |
| 35 |
|
| 36 |
<!-- Left column: user info + search --> |
| 37 |
<aside class="mastodon-left-col"> |
| 38 |
<a class="mastodon-user-card" href="<?php echo esc_url( home_url( '/friends/' ) ); ?>"><?php echo get_avatar( $mastodon_current_user->ID, 46, '', '', array( 'class' => 'mastodon-avatar' ) ); ?><div class="mastodon-user-info"> |
| 39 |
<strong class="mastodon-display-name"><?php echo esc_html( $mastodon_current_user->display_name ); ?></strong> |
| 40 |
<span class="mastodon-handle">@<?php echo esc_html( $mastodon_current_user->user_login ); ?></span> |
| 41 |
</div></a> |
| 42 |
<form method="post" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" class="mastodon-compose-form friends-post-inline"> |
| 43 |
<?php wp_nonce_field( 'friends_publish' ); ?> |
| 44 |
<input type="hidden" name="action" value="friends_publish" /> |
| 45 |
<input type="hidden" name="format" value="<?php echo esc_attr( get_option( 'friends_compose_post_format', 'status' ) ); ?>" /> |
| 46 |
<textarea name="content" rows="4" placeholder="<?php echo esc_attr( sprintf( /* translators: %s is the user's display name */ __( "What's on your mind, %s?", 'friends' ), $mastodon_current_user->display_name ) ); ?>"></textarea> |
| 47 |
<div class="mastodon-compose-footer"> |
| 48 |
<a href="<?php echo esc_url( admin_url( 'admin.php?page=friends-settings#compose' ) ); ?>" class="mastodon-compose-settings" title="<?php esc_attr_e( 'Compose settings', 'friends' ); ?>"><span class="dashicons dashicons-admin-generic"></span></a> |
| 49 |
<button type="submit" class="mastodon-compose-submit"><?php esc_html_e( 'Post', 'friends' ); ?></button> |
| 50 |
</div> |
| 51 |
</form> |
| 52 |
<form class="mastodon-search-form form-autocomplete" action="<?php echo esc_url( home_url( '/friends/' ) ); ?>"> |
| 53 |
<div class="form-autocomplete-input mastodon-search-wrap"> |
| 54 |
<input class="mastodon-search-input master-search" type="text" name="s" placeholder="<?php /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ esc_attr_e( 'Search or paste URL' ); ?>" value="<?php echo esc_attr( $_search ); ?>" autocomplete="off" data-nonce="<?php echo esc_attr( wp_create_nonce( 'friends-autocomplete' ) ); ?>" id="master-search" /> |
| 55 |
<i class="form-icon"></i> |
| 56 |
</div> |
| 57 |
<ul class="menu" style="display: none"></ul> |
| 58 |
</form> |
| 59 |
</aside> |
| 60 |
|
| 61 |
<!-- Center column: timeline (left open, footer closes it) --> |
| 62 |
<div class="mastodon-center-col"> |
| 63 |
<details class="mastodon-mobile-panel"> |
| 64 |
<summary class="mastodon-mobile-panel-toggle"> |
| 65 |
<?php echo get_avatar( $mastodon_current_user->ID, 32, '', '', array( 'class' => 'mastodon-avatar' ) ); ?> |
| 66 |
<span><?php echo esc_html( $mastodon_current_user->display_name ); ?></span> |
| 67 |
<i class="dashicons dashicons-arrow-down-alt2"></i> |
| 68 |
</summary> |
| 69 |
<div class="mastodon-mobile-panel-content"> |
| 70 |
<form method="post" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" class="mastodon-compose-form friends-post-inline"> |
| 71 |
<?php wp_nonce_field( 'friends_publish' ); ?> |
| 72 |
<input type="hidden" name="action" value="friends_publish" /> |
| 73 |
<input type="hidden" name="format" value="<?php echo esc_attr( get_option( 'friends_compose_post_format', 'status' ) ); ?>" /> |
| 74 |
<textarea name="content" rows="3" placeholder="<?php echo esc_attr( sprintf( /* translators: %s is the user's display name */ __( "What's on your mind, %s?", 'friends' ), $mastodon_current_user->display_name ) ); ?>"></textarea> |
| 75 |
<div class="mastodon-compose-footer"> |
| 76 |
<a href="<?php echo esc_url( admin_url( 'admin.php?page=friends-settings#compose' ) ); ?>" class="mastodon-compose-settings" title="<?php esc_attr_e( 'Compose settings', 'friends' ); ?>"><span class="dashicons dashicons-admin-generic"></span></a> |
| 77 |
<button type="submit" class="mastodon-compose-submit"><?php esc_html_e( 'Post', 'friends' ); ?></button> |
| 78 |
</div> |
| 79 |
</form> |
| 80 |
<form class="mastodon-search-form form-autocomplete" action="<?php echo esc_url( home_url( '/friends/' ) ); ?>"> |
| 81 |
<div class="form-autocomplete-input mastodon-search-wrap"> |
| 82 |
<input class="mastodon-search-input master-search" type="text" name="s" placeholder="<?php /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ esc_attr_e( 'Search or paste URL' ); ?>" value="<?php echo esc_attr( $_search ); ?>" autocomplete="off" data-nonce="<?php echo esc_attr( wp_create_nonce( 'friends-autocomplete' ) ); ?>" /> |
| 83 |
<i class="form-icon"></i> |
| 84 |
</div> |
| 85 |
<ul class="menu" style="display: none"></ul> |
| 86 |
</form> |
| 87 |
</div> |
| 88 |
</details> |
| 89 |
<div class="mastodon-col-header<?php echo is_single() ? ' is-single' : ''; ?>"> |
| 90 |
<div class="mastodon-col-title-row"> |
| 91 |
<?php |
| 92 |
if ( $args['friend_user'] && $args['friend_user'] instanceof Friends\User && is_singular() ) { |
| 93 |
Friends\Friends::template_loader()->get_template_part( |
| 94 |
'frontend/single-header', |
| 95 |
$args['post_format'], |
| 96 |
$args |
| 97 |
); |
| 98 |
} elseif ( $args['friend_user'] && $args['friend_user'] instanceof Friends\User ) { |
| 99 |
echo '<h2 id="page-title"><a href="' . esc_url( $args['friend_user']->get_local_friends_page_url() ) . '">'; |
| 100 |
if ( $args['friend_user']->get_avatar_url() ) { |
| 101 |
echo '<img src="' . esc_url( $args['friend_user']->get_avatar_url() ) . '" width="24" height="24" class="mastodon-title-avatar" /> '; |
| 102 |
} |
| 103 |
echo esc_html( $args['friend_user']->display_name ); |
| 104 |
echo '</a></h2>'; |
| 105 |
} elseif ( isset( $args['title'] ) ) { |
| 106 |
echo '<h2 id="page-title"><a href="' . esc_url( home_url( '/friends/' ) ) . '">' . esc_html( $args['title'] ) . '</a></h2>'; |
| 107 |
} else { |
| 108 |
$_title = __( 'Home', 'friends' ); |
| 109 |
echo '<h2 id="page-title"><a href="' . esc_url( home_url( '/friends/' ) ) . '">' . esc_html( $_title ) . '</a></h2>'; |
| 110 |
} |
| 111 |
?> |
| 112 |
<a class="off-canvas-toggle" href="#friends-sidebar" aria-label="<?php esc_attr_e( 'Open sidebar', 'friends' ); ?>"><i class="dashicons dashicons-menu"></i></a> |
| 113 |
</div> |
| 114 |
<?php if ( ! is_single() && empty( $args['no-bottom-margin'] ) ) : ?> |
| 115 |
<div class="mastodon-chips-area"> |
| 116 |
<?php |
| 117 |
if ( $args['friend_user'] && $args['friend_user'] instanceof Friends\User ) { |
| 118 |
Friends\Friends::template_loader()->get_template_part( |
| 119 |
'frontend/author-header', |
| 120 |
$args['post_format'], |
| 121 |
$args |
| 122 |
); |
| 123 |
} else { |
| 124 |
Friends\Friends::template_loader()->get_template_part( |
| 125 |
'frontend/main-feed-header', |
| 126 |
$args['post_format'], |
| 127 |
$args |
| 128 |
); |
| 129 |
} |
| 130 |
?> |
| 131 |
</div> |
| 132 |
<?php endif; ?> |
| 133 |
</div> |
| 134 |
|
| 135 |
<?php do_action( 'friends_after_header', $args ); ?> |
| 136 |
|