-
-
Save contempoinc/4685958b579a6d24af10d03b4d961019 to your computer and use it in GitHub Desktop.
RE4
This file contains 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 | |
/** | |
* Theme Functions | |
* | |
* @package WP Pro Real Estate 4 | |
* @subpackage Admin | |
*/ | |
if (is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) { | |
/* Call action that sets */ | |
add_action('admin_head','ct_option_setup'); | |
/* Do redirect */ | |
header( 'Location: '.admin_url().'themes.php?page=optionsframework' ) ; | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Body IDs */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_body_id() { | |
if (is_home()) { | |
echo ' id="home"'; | |
} elseif (is_single()) { | |
echo ' id="single"'; | |
} elseif (is_page()) { | |
echo ' id="page"'; | |
} elseif (is_search()) { | |
echo ' id="search"'; | |
} elseif (is_archive()) { | |
echo ' id="archive"'; | |
} | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* SEO Friendly Title Tags */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_title() { | |
if (is_category()) { | |
echo wp_title(''); echo ' - '; | |
} elseif (function_exists('is_tag') && is_tag()) { | |
single_tag_title('Tag Archive for "'); echo '" - '; | |
} elseif (is_archive()) { | |
wp_title(''); echo ' Archive - '; | |
} elseif (is_page()) { | |
echo wp_title(''); echo ' - '; | |
} elseif (is_search()) { | |
echo 'Search for "'.esc_html($s).'" - '; | |
} elseif (!(is_404()) && (is_single()) || (is_page())) { | |
wp_title(''); echo ' - '; | |
} elseif (is_404()) { | |
echo 'Not Found - '; | |
} bloginfo('name'); | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Add Post Formats */ | |
/*-----------------------------------------------------------------------------------*/ | |
// add_theme_support('post-formats', array('aside', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video', 'audio')); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Add Editor Stylesheet Support */ | |
/*-----------------------------------------------------------------------------------*/ | |
if ( function_exists('add_editor_style') ) { | |
add_editor_style(); | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Set Content Width */ | |
/*-----------------------------------------------------------------------------------*/ | |
if ( ! isset( $content_width ) ) $content_width = 940; | |
/*-----------------------------------------------------------------------------------*/ | |
/* Screenr oEmbed Support | |
/*-----------------------------------------------------------------------------------*/ | |
wp_oembed_add_provider( '#http://(www\.)?screenr\.com/.*#i', 'http://www.screenr.com/api/oembed.json', true ); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Add WordPress 3.0 Menu Support */ | |
/*-----------------------------------------------------------------------------------*/ | |
if ( function_exists('register_nav_menu') ) { | |
register_nav_menus( array( 'primary' => __( 'Primary Menu', 'contempo' ) ) ); | |
register_nav_menus( array( 'footer' => __( 'Footer Menu', 'contempo' ) ) ); | |
} | |
function ct_nav() { ?> | |
<nav> | |
<?php wp_nav_menu( array( 'container_id' => 'nav', 'theme_location' => 'primary') ); ?> | |
</nav> | |
<?php } | |
function ct_footer_nav() { ?> | |
<nav class="left"> | |
<?php wp_nav_menu( array( 'container_id' => 'footer-nav', 'theme_location' => 'footer') ); ?> | |
</nav> | |
<?php } | |
/*-----------------------------------------------------------------------------------*/ | |
/* Register Scripts and CSS */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_register_cssjs() { | |
wp_register_script('flexslider', get_template_directory_uri() . '/js/jquery.flexslider-min.js', 'jquery'); | |
wp_register_script('validationEngine', get_template_directory_uri() . '/js/jquery.validationEngine.js', 'jquery'); | |
wp_register_script('innerfade', get_template_directory_uri() . '/js/jquery.innerfade.js', 'jquery'); | |
wp_register_script('prettyPhoto', get_template_directory_uri() . '/js/jquery.prettyPhoto.js', 'jquery'); | |
wp_register_script('fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', 'jquery'); | |
wp_register_script('gmaps', '//maps.google.com/maps/api/js?v=3.22', '', '1.0', false); | |
wp_register_script('infobubble', 'http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/src/infobubble.js', 'gmaps'); | |
wp_register_script('marker', get_template_directory_uri() . '/js/markerwithlabel.js', 'gmaps'); | |
wp_register_script('geocode', get_template_directory_uri() . '/js/ct.geocode.markers.js', 'gmaps'); | |
wp_register_script('mapping', get_template_directory_uri() . '/js/mapping.js', 'gmaps'); | |
wp_register_script('backstretch', get_template_directory_uri() . '/js/jquery.backstretch.min.js', 'jquery'); | |
wp_register_script('base', get_template_directory_uri() . '/js/base.js', 'gmaps'); | |
wp_register_style('base', get_template_directory_uri() . '/css/base.css', '', '', 'screen, projection'); | |
wp_register_style('framework', get_template_directory_uri() . '/css/framework.css', '', '', 'screen, projection'); | |
wp_register_style('layout', get_template_directory_uri() . '/css/layout.css', '', '', 'screen, projection'); | |
wp_register_style('dropdowns', get_template_directory_uri() . '/css/ct-dropdowns.css', '', '', 'screen and (min-width: 768px)'); | |
wp_register_style('comments', get_template_directory_uri() . '/css/comments.css', '', '', 'screen, projection'); | |
wp_register_style('flexslider', get_template_directory_uri() . '/css/flexslider.css', '', '', 'screen, projection'); | |
wp_register_style('validationEngine', get_template_directory_uri() . '/css/validationEngine.jquery.css', '', '', 'screen, projection'); | |
wp_register_style('prettyPhoto', get_template_directory_uri() . '/css/prettyPhoto.css', '', '', 'screen, projection'); | |
wp_register_style('print', get_template_directory_uri() . '/css/post-print.css', '', '', 'print'); | |
wp_register_style('shortcodes', get_template_directory_uri() . '/admin/shortcodes/css/shortcodes.css', '', '', 'screen, projection'); | |
wp_register_style('dsidxpress', get_template_directory_uri() . '/css/dsidxpress.css', '', '', 'screen, projection'); | |
} | |
add_action('wp_enqueue_scripts', 'ct_register_cssjs'); | |
function ct_init_scripts() { | |
// Enqueue Styles | |
wp_enqueue_style('base'); | |
wp_enqueue_style('framework'); | |
wp_enqueue_style('dropdowns'); | |
wp_enqueue_style('layout'); | |
wp_enqueue_style('prettyPhoto'); | |
wp_enqueue_style('dsidxpress'); | |
if(is_home() || is_archive('listings') || is_singular('listings')) { | |
wp_enqueue_style('flexslider'); | |
} | |
if(is_singular('listings')) { | |
wp_enqueue_style('print'); | |
} | |
if(is_single() || is_page()) { | |
wp_enqueue_style('comments'); | |
wp_enqueue_style('shortcodes'); | |
} | |
if(is_page_template('template-contact.php') || is_singular('listings')) { | |
wp_enqueue_style('validationEngine'); | |
} | |
// Enqueue Scripts | |
wp_enqueue_script('prettyPhoto'); | |
wp_enqueue_script('fitvids'); | |
wp_enqueue_script('innerfade'); | |
wp_enqueue_script('backstretch'); | |
wp_enqueue_script('base'); | |
if(is_single() || is_page()) { | |
wp_enqueue_script('comment-reply'); | |
} | |
if(is_home() || is_archive('listings') || is_singular('listings')) { | |
wp_enqueue_script('flexslider'); | |
} | |
if(is_archive('listings') || is_singular('listings') || is_author() || is_page_template('template-contact.php')) { | |
wp_enqueue_script('gmaps'); | |
wp_enqueue_script('infobubble'); | |
wp_enqueue_script('marker'); | |
wp_enqueue_script('mapping'); | |
} | |
if(is_page_template('template-contact.php') || is_singular('listings')) { | |
wp_enqueue_script('validationEngine'); | |
} | |
} | |
add_action('wp_enqueue_scripts', 'ct_init_scripts'); | |
/*-----------------------------------------------------------------------------------*/ | |
/* CT Head */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_wp_head() { | |
/* Load Theme Options */ | |
global $ct_options; | |
if($ct_options['ct_custom_favicon']) { ?> | |
<link rel="shortcut icon" href="<?php echo $ct_options['ct_custom_favicon']; ?>" /> | |
<?php } ?> | |
<!--[if lt IE 9]> | |
<script src="<?php echo get_template_directory_uri(); ?>/js/respond.min.js"></script> | |
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<?php if(is_home() || is_archive('listings')) { ?> | |
<script type="text/javascript"> | |
jQuery(window).load(function() { | |
// Slider | |
jQuery('#slider').flexslider({ | |
animation: "<?php echo strtolower($ct_options['ct_flex_animation']); ?>", | |
slideDirection: "<?php echo strtolower($ct_options['ct_flex_direction']); ?>", | |
slideshow: true, | |
slideshowSpeed: <?php echo $ct_options['ct_flex_speed']; ?>, | |
animationDuration: <?php echo $ct_options['ct_flex_duration']; ?>, | |
directionNav: true, | |
keyboardNav: true, | |
randomize: <?php echo strtolower($ct_options['ct_flex_randomize']); ?>, | |
pauseOnAction: true, | |
pauseOnHover: false, | |
<?php if(is_home()) { | |
echo 'controlsContainer: ".slideshow",'; | |
} ?> | |
<?php if(is_single()) { | |
echo 'animation: "slide",'; | |
echo 'controlNav: "thumbnails",'; | |
} ?> | |
animationLoop: true | |
}); | |
// Carousel | |
jQuery('#carousel').flexslider({ | |
animation: "slide", | |
animationLoop: false, | |
directionNav: true, | |
controlNav: false, | |
<?php if(is_home()) { | |
echo 'itemWidth: 227,'; | |
} elseif(is_archive('listings')) { | |
echo 'itemWidth: 580,'; | |
} ?> | |
itemMargin: 10 | |
}); | |
}); | |
</script> | |
<?php } ?> | |
<?php if(is_single()) { ?> | |
<script type="text/javascript"> | |
jQuery(window).load(function() { | |
jQuery('#carousel').flexslider({ | |
animation: "slide", | |
controlNav: false, | |
directionNav: true, | |
animationLoop: false, | |
slideshow: true, | |
slideshowSpeed: <?php echo $ct_options['ct_flex_speed']; ?>, | |
animationDuration: <?php echo $ct_options['ct_flex_duration']; ?>, | |
itemWidth: 120, | |
itemMargin: 0, | |
asNavFor: '#slider' | |
}); | |
jQuery('#slider').flexslider({ | |
animation: "slide", | |
controlNav: false, | |
animationLoop: false, | |
slideshow: false, | |
sync: "#carousel" | |
}); | |
}); | |
</script> | |
<?php } ?> | |
<?php if(is_page_template('template-contact.php')) { ?> | |
<script> | |
jQuery(document).ready(function() { | |
jQuery("#contactform").validationEngine({ | |
ajaxSubmit: true, | |
ajaxSubmitFile: "<?php echo get_template_directory_uri(); ?>/includes/ajax-submit-contact.php", | |
ajaxSubmitMessage: "<?php echo stripslashes($ct_options['ct_contact_success']); ?>", | |
success : false, | |
failure : function() {} | |
}) | |
}); | |
</script> | |
<?php } ?> | |
<?php if(is_singular('listings')) { ?> | |
<script> | |
jQuery(document).ready(function() { | |
jQuery("#listingscontact").validationEngine({ | |
ajaxSubmit: true, | |
ajaxSubmitFile: "<?php echo get_template_directory_uri(); ?>/includes/ajax-submit-listings.php", | |
ajaxSubmitMessage: "<?php echo stripslashes($ct_options['ct_contact_success']); ?>", | |
success : false, | |
failure : function() {} | |
}) | |
}); | |
</script> | |
<?php } ?> | |
<!-- FitVids & Backstretch --> | |
<script> | |
jQuery(document).ready(function($){ | |
$("#container").fitVids(); | |
<?php if($ct_options['ct_header_bg'] !='') { ?> | |
$.backstretch("<?php echo $ct_options['ct_header_bg']; ?>") | |
<?php } else { ?> | |
$.backstretch("<?php echo get_template_directory_uri(); ?>/images/body_bg.jpg") | |
<?php } ?> | |
$('.testimonial-content').innerfade({ | |
speed: 1000, | |
timeout: 2000, | |
type: 'random', | |
containerheight: '140px' | |
}); | |
}); | |
</script> | |
<?php if($ct_options['ct_home_map'] == "No") { ?> | |
<style type="text/css"> | |
#home #map { display: none;} | |
#home .container[role="masthead"] { margin-bottom: 0 !important;} | |
</style> | |
<?php } ?> | |
<?php | |
/* Inject Custom Google Fonts */ | |
$ct_font = str_replace(' ','+',$ct_options['ct_custom_font']); | |
?> | |
<link href='http://fonts.googleapis.com/css?family=<?php echo $ct_font; ?>' rel='stylesheet' type='text/css'> | |
<style type="text/css"> | |
body { font-family: '<?php echo $ct_options['ct_custom_font']; ?>', Helvetica, Arial, sans-serif;} | |
</style> | |
<?php | |
/* Inject Custom Stylesheet */ | |
if($ct_options['ct_use_styles'] == "Yes") { | |
include(TEMPLATEPATH . '/includes/custom-stylesheet.php'); | |
} | |
/* Date format */ | |
$GLOBALS['ctdate'] = get_option('ct_dateformat'); | |
if ( $GLOBALS['ctdate'] == "" ) | |
$GLOBALS['ctdate'] = "M j, Y"; | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Contact Us Map */ | |
/*-----------------------------------------------------------------------------------*/ | |
function contact_us_map() { | |
global $ct_options; | |
if($ct_options['ct_contact_map'] =="Yes") { ?> | |
<style type="text/css"> | |
.label { height: 51px; width: 47px; font-weight: bold; color: #fff; padding: 1px 4px; background: url(<?php echo get_template_directory_uri(); ?>/images/map-pin.png) no-repeat;} | |
</style> | |
<script> | |
function setMapAddress(address) { | |
var geocoder = new google.maps.Geocoder(); | |
geocoder.geocode( { address : address }, function( results, status ) { | |
if( status == google.maps.GeocoderStatus.OK ) { | |
var location = results[0].geometry.location; | |
var options = { | |
zoom: 15, | |
center: location, | |
mapTypeId: google.maps.MapTypeId.<?php echo strtoupper($ct_options['ct_contact_map_type']); ?>, | |
streetViewControl: true | |
}; | |
var mymap = new google.maps.Map( document.getElementById( 'map' ), options ); | |
var marker = new MarkerWithLabel({ | |
map: mymap, | |
draggable: false, | |
flat: true, | |
labelContent: '', | |
labelAnchor: new google.maps.Point(22, 0), | |
labelClass: "label", // the CSS class for the label | |
labelStyle: {opacity: 1}, | |
icon: 'images/blank.png', | |
position: results[0].geometry.location | |
}); | |
} | |
}); | |
} | |
setMapAddress( "<?php echo $ct_options['ct_contact_map_location']; ?>" ); | |
</script> | |
<div id="location" class="marB18"> | |
<div id="map"></div> | |
</div> | |
<?php } | |
} | |
function listing_map() { | |
global $ct_options; | |
?> | |
<script> | |
function setMapAddress(address) { | |
var geocoder = new google.maps.Geocoder(); | |
geocoder.geocode( { address : address }, function( results, status ) { | |
if( status == google.maps.GeocoderStatus.OK ) { | |
<?php if((get_post_meta(get_the_ID(), "_ct_latlng", true))) { ?> | |
var location = new google.maps.LatLng(<?php echo get_post_meta(get_the_ID(), "_ct_latlng", true); ?>); | |
<?php } else { ?> | |
var location = results[0].geometry.location; | |
<?php } ?> | |
var options = { | |
zoom: 15, | |
center: location, | |
mapTypeId: google.maps.MapTypeId.<?php echo strtoupper($ct_options['ct_contact_map_type']); ?>, | |
streetViewControl: true | |
}; | |
var mymap = new google.maps.Map( document.getElementById( 'map' ), options ); | |
var marker = new google.maps.Marker({ | |
map: mymap, | |
draggable: false, | |
flat: true, | |
icon: '<?php echo get_template_directory_uri(); ?>/images/map-pin.png', | |
<?php if((get_post_meta(get_the_ID(), "_ct_latlng", true))) { ?> | |
position: new google.maps.LatLng(<?php echo get_post_meta(get_the_ID(), "_ct_latlng", true); ?>) | |
<?php } else { ?> | |
position: results[0].geometry.location | |
<?php } ?> | |
}); | |
} | |
}); | |
} | |
<?php if((get_post_meta(get_the_ID(), "_ct_latlng", true))) { ?> | |
setMapAddress( "<?php echo get_post_meta(get_the_ID(), "_ct_latlng", true); ?>"); | |
<?php } else { ?> | |
setMapAddress( "<?php the_title(); ?>, <?php city(); ?>, <?php state(); ?>, <?php zipcode(); ?>" ); | |
<?php } ?> | |
</script> | |
<div id="map"></div> | |
<?php } | |
function multi_marker_map() { | |
global $ct_options; | |
global $post; | |
$count = 0; | |
$num = $ct_options['ct_home_map_num']; | |
query_posts(array( | |
'post_type' => 'listings', | |
'posts_per_page' => $num, | |
'status' => 'featured', | |
'order' => 'DSC' | |
)); | |
?> | |
<script> | |
var property_list = []; | |
var default_mapcenter = []; | |
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $count++; ?> | |
var property = { | |
thumb: "<?php ct_first_image_tn_map() ?>", | |
<?php if( (get_post_meta($post->ID, "_ct_price", true)) != "" ) { ?>price: "<?php currency(); ?><?php map_pin_price(); ?>",<?php } ?> | |
<?php if( (get_post_meta($post->ID, "_ct_price", true)) != "" ) { ?>fullPrice: "<?php currency(); ?><?php listing_price(); ?>",<?php } ?> | |
bed: "<?php beds(); ?>", | |
bath: "<?php baths(); ?>", | |
size: "<?php echo get_post_meta($post->ID, "_ct_sqft", true); ?> <?php sqftsqm(); ?>", | |
street: "<?php the_title(); ?>", | |
city: "<?php city(); ?>", | |
state: "<?php state(); ?>", | |
zip: "<?php zipcode(); ?>", | |
latlong: "<?php echo get_post_meta(get_the_ID(), "_ct_latlng", true); ?>", | |
permalink: "<?php the_permalink(); ?>", | |
agentThumb: "<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php the_author_meta('ct_profile_url'); ?>&w=40&zc=1'", | |
agentName: "<?php the_author_meta('first_name'); ?> <?php the_author_meta('last_name'); ?>", | |
agentTagline: "<?php if(get_the_author_meta('tagline')) { the_author_meta('tagline'); } ?>", | |
agentPhone: "<?php if(get_the_author_meta('office')) { the_author_meta('office'); } ?>", | |
agentEmail: "<?php if(get_the_author_meta('email')) { the_author_meta('email'); } ?>", | |
isHome: "<?php if(is_home()) { echo "false"; } else { echo "true"; } ?>", | |
commercial: "<?php if(has_type('commercial')) { echo 'commercial'; } ?>" | |
} | |
property_list.push(property); | |
<?php | |
endwhile; endif; | |
wp_reset_query(); | |
?> | |
</script> | |
<script>var defaultmapcenter = {mapcenter: "<?php echo $ct_options['ct_home_map_center']; ?>"}; google.maps.event.addDomListener(window, 'load', function(){ estateMapping.init_property_map(property_list, defaultmapcenter); });</script> | |
<?php } | |
function search_results_map() { | |
global $ct_options; | |
global $post; | |
$count = 0; | |
?> | |
<script> | |
var property_list = []; | |
var default_mapcenter = []; | |
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $count++; ?> | |
var property = { | |
thumb: "<?php ct_first_image_tn_map() ?>", | |
<?php if( (get_post_meta($post->ID, "_ct_price", true)) != "" ) { ?>price: "<?php currency(); ?><?php map_pin_price(); ?>",<?php } ?> | |
<?php if( (get_post_meta($post->ID, "_ct_price", true)) != "" ) { ?>fullPrice: "<?php currency(); ?><?php listing_price(); ?>",<?php } ?> | |
bed: "<?php beds(); ?>", | |
bath: "<?php baths(); ?>", | |
size: "<?php echo get_post_meta($post->ID, "_ct_sqft", true); ?> <?php sqftsqm(); ?>", | |
street: "<?php the_title(); ?>", | |
city: "<?php city(); ?>", | |
state: "<?php state(); ?>", | |
zip: "<?php zipcode(); ?>", | |
latlong: "<?php echo get_post_meta(get_the_ID(), "_ct_latlng", true); ?>", | |
permalink: "<?php the_permalink(); ?>", | |
agentThumb: "<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php the_author_meta('ct_profile_url'); ?>&w=40&zc=1'", | |
agentName: "<?php the_author_meta('first_name'); ?> <?php the_author_meta('last_name'); ?>", | |
agentTagline: "<?php if(get_the_author_meta('tagline')) { the_author_meta('tagline'); } ?>", | |
agentPhone: "<?php if(get_the_author_meta('office')) { the_author_meta('office'); } ?>", | |
agentEmail: "<?php if(get_the_author_meta('email')) { the_author_meta('email'); } ?>", | |
isHome: "<?php if(is_home()) { echo "false"; } else { echo "true"; } ?>", | |
commercial: "<?php if(has_type('commercial')) { echo 'commercial'; } ?>" | |
} | |
property_list.push(property); | |
<?php | |
endwhile; endif; | |
wp_reset_query(); | |
?> | |
</script> | |
<script>var defaultmapcenter = {mapcenter: "<?php echo $ct_options['ct_map_center']; ?>"}; google.maps.event.addDomListener(window, 'load', function(){ estateMapping.init_property_map(property_list, defaultmapcenter); });</script> | |
<?php } | |
/*-----------------------------------------------------------------------------------*/ | |
/* Homepage Slider */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_slider() { | |
global $ct_options; | |
$slides = $ct_options['ct_flex_slider']; ?> | |
<?php if(is_home()) { echo '<div class="sixteen columns alpha omega marB20">'; } ?> | |
<div id="slider" class="flexslider <?php if(is_home()) { echo 'sixteen columns alpha omega '; } ?>marT40"> | |
<ul class="slides"> | |
<?php | |
foreach ($slides as $slide => $value) { | |
if (!empty ($value['url'])) { | |
$imgURL = $value['url']; | |
$imgID = get_attachment_id_from_src($imgURL); | |
?> | |
<li> | |
<?php if (!empty ($value['link'])) { ?> | |
<a href="<?php echo $value['link']; ?>"> | |
<img src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo $value['url']; ?>&h=<?php if($ct_options['ct_flex_height']) { echo $ct_options['ct_flex_height']; } else { echo '300'; } ?>&w=960&zc=1" /> | |
</a> | |
<?php } else { ?> | |
<img src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo $value['url']; ?>&h=<?php if($ct_options['ct_flex_height']) { echo $ct_options['ct_flex_height']; } else { echo '300'; } ?>&w=960&zc=1" /> | |
<?php } ?> | |
<?php if (!empty ($value['title']) || !empty ($value['description'])) { ?> | |
<div class="flex-caption"> | |
<?php if (!empty ($value['title'])) { ?> | |
<h4 class="marB5"><?php echo $value['title']; ?></h4> | |
<?php } ?> | |
<?php if (!empty ($value['description'])) { ?> | |
<p><?php echo $value['description']; ?></p> | |
<?php } ?> | |
</div> | |
<?php } ?> | |
</li> | |
<?php } else { | |
echo '<li class="video">'; | |
echo stripslashes($value['embed']); | |
echo '</li>'; | |
} | |
} ?> | |
</ul> | |
</div> | |
<?php if(is_home()) { echo '</div>'; } ?> | |
<?php } | |
/*-----------------------------------------------------------------------------------*/ | |
/* Fix Pagination on Search Results */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_fix_query($query) { | |
global $paged; | |
if( $query->is_main_query() && $query->is_home() ) { | |
$query->set('post_type', array('post', 'listings')); | |
} | |
} | |
add_action('pre_get_posts', 'ct_fix_query'); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Add Custom Post Type Archive to Menus */ | |
/*-----------------------------------------------------------------------------------*/ | |
/* inject cpt archives meta box */ | |
add_action( 'admin_head-nav-menus.php', 'inject_cpt_archives_menu_meta_box' ); | |
function inject_cpt_archives_menu_meta_box() { | |
add_meta_box( 'add-cpt', __( 'CPT Archives', 'default' ), 'wp_nav_menu_cpt_archives_meta_box', 'nav-menus', 'side', 'default' ); | |
} | |
/* render custom post type archives meta box */ | |
function wp_nav_menu_cpt_archives_meta_box() { | |
/* get custom post types with archive support */ | |
$post_types = get_post_types( array( 'show_in_nav_menus' => true, 'has_archive' => true ), 'object' ); | |
/* hydrate the necessary object properties for the walker */ | |
foreach ( $post_types as &$post_type ) { | |
$post_type->classes = array(); | |
$post_type->type = $post_type->name; | |
$post_type->object_id = $post_type->name; | |
$post_type->title = $post_type->labels->name . ' ' . __( 'Archive', 'default' ); | |
$post_type->object = 'cpt-archive'; | |
} | |
$walker = new Walker_Nav_Menu_Checklist( array() ); | |
?> | |
<div id="cpt-archive" class="posttypediv"> | |
<div id="tabs-panel-cpt-archive" class="tabs-panel tabs-panel-active"> | |
<ul id="ctp-archive-checklist" class="categorychecklist form-no-clear"> | |
<?php | |
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $post_types), 0, (object) array( 'walker' => $walker) ); | |
?> | |
</ul> | |
</div><!-- /.tabs-panel --> | |
</div> | |
<p class="button-controls"> | |
<span class="add-to-menu"> | |
<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> | |
<input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-ctp-archive-menu-item" id="submit-cpt-archive" /> | |
</span> | |
</p> | |
<?php | |
} | |
/* take care of the urls */ | |
add_filter( 'wp_get_nav_menu_items', 'cpt_archive_menu_filter', 10, 3 ); | |
function cpt_archive_menu_filter( $items, $menu, $args ) { | |
/* alter the URL for cpt-archive objects */ | |
foreach ( $items as &$item ) { | |
if ( $item->object != 'cpt-archive' ) continue; | |
$item->url = get_post_type_archive_link( $item->type ); | |
/* set current */ | |
if ( get_query_var( 'post_type' ) == $item->type ) { | |
$item->classes []= 'current-menu-item'; | |
$item->current = true; | |
} | |
} | |
return $items; | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Filter "Enter title here" with custom text */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_change_default_title( $title ){ | |
$screen = get_current_screen(); | |
if ( 'listings' == $screen->post_type ) { | |
$title = 'Enter the listing address here'; | |
} | |
return $title; | |
} | |
add_filter( 'enter_title_here', 'ct_change_default_title' ); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Demo Changer */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_demo_head() { | |
require_once(TEMPLATEPATH . '/demo/demo-styles.php'); | |
} | |
function ct_demo_footer() { | |
require_once(TEMPLATEPATH . '/demo/demo-styles-footer.php'); | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Remove WLW and RSD for validation */ | |
/*-----------------------------------------------------------------------------------*/ | |
remove_action('wp_head', 'wlwmanifest_link'); | |
remove_action('wp_head', 'rsd_link'); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Status Snipes */ | |
/*-----------------------------------------------------------------------------------*/ | |
function has_status( $status, $_post = null ) { | |
if ( empty( $status ) ) | |
return false; | |
if ( $_post ) | |
$_post = get_post( $_post ); | |
else | |
$_post =& $GLOBALS['post']; | |
if ( !$_post ) | |
return false; | |
$r = is_object_in_term( $_post->ID, 'status', $status ); | |
if ( is_wp_error( $r ) ) | |
return false; | |
return $r; | |
} | |
function ct_status() { ?> | |
<?php if(has_status('reduced') || has_status('sold') || has_status('leased') || has_status('open-house') || has_status('for-rent') || has_status('rental')) { ?> | |
<h6 class="snipe <?php if(has_status('reduced')) { echo "reduced"; } elseif(has_status('sold')) { echo "sold"; } elseif(has_status('leased')) { echo "leased"; } elseif(has_status('open-house')) { echo "open-house"; } elseif(has_status('available')) { echo "available"; } elseif(has_status('for-rent') || has_status('rental')) { echo "rental"; } ?>"><?php if(has_status('reduced')) { ?><?php _e('Reduced', 'contempo'); ?><?php } elseif(has_status('leased')) { ?><?php _e('Leased', 'contempo'); ?><?php } elseif(has_status('sold')) { ?><?php _e('Sold', 'contempo'); ?><?php } elseif(has_status('open-house')) { ?><?php _e('Open House', 'contempo'); ?><?php } elseif(has_status('available')) { ?><?php _e('Available', 'contempo'); ?><?php } elseif(has_status('for-rent') || has_status('rental')) { ?><?php _e('Rental', 'contempo'); ?><?php } ?></h6> | |
<?php } ?> | |
<?php } | |
/*-----------------------------------------------------------------------------------*/ | |
/* Currency */ | |
/*-----------------------------------------------------------------------------------*/ | |
function currency() { | |
global $ct_options; | |
if($ct_options['ct_currency']) { | |
echo $ct_options['ct_currency']; | |
} else { | |
echo "$"; | |
} | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Listing Price */ | |
/*-----------------------------------------------------------------------------------*/ | |
function listing_price() { | |
global $post; | |
$price_meta = get_post_meta(get_the_ID(), '_ct_price', true); | |
$price_meta= preg_replace('/[\$,]/', '', $price_meta); | |
echo number_format($price_meta, 0, '.', ','); | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Map Pin Price */ | |
/*-----------------------------------------------------------------------------------*/ | |
function map_pin_price() { | |
global $post; | |
$ct_price = get_post_meta($post->ID, "_ct_price", true); | |
if($ct_price < 10000) { | |
echo substr(get_post_meta($post->ID, "_ct_price", true), 0, 4); | |
} elseif($ct_price < 100000) { | |
echo substr(get_post_meta($post->ID, "_ct_price", true), 0, 2) . 'K'; | |
} elseif($ct_price < 1000000) { | |
echo substr(get_post_meta($post->ID, "_ct_price", true), 0, 3) . 'K'; | |
} elseif($ct_price >= 1000000) { | |
echo substr(get_post_meta($post->ID, "_ct_price", true), 0, 1) . 'M+'; | |
} | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Sq Ft or Sq Meters */ | |
/*-----------------------------------------------------------------------------------*/ | |
function sqftsqm() { | |
global $ct_options; | |
if($ct_options['ct_sq'] == "Sq Ft") { | |
echo _e('Sq Ft', 'contempo'); | |
} elseif($ct_options['ct_sq'] == "Sq Meters") { | |
echo _e('m<sup>2</sup>', 'contempo'); | |
} | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Acres or Sq Meters */ | |
/*-----------------------------------------------------------------------------------*/ | |
function acres() { | |
global $ct_options; | |
if($ct_options['ct_sq'] == "sqft") { | |
echo _e('Acres', 'contempo'); | |
} elseif($ct_options['ct_sq'] == "sqmeters") { | |
echo _e('m<sup>2</sup>', 'contempo'); | |
} | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Property Type Tags */ | |
/*-----------------------------------------------------------------------------------*/ | |
function has_type( $type, $_post = null ) { | |
if ( empty( $type ) ) | |
return false; | |
if ( $_post ) | |
$_post = get_post( $_post ); | |
else | |
$_post =& $GLOBALS['post']; | |
if ( !$_post ) | |
return false; | |
$r = is_object_in_term( $_post->ID, 'property_type', $type ); | |
if ( is_wp_error( $r ) ) | |
return false; | |
return $r; | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Advanced Search Select */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_search_form_select($name, $taxonomy_name = null) { | |
global $search_values; | |
if (!$taxonomy_name) { | |
$taxonomy_name = $name; | |
} | |
?> | |
<select id="ct_<?php echo $name; ?>" name="ct_<?php echo $name; ?>"> | |
<option value="0"><?php _e('Any', 'contempo'); ?></option> | |
<?php foreach( get_terms($taxonomy_name, 'hide_empty=0') as $t ) : ?> | |
<?php if ($search_values[$name] == $t->slug) { $selected = 'selected="selected" '; } else { $selected = ''; } ?> | |
<option <?php echo $selected; ?>value="<?php echo $t->slug; ?>"><?php echo $t->name; ?></option> | |
<?php endforeach; ?> | |
</select> | |
<?php | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Tags Navigation for Portfolio */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_tags_nav() { ?> | |
<ul id="tags-nav" class="marB18 padT18 clear <?php global $ct_options; if($ct_options['ct_portfolio_archive_header'] == 'No') { ?>no-border<?php } ?>"> | |
<li id="select"><?php _e('Filter:', 'contempo'); ?></li> | |
<li><a href="#" class="all"><?php _e('All','contempo'); ?></a></li> | |
<?php | |
if(is_post_type_archive('portfolio')) { | |
$terms = get_terms('portfolio_tags'); | |
} | |
$count = count($terms); | |
if ( $count > 0 ){ | |
foreach ( $terms as $term ) { | |
echo "<li><a href='#' class='$term->slug'>" . ucfirst($term->name) . "</a></li>"; | |
} | |
} ?> | |
</ul> | |
<?php } | |
/*-----------------------------------------------------------------------------------*/ | |
/* Output all term slugs */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_terms() { | |
if(is_post_type_archive('portfolio')) { | |
$terms = get_the_terms( $post->id, 'portfolio_tags' ); | |
} | |
if ($terms) { | |
foreach($terms as $term) { | |
echo $term->slug; | |
} | |
} | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Show the first term name only */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_first_term() { | |
global $post; | |
if(is_post_type_archive('portfolio')) { | |
$terms = get_the_terms( $post->id, 'portfolio_tags' ); | |
} | |
$count = 0; | |
if ($terms) { | |
foreach($terms as $term) { | |
$count++; | |
if (1 == $count) { | |
echo $term->name; | |
} | |
} | |
} | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Get image ID from URL - http://goo.gl/q9D9L | |
/*-----------------------------------------------------------------------------------*/ | |
function get_attachment_id_from_src($image_src) { | |
global $wpdb; | |
$query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$image_src'"; | |
$id = $wpdb->get_var($query); | |
return $id; | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Custom excerpt length */ | |
/*-----------------------------------------------------------------------------------*/ | |
function new_excerpt_length($length) { | |
global $ct_options; | |
$ct_excerpt_length = $ct_options['ct_excerpt_length']; | |
return $ct_excerpt_length; | |
} | |
add_filter('excerpt_length', 'new_excerpt_length'); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Remove <p> tags from the_excerpt */ | |
/*-----------------------------------------------------------------------------------*/ | |
remove_filter('the_excerpt', 'wpautop'); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Add read more link to excerpt */ | |
/*-----------------------------------------------------------------------------------*/ | |
function new_excerpt_more($more) { | |
return '.'; | |
} | |
add_filter('excerpt_more', 'new_excerpt_more'); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Read More Link */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_read_more_link() { | |
global $ct_options; | |
$ct_read_more = $ct_options['ct_read_more']; ?> | |
<a class="read-more right" href="<?php the_permalink(); ?>'"> | |
<?php if($ct_read_more) { | |
echo $ct_read_more; | |
} else { | |
echo "Read more <em>→</em>"; | |
} ?> | |
</a> | |
<?php } | |
/*-----------------------------------------------------------------------------------*/ | |
/* Custom Author */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_author() { | |
global $post; | |
if(get_post_meta($post->ID, "_ct_custom_author", true)) { | |
echo get_post_meta($post->ID, "_ct_custom_author", true); | |
} else { | |
the_author_meta('display_name'); | |
} | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Remove <p> tags from category_description */ | |
/*-----------------------------------------------------------------------------------*/ | |
remove_filter('term_description','wpautop'); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Allow Shortcodes to be used in widgets */ | |
/*-----------------------------------------------------------------------------------*/ | |
add_filter('widget_text', 'do_shortcode'); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Add CPTs to RSS feed */ | |
/*-----------------------------------------------------------------------------------*/ | |
function myfeed_request($qv) { | |
if (isset($qv['feed'])) | |
$qv['post_type'] = get_post_types(); | |
return $qv; | |
} | |
add_filter('request', 'myfeed_request'); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Pagination */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_pagination($pages = '', $range = 2) { | |
global $wp_query, $wp_rewrite; | |
$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1; | |
$pagination = array( | |
'base' => @add_query_arg('page','%#%'), | |
'format' => '', | |
'total' => $wp_query->max_num_pages, | |
'current' => $current, | |
'show_all' => true, | |
'type' => 'list', | |
'next_text' => '»', | |
'prev_text' => '«' | |
); | |
if( $wp_rewrite->using_permalinks() ) | |
$pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' ); | |
if( !empty($wp_query->query_vars['s']) ) | |
$pagination['add_args'] = array( 's' => get_query_var( 's' ) ); | |
echo paginate_links( $pagination ); | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Get all of the images attached to the current post */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_get_images($size = 'full') { | |
global $post; | |
$photos = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') ); | |
$results = array(); | |
if ($photos) { | |
foreach ($photos as $photo) { | |
// get the correct image html for the selected size | |
$results[] = wp_get_attachment_url($photo->ID); | |
} | |
} | |
return $results; | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Display all images attached to listing - homepage featured */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_slider_images() { | |
$photos = ct_get_images('full'); | |
if ($photos) { | |
foreach ($photos as $photo) { ?> | |
<li data-thumb="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo $photo ?>&w=500&zc=1"> | |
<img class="photo" src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo $photo ?>&h=400&w=945&zc=1" title="<?php the_title(); ?>" /> | |
</li> | |
<?php } | |
} | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Display all images attached to listing - detail */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_listing_images() { | |
$photos = ct_get_images('full'); | |
if ($photos) { | |
foreach ($photos as $photo) { ?> | |
<img class="marB18" src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo $photo ?>&w=945&zc=1" /> | |
<?php } | |
} | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Display all images attached to post - detail */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_gallery_images() { | |
$photos = ct_get_images('full'); | |
if ($photos) { | |
foreach ($photos as $photo) { ?> | |
<img class="marB18" src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo $photo ?>&w=945&zc=1" /> | |
<?php } | |
} | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Get the first image attached to the current post */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_get_post_image() { | |
global $post; | |
$photos = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID')); | |
if ($photos) { | |
$photo = array_shift($photos); | |
return wp_get_attachment_url($photo->ID); | |
} | |
return false; | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Display first image thumb */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_first_image_tn() { | |
$photo = ct_get_post_image(); | |
if ($photo) { ?> | |
<img src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&w=150&zc=1" /> | |
<?php } | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Display first image linked */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_first_image_linked() { | |
$photo = ct_get_post_image(); | |
if ($photo) { ?> | |
<a href="<?php the_permalink(); ?>"> | |
<img src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&w=598&zc=1" /> | |
</a> | |
<?php } | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Display first image large linked */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_first_image_lrg_linked() { | |
$photo = ct_get_post_image(); | |
if ($photo) { ?> | |
<a href="<?php the_permalink(); ?>"> | |
<img src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&w=945&zc=1" /> | |
</a> | |
<?php } | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Display first image thumbnail - info bubble */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_first_image_tn_map() { | |
$photo = ct_get_post_image(); | |
if ($photo) { | |
echo get_template_directory_uri() . '/img_resize/timthumb.php?src=' . ct_get_post_image() . '&w=69&zc=1'; | |
} | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Display first image thumbnail - float left */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_first_image_tn_left() { | |
$photo = ct_get_post_image(); | |
if ($photo) { ?> | |
<div class="img-wrap"> | |
<?php ct_status(); ?> | |
<a href="<?php the_permalink(); ?>"> | |
<img src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&w=500&zc=1&s=1" /> | |
</a> | |
</div> | |
<?php } | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Display first image thumbnail - float right */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_first_image_tn_right() { | |
$photo = ct_get_post_image(); | |
if ($photo) { ?> | |
<a href="<?php the_permalink(); ?>"> | |
<img class="tn right" src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&h=40&w=69&zc=1" /> | |
</a> | |
<?php } | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Display first image medium */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_first_image_md() { | |
$photo = ct_get_post_image(); | |
if ($photo) { ?> | |
<a href="<?php the_permalink(); ?>"> | |
<img src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&w=598&zc=1" /> | |
</a> | |
<?php } | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Display first image large */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_first_image_lrg() { | |
$photo = ct_get_post_image(); | |
if ($photo) { ?> | |
<a href="<?php the_permalink(); ?>"> | |
<img src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&w=945&zc=1" /> | |
</a> | |
<?php } | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Display first image print only */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_first_image_print() { | |
$photo = ct_get_post_image(); | |
if ($photo) { ?> | |
<img class="marR20" src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&w=160&zc=1" /> | |
<?php } | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Get users */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_get_users($users_per_page = 10, $paged = 1, $role = '', $orderby = 'login', $order = 'ASC', $usersearch = '' ) { | |
global $blog_id; | |
$args = array( | |
'number' => $users_per_page, | |
'offset' => ( $paged-1 ) * $users_per_page, | |
'role' => $role, | |
'search' => $usersearch, | |
'fields' => 'all_with_meta', | |
'blog_id' => $blog_id, | |
'orderby' => $orderby, | |
'order' => $order | |
); | |
$wp_user_search = new WP_User_Query( $args ); | |
$user_results = $wp_user_search->get_results(); | |
return $user_results; | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Listings Navigation */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_listings_nav() { ?> | |
<div class="clear"></div> | |
<nav class="columns content-nav"> | |
<div class="nav-previous left"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older listings', 'contempo' ) ); ?></div> | |
<div class="nav-next right"><?php previous_posts_link( __( 'Newer listings <span class="meta-nav">→</span>', 'contempo' ) ); ?></div> | |
</nav> | |
<?php } | |
/*-----------------------------------------------------------------------------------*/ | |
/* Content Navigation */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_content_nav() { ?> | |
<div class="clear"></div> | |
<nav class="columns content-nav"> | |
<div class="nav-previous left"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'contempo' ) ); ?></div> | |
<div class="nav-next right"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'contempo' ) ); ?></div> | |
</nav> | |
<?php } | |
/** | |
* The code below is inspired by Justin Tadlock's Hybrid Core. | |
* | |
* ct_breadcrumbs() shows a breadcrumb for all types of pages. Themes and plugins can filter $args or input directly. | |
* Allow filtering of only the $args using get_the_breadcrumb_args. | |
* | |
* @since 3.7.0 | |
* @param array $args Mixed arguments for the menu. | |
* @return string Output of the breadcrumb menu. | |
*/ | |
function ct_breadcrumbs( $args = array() ) { | |
global $wp_query, $wp_rewrite; | |
/* Get the textdomain. */ | |
$textdomain = 'contempo'; | |
/* Create an empty variable for the breadcrumb. */ | |
$breadcrumb = ''; | |
/* Create an empty array for the trail. */ | |
$trail = array(); | |
$path = ''; | |
/* Set up the default arguments for the breadcrumb. */ | |
$defaults = array( | |
'separator' => '»', | |
'before' => '<span class="breadcrumb-title"></span>', | |
'after' => false, | |
'front_page' => true, | |
'show_home' => __( 'Home', $textdomain ), | |
'echo' => true | |
); | |
/* Allow singular post views to have a taxonomy's terms prefixing the trail. */ | |
if ( is_singular() ) | |
$defaults["singular_{$wp_query->post->post_type}_taxonomy"] = false; | |
/* Apply filters to the arguments. */ | |
$args = apply_filters( 'ct_breadcrumbs_args', $args ); | |
/* Parse the arguments and extract them for easy variable naming. */ | |
extract( wp_parse_args( $args, $defaults ) ); | |
/* If $show_home is set and we're not on the front page of the site, link to the home page. */ | |
if ( !is_front_page() && $show_home ) | |
$trail[] = '<a href="' . home_url() . '" title="' . esc_attr( get_bloginfo( 'name' ) ) . '" rel="home" class="trail-begin">' . $show_home . '</a>'; | |
/* If viewing the front page of the site. */ | |
if ( is_front_page() ) { | |
if ( !$front_page ) | |
$trail = false; | |
elseif ( $show_home ) | |
$trail['trail_end'] = "{$show_home}"; | |
} | |
/* If viewing the "home"/posts page. */ | |
elseif ( is_home() ) { | |
$home_page = get_page( $wp_query->get_queried_object_id() ); | |
$trail = array_merge( $trail, ct_breadcrumbs_get_parents( $home_page->post_parent, '' ) ); | |
$trail['trail_end'] = get_the_title( $home_page->ID ); | |
} | |
/* If viewing a singular post (page, attachment, etc.). */ | |
elseif ( is_singular() ) { | |
/* Get singular post variables needed. */ | |
$post = $wp_query->get_queried_object(); | |
$post_id = absint( $wp_query->get_queried_object_id() ); | |
$post_type = $post->post_type; | |
$parent = $post->post_parent; | |
/* If a custom post type, check if there are any pages in its hierarchy based on the slug. */ | |
if ( 'page' !== $post_type ) { | |
$post_type_object = get_post_type_object( $post_type ); | |
/* If $front has been set, add it to the $path. */ | |
if ( 'post' == $post_type || 'attachment' == $post_type || ( $post_type_object->rewrite['with_front'] && $wp_rewrite->front ) ) | |
$path .= trailingslashit( $wp_rewrite->front ); | |
/* If there's a slug, add it to the $path. */ | |
if ( !empty( $post_type_object->rewrite['slug'] ) ) | |
$path .= $post_type_object->rewrite['slug']; | |
/* If there's a path, check for parents. */ | |
if ( !empty( $path ) ) | |
$trail = array_merge( $trail, ct_breadcrumbs_get_parents( '', $path ) ); | |
/* If there's an archive page, add it to the trail. */ | |
if ( !empty( $post_type_object->rewrite['archive'] ) && function_exists( 'get_post_type_archive_link' ) ) | |
$trail[] = '<a href="' . get_post_type_archive_link( $post_type ) . '" title="' . esc_attr( $post_type_object->labels->name ) . '">' . $post_type_object->labels->name . '</a>'; | |
} | |
/* If the post type path returns nothing and there is a parent, get its parents. */ | |
if ( empty( $path ) && 0 !== $parent || 'attachment' == $post_type ) | |
$trail = array_merge( $trail, ct_breadcrumbs_get_parents( $parent, '' ) ); | |
/* Display terms for specific post type taxonomy if requested. */ | |
if ( isset( $args["singular_{$post_type}_taxonomy"] ) && $terms = get_the_term_list( $post_id, $args["singular_{$post_type}_taxonomy"], '', ', ', '' ) ) | |
$trail[] = $terms; | |
/* End with the post title. */ | |
$post_title = get_the_title( $post_id ); // Force the post_id to make sure we get the correct page title. | |
if ( !empty( $post_title ) ) | |
$trail['trail_end'] = $post_title; | |
} | |
/* If we're viewing any type of archive. */ | |
elseif ( is_archive() ) { | |
/* If viewing a taxonomy term archive. */ | |
if ( is_tax() || is_category() || is_tag() ) { | |
/* Get some taxonomy and term variables. */ | |
$term = $wp_query->get_queried_object(); | |
$taxonomy = get_taxonomy( $term->taxonomy ); | |
/* Get the path to the term archive. Use this to determine if a page is present with it. */ | |
if ( is_category() ) | |
$path = get_option( 'category_base' ); | |
elseif ( is_tag() ) | |
$path = get_option( 'tag_base' ); | |
else { | |
if ( $taxonomy->rewrite['with_front'] && $wp_rewrite->front ) | |
$path = trailingslashit( $wp_rewrite->front ); | |
$path .= $taxonomy->rewrite['slug']; | |
} | |
/* Get parent pages by path if they exist. */ | |
if ( $path ) | |
$trail = array_merge( $trail, ct_breadcrumbs_get_parents( '', $path ) ); | |
/* If the taxonomy is hierarchical, list its parent terms. */ | |
if ( is_taxonomy_hierarchical( $term->taxonomy ) && $term->parent ) | |
$trail = array_merge( $trail, ct_breadcrumbs_get_term_parents( $term->parent, $term->taxonomy ) ); | |
/* Add the term name to the trail end. */ | |
$trail['trail_end'] = $term->name; | |
} | |
/* If viewing a post type archive. */ | |
elseif ( function_exists( 'is_post_type_archive' ) && is_post_type_archive() ) { | |
/* Get the post type object. */ | |
$post_type_object = get_post_type_object( get_query_var( 'post_type' ) ); | |
/* If $front has been set, add it to the $path. */ | |
if ( $post_type_object->rewrite['with_front'] && $wp_rewrite->front ) | |
$path .= trailingslashit( $wp_rewrite->front ); | |
/* If there's a slug, add it to the $path. */ | |
if ( !empty( $post_type_object->rewrite['archive'] ) ) | |
$path .= $post_type_object->rewrite['archive']; | |
/* If there's a path, check for parents. */ | |
if ( !empty( $path ) ) | |
$trail = array_merge( $trail, ct_breadcrumbs_get_parents( '', $path ) ); | |
/* Add the post type [plural] name to the trail end. */ | |
$trail['trail_end'] = $post_type_object->labels->name; | |
} | |
/* If viewing an author archive. */ | |
elseif ( is_author() ) { | |
/* If $front has been set, add it to $path. */ | |
if ( !empty( $wp_rewrite->front ) ) | |
$path .= trailingslashit( $wp_rewrite->front ); | |
/* If an $author_base exists, add it to $path. */ | |
if ( !empty( $wp_rewrite->author_base ) ) | |
$path .= $wp_rewrite->author_base; | |
/* If $path exists, check for parent pages. */ | |
if ( !empty( $path ) ) | |
$trail = array_merge( $trail, ct_breadcrumbs_get_parents( '', $path ) ); | |
/* Add the author's display name to the trail end. */ | |
$trail['trail_end'] = get_the_author_meta( 'display_name', get_query_var( 'author' ) ); | |
} | |
/* If viewing a time-based archive. */ | |
elseif ( is_time() ) { | |
if ( get_query_var( 'minute' ) && get_query_var( 'hour' ) ) | |
$trail['trail_end'] = get_the_time( __( 'g:i a', $textdomain ) ); | |
elseif ( get_query_var( 'minute' ) ) | |
$trail['trail_end'] = sprintf( __( 'Minute %1$s', $textdomain ), get_the_time( __( 'i', $textdomain ) ) ); | |
elseif ( get_query_var( 'hour' ) ) | |
$trail['trail_end'] = get_the_time( __( 'g a', $textdomain ) ); | |
} | |
/* If viewing a date-based archive. */ | |
elseif ( is_date() ) { | |
/* If $front has been set, check for parent pages. */ | |
if ( $wp_rewrite->front ) | |
$trail = array_merge( $trail, ct_breadcrumbs_get_parents( '', $wp_rewrite->front ) ); | |
if ( is_day() ) { | |
$trail[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . get_the_time( esc_attr__( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>'; | |
$trail[] = '<a href="' . get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) . '" title="' . get_the_time( esc_attr__( 'F', $textdomain ) ) . '">' . get_the_time( __( 'F', $textdomain ) ) . '</a>'; | |
$trail['trail_end'] = get_the_time( __( 'j', $textdomain ) ); | |
} | |
elseif ( get_query_var( 'w' ) ) { | |
$trail[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . get_the_time( esc_attr__( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>'; | |
$trail['trail_end'] = sprintf( __( 'Week %1$s', $textdomain ), get_the_time( esc_attr__( 'W', $textdomain ) ) ); | |
} | |
elseif ( is_month() ) { | |
$trail[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . get_the_time( esc_attr__( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>'; | |
$trail['trail_end'] = get_the_time( __( 'F', $textdomain ) ); | |
} | |
elseif ( is_year() ) { | |
$trail['trail_end'] = get_the_time( __( 'Y', $textdomain ) ); | |
} | |
} | |
} | |
/* If viewing search results. */ | |
elseif ( is_search() ) | |
$trail['trail_end'] = sprintf( __( 'Search results for "%1$s"', $textdomain ), esc_attr( get_search_query() ) ); | |
/* If viewing a 404 error page. */ | |
elseif ( is_404() ) | |
$trail['trail_end'] = __( '404 Not Found', $textdomain ); | |
/* Connect the breadcrumb trail if there are items in the trail. */ | |
if ( is_array( $trail ) ) { | |
/* Open the breadcrumb trail containers. */ | |
$breadcrumb = '<div class="breadcrumb breadcrumbs ct-breadcrumbs"><div class="breadcrumb-trail">'; | |
/* If $before was set, wrap it in a container. */ | |
if ( !empty( $before ) ) | |
$breadcrumb .= '<span class="trail-before">' . $before . '</span> '; | |
/* Wrap the $trail['trail_end'] value in a container. */ | |
if ( !empty( $trail['trail_end'] ) ) | |
$trail['trail_end'] = '<span class="trail-end">' . $trail['trail_end'] . '</span>'; | |
/* Format the separator. */ | |
if ( !empty( $separator ) ) | |
$separator = '<span class="sep">' . $separator . '</span>'; | |
/* Join the individual trail items into a single string. */ | |
$breadcrumb .= join( " {$separator} ", $trail ); | |
/* If $after was set, wrap it in a container. */ | |
if ( !empty( $after ) ) | |
$breadcrumb .= ' <span class="trail-after">' . $after . '</span>'; | |
/* Close the breadcrumb trail containers. */ | |
$breadcrumb .= '</div></div>'; | |
} | |
/* Allow developers to filter the breadcrumb trail HTML. */ | |
$breadcrumb = apply_filters( 'ct_breadcrumbs', $breadcrumb ); | |
/* Output the breadcrumb. */ | |
if ( $echo ) | |
echo $breadcrumb; | |
else | |
return $breadcrumb; | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Get parents */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_breadcrumbs_get_parents( $post_id = '', $path = '' ) { | |
/* Set up an empty trail array. */ | |
$trail = array(); | |
/* If neither a post ID nor path set, return an empty array. */ | |
if ( empty( $post_id ) && empty( $path ) ) | |
return $trail; | |
/* If the post ID is empty, use the path to get the ID. */ | |
if ( empty( $post_id ) ) { | |
/* Get parent post by the path. */ | |
$parent_page = get_page_by_path( $path ); | |
if( empty( $parent_page ) ) | |
// search on page name (single word) | |
$parent_page = get_page_by_title ( $path ); | |
if( empty( $parent_page ) ) | |
// search on page title (multiple words) | |
$parent_page = get_page_by_title ( str_replace( array('-', '_'), ' ', $path ) ); | |
/* End Modification */ | |
/* If a parent post is found, set the $post_id variable to it. */ | |
if ( !empty( $parent_page ) ) | |
$post_id = $parent_page->ID; | |
} | |
/* If a post ID and path is set, search for a post by the given path. */ | |
if ( $post_id == 0 && !empty( $path ) ) { | |
/* Separate post names into separate paths by '/'. */ | |
$path = trim( $path, '/' ); | |
preg_match_all( "/\/.*?\z/", $path, $matches ); | |
/* If matches are found for the path. */ | |
if ( isset( $matches ) ) { | |
/* Reverse the array of matches to search for posts in the proper order. */ | |
$matches = array_reverse( $matches ); | |
/* Loop through each of the path matches. */ | |
foreach ( $matches as $match ) { | |
/* If a match is found. */ | |
if ( isset( $match[0] ) ) { | |
/* Get the parent post by the given path. */ | |
$path = str_replace( $match[0], '', $path ); | |
$parent_page = get_page_by_path( trim( $path, '/' ) ); | |
/* If a parent post is found, set the $post_id and break out of the loop. */ | |
if ( !empty( $parent_page ) && $parent_page->ID > 0 ) { | |
$post_id = $parent_page->ID; | |
break; | |
} | |
} | |
} | |
} | |
} | |
/* While there's a post ID, add the post link to the $parents array. */ | |
while ( $post_id ) { | |
/* Get the post by ID. */ | |
$page = get_page( $post_id ); | |
/* Add the formatted post link to the array of parents. */ | |
$parents[] = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . get_the_title( $post_id ) . '</a>'; | |
/* Set the parent post's parent to the post ID. */ | |
$post_id = $page->post_parent; | |
} | |
/* If we have parent posts, reverse the array to put them in the proper order for the trail. */ | |
if ( isset( $parents ) ) | |
$trail = array_reverse( $parents ); | |
/* Return the trail of parent posts. */ | |
return $trail; | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Get term parents */ | |
/*-----------------------------------------------------------------------------------*/ | |
function ct_breadcrumbs_get_term_parents( $parent_id = '', $taxonomy = '' ) { | |
/* Set up some default arrays. */ | |
$trail = array(); | |
$parents = array(); | |
/* If no term parent ID or taxonomy is given, return an empty array. */ | |
if ( empty( $parent_id ) || empty( $taxonomy ) ) | |
return $trail; | |
/* While there is a parent ID, add the parent term link to the $parents array. */ | |
while ( $parent_id ) { | |
/* Get the parent term. */ | |
$parent = get_term( $parent_id, $taxonomy ); | |
/* Add the formatted term link to the array of parent terms. */ | |
$parents[] = '<a href="' . get_term_link( $parent, $taxonomy ) . '" title="' . esc_attr( $parent->name ) . '">' . $parent->name . '</a>'; | |
/* Set the parent term's parent as the parent ID. */ | |
$parent_id = $parent->parent; | |
} | |
/* If we have parent terms, reverse the array to put them in the proper order for the trail. */ | |
if ( !empty( $parents ) ) | |
$trail = array_reverse( $parents ); | |
/* Return the trail of parent terms. */ | |
return $trail; | |
/*-----------------------------------------------------------------------------------*/ | |
/* Clean Up WordPress Shortcode Formatting - important for nested shortcodes */ | |
/*-----------------------------------------------------------------------------------*/ | |
function parse_shortcode_content( $content ) { | |
/* Parse nested shortcodes and add formatting. */ | |
$content = trim( do_shortcode( shortcode_unautop( $content ) ) ); | |
/* Remove '' from the start of the string. */ | |
if ( substr( $content, 0, 4 ) == '' ) | |
$content = substr( $content, 4 ); | |
/* Remove '' from the end of the string. */ | |
if ( substr( $content, -3, 3 ) == '' ) | |
$content = substr( $content, 0, -3 ); | |
/* Remove any instances of ''. */ | |
$content = str_replace( array( '<p></p>' ), '', $content ); | |
$content = str_replace( array( '<p> </p>' ), '', $content ); | |
return $content; | |
} | |
// Move wpautop filter to AFTER shortcode is processed | |
remove_filter( 'the_content', 'wpautop' ); | |
add_filter( 'the_content', 'wpautop' , 99); | |
add_filter( 'the_content', 'shortcode_unautop',100 ); | |
} ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment