2023-01-21 01:31:34 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Partial: Archive Loop
|
|
|
|
*
|
|
|
|
* Renders a list of post type specific cards.
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Fictioneer
|
|
|
|
* @since 3.0
|
|
|
|
* @see category.php
|
|
|
|
* @see tag.php
|
|
|
|
* @see taxonomy-fcn_character.php
|
|
|
|
* @see taxonomy-fcn_content_warning.php
|
|
|
|
* @see taxonomy-fcn_fandom.php
|
|
|
|
* @see taxonomy-fcn_genre.php
|
|
|
|
*/
|
|
|
|
?>
|
|
|
|
|
2023-06-11 16:15:15 +02:00
|
|
|
<?php
|
|
|
|
|
2023-08-20 20:21:48 +02:00
|
|
|
// No direct access!
|
|
|
|
defined( 'ABSPATH' ) OR exit;
|
|
|
|
|
2023-06-11 16:15:15 +02:00
|
|
|
// Setup
|
|
|
|
$page = get_query_var( 'paged', 1 ) ?: 1; // Main query
|
2023-08-30 23:15:17 +02:00
|
|
|
$order = array_intersect( [sanitize_key( $_GET['order'] ?? 0 )], ['desc', 'asc'] );
|
2023-06-11 16:15:15 +02:00
|
|
|
$order = reset( $order ) ?: 'desc';
|
2023-08-30 23:15:17 +02:00
|
|
|
$orderby = array_intersect( [sanitize_key( $_GET['orderby'] ?? 0 )], fictioneer_allowed_orderby() );
|
2023-06-11 16:15:15 +02:00
|
|
|
$orderby = reset( $orderby ) ?: 'date';
|
|
|
|
$ago = $_GET['ago'] ?? 0;
|
|
|
|
$ago = is_numeric( $ago ) ? absint( $ago ) : sanitize_text_field( $ago );
|
|
|
|
|
|
|
|
// Prepare sort-order-filter arguments
|
|
|
|
$hook_args = array(
|
|
|
|
'page' => $page,
|
|
|
|
'order' => $order,
|
|
|
|
'orderby' => $orderby,
|
|
|
|
'ago' => $ago
|
|
|
|
);
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php do_action( 'fictioneer_archive_loop_before', $hook_args ); ?>
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
<?php if ( have_posts() ) : ?>
|
2023-06-11 16:15:15 +02:00
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
<section class="archive__posts">
|
|
|
|
<ul class="card-list _no-mutation-observer" id="archive-list">
|
|
|
|
<?php
|
|
|
|
while ( have_posts() ) {
|
|
|
|
the_post();
|
|
|
|
|
|
|
|
// Setup
|
|
|
|
$type = get_post_type();
|
2023-06-11 16:15:15 +02:00
|
|
|
$card_args = array(
|
|
|
|
'cache' => fictioneer_caching_active() && ! fictioneer_private_caching_active(),
|
|
|
|
'show_type' => true,
|
|
|
|
'order' => $order,
|
|
|
|
'orderby' => $orderby,
|
|
|
|
'ago' => $ago
|
|
|
|
);
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
// Cached?
|
2023-08-28 10:43:04 +02:00
|
|
|
if ( fictioneer_caching_active() && ! fictioneer_private_caching_active() ) {
|
|
|
|
$card_args['cache'] = true;
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
// Special conditions for chapters...
|
|
|
|
if ( $type == 'fcn_chapter' ) {
|
2023-08-28 10:43:04 +02:00
|
|
|
if (
|
|
|
|
fictioneer_get_field( 'fictioneer_chapter_no_chapter' ) ||
|
|
|
|
fictioneer_get_field( 'fictioneer_chapter_hidden' )
|
|
|
|
) {
|
|
|
|
continue;
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Echo correct card
|
|
|
|
fictioneer_echo_card( $card_args );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pagination
|
|
|
|
$pag_args = array(
|
|
|
|
'prev_text' => fcntr( 'previous' ),
|
|
|
|
'next_text' => fcntr( 'next' ),
|
|
|
|
'add_fragment' => '#archive-list'
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( $GLOBALS['wp_query']->found_posts > get_option( 'posts_per_page' ) ) {
|
2023-06-09 11:31:40 +02:00
|
|
|
?><li class="pagination"><?php echo fictioneer_paginate_links( $pag_args ); ?></li><?php
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
</ul>
|
|
|
|
</section>
|
2023-06-11 16:15:15 +02:00
|
|
|
|
|
|
|
<?php else : ?>
|
|
|
|
|
|
|
|
<section class="archive__posts">
|
|
|
|
<ul class="card-list _no-mutation-observer" id="archive-list">
|
|
|
|
<li class="no-results">
|
|
|
|
<span><?php _e( 'No matching posts found.', 'fictioneer' ) ?></span>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
<?php endif; ?>
|
2023-06-11 16:15:15 +02:00
|
|
|
|
|
|
|
<?php do_action( 'fictioneer_archive_loop_after', $hook_args ); ?>
|