Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Core Theme Functions
- *
- * @package WP Executive
- * @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().'admin.php?page=ct-options' ) ;
- }
- function ct_admin_head() {
- ?>
- <script>
- jQuery(function(){
- var message = '<p>This theme comes with a <a href="<?php echo admin_url('admin.php?page=functions.php'); ?>">comprehensive options panel</a>. This theme also supports widgets, please visit the <a href="<?php echo admin_url('widgets.php'); ?>">widgets settings page</a> to configure them.</p>';
- jQuery('.themes-php #message2').html(message);
- });
- </script>
- <?php
- }
- // Body ID's
- function ct_body_id() {
- if (is_home()) {
- echo ' id="home"';
- } elseif (is_singular('listings')) {
- echo ' id="listing"';
- } 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 Editor Stylesheet Support
- if ( function_exists('add_editor_style') ) {
- add_editor_style();
- }
- // 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 class="left clear">
- <?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 }
- function ct_wp_head() {
- if(get_option("ct_custom_favicon_url", true) !="") { ?>
- <link rel="shortcut icon" href="<?php echo get_option("ct_custom_favicon_url", true); ?>" />
- <?php } ?>
- <!--[if lt IE 9]>
- <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
- <![endif]-->
- <?php if(is_single()) { ?>
- <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/post-print.css" media="print" />
- <?php } ?>
- <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/ct_dropdowns.css" media="screen" />
- <?php if(get_option("ct_alert", true) == "yes") { ?>
- <!-- Alert Bar -->
- <script src="<?php echo get_template_directory_uri(); ?>/js/jquery.easing.1.3.js"></script>
- <script src="<?php echo get_template_directory_uri(); ?>/js/jquery.cookie.js"></script>
- <script src="<?php echo get_template_directory_uri(); ?>/js/jquery.ct.alertBar.js"></script>
- <?php if(get_option("ct_alert_sticky", true) == "yes" || get_option("ct_alert_fontcolor", true) || get_option("ct_alert_fontsize") || get_option("ct_alert_linkcolor", true) || get_option("ct_alert_bgcolor", true)) { ?>
- <style type="text/css">
- <?php if(get_option("ct_alert_sticky", true) == "yes") { ?>#alert-wrapper { position: fixed; top: 0;} section#main { margin-top: 50px;}<?php } ?>
- <?php if(get_option("ct_alert_fontcolor", true) || get_option("ct_alert_fontsize") !="") { ?>#alert p { color: #<?php echo get_option("ct_alert_fontcolor", true); ?>; font-size: <?php echo get_option("ct_alert_fontsize", true); ?>;}<?php } ?>
- <?php if(get_option("ct_alert_linkcolor", true) !="") { ?>#alert p a:link { color: #<?php echo get_option("ct_alert_linkcolor", true); ?>;}<?php } ?>
- <?php if(get_option("ct_alert_bgcolor", true) !="") { ?>#alert, #alert-open { background-color: #<?php echo get_option("ct_alert_bgcolor", true); ?>;}<?php } ?>
- </style>
- <?php } ?>
- <?php } ?>
- <?php if(is_post_type_archive('portfolio') || is_post_type_archive('products')) { ?>
- <script src="<?php echo get_template_directory_uri(); ?>/js/jquery.easing.1.3.js"></script>
- <script src="<?php echo get_template_directory_uri(); ?>/js/jquery.quicksand.js"></script>
- <script src="<?php echo get_template_directory_uri(); ?>/js/jquery.quicksand.init.js"></script>
- <?php } ?>
- <?php if(is_single() || is_page()) { ?>
- <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/comments.css" media="screen" />
- <?php wp_enqueue_script( "comment-reply" ); ?>
- <?php } ?>
- <?php if(get_option("ct_featured", true) == "yes") {
- if(is_home() || get_post_type() == 'portfolio' || get_post_type() == 'products') { ?>
- <!-- Nivo Slider -->
- <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/nivo-slider.css" media="screen" />
- <?php if(is_home()) { ?>
- <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/home-nivo-slider.css" media="screen" />
- <?php } ?>
- <?php if( get_post_type() == 'portfolio' || get_post_type() == 'products' ) { ?>
- <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/portfolio-nivo-slider.css" media="screen" />
- <?php } ?>
- <script src="<?php echo get_template_directory_uri(); ?>/js/jquery.nivo.slider.pack.js"></script>
- <script>
- jQuery(window).load(function() {
- jQuery('#slider').nivoSlider({
- effect:'<?php echo get_option("ct_nivo_effect", true); ?>',
- slices:<?php echo get_option("ct_nivo_slices", true); ?>,
- animSpeed:<?php echo get_option("ct_nivo_speed", true); ?>,
- pauseTime:<?php echo get_option("ct_nivo_pause", true); ?>,
- directionNav:<?php echo get_option("ct_nivo_arrows", true); ?>, //Next & Prev
- <?php if(is_home()) { ?>
- directionNavHide: false, //Only show on hover
- <?php } else { ?>
- directionNavHide: true,
- <?php } ?>
- controlNav:<?php echo get_option("ct_nivo_control", true); ?>, //1,2,3...
- pauseOnHover:<?php echo get_option("ct_nivo_pausehover", true); ?>, //Stop animation while hovering
- beforeChange: function(){},
- afterChange: function(){}
- });
- });
- </script>
- <?php } ?>
- <?php } ?>
- <!-- PrettyPhoto -->
- <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/prettyPhoto.css" media="screen" />
- <script src="<?php echo get_template_directory_uri(); ?>/js/jquery.prettyPhoto.js"></script>
- <!-- Contact Form Validation and Ajax Submit -->
- <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/validationEngine.jquery.css" media="screen" />
- <script src="<?php echo get_template_directory_uri(); ?>/js/jquery.validationEngine.js"></script>
- <script>
- // Ajax Submit
- // Full documentation on this can be found at http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/
- jQuery(document).ready(function() {
- jQuery("#contactform").validationEngine({
- ajaxSubmit: true,
- ajaxSubmitFile: "<?php echo get_template_directory_uri(); ?>/includes/ajaxSubmit.php",
- ajaxSubmitMessage: "<?php echo stripslashes(get_option("ct_success", true)); ?>",
- success : false,
- failure : function() {}
- })
- });
- </script>
- <!-- Core Javascript -->
- <script src="<?php echo get_template_directory_uri(); ?>/js/core.js"></script>
- <?php if(get_option("ct_stylesheet", true) =="fabric") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/fabric_1.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="fabric2") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/fabric_2.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="60lines") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/60degree_gray.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="blackdenim") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/black_denim.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="cork") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/cork_1.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="graysand") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/gray_sand.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="leather") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/leather_1.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="metaldots") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/metal_dots.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="metaldots") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/metal_dots.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="paper") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/paper_1.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="paper2") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/paper_2.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="paper3") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/paper_3.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="paper4") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/paper_4.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="smoothwall") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/smooth_wall.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="tactilenoise") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/tactile_noise.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="whitecarbon") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/white_carbon.gif) repeat;}</style>
- <?php } elseif(get_option("ct_stylesheet", true) =="whitesand") { ?>
- <style>body { background: url(<?php echo get_template_directory_uri(); ?>/images/skins/white_sand.gif) repeat;}</style>
- <?php } else { }
- //Inject Custom Stylesheet
- if(get_option("ct_usestyles", true) =="yes") { ?>
- <?php include(TEMPLATEPATH . '/includes/custom_stylesheet.php'); ?>
- <?php }
- //Inject Custom Fonts
- if(get_option("ct_font", true) =="quattrocentosans") { ?>
- <link type="text/css" href="http://fonts.googleapis.com/css?family=Quattrocento+Sans:regular" rel="stylesheet" />
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'Quattrocento Sans', serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="varela") { ?>
- <link type="text/css" href="http://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet" />
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'Varela Round', sans-serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="specialelite") { ?>
- <link type="text/css" href="http://fonts.googleapis.com/css?family=Special+Elite:regular" rel="stylesheet" />
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'Special Elite', serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="sixcaps") { ?>
- <link type="text/css" href="http://fonts.googleapis.com/css?family=Six+Caps:regular" rel="stylesheet" />
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'Six Caps', serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="ebgaramond") { ?>
- <link type="text/css" href="http://fonts.googleapis.com/css?family=EB+Garamond:regular" rel="stylesheet" />
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'EB Garamond', serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="terminaldosislight") { ?>
- <link href="http://fonts.googleapis.com/css?family=Terminal+Dosis+Light:regular" rel="stylesheet" />
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'Terminal Dosis Light', serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="michroma") { ?>
- <link href="http://fonts.googleapis.com/css?family=Michroma:regular" rel="stylesheet" />
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'Michroma', serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="bevan") { ?>
- <link href="http://fonts.googleapis.com/css?family=Bevan:regular" rel="stylesheet" >
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'Bevan', serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="droidsans") { ?>
- <link type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans:regular,bold" rel="stylesheet" />
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'Droid Sans', serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="droidserif") { ?>
- <link href="http://fonts.googleapis.com/css?family=Droid+Serif:regular,italic,bold,bolditalic" rel="stylesheet" />
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'Droid serif', serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="goudy bookletter") { ?>
- <link href="http://fonts.googleapis.com/css?family=Goudy+Bookletter+1911:regular" rel="stylesheet" />
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'Goudy Bookletter 1911', serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="pacifico") { ?>
- <link href="http://fonts.googleapis.com/css?family=Pacifico:regular" rel="stylesheet" />
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'Pacifico', serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="pacifico") { ?>
- <link href="http://fonts.googleapis.com/css?family=Amaranth:regular" rel="stylesheet" />
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'Amaranth', serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="allerta") { ?>
- <link href="http://fonts.googleapis.com/css?family=Allerta:regular" rel="stylesheet" >
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'Allerta', serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="crushed") { ?>
- <link href="http://fonts.googleapis.com/css?family=Crushed:regular" rel="stylesheet" >
- <style>h1,h2,h3,h4,h5,h6 { font-family: 'Crushed', serif;}</style>
- <?php } elseif(get_option("ct_font", true) =="defaultstack") {}
- // Date format
- $GLOBALS['ctdate'] = get_option('ct_dateformat');
- if ( $GLOBALS['ctdate'] == "" )
- $GLOBALS['ctdate'] = "M j, Y";
- }
- // Contact Us Validation
- function contact_us_validation() { ?>
- <!-- Contact Form Validation and Ajax Submit -->
- <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/validationEngine.jquery.css" media="screen" charset="utf-8" />
- <script src="<?php echo get_template_directory_uri(); ?>/js/jquery.validationEngine.js"></script>
- <script>
- // Ajax Submit
- // Full documentation on this can be found at http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/
- jQuery(document).ready(function() {
- jQuery("#contactform").validationEngine({
- ajaxSubmit: true,
- ajaxSubmitFile: "<?php echo get_template_directory_uri(); ?>/includes/ajaxSubmit.php",
- ajaxSubmitMessage: "<?php echo stripslashes(get_option("ct_success", true)); ?>",
- success : false,
- failure : function() {}
- })
- });
- </script>
- <?php }
- // Contact Us Map
- function contact_us_map() {
- if(get_option("ct_gmap", true) =="yes") { ?>
- <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
- <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 get_option("ct_gmap_type", true); ?>,
- streetViewControl: true
- };
- var mymap = new google.maps.Map( document.getElementById( 'map' ), options );
- var marker = new google.maps.Marker({
- map: mymap,
- position: results[0].geometry.location
- });
- }
- } );
- }
- setMapAddress( "<?php echo get_option("ct_address", true); ?>" );
- </script>
- <div id="location" class="onethirdcol left last">
- <?php if(get_option("ct_companyinfo", true) !="") { ?>
- <?php echo stripslashes(get_option("ct_companyinfo", true)); ?>
- <?php } ?>
- <div id="map" class="left">Loading...</div>
- </div>
- <?php }
- }
- // Required footer credit for Museo typeface
- function footer_font_credit () {
- if(get_option("ct_font", true) =="museosans") { ?>
- Museo Font by <a href="http://www.exljbris.com">Jos Buivenga</a>.
- <?php } elseif(get_option("ct_font", true) =="museoslab") { ?>
- Museo Font by <a href="http://www.exljbris.com">Jos Buivenga</a>.
- <?php }
- }
- /*-----------------------------------------------------------------------------------*/
- /* Demo Changer */
- /*-----------------------------------------------------------------------------------*/
- function ct_demo_head() {
- require_once(STYLESHEETPATH . '/demo/demo-styles.php');
- }
- function ct_demo_footer() {
- require_once(STYLESHEETPATH . '/demo/demo-styles-footer.php');
- }
- // Remove WLW and RSD for validation
- remove_action('wp_head', 'wlwmanifest_link');
- remove_action('wp_head', 'rsd_link');
- // Tags Navigation for Product & Portfolio
- function ct_tags_nav() { ?>
- <ul id="tags-nav" class="clear">
- <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');
- } elseif(is_post_type_archive('products')) {
- $terms = get_terms('product_tags');
- }
- $count = count($terms);
- if ( $count > 0 ){
- foreach ( $terms as $term ) {
- echo "<li><a href='#' class='$term->slug'>" . $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' );
- } elseif(is_post_type_archive('products')) {
- $terms = get_the_terms( $post->id, 'product_tags' );
- }
- if ($terms) {
- foreach($terms as $term) {
- echo $term->slug;
- }
- }
- }
- // Show the first term name only
- function ct_first_term() {
- if(is_post_type_archive('portfolio')) {
- $terms = get_the_terms( $post->id, 'portfolio_tags' );
- } elseif(is_post_type_archive('products')) {
- $terms = get_the_terms( $post->id, 'product_tags' );
- }
- $count = 0;
- if ($terms) {
- foreach($terms as $term) {
- $count++;
- if (1 == $count) {
- echo $term->name;
- }
- }
- }
- }
- // Access post data outside the loop
- function get_post_data($postId) {
- global $wpdb;
- return $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID=$postId");
- }
- // Custom Excerpt Length
- function new_excerpt_length($length) {
- $exlength = get_option("ct_excerpt_length", true);
- return $exlength;
- }
- add_filter('excerpt_length', 'new_excerpt_length');
- // Remove <p> tags from the_excerpt
- remove_filter('the_excerpt', 'wpautop');
- // Allow Shortcodes to be used in widgets
- add_filter('widget_text', 'do_shortcode');
- // Pagination
- function ct_pagination($pages = '', $range = 2) {
- $showitems = ($range * 2)+1;
- global $paged;
- if(empty($paged)) $paged = 1;
- if($pages == '') {
- global $wp_query;
- $pages = $wp_query->max_num_pages;
- if(!$pages) {
- $pages = 1;
- }
- }
- if(1 != $pages) {
- echo "<div class='pagination clear'>";
- if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>«</a>";
- if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹</a>";
- for ($i=1; $i <= $pages; $i++)
- {
- if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
- {
- echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
- }
- }
- if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'>›</a>";
- if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>»</a>";
- echo "<div class='clear'></div>\n";
- echo "</div>\n";
- }
- }
- // 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_featured_images() {
- $photos = ct_get_images('full');
- if ($photos) {
- foreach ($photos as $photo) { ?>
- <img src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo $photo ?>&h=348&w=916&zc=1" title="<?php the_title(); ?>" />
- <?php }
- }
- }
- // Display all images attached to portfolio - detail
- function ct_portfolio_images() {
- $photos = ct_get_images('full');
- if ($photos) {
- foreach ($photos as $photo) { ?>
- <img class="lead" src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo $photo ?>&h=430&w=583&zc=1" />
- <?php }
- }
- }
- // Display all images attached to client portfolio
- function ct_client_logos() {
- $photos = ct_get_images('full');
- if ($photos) {
- foreach ($photos as $photo) { ?>
- <div class="client-logo imgwraptn left">
- <a href="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo $photo ?>&w=500&zc=1" rel="prettyPhoto[clients]">
- <img class="tn imgfade" src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo $photo ?>&h=68&w=118&zc=1" />
- </a>
- </div>
- <?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 thumbnail
- function ct_first_image_tn() {
- $photo = ct_get_post_image();
- if ($photo) { ?>
- <div class="imgwraptn">
- <a href="<?php the_permalink(); ?>"><img class="tn imgfade" 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>
- </div>
- <?php }
- }
- // Display first image thumbnail - float left
- function ct_first_image_tn_left() {
- $photo = ct_get_post_image();
- if ($photo) { ?>
- <div class="imgwraptn left">
- <a href="<?php the_permalink(); ?>"><img class="tn left imgfade" 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>
- </div>
- <?php }
- }
- // Display first image thumbnail - float right
- function ct_first_image_tn_right() {
- $photo = ct_get_post_image();
- if ($photo) { ?>
- <div class="imgwraptn right">
- <a href="<?php the_permalink(); ?>"><img class="tn right imgfade" 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>
- </div>
- <?php }
- }
- // Display first image headshot for testimonial widget
- function ct_first_image_headshot() {
- $photo = ct_get_post_image();
- if ($photo) { ?>
- <div class="imgwrapheadshot right">
- <img class="tn imgfade" src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&h=54&w=40&zc=1" />
- </div>
- <?php }
- }
- // Display first image headshot for testimonial widget
- function ct_first_image_headshot_left() {
- $photo = ct_get_post_image();
- if ($photo) { ?>
- <div class="imgwrapheadshot left">
- <img class="tn imgfade" src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&h=54&w=40&zc=1" />
- </div>
- <?php }
- }
- function ct_first_image_headshot_lrg() {
- $photo = ct_get_post_image();
- if ($photo) { ?>
- <div class="imgwrapheadshotlrg right">
- <img class="tn imgfade" src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&h=95&w=70&zc=1" />
- </div>
- <?php }
- }
- // Display first image medium
- function ct_first_image_md() {
- $photo = ct_get_post_image();
- if ($photo) { ?>
- <div class="imgwrapmd">
- <?php if(!is_single()) { ?>
- <a href="<?php the_permalink(); ?>">
- <?php } ?>
- <span class="overlay"></span>
- <img class="med imgfade" src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&h=163&w=272&zc=1" />
- <?php if(!is_single()) { ?>
- </a>
- <?php } ?>
- </div>
- <?php }
- }
- // Display first image blog archive
- function ct_first_image_blog() {
- $photo = ct_get_post_image();
- if ($photo) { ?>
- <div class="imgwraplead">
- <a href="<?php if(is_single()) { ?><?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&w=800&zc=1<?php } else { ?><?php the_permalink(); ?><?php } ?>" <?php if(is_single()) { ?>rel="prettyPhoto"<?php } ?>><img class="lead imgfade" src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&h=240&w=583&zc=1" /></a>
- </div>
- <?php }
- }
- // Display first image portfolio
- function ct_first_image_portfolio() {
- $photo = ct_get_post_image();
- if ($photo) { ?>
- <div class="imgwrapportfolio left">
- <a href="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&w=800&zc=1" rel="prettyPhoto[portfolio]" title="<?php the_excerpt(); ?>">
- <img class="lead imgfade" src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&h=430&w=583&zc=1" />
- </a>
- </div>
- <?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;
- }
- /**
- * 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;
- } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement