wp_back/wp-content/themes/simple-theme/author copy 5.php
2024-05-20 15:37:46 +03:00

212 lines
8.0 KiB
PHP

<?php
//author.php
get_header(author);
// get_header( null, [ 'container_class' => 'A value' ] );
if(is_author()){
$author_id = get_the_author_meta('ID');
$author_name = get_the_author_meta('display_name');
$user_nicename = get_the_author_meta('user_nicename');
$author_description = get_the_author_meta('description', $author_id);
$author_avatar = get_avatar_url( $author_id, array(
'size' => 450,
'default'=>'mystery',
));
}
$number_posts = 11;
$offset_posts = (isset($_GET['offset'])) ? $_GET['offset'] : 0;
$search_tags = (isset($_GET['tags'])) ? $_GET['tags'] : [];
$total_blog_posts = wp_count_posts()->publish;
$count_user_posts = count_user_posts( $author_id );
if ($offset_posts < 0) {
$offset_posts = 0;
}
if (($offset_posts + 11) > $total_blog_posts) {
$args = array(
'numberposts' => $number_posts,
'offset' => $total_blog_posts - 11,
);
$offset_posts -= 11;
} else {
$args = array(
'numberposts' => $number_posts,
'offset' => $offset_posts,
);
}
$number_posts = count($posts);
$telegram = get_the_author_meta( 'tumblr', $post->post_author );
$facebook = get_the_author_meta( 'facebook', $post->post_author );
$vk = get_the_author_meta( 'linkedin', $post->post_author );
$instagram = get_the_author_meta( 'instagram', $post->post_author );
$odnoklassniki = get_the_author_meta( 'myspace', $post->post_author );
$author_bio__links_list = '';
if(!empty($telegram)) {
$author_bio__links_list .='
<a href="'. $telegram .'" target="_blank" rel="nofollow" style="text-decoration: none;">
<img height="20" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIiIGhlaWdodD0iMTgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIxLjkzNyAxLjYzOWwtMy4zMiAxNS4yNzRjLS4yNSAxLjA3OC0uOTAzIDEuMzQ3LTEuODMxLjgzOWwtNS4wNTktMy42MzctMi40NCAyLjI5Yy0uMjcuMjY0LS40OTcuNDg0LTEuMDE3LjQ4NGwuMzYzLTUuMDI2IDkuMzc1LTguMjY1Yy40MDgtLjM1NC0uMDg4LS41NS0uNjMzLS4xOTZsLTExLjU5IDcuMTItNC45OS0xLjUyNEMtLjI5MSA4LjY2OC0uMzEgNy45NCAxLjAyIDcuNDMxTDIwLjUzOC4wOTZjLjkwMy0uMzMgMS42OTQuMTk2IDEuNCAxLjU0M3oiIGZpbGw9IiM3MjQ1RkYiIGZpbGwtcnVsZT0ibm9uemVybyIvPjwvc3ZnPg==" alt="telegram">
</a>
';
}
if(!empty($facebook)) {
$author_bio__links_list .='
<a href="'. $facebook .'" rel="nofollow" target="_blank" style="text-decoration: none;">
<img height="20" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxOCAxOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik0xOCAyLjk4NDQ1QzE4IDEuMzk4OTYgMTYuNjAxIDAgMTUuMDE1NSAwSDIuOTg0NDVDMS4zOTg5NiAwIDAgMS4zOTg5NiAwIDIuOTg0NDVWMTUuMDE1NUMwIDE2LjYwMSAxLjM5ODk2IDE4IDIuOTg0NDUgMThIOS4wNDY2M1YxMS4xOTE3SDYuODA4MjlWOC4yMDcyNkg5LjA0NjYzVjYuOTk0ODJDOS4wNDY2MyA0Ljk0MyAxMC41Mzg5IDMuMTcwOTggMTIuNDA0MSAzLjE3MDk4SDE0LjgyOVY2LjE1NTQzSDEyLjQwNDFDMTIuMTI0NCA2LjE1NTQzIDExLjg0NDYgNi40MzUyMyAxMS44NDQ2IDYuOTk0ODJWOC4yMDcyNkgxNC44MjlWMTEuMTkxN0gxMS44NDQ2VjE4SDE1LjAxNTVDMTYuNjAxIDE4IDE4IDE2LjYwMSAxOCAxNS4wMTU1VjIuOTg0NDVaIiBmaWxsPSIjNzI0NUZGIi8+DQo8L3N2Zz4NCg==" alt="facebook">
</a>
';
}
if(!empty($vk)) {
$author_bio__links_list .='
<a href="'. $vk .'" rel="nofollow" target="_blank" style="text-decoration: none;">
<img width="25" src="https://pampadu.ru/_nuxt/img/vk.384e0ec.svg" alt="vk">
</a>
';
}
if(!empty($instagram)) {
$author_bio__links_list .='
<a href="'. $instagram .'" rel="nofollow" target="_blank" style="text-decoration: none;">
<img width="18" src="https://pampadu.ru/_nuxt/img/instagramm.16d5f97.svg" alt="instagramm">
</a>
';
}
if(!empty($odnoklassniki)) {
$author_bio__links_list .='
<a href="'. $odnoklassniki .'" rel="nofollow" target="_blank" style="text-decoration: none;">
<img width="11" src="https://pampadu.ru/_nuxt/img/ok.3c137f5.svg" alt="ok"></a>
';
}
$uri = $_SERVER['REQUEST_URI'];
$host=$_SERVER['HTTP_HOST'];
// $complete_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
//To use whether HTTP OR HTTPS
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === "on"){
$htp = "https";
}else{
$htp = "http";
}
$complete_url = "//".$host.$uri;
var_dump('$uri = ' . $uri);
var_dump('$host = ' . $host);
?>
<div class="author-bio_container ppd-container layout">
<div class="author-bio__img">
<img src="<?php echo $author_avatar; ?>" />
</div>
<div class="author-bio__txt">
<span class="author-bio__name-label">Автор</span>
<h1 class="author-bio__name"><?php echo $author_name; ?></h1>
<p class="author-bio__description"><?php echo $author_description; ?></p>
<?php
if(!empty($author_bio__links_list) ) {
echo '
<div class="author-bio__links">
<p>Соц.сети автора:</p>
<div class="author-bio__links-list">
'.$author_bio__links_list.'
</div>
</div>
';
}
?>
</div>
</div>
<div class="layout ppd-container align-start column_mobile">
<div class="layout blog-tags wrap">
<a href="<?=str_replace("\"", "", "http://pamtest.ru");?>/">
<div id="all" class="blog-tag v-card v-card--link v-sheet theme--light <?php if(!is_tag()):?>active<?php endif;?>">Статьи автора</div>
</a>
<?php $terms = get_tags([]); ?>
<?php if (!empty($terms)) : ?>
<?php foreach ($terms as $term) : ?>
<a tabindex="0" href="<?=str_replace("\"", "", "http://pamtest.ru");?>/tag/<?= $term->slug ?>/">
<div id="<?= $term->slug ?>" class="blog-tag v-card v-card--link v-sheet theme--light <?php if(is_tag($term->slug)):?>active<?php endif;?>"><?= $term->name ?></div>
</a>
<?php endforeach; ?>
<?php endif; ?>
</div>
<div class="layout column align-end links-container" style="min-width: 288px;">
<div class="layout align-center" style="min-width: 288px; height: 36px; margin-left: 12px;">
<div style="font-weight: 500; font-size: 17px; margin-right: 12px;">Мы в соц.сетях</div>
<?php if (have_rows('social_links', 'option')) : ?>
<?php while (have_rows('social_links', 'option')) : the_row(); ?>
<a href="<?= get_sub_field('social_link'); ?>" target="_blank" style="width: 26px; height: 26px; margin: 0px 2px;"><img src="<?= get_sub_field('social_icon')['url'] ?>" style="width: 26px; height: 26px;" alt="logo"></a>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
</div>
<div class="layout ppd-container column">
<?php global $PAGEN; $tag = get_queried_object(); $tag = $tag->slug; ?>
<div class="layout article-cards wrap author-articles" id="articles-container" data-paged="<?php echo $PAGEN; ?>" data-title="Статьи автора <?php echo $author_name; ?>" data-total="<?php echo get_pages_count($tag); ?>">
<?php
$current = absint(
max(
1,
get_query_var( 'paged' ) ? get_query_var( 'paged' ) : get_query_var( 'page' )
)
);
$posts_per_page = 11;
$query = new WP_Query(
[
'post_type' => 'post',
'posts_per_page' => $posts_per_page,
'paged' => $current,
'author' => $author_id,
]
);
if ( $query->have_posts() ) {
?>
<h1>Текущая страница <?php echo absint( $current ); ?></h1>
<?php
while ( $query->have_posts() ) {
$query->the_post();
echo get_template_part('blog-posts/blog-post-small');
echo '<br>';
}
wp_reset_postdata();
echo wp_kses_post(
paginate_links(
[
'total' => $query->max_num_pages,
'current' => $current,
'format' => '?page=%#%',
'base' => 'http://pamtest.ru'. $uri .'%_%',
]
)
);
} else {
global $wp_query;
$wp_query->set_404();
status_header( 404 );
nocache_headers();
require get_404_template();
}
?>
</div>
</div>
<div class="layout ppd-container">
<?php echo '$count_user_posts = ' . $count_user_posts . $user_nicename ; ?>
<?php if ($posts_counter >= $numberposts):?>
<div id="show-more" class="btn show-more" style="align-self: center; margin: 36px auto 60px; width: 213px; text-align: center; cursor: pointer;"><a style="color: #fff !important;" href="">Показать ещё</a></div>
<?php endif;?>
</div>
<?php
get_footer();
?>