2019-03-13 13:41:32 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* The template for displaying archive pages for questions
|
|
|
|
*
|
|
|
|
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Twenty_Nineteen
|
|
|
|
* @since 1.0.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
get_header();
|
|
|
|
|
|
|
|
$termid = get_queried_object()->term_id;
|
|
|
|
$term = get_term_by( 'id', $termid, 'question' );
|
|
|
|
?>
|
|
|
|
|
|
|
|
<section id="primary" class="content-area">
|
|
|
|
<main id="main" class="site-main">
|
|
|
|
<article class="entry">
|
|
|
|
<header class="entry-header">
|
2023-01-12 20:14:23 +00:00
|
|
|
<h1 class="entry-title">
|
|
|
|
<?php echo wasmo_get_icon_svg( 'question', 36 ); ?>
|
|
|
|
<?php echo wp_kses_post( $term->name ); ?>
|
|
|
|
</h1>
|
2023-02-01 18:40:48 +00:00
|
|
|
<h2 class="entry-description has-regular-font-size"><?php echo wp_kses_post( $term->description ); ?></h2>
|
2019-03-13 13:41:32 +00:00
|
|
|
</header><!-- .page-header -->
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
//define transient name - taxid + user state.
|
|
|
|
$transient_name = 'answers-tax-question-' . $termid . '-' . is_user_logged_in();
|
2022-12-01 16:47:36 +00:00
|
|
|
if ( current_user_can('administrator') ) {
|
2019-03-13 13:41:32 +00:00
|
|
|
$transient_name = time();
|
|
|
|
}
|
|
|
|
//use transient to cache data
|
|
|
|
if ( false === ( $the_answers = get_transient( $transient_name ) ) ) {
|
|
|
|
|
|
|
|
//get users
|
|
|
|
$args = array(
|
2019-03-22 19:11:51 +00:00
|
|
|
'orderby' => 'meta_value',
|
|
|
|
'meta_key' => 'last_save',
|
|
|
|
'order' => 'DESC',
|
2019-03-13 13:41:32 +00:00
|
|
|
);
|
|
|
|
$users = get_users( $args );
|
|
|
|
//user loop
|
|
|
|
foreach ( $users as $user ) {
|
|
|
|
$userid = $user->ID;
|
|
|
|
|
|
|
|
//questions loop
|
|
|
|
if( have_rows( 'questions', 'user_' . $userid ) ) {
|
|
|
|
|
|
|
|
// loop through the rows of data
|
|
|
|
while ( have_rows( 'questions', 'user_' . $userid ) ) {
|
|
|
|
the_row();
|
|
|
|
|
|
|
|
$termtaxid = get_sub_field( 'question', 'users_' . $userid );
|
2022-12-01 16:47:36 +00:00
|
|
|
$answer = get_sub_field( 'answer', 'user_' . $userid );
|
2019-03-13 13:41:32 +00:00
|
|
|
|
|
|
|
//check if they answered this question
|
2022-12-01 16:47:36 +00:00
|
|
|
if ( $termtaxid === $termid && $answer ) {
|
2019-03-13 13:41:32 +00:00
|
|
|
|
|
|
|
// answer
|
|
|
|
$the_answers .= '<div class="answer answer-' . $userid . '">';
|
|
|
|
$the_answers .= '<blockquote>';
|
2022-12-01 16:47:36 +00:00
|
|
|
$the_answers .= auto_link_text( wp_kses_post( $answer ) );
|
2019-03-13 13:41:32 +00:00
|
|
|
$the_answers .= '</blockquote>';
|
|
|
|
|
|
|
|
// user attribution - photo and name and link (only if they want to be listed in directory)
|
2022-10-26 13:56:26 +00:00
|
|
|
$in_directory = get_field( 'in_directory', 'user_' . $userid );
|
|
|
|
if (
|
|
|
|
'true' === $in_directory ||
|
|
|
|
'website' === $in_directory ||
|
|
|
|
( 'private' === $in_directory && is_user_logged_in() )
|
|
|
|
) {
|
2019-03-13 13:41:32 +00:00
|
|
|
$username = esc_html( $user->nickname );
|
|
|
|
$the_answers .= '<cite>';
|
2023-04-28 15:11:24 +00:00
|
|
|
$the_answers .= '<a class="person person-' . esc_attr( $userid ) . '" href="';
|
|
|
|
$the_answers .= get_author_posts_url( $userid ) . '#' . esc_attr( $term->slug );
|
|
|
|
$the_answers .= '"><span class="directory-img">';
|
2023-01-23 23:32:21 +00:00
|
|
|
$the_answers .= wasmo_get_user_image( $userid );
|
2019-03-13 13:41:32 +00:00
|
|
|
$the_answers .= '</span>';
|
|
|
|
$the_answers .= '<span class="directory-name">' . $username . '</span>';
|
|
|
|
$the_answers .= '</a>';
|
|
|
|
$the_answers .= '</cite>';
|
2023-03-01 20:03:47 +00:00
|
|
|
} elseif (
|
|
|
|
'false' === $in_directory ||
|
|
|
|
( 'private' === $in_directory && !is_user_logged_in() )
|
|
|
|
) {
|
|
|
|
$the_answers .= '<cite>';
|
|
|
|
$the_answers .= '<span class="person person-' . esc_attr( $userid ) . '">';
|
|
|
|
$the_answers .= '<span class="directory-img">';
|
|
|
|
$the_answers .= wasmo_get_user_image( 0 );
|
|
|
|
$the_answers .= '</span>';
|
|
|
|
$the_answers .= '<span class="directory-name">Anonymous</span>';
|
|
|
|
$the_answers .= '</span>';
|
|
|
|
$the_answers .= '</cite>';
|
2019-03-13 13:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$the_answers .= '</div>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set_transient( $transient_name, $the_answers, 24 * HOUR_IN_SECONDS );
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
2019-03-13 13:43:07 +00:00
|
|
|
<div class="entry-content answers">
|
2019-03-14 12:33:15 +00:00
|
|
|
|
2023-03-01 20:03:47 +00:00
|
|
|
<?php if ( empty( $the_answers ) ) { ?>
|
|
|
|
<p>There are no available answers for this question currently. Add your own story and be the first to contribute your own answer to the question!</p>
|
|
|
|
<?php } else {
|
|
|
|
echo $the_answers;
|
|
|
|
} ?>
|
2019-03-13 13:41:32 +00:00
|
|
|
|
2023-01-12 20:14:23 +00:00
|
|
|
<hr />
|
|
|
|
|
|
|
|
<div class="is-layout-flex wp-block-buttons">
|
|
|
|
<div class="wp-block-button has-custom-font-size" style="font-size:20px">
|
|
|
|
<a class="wp-block-button__link wp-element-button" href="<?php echo home_url( '/login/' ); ?>" style="border-radius:100px">Create a Profile</a>
|
|
|
|
</div>
|
|
|
|
<div class="wp-block-button has-custom-font-size is-style-outline" style="font-size:20px">
|
|
|
|
<a class="wp-block-button__link wp-element-button" href="<?php echo home_url( '/profiles/' ); ?>" style="border-radius:100px">See All Profiles</a>
|
|
|
|
</div>
|
|
|
|
<div class="wp-block-button has-custom-font-size is-style-outline" style="font-size:20px">
|
|
|
|
<a class="wp-block-button__link wp-element-button" href="<?php echo home_url( '/questions/' ); ?>" style="border-radius:100px">See Questions</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2019-03-13 13:43:07 +00:00
|
|
|
<footer class="entry-footer">
|
2023-01-12 20:14:23 +00:00
|
|
|
<?php
|
|
|
|
// load related posts for this question
|
|
|
|
set_query_var( 'tax', 'question' );
|
|
|
|
set_query_var( 'termid', $termid );
|
|
|
|
get_template_part( 'template-parts/content/taxonomy', 'relatedposts' );
|
|
|
|
?>
|
2019-03-13 13:43:07 +00:00
|
|
|
</footer>
|
2019-03-13 13:41:32 +00:00
|
|
|
|
|
|
|
</article>
|
|
|
|
|
|
|
|
</main><!-- #main -->
|
|
|
|
</section><!-- #primary -->
|
|
|
|
|
|
|
|
<?php
|
2019-03-14 12:33:15 +00:00
|
|
|
get_footer();
|