2023-01-21 01:31:34 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
// LIST OF ALL RECOMMENDATIONS
|
|
|
|
// =============================================================================
|
|
|
|
|
2023-08-08 22:45:55 +02:00
|
|
|
/**
|
|
|
|
* Outputs the paginated card list for all recommendations
|
|
|
|
*
|
2024-01-26 17:45:59 +01:00
|
|
|
* @since 5.0.0
|
2023-08-08 22:45:55 +02:00
|
|
|
* @see recommendations.php
|
|
|
|
*
|
|
|
|
* @param int $args['current_page'] Current page number of pagination or 1.
|
|
|
|
* @param int $args['post_id'] The post ID.
|
|
|
|
* @param WP_Query $args['recommendations'] Paginated query of all published recommendations.
|
|
|
|
* @param string $args['queried_type'] The queried post type ('fcn_recommendation').
|
|
|
|
* @param array $args['query_args'] The query arguments used.
|
|
|
|
* @param string $args['order'] Current order. Default 'desc'.
|
|
|
|
* @param string $args['orderby'] Current orderby. Default 'modified'.
|
|
|
|
* @param int|string $args['ago'] Current date query argument part. Default 0.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_recommendations_list( $args ) {
|
|
|
|
// Start HTML ---> ?>
|
2024-01-21 22:58:26 +01:00
|
|
|
<section class="recommendations__list spacing-top container-inline-size">
|
2023-09-16 02:52:18 +02:00
|
|
|
<ul id="list-of-recommendations" class="scroll-margin-top card-list">
|
2023-08-08 22:45:55 +02:00
|
|
|
|
|
|
|
<?php if ( $args['recommendations']->have_posts() ) : ?>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
<?php
|
2023-08-08 22:45:55 +02:00
|
|
|
// Card arguments
|
|
|
|
$card_args = array(
|
2024-01-29 17:08:56 +01:00
|
|
|
'cache' => fictioneer_caching_active( 'card_args' ) && ! fictioneer_private_caching_active(),
|
2023-08-08 22:45:55 +02:00
|
|
|
'order' => $args['order'] ?? 'desc',
|
|
|
|
'orderby' => $args['orderby'] ?? 'modified',
|
|
|
|
'ago' => $args['ago'] ?? 0
|
2023-01-21 01:31:34 +01:00
|
|
|
);
|
2023-08-08 22:45:55 +02:00
|
|
|
|
|
|
|
// Filter card arguments
|
|
|
|
$card_args = apply_filters( 'fictioneer_filter_recommendations_card_args', $card_args, $args );
|
|
|
|
|
|
|
|
while ( $args['recommendations']->have_posts() ) {
|
|
|
|
$args['recommendations']->the_post();
|
|
|
|
get_template_part( 'partials/_card-recommendation', null, $card_args );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Actions at end of results
|
|
|
|
do_action( 'fictioneer_recommendations_end_of_results', $args );
|
2023-01-21 01:31:34 +01:00
|
|
|
?>
|
|
|
|
|
2023-11-30 17:52:19 +01:00
|
|
|
<?php else : ?>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-08-08 22:45:55 +02:00
|
|
|
<?php do_action( 'fictioneer_recommendations_no_results', $args ); ?>
|
|
|
|
|
|
|
|
<li class="no-results">
|
2023-09-16 14:25:26 +02:00
|
|
|
<span><?php _e( 'No recommendations found.', 'fictioneer' ); ?></span>
|
2023-08-08 22:45:55 +02:00
|
|
|
</li>
|
|
|
|
|
|
|
|
<?php endif; wp_reset_postdata(); ?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
$pag_args = array(
|
|
|
|
'current' => max( 1, get_query_var( 'paged' ) ),
|
|
|
|
'total' => $args['recommendations']->max_num_pages,
|
|
|
|
'prev_text' => fcntr( 'previous' ),
|
|
|
|
'next_text' => fcntr( 'next' ),
|
|
|
|
'add_fragment' => '#list-of-recommendations'
|
|
|
|
);
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php if ( $args['recommendations']->max_num_pages > 1 ) : ?>
|
|
|
|
<li class="pagination"><?php echo fictioneer_paginate_links( $pag_args ); ?></li>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
<?php // <--- End HTML
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
add_action( 'fictioneer_recommendations_after_content', 'fictioneer_recommendations_list', 30 );
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
// RECOMMENDATION TAGS
|
|
|
|
// =============================================================================
|
|
|
|
|
2023-08-08 22:45:55 +02:00
|
|
|
/**
|
|
|
|
* Outputs the HTML for the recommendation page tags
|
|
|
|
*
|
2024-01-26 17:45:59 +01:00
|
|
|
* @since 5.0.0
|
2023-08-08 22:45:55 +02:00
|
|
|
*
|
|
|
|
* @param WP_Post $args['recommendation'] The recommendation object.
|
|
|
|
* @param int $args['recommendation_id'] The recommendation post ID.
|
|
|
|
* @param int $args['title'] The safe recommendation title.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_recommendation_tags( $args ) {
|
|
|
|
// Setup
|
|
|
|
$tag_args = [];
|
|
|
|
|
|
|
|
// Show tags?
|
|
|
|
if ( ! get_option( 'fictioneer_hide_tags_on_pages' ) ) {
|
|
|
|
$tags = get_the_tags( $args['recommendation_id'] );
|
|
|
|
|
2023-08-20 06:14:17 +02:00
|
|
|
if ( ! empty( $tags ) ) {
|
2023-11-30 20:36:00 +01:00
|
|
|
$tag_args['tags'] = $tags;
|
2023-08-20 06:14:17 +02:00
|
|
|
}
|
2023-08-08 22:45:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Show content warnings?
|
|
|
|
if ( ! get_option( 'fictioneer_hide_content_warnings_on_pages' ) ) {
|
|
|
|
$warnings = get_the_terms( $args['recommendation_id'], 'fcn_content_warning' );
|
|
|
|
|
2023-08-20 06:14:17 +02:00
|
|
|
if ( ! empty( $warnings ) ) {
|
2023-11-30 20:36:00 +01:00
|
|
|
$tag_args['warnings'] = $warnings;
|
2023-08-20 06:14:17 +02:00
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
2023-08-08 22:45:55 +02:00
|
|
|
|
|
|
|
// Abort conditions...
|
2023-08-20 06:14:17 +02:00
|
|
|
if ( empty( $tag_args ) ) {
|
|
|
|
return;
|
|
|
|
}
|
2023-08-08 22:45:55 +02:00
|
|
|
|
|
|
|
// Start HTML ---> ?>
|
|
|
|
<section class="recommendation__tags tag-group">
|
2023-11-30 20:53:35 +01:00
|
|
|
<?php echo fictioneer_get_taxonomy_pills( $tag_args, 'recommendation_after_content', '_secondary' ); ?>
|
2023-08-08 22:45:55 +02:00
|
|
|
</section>
|
|
|
|
<?php // <--- End HTML
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
add_action( 'fictioneer_recommendation_after_content', 'fictioneer_recommendation_tags', 10 );
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
// RECOMMENDATION LINKS
|
|
|
|
// =============================================================================
|
|
|
|
|
2023-08-08 22:45:55 +02:00
|
|
|
/**
|
|
|
|
* Outputs the HTML for the recommendation page links
|
|
|
|
*
|
2024-01-26 17:45:59 +01:00
|
|
|
* @since 5.0.0
|
2023-08-08 22:45:55 +02:00
|
|
|
*
|
2023-08-20 06:14:17 +02:00
|
|
|
* @param WP_Post $args['recommendation'] The recommendation object.
|
|
|
|
* @param int $args['recommendation_id'] The recommendation post ID.
|
|
|
|
* @param int $args['title'] The safe recommendation title.
|
2023-08-08 22:45:55 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_recommendation_links( $args ) {
|
|
|
|
// Setup
|
2023-11-30 16:03:53 +01:00
|
|
|
$links = get_post_meta( $args['recommendation_id'], 'fictioneer_recommendation_urls', true );
|
2023-10-02 00:02:12 +02:00
|
|
|
$links = fictioneer_url_list_to_array( $links );
|
2023-08-08 22:45:55 +02:00
|
|
|
|
|
|
|
// Abort conditions...
|
2023-10-02 00:02:12 +02:00
|
|
|
if ( empty( $links ) ) {
|
2023-08-28 10:43:04 +02:00
|
|
|
return;
|
|
|
|
}
|
2023-08-08 22:45:55 +02:00
|
|
|
|
|
|
|
// Prepare
|
2023-10-02 00:02:12 +02:00
|
|
|
$output = [];
|
2023-08-08 22:45:55 +02:00
|
|
|
|
2024-06-17 22:12:39 +02:00
|
|
|
foreach ( $links as $link ) {
|
2023-10-02 00:02:12 +02:00
|
|
|
$output[] = '<li class="recommendation__list-item"><i class="fa-solid fa-external-link-square-alt"></i><a href="' . esc_url( $link['url'] ) . '" class="link" rel="noopener" target="_blank">' . $link['name'] . '</a></li>';
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
2023-08-08 22:45:55 +02:00
|
|
|
|
|
|
|
// Start HTML ---> ?>
|
|
|
|
<div class="recommendation__read-on">
|
2023-09-16 14:25:26 +02:00
|
|
|
<h5><?php _e( 'Read on', 'fictioneer' ); ?></h5>
|
2023-10-02 00:02:12 +02:00
|
|
|
<ul class="recommendation__list"><?php echo implode( '', $output ); ?></ul>
|
2023-08-08 22:45:55 +02:00
|
|
|
</div>
|
|
|
|
<?php // <--- End HTML
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
add_action( 'fictioneer_recommendation_after_content', 'fictioneer_recommendation_links', 20 );
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
// RECOMMENDATION AUTHOR LINKS
|
|
|
|
// =============================================================================
|
|
|
|
|
2023-08-08 22:45:55 +02:00
|
|
|
/**
|
|
|
|
* Outputs the HTML for the recommendation page author links
|
|
|
|
*
|
2024-01-26 17:45:59 +01:00
|
|
|
* @since 5.0.0
|
2023-08-08 22:45:55 +02:00
|
|
|
*
|
2023-08-20 06:14:17 +02:00
|
|
|
* @param WP_Post $args['recommendation'] The recommendation object.
|
|
|
|
* @param int $args['recommendation_id'] The recommendation post ID.
|
|
|
|
* @param int $args['title'] The safe recommendation title.
|
2023-08-08 22:45:55 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_recommendation_support_links( $args ) {
|
|
|
|
// Setup
|
2023-11-30 16:03:53 +01:00
|
|
|
$links = get_post_meta( $args['recommendation_id'], 'fictioneer_recommendation_support', true );
|
2023-10-02 00:02:12 +02:00
|
|
|
$links = fictioneer_url_list_to_array( $links );
|
2023-08-08 22:45:55 +02:00
|
|
|
|
|
|
|
// Abort conditions...
|
2023-08-28 10:43:04 +02:00
|
|
|
if ( ! $links ) {
|
|
|
|
return;
|
|
|
|
}
|
2023-08-08 22:45:55 +02:00
|
|
|
|
|
|
|
// Prepare
|
2023-10-02 00:02:12 +02:00
|
|
|
$output = [];
|
2023-08-08 22:45:55 +02:00
|
|
|
|
2024-06-17 22:12:39 +02:00
|
|
|
foreach ( $links as $link ) {
|
2023-10-02 00:02:12 +02:00
|
|
|
$output[] = '<li class="recommendation__list-item"><i class="fa-solid fa-external-link-square-alt"></i><a href="' . esc_url( $link['url'] ) . '" class="link" rel="noopener" target="_blank">' . $link['name'] . '</a></li>';
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
2023-08-08 22:45:55 +02:00
|
|
|
|
|
|
|
// Start HTML ---> ?>
|
|
|
|
<div class="recommendation__support">
|
|
|
|
<h5><?php
|
|
|
|
printf(
|
|
|
|
_x( 'Support <em>%s</em>', 'Support _author_', 'fictioneer' ),
|
2023-11-30 16:03:53 +01:00
|
|
|
get_post_meta( $args['recommendation_id'], 'fictioneer_recommendation_author', true )
|
2023-08-08 22:45:55 +02:00
|
|
|
)
|
|
|
|
?></h5>
|
2023-10-02 00:02:12 +02:00
|
|
|
<ul class="recommendation__list"><?php echo implode( '', $output ); ?></ul>
|
2023-08-08 22:45:55 +02:00
|
|
|
</div>
|
|
|
|
<?php // <--- End HTML
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
add_action( 'fictioneer_recommendation_after_content', 'fictioneer_recommendation_support_links', 30 );
|