| Server IP : 127.0.0.1 / Your IP : 216.73.216.109 Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10 System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64 User : SERVERWEB ( 0) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/laragon/www/modules/prensa/ |
Upload File : |
<?php
include(__DIR__ . '/../../app/prensa.php');
function fetchPosts($url) {
return decode_api($url);
}
$catList = getList("categories");
$userList = getListC("users");
$noticias = [];
$itemsPerPage = 5;
$totalPages ="1";
$currentPage = isset($_POST['page']) ? max(1, intval($_POST['page'])) : 1;
// if (isset($_POST['page'])) {
// $currentPage = max(1, intval($_POST['page']));
// }
$params = [
'per_page' => $itemsPerPage,
'page' => $currentPage,
];
$category = isset($_POST['category']) ? $_POST['category'] : null;
if ($category !== null) {
$categoryId = find_wp_category_id($category, $catList);
if ($categoryId !== null) {
$params['categories'] = $categoryId;
}
}
$author = isset($_POST['author']) ? $_POST['author'] : null;
if ($author !== null) {
$params['author'] = $author;
}
$url = wp_posts_url($params);
$noticias = fetchPosts($url);
$totalPages = wp_api_last_total_pages(1);
function news_page_url($page, $category = null) {
$query = ['page' => (int) $page];
if ($category !== null && $category !== '') {
$query['category'] = $category;
}
return '/pages/news.html?' . http_build_query($query);
}
?>
<div class="section ">
<div class="section_wrapper clearfix">
<?php if($category==null ): ?>
<div class="column one column_fancy_heading">
<div class="fancy_heading fancy_heading_icon">
<h2 class="title">Ultimas Publicaciones</h2>
</div>
</div>
<?php endif?>
<div class="column one column_blog">
<div class="blog_wrapper isotope_wrapper">
<div class="posts_group lm_wrapper timeline">
<?php
foreach($noticias as $post){
$content = $post['content']['rendered'];
$firstImageURL = $firstDocURL = $firstVideoURL = null;
$postTitle = strip_tags($post['title']['rendered'] ?? '');
$postLink = $post['link'] ?? '#';
$firstImageURL = wp_post_featured_image_url($post, false);
if (preg_match('/<a[^>]+href="([^"]+\.pdf)"/i', $content, $matches)) {
$pdfUrl = $matches[1];
$firstDocURL = wp_secure_media_url($matches[1]);
}
foreach ($userList as $authorData) {
if ($authorData['id'] == $post['author']) {
$author = $authorData;
break;
}
}
$categories = [];
foreach ($catList as $cat) {
if(!empty($post['categories'])){
foreach ($post['categories'] as $catPost) {
if ($cat['id'] == $catPost) {
$categories[] = $cat;
if($cat['id']==26 && empty($firstImageURL)){
$firstImageURL="/assets/images/content/news/leyes.jpg";}
}
} }
}
?>
<?php if(!empty($firstImageURL) || !empty($firstDocURL)){ ?>
<div class="post format-image has-post-thumbnail category-motion category-photography post-item isotope-item clearfix">
<div class="date_label">
<?php echo date("d-m-Y", strtotime($post['date_gmt']));?>
</div>
<div class="image_frame post-photo-wrapper scale-with-grid">
<div class="image_wrapper">
<div class="mask"></div>
<?php if(!empty($firstImageURL)){?>
<a href="<?= $postLink ?>">
<img width="576" height="750" src="<?= htmlspecialchars($firstImageURL) ?>" class="scale-with-grid wp-post-image" loading="lazy" decoding="async" />
</a>
<div class="image_links double">
<a href="<?= $firstImageURL ?>" class="zoom" rel="prettyphoto"><i class="icon-search"></i></a>
<a href="<?= $postLink ?>" class="link"><i class="icon-link"></i></a>
</div>
<?php }else if(!empty($firstDocURL)){?>
<object class="wp-block-file__embed" data="<?=$firstDocURL?>" style="width:100%;height:600px" aria-label="Incrustado de Carta-de-Inscripcion."></object>
<?php }?>
</div>
</div>
<div class="post-desc-wrapper">
<div class="post-desc">
<div class="post-meta clearfix">
<div class="author-date">
<span class="author"><span>Publicado por </span>
<i class="icon-user"></i> <a href="#"><?= $author['name'] ?></a>
</span>
<span class="date"><span> Fecha </span><i class="icon-clock"></i>
<?php echo date("d-m-Y", strtotime($post['date_gmt']));?>
</span>
</div>
<div class="category">
<span class="cat-btn">Categoría <i class="icon-down-dir"></i></span>
<div class="cat-wrapper">
<ul class="post-categories">
<?php foreach($categories as $cat){?>
<li>
<a href="<?= $cat['link']?>" rel="category tag"><?= $cat['name']?></a>
</li>
<?php }?>
</ul>
</div>
</div>
</div>
<div class="post-title">
<h3 class="entry-title">
<a href="<?= $postLink ?>"><?= $post['title']['rendered'] ?></a>
</h3>
</div>
<div class="post-excerpt">
<p>
<?= $post['excerpt']['rendered'] ?>
</p>
</div>
<div class="post-footer">
<div class="button-love">
<span class="love-text">Compartir : </span>
</div>
<div class="button-love">
<a href="https://www.facebook.com/sharer/sharer.php?u=<?= urlencode($postLink) ?>" class="icon_bar icon_bar_facebook icon_bar_small">
<span class="t"><i class="icon-facebook"></i></span><span class="b"><i class="icon-facebook"></i></span></a>
<a href="https://twitter.com/intent/tweet?url=<?= urlencode($postLink) ?>&text=<?= urlencode('Leer Publicacion: ' . $postTitle) ?>" class="icon_bar icon_bar_twitter icon_bar_small">
<span class="t"><i class="icon-twitter"></i></span><span class="b"><i class="icon-twitter"></i></span></a>
<a href="whatsapp://send?text=<?= urlencode('Visita - ' . $postLink) ?>" class="icon_bar icon_bar_whatsaap icon_bar_small">
<span class="t"><i class="icon-comment-line"></i></span><span class="b"><i class="icon-comment-line"></i></span></a>
</div>
<div class="post-links">
<!-- <i class="icon-comment-empty-fa"></i>
<a href="blog-single-content-builder.html#comments" class="post-comments"></a> -->
<i class="icon-doc-text"></i>
<a href="<?= $postLink ?>" class="post-more">Leer más...</a>
</div>
</div>
</div>
</div>
</div>
<?php } else if(!empty($firstVideoURL)){?>
<div class="post format-video has-post-thumbnail category-mobile category-photography tag-css3 tag-zend post-item isotope-item clearfix">
<div class="date_label">
<?php echo date("d-m-Y", strtotime($post['date_gmt']));?>
</div>
<div class="image_frame post-photo-wrapper scale-with-grid">
<div class="image_wrapper">
<div id="jp_container_102" class="jp-video mfn-jcontainer">
<div class="jp-type-single">
<div id="jquery_jplayer_102" class="jp-jplayer mfn-jplayer" data-m4v="<?= $firstVideoURL ?>" data-img="images/blog_html5-576x399.jpg">
</div>
<div class="jp-gui">
<div class="jp-video-play">
<a href="javascript:;" class="jp-video-play-icon" tabindex="1">play</a>
</div>
<div class="jp-interface">
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-current-time"></div>
<div class="jp-duration"></div>
<div class="jp-controls-holder">
<ul class="jp-controls">
<li>
<a href="javascript:;" class="jp-play" tabindex="1">play</a>
</li>
<li>
<a href="javascript:;" class="jp-pause" tabindex="1">pause</a>
</li>
<li>
<a href="javascript:;" class="jp-stop" tabindex="1">stop</a>
</li>
<li>
<a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a>
</li>
<li>
<a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a>
</li>
<li>
<a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a>
</li>
</ul>
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
<ul class="jp-toggles">
<li>
<a href="javascript:;" class="jp-full-screen" tabindex="1" title="full screen">full screen</a>
</li>
<li>
<a href="javascript:;" class="jp-restore-screen" tabindex="1" title="restore screen">restore screen</a>
</li>
<li>
<a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat">repeat</a>
</li>
<li>
<a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off">repeat off</a>
</li>
</ul>
</div>
<div class="jp-title">
<ul>
<li>
<a href="<?= $post['link'] ?>"><?= $post['title']['rendered'] ?></a>
</li>
</ul>
</div>
</div>
</div>
<div class="jp-no-solution">
<span>Update Required</span>To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>
</div>
</div>
</div>
</div>
</div>
<div class="post-desc-wrapper">
<div class="post-desc">
<div class="post-meta clearfix">
<div class="author-date">
<span class="author">
<span>Publicado por </span>
<i class="icon-user"></i> <a href="#"><?= $author['name'] ?></a>
</span>
<span class="date"><span>
Fecha </span><i class="icon-clock"></i>
<?php echo date("d-m-Y", strtotime($post['date_gmt']));?>
</span>
</div>
<div class="category">
<span class="cat-btn">Categoría <i class="icon-down-dir"></i></span>
<div class="cat-wrapper">
<ul class="post-categories">
<?php foreach($categories as $cat){?>
<li>
<a href="<?= $cat['link']?>" rel="category tag"><?= $cat['name']?></a>
</li>
<?php }?>
</ul>
</div>
</div>
</div>
<div class="post-title">
<h2 class="entry-title">
<a href="<?= $post['link'] ?>"><?= $post['title']['rendered'] ?></a>
</a></h2>
</div>
<div class="post-excerpt">
<span class="big">
<?= $post['excerpt']['rendered'] ?>
</span>
</div>
<div class="post-footer">
<div class="post-links">
<i class="icon-doc-text"></i>
<a href="<?= $post['link'] ?>" class="post-more">Leer más...</a>
</div>
</div>
</div>
</div>
</div>
<?php }else{?>
<div class="post format-quote tag-css3 tag-design post-item isotope-item clearfix no-img">
<div class="date_label">
<?php echo date("d-m-Y", strtotime($post['date_gmt']));?>
</div>
<div class="image_frame post-photo-wrapper scale-with-grid">
<div class="image_wrapper"></div>
</div>
<div class="post-desc-wrapper">
<div class="post-desc">
<div class="post-meta clearfix">
<div class="author-date">
<span class="author">
<span>Publicado por </span>
<i class="icon-user"></i> <a href="#"><?= $author['name'] ?></a>
</span>
<span class="date">
<span> Fecha </span><i class="icon-clock"></i>
<?php echo date("d-m-Y", strtotime($post['date_gmt']));?>
</span>
</div>
<div class="category">
<span class="cat-btn">Categoría <i class="icon-down-dir"></i></span>
<div class="cat-wrapper">
<ul class="post-categories">
<?php foreach($categories as $cat):?>
<li>
<a href="<?= $cat['link']?>" rel="category tag"><?= $cat['name']?></a>
</li>
<?php endforeach?>
</ul>
</div>
</div>
</div>
<div class="post-title">
<h4 class="entry-title">
<a href="<?= $post['link'] ?>"><?= $post['title']['rendered'] ?></a>
</h4>
</div>
<div class="post-excerpt">
<span class="big">
<?= $post['excerpt']['rendered'] ?>
</span>
</div>
<div class="post-footer">
<div class="post-links">
<i class="icon-comment-empty-fa"></i>
<a href="blog-single-video.html#comments" class="post-comments">0</a>
<i class="icon-doc-text"></i>
<a href="<?= $post['link'] ?>" class="post-more">Leer más...</a>
</div>
</div>
</div>
</div>
</div>
<?php }?>
<?php }?>
</div>
<div class="column one pager_wrapper news-pagination">
<div class="pager">
<?php
$maxPagesToShow = 3;
$midpoint = ceil($maxPagesToShow / 2);
// Calculate the range of pages to show around the current page
$startPage = max($currentPage - $midpoint, 1);
$endPage = min($startPage + $maxPagesToShow - 1, $totalPages);
if ($startPage === 1) {
$endPage = min($maxPagesToShow, $totalPages);
}
if ($currentPage > 1): ?>
<a class="prev_page" href="<?= news_page_url($currentPage - 1, $category) ?>">
<i class="icon-left-open"></i> Atras
</a>
<?php endif; ?>
<div class="pages">
<?php
if ($startPage > 1) {
echo '<a href="' . news_page_url(1, $category) . '">1</a>';
if ($startPage > 2) {
echo '<span class="ellipsis">...</span>';
}
}
for ($i = $startPage; $i <= $endPage; $i++): ?>
<a href="<?= news_page_url($i, $category) ?>" class="<?= $currentPage == $i ? 'active' : '' ?>">
<?= $i ?>
</a>
<?php endfor;
if ($endPage < $totalPages) {
if ($endPage < $totalPages - 1) {
echo '<span class="ellipsis">...</span>';
}
echo '<a href="' . news_page_url($totalPages, $category) . '">' . $totalPages . '</a>';
} ?>
</div>
<?php if ($currentPage < $totalPages): ?>
<a class="next_page" href="<?= news_page_url($currentPage + 1, $category) ?>">
Siguiente <i class="icon-right-open"></i>
</a>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<style>
.news-pagination {
width: 100% !important;
margin: 28px 0 10px !important;
}
.news-pagination .pager {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
gap: 14px;
max-width: 100%;
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
-webkit-overflow-scrolling: touch;
}
.news-pagination .pages {
display: flex !important;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
gap: 8px;
width: 100%;
max-width: 100%;
margin: 0 !important;
padding: 0 !important;
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap !important;
-webkit-overflow-scrolling: touch;
}
.news-pagination .pages a,
.news-pagination .pages .ellipsis {
display: inline-flex;
flex: 0 0 auto;
align-items: center;
justify-content: center;
width: auto !important;
min-width: 38px;
height: 38px;
line-height: 38px;
margin: 0 !important;
padding: 0 10px;
border-radius: 6px;
white-space: nowrap;
box-sizing: border-box;
}
.news-pagination .pages .ellipsis {
min-width: auto;
color: #444;
}
.news-pagination .prev_page,
.news-pagination .next_page {
display: inline-flex;
flex: 0 0 auto;
align-items: center;
gap: 6px;
margin: 0 !important;
}
@media (max-width: 480px) {
.news-pagination {
margin-top: 18px !important;
}
.news-pagination .pager {
justify-content: flex-start;
gap: 8px;
padding: 0 8px 4px;
}
.news-pagination .pages {
gap: 4px;
justify-content: flex-start;
padding: 0 4px !important;
}
.news-pagination .pages a,
.news-pagination .pages .ellipsis {
min-width: 32px;
height: 34px;
line-height: 34px;
padding: 0 7px;
}
}
</style>