<?php

if (!defined('ABSPATH')) {
  exit; // Exit if accessed directly.
}

if (function_exists('YoastSEO')) {
    $title = YoastSEO()->meta->for_current_page()->title;
} else {
    $title = get_the_title();
}

global $PAGEN; 
$PAGEN = filter_var ($_REQUEST["PAGEN"], FILTER_SANITIZE_STRING) ? filter_var ($_REQUEST["PAGEN"], FILTER_SANITIZE_STRING) : 1; 
$author_id = get_the_author_meta('ID');
$count_user_posts = count_user_posts( $author_id );
$have_more_posts = ($PAGEN * 11) < $count_user_posts ? true : false; 
?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
    <title><?php echo $title; ?><?php if ($PAGEN > 1) echo ". Страница " . $PAGEN; ?></title>
    <script>console.log('title', document.title);</script>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta charset="UTF-8">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
  <link rel="profile" href="http://gmpg.org/xfn/11">
  <link rel="shortcut icon" href="<?php tUrl(); ?>/img/favicon.png" />
	

  <link rel="icon" href="https://pampadu.ru/favicon.ico">
  <link rel="icon" type="image/png" href="https://pampadu.ru/favicon.png">

<?php
    $url = $_SERVER[REQUEST_URI];
     
    $tag = get_queried_object(); 
    $tag = $tag->slug; 
    $total_pages = get_pages_count($tag);
    $author_slug = get_the_author_meta('user_nicename'); 

?>

<?php if ($have_more_posts) {
    ?>
        <link id="rel_next" rel="next" href="https://pampadu.ru/blog/author/<?php echo $author_slug ?>/?PAGEN=<?php echo $PAGEN + 1; ?>">
    <?php
}
?>

<?php if ($PAGEN >= 2 ) { 
    $suffix = str_replace("//", "/", $suffix); ?>
    <link id="rel_prev" rel="prev" href="https://pampadu.ru/blog/author/<?php echo $author_slug ?>/?PAGEN=<?php echo $PAGEN - 1; ?>"><?php 
    } 
    ?>

  <script src="<?= get_template_directory_uri() ?>/js/app.js" async></script>
  <?php wp_head(); ?>
    <!-- Google Tag Manager -->
    <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
                new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
            j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
            'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
        })(window,document,'script','dataLayer','GTM-P5DVMNZ');</script>
    <!-- End Google Tag Manager -->

    <!-- Google Tag Manager -->
    <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
                new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
            j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
            'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
        })(window,document,'script','dataLayer','GTM-TH2Z6M2');</script>
    <!-- End Google Tag Manager -->

    <!--TikTok-->
    <script>
        !function (w, d, t) {
            w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=["page","track","identify","instances","debug","on","off","once","ready","alias","group","enableCookie","disableCookie"],ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.instance=function(t){for(var e=ttq._i[t]||[],n=0;n<ttq.methods.length;n++)ttq.setAndDefer(e,ttq.methods[n]);return e},ttq.load=function(e,n){var i="https://analytics.tiktok.com/i18n/pixel/events.js";ttq._i=ttq._i||{},ttq._i[e]=[],ttq._i[e]._u=i,ttq._t=ttq._t||{},ttq._t[e]=+new Date,ttq._o=ttq._o||{},ttq._o[e]=n||{};var o=document.createElement("script");o.type="text/javascript",o.async=!0,o.src=i+"?sdkid="+e+"&lib="+t;var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(o,a)};

            ttq.load('C0UGCH1URMH959SC3RDG');
            ttq.page();
        }(window, document, 'ttq');
    </script>
    <!--TikTok-->
    <!-- Global site tag (gtag.js) - Google Analytics  NEW -->
    <script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-153452091-1"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag() {
            dataLayer.push(arguments);
        }
        gtag('js', new Date());
        gtag('config', 'UA-153452091-1');
        gtag('config', 'AW-713051355');
    </script>
    <!-- /Google Analytics -->


    <!-- Google Analytics  OLD-->
    <script>
        (function (i, s, o, g, r, a, m) {
            i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
                (i[r].q = i[r].q || []).push(arguments)
            }, i[r].l = 1 * new Date(); a = s.createElement(o),
                m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
        })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

        ga('create', 'UA-153452091-1', 'auto');

        ga(function (tracker) {
            var clientId = tracker.get('clientId'); // получаем clientId из Google Analytics
            document.cookie = "_ga_cid=" + clientId + "; path=/"; // сохраняем cookie в _ga_cid
            ga('set', 'dimension1', clientId); // записываем clientId пользователя в параметр
        });

        ga('send', 'pageview');
    </script>

    <!-- /Google Analytics -->
    <script>
        function gtag_report_conversion(url) {
            var callback = function () {};
            gtag('event', 'conversion', { 'send_to': 'AW-842331931/0xX4CNjWqbcBENuZgdQC', 'event_callback': callback });
            return false;
        }
    </script>
    <!-- /gtag -->
</head>

<body>

    <noscript>
        <iframe src="https://www.googletagmanager.com/ns.html?id=GTM-P5DVMNZ" height="0" width="0" style="display:none;visibility:hidden"></iframe>
    </noscript>

    <!-- Google Tag Manager (noscript) -->
    <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TH2Z6M2"
                      height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    <!-- End Google Tag Manager (noscript) -->


<div class="i-body theme--light v-application v-application--is-ltr">
  <div class="v-application--wrap">
    <?php
    // body_class();
    get_template_part('template-parts/header');
	   echo '<div style="margin-top: 201px;position: fixed;z-index: 9999;">';
    if ($have_more_posts) {
        ?>
            next
        <?php
    }
    ?>
    
    <?php if ($PAGEN >= 2 ) { ?>
      prev
      <?php 
        } 
    
	  echo '</div>';
    ?>

    <div class="content-wrapper">

      <?php