Created
October 6, 2015 15:28
-
-
Save contempoinc/52d73d274dcc8f987c90 to your computer and use it in GitHub Desktop.
Agents Random Order - Real Estate 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Template Name: Agents | |
* | |
* @package WP Pro Real Estate 7 | |
* @subpackage Template | |
*/ | |
global $ct_options; | |
$inside_page_title = get_post_meta($post->ID, "_ct_inner_page_title", true); | |
get_header(); | |
if ( have_posts() ) : while ( have_posts() ) : the_post(); | |
if($inside_page_title == "Yes") { | |
// Custom Page Header Background Image | |
if(get_post_meta($post->ID, '_ct_page_header_bg_image', true) != '') { | |
echo'<style type="text/css">'; | |
echo '#single-header { background: url('; | |
echo get_post_meta($post->ID, '_ct_page_header_bg_image', true); | |
echo ') no-repeat center center; background-size: cover;}'; | |
echo '</style>'; | |
} ?> | |
<!-- Single Header --> | |
<div id="single-header"> | |
<div class="dark-overlay"> | |
<div class="container"> | |
<h1 class="marT0 marB0"><?php the_title(); ?></h1> | |
<?php if(get_post_meta($post->ID, '_ct_page_sub_title', true) != '') { ?> | |
<h2 class="marT0 marB0"><?php echo get_post_meta($post->ID, "_ct_page_sub_title", true); ?></h2> | |
<?php } ?> | |
</div> | |
</div> | |
</div> | |
<!-- //Single Header --> | |
<?php } ?> | |
<div class="container marT60 padB60"> | |
<article class="col span_12"> | |
<?php the_content(); ?> | |
<ul> | |
<?php | |
add_action( 'pre_user_query', 'my_random_user_query' ); | |
function my_random_user_query( $class ) { | |
if( 'rand' == $class->query_vars['orderby'] ) | |
$class->query_orderby = str_replace( 'user_login', 'RAND()', $class->query_orderby ); | |
return $class; | |
} | |
global $wpdb; | |
$query = "SELECT ID, user_nicename from $wpdb->users ORDER BY rand"; | |
$author_ids = $wpdb->get_results($query); | |
foreach($author_ids as $author) : | |
$curauth = get_userdata($author->ID); | |
$author_id = get_the_author_meta('ID'); | |
$user_link = get_author_posts_url($curauth->ID); | |
if($curauth->user_level >= 0 && $curauth->isagent == 'yes') : ?> | |
<?php if($curauth->user_email) { | |
$email = $curauth->user_email; ?> | |
<!-- Agent Contact Modal --> | |
<div id="overlay" class="contact-modal-<?php echo esc_html($curauth->ID); ?> agent-modal"> | |
<div id="modal"> | |
<div id="modal-inner"> | |
<a href="#" class="close"><i class="fa fa-close"></i></a> | |
<form id="listingscontact" class="formular" method="post"> | |
<fieldset class="col span_12"> | |
<select id="ctsubject" name="ctsubject"> | |
<option><?php esc_html_e('Tell me more about a property', 'contempo'); ?></option> | |
<option><?php esc_html_e('Request a showing', 'contempo'); ?></option> | |
<option><?php esc_html_e('General Questions', 'contempo'); ?></option> | |
</select> | |
<div class="clear"></div> | |
<input type="text" name="name" id="name" class="validate[required,custom[onlyLetter]] text-input" placeholder="<?php esc_html_e('Name', 'contempo'); ?>" /> | |
<input type="text" name="email" id="email" class="validate[required,custom[email]] text-input" placeholder="<?php esc_html_e('Email', 'contempo'); ?>" /> | |
<input type="text" name="ctphone" id="ctphone" class="text-input" placeholder="<?php esc_html_e('Phone', 'contempo'); ?>" /> | |
<textarea class="validate[required,length[2,1000]] text-input" name="message" id="message" rows="6" cols="10"></textarea> | |
<input type="hidden" id="ctyouremail" name="ctyouremail" value="<?php echo antispambot($email,1 ) ?>" /> | |
<input type="hidden" id="ctproperty" name="ctproperty" value="<?php the_title(); ?>, <?php city(); ?>, <?php state(); ?> <?php zipcode(); ?>" /> | |
<input type="hidden" id="ctpermalink" name="ctpermalink" value="<?php the_permalink(); ?>" /> | |
<input type="submit" name="Submit" value="<?php esc_html_e('Submit', 'contempo'); ?>" id="submit" class="btn" /> | |
</fieldset> | |
<div class="clear"></div> | |
</form> | |
</div> | |
</div> | |
</div> | |
<!-- //Agent Contact Modal --> | |
<?php } ?> | |
<!-- Agent --> | |
<li class="agent"> | |
<?php if($curauth->ct_profile_url) { ?> | |
<figure class="col span_3 first"> | |
<a href="<?php echo esc_url(home_url()); ?>/?author=<?php echo esc_html($curauth->ID); ?>" title="<?php echo esc_html($curauth->display_name); ?>"> | |
<img class="author-img" src="<?php echo esc_html($curauth->ct_profile_url); ?>" /> | |
</a> | |
</figure> | |
<?php } ?> | |
<div class="agent-info col span_9"> | |
<h3><a href="<?php echo esc_url(home_url()); ?>/?author=<?php echo esc_html($curauth->ID); ?>" title="<?php echo esc_html($curauth->display_name); ?>"><?php echo esc_html($curauth->display_name); ?></a></h3> | |
<?php if ($curauth->title) { ?><h5 class="muted position"><?php echo esc_html($curauth->title); ?></h5><?php } ?> | |
<div class="agent-bio col span_8 first"> | |
<p><?php if($curauth->tagline) { ?><strong class="tagline"><?php echo esc_html($curauth->tagline); ?></strong> <?php } ?><?php $bio = $curauth->description; echo nl2br($bio); ?></p> | |
<ul class="social marT20 marL0"> | |
<?php if ($curauth->twitterhandle) { ?><li class="twitter"><a href="http://twitter.com/#!/<?php echo esc_html($curauth->twitterhandle); ?>" target="_blank"><i class="fa fa-twitter"></i></a></li><?php } ?> | |
<?php if ($curauth->facebookurl) { ?><li class="facebook"><a href="<?php echo esc_html($curauth->facebookurl); ?>" target="_blank"><i class="fa fa-facebook"></i></a></li><?php } ?> | |
<?php if ($curauth->linkedinurl) { ?><li class="linkedin"><a href="<?php echo esc_html($curauth->linkedinurl); ?>" target="_blank"><i class="fa fa-linkedin"></i></a></li><?php } ?> | |
<?php if ($curauth->gplus) { ?><li class="google"><a href="<?php echo esc_html($curauth->gplus); ?>" target="_blank"><i class="fa fa-google-plus"></i></a></li><?php } ?> | |
</ul> | |
</div> | |
<script> | |
jQuery(document).ready(function() { | |
jQuery(".agent-contact-<?php echo esc_html($curauth->ID); ?>").click(function() { | |
jQuery("#overlay.contact-modal-<?php echo esc_html($curauth->ID); ?>").addClass('open'); | |
}); | |
jQuery(".close").click(function() { | |
jQuery("#overlay.contact-modal-<?php echo esc_html($curauth->ID); ?>").removeClass('open'); | |
jQuery(".formError").hide(); | |
}); | |
}); | |
</script> | |
<ul class="col span_4"> | |
<?php if($curauth->mobile) { ?><li class="row"><span class="muted left"><i class="fa fa-phone"></i></span> <span class="right"><?php echo esc_html($curauth->mobile); ?></span></span></li><?php } ?> | |
<?php if($curauth->office) { ?><li class="row"><span class="muted left"><i class="fa fa-building"></i></span> <span class="right"><?php echo esc_html($curauth->office); ?></span></li><?php } ?> | |
<?php if($curauth->fax) { ?><li class="row"><span class="muted left"><i class="fa fa-print"></i></span> <span class="right"><?php echo esc_html($curauth->fax); ?></span></li><?php } ?> | |
<?php if($curauth->user_email) { $email = $curauth->user_email; ?><li class="row"><span class="muted left"><i class="fa fa-envelope"></i></span> <span class="right"><a class="agent-contact-<?php echo esc_html($curauth->ID); ?>" href="#"><?php esc_html_e('Email', 'contempo'); ?></a></span></li><?php } ?> | |
<?php if($curauth->brokername) { ?><p class="marB3"><strong><?php echo esc_html($curauth->brokername); ?></strong></p><?php } ?> | |
<?php if($curauth->brokernum) { ?><p class="marB3"><?php echo esc_html($curauth->brokernum); ?></p><?php } ?> | |
</ul> | |
<div class="clear"></div> | |
<div class="view-listings"> | |
<a class="btn" href="<?php echo esc_url(home_url()); ?>/?author=<?php echo esc_html($curauth->ID); ?>"><?php esc_html_e('View Listings', 'contempo'); ?></a> | |
</div> | |
</div> | |
<div class="clear"></div> | |
</li> | |
<!-- //Agent --> | |
<?php endif; ?> | |
<?php endforeach; ?> | |
</ul> | |
<?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'contempo' ) . '</span>', 'after' => '</div>' ) ); ?> | |
<?php endwhile; endif; ?> | |
<div class="clear"></div> | |
</article> | |
<div class="clear"></div> | |
</div> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment