Skip to content

Instantly share code, notes, and snippets.

@rambuvn
Created February 28, 2014 10:14
Show Gist options
  • Save rambuvn/9268584 to your computer and use it in GitHub Desktop.
Save rambuvn/9268584 to your computer and use it in GitHub Desktop.
Show sidebar of DW QA
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
global $dwqa_options;
if( ( $dwqa_options['pages']['archive-question'] && is_page( $dwqa_options['pages']['archive-question'] ) ) || is_archive() ) { ?>
</div>
<div id="secondary">
<?php if (is_user_logged_in()) : ?>
<?php dwqa_get_ask_question_link( true, false, 'btn btn-block btn-success' ); ?>
<?php else : ?>
<a data-toggle="modal" class="open-login-modal btn btn-block btn-success" data-referer="http://www.designwall.com/ask-question/" href="#loginModal" alt="signin-tab">Login to Ask question</a>
<?php endif; ?>
<?php dynamic_sidebar( 'sidebar-question' ); ?>
</div>
<?php }
if(is_single()) {
global $post;
$question_tags = wp_get_object_terms($post->ID, 'dwqa-question_tag');
if( $question_tags ) {
$related_product_arg = array(
'post_type' => 'download',
'name' => $question_tags[0]->slug,
'posts_per_page' => 1,
);
$related_question_arg = array(
'post_type' => 'dwqa-question',
'name' => $question_tags[0]->slug,
'posts_per_page' => 1,
);
}
?>
</div>
<div id="secondary">
<?php if( isset($related_product_arg) ) : ?>
<?php $related_product = new WP_Query( $related_product_arg ); ?>
<?php if ( $related_product->have_posts() ) : ?>
<?php while ( $related_product->have_posts() ) : $related_product->the_post(); ?>
<div class="well related-product-info">
<div class="media">
<a href="<?php the_permalink(); ?>" title="View Product Info" class="pull-left related-product-thumbnail">
<?php
$image = rwmb_meta( 'nex_favicon_64', 'type=image', get_the_ID() );
?>
<?php if($image) : ?>
<?php $image = array_shift($image); ?>
<img src="<?php echo $image['full_url']; ?>" alt="" />
<?php else : ?>
<?php echo get_the_post_thumbnail( get_the_ID(), array(64,64) ); ?>
<?php endif; ?>
</a>
<div class="media-body">
<h5 class="media-heading"><a href="<?php the_permalink(); ?>" title="View Product Info"><?php the_title(); ?></a></h5>
<?php $opts = get_option( 'dwqa_options' ); ?>
<span class="media">
<a href="<?php echo get_home_url() . '/' . $opts['question-tag-rewrite'] . '/' . $question_tags[0]->slug; ?>"><?php echo $question_tags[0]->count; ?> Questions asked</a>
<div class="related-question-meta">
<?php $demo = rwmb_meta( 'nex_product_demo', 'type=text', get_the_ID() ); if($demo) : ?><a href="<?php echo $demo; ?>">Live Demo</a> &sdot;<?php endif; ?>
<a href="<?php the_permalink(); ?>">More info</a></div>
</span>
</div>
</div>
</div>
<?php if (is_user_logged_in()) : ?>
<?php dwqa_get_ask_question_link( true, 'Ask a question in '.get_the_title(), 'btn btn-block btn-success' ); ?>
<?php else : ?>
<a data-toggle="modal" class="open-login-modal btn btn-block btn-success" data-referer="http://www.designwall.com/ask-question/" href="#loginModal" alt="signin-tab">Login to Ask question</a>
<?php endif; ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
<?php endif; // Related product ?>
<div class="related-questions">
<?php dwqa_related_question(); ?>
</div>
<?php $followers = dwqa_get_following_user($post->ID); ?>
<?php if( !empty($followers) ) : ?>
<div class="question-followers">
<h3 class="small-title"><?php echo count($followers); ?> people are following this question.</h3>
<?php
foreach ($followers as $follower) :
$user_info = get_userdata($follower);
if( $user_info ) :
?>
<a href="<?php echo home_url().'/profile/'.$user_info->user_nicename; ?>" title="<?php echo $user_info->display_name; ?>"><?php echo get_avatar( $follower, 32 ); ?></a>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
<?php }
echo '</div>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment