Example #1
0
    function widget($args, $instance)
    {
        if (is_single() && get_post_type() == 'property') {
            extract($args, EXTR_SKIP);
            $title = isset($instance['title']) ? strip_tags($instance['title']) : false;
            $exclude_featured = isset($instance['exclude_featured']) ? $instance['exclude_featured'] : false;
            $effect = isset($instance['effect']) ? $instance['effect'] : 'horizontal';
            $pause = isset($instance['pause']) ? (int) $instance['pause'] : 5000;
            $controls = isset($instance['controls']) ? $instance['controls'] : true;
            $controls_auto = isset($instance['controls_auto']) ? $instance['controls_auto'] : true;
            $auto_start = isset($instance['auto_start']) ? $instance['auto_start'] : false;
            $wpsight_gallery = new wpSight_Gallery();
            $wpsight_gallery_view = $wpsight_gallery->wpsight_gallery_public_view($id, $exclude_featured, $this->id);
            $notitle = empty($title) ? ' no-title' : '';
            $controls = $controls != 0 ? 'true' : 'false';
            $controls_auto = $controls_auto != 0 ? 'true' : 'false';
            $auto_start = $auto_start != 0 ? 'true' : 'false';
            $sidebar = function_exists('wpsight_get_sidebar') ? wpsight_get_sidebar('sidebar-listing') : 'sidebar-property';
            ?>
			
        	<script type="text/javascript">
			
        	jQuery(document).ready(function() {
			
	    	    var effect	         = "<?php 
            echo $effect;
            ?>
";
	    	    var pause	         = <?php 
            echo $pause;
            ?>
;
	    	    var controls         = <?php 
            echo $controls;
            ?>
;
	    	    var auto_start       = <?php 
            echo $auto_start;
            ?>
;
	    	    var auto_controls    = <?php 
            echo $controls_auto;
            ?>
;
	    	    var auto_hover       = true;
			
	    	    <?php 
            if ($id == $sidebar) {
                ?>
				
	    	    jQuery('#<?php 
                echo $this->id;
                ?>
_sidebar_listing_gallery').bxSlider({
					pagerCustom: '#<?php 
                echo $this->id;
                ?>
_bx-pager-sidebar',
					mode: effect,
					pause: pause,
					controls: controls,
					autoControls: auto_controls,
					autoStart: auto_start,
					auto: true,
					autoHover: true
			    });
			
			    <?php 
            } else {
                ?>
			    jQuery('#<?php 
                echo $this->id;
                ?>
_content_listing_gallery').bxSlider({
					pagerCustom: '#<?php 
                echo $this->id;
                ?>
_bx-pager-content',
					mode: effect,
					pause: pause,
					controls: controls,
					autoControls: auto_controls,
					autoStart: auto_start,
					auto: true,
					autoHover: true
			    });
			
			    <?php 
            }
            ?>
 	            
			});
			</script>
        	
			<div id="<?php 
            echo wpcasa_dashes($widget_id);
            ?>
-wrap" class="widget-wrap section widget-gallery-wrap<?php 
            echo $notitle;
            ?>
">
			
			    <div id="<?php 
            echo wpcasa_dashes($widget_id);
            ?>
" class="widget widget-gallery clearfix">
			    
			    	<div class="widget-inner">
			    		
			    		<?php 
            if (!empty($title)) {
                echo '<h3 class="title">' . $title . '</h3>';
            }
            echo $wpsight_gallery_view;
            ?>
			
			    	</div><!-- .widget-inner -->
			    	
			    </div><!-- .widget -->
			    
			</div><!-- .widget-wrap -->

			<?php 
        }
    }
Example #2
0
<div id="sidebar" class="<?php 
echo wpsight_get_span('small');
?>
"><?php 
do_action('wpsight_sidebar_listing_widgets_before');
if (is_singular() && get_post_type() == wpsight_listing_post_type() && !is_page_template('page-tpl-listings.php') && !is_page_template('page-tpl-properties.php') && !is_page_template('page-tpl-favorites.php') && !is_page_template('page-tpl-compare.php') && !is_page_template('page-tpl-map.php') && is_active_sidebar(wpsight_get_sidebar('sidebar-listing'))) {
    dynamic_sidebar(wpsight_get_sidebar('sidebar-listing'));
} else {
    dynamic_sidebar(wpsight_get_sidebar('sidebar-listing-archive'));
}
do_action('wpsight_sidebar_listing_widgets_after');
?>

</div><!-- #sidebar -->
Example #3
0
?>

<div id="main-wrap" class="wrap">	

	<?php 
// Action hook to add content before main
do_action('wpsight_main_before');
// Open layout wrap
wpsight_layout_wrap('main-middle-wrap');
?>
	
	<div id="main-middle" class="row">
	
		<?php 
// Set class of #content div depending on active sidebars
$content_class = is_active_sidebar(wpsight_get_sidebar('sidebar-listing-archive')) ? wpsight_get_span('big') : wpsight_get_span('full');
?>
	
	    <div id="content" class="<?php 
echo $content_class;
?>
">
	    
			<div class="title title-archive clearfix"><?php 
// Display current term
echo apply_filters('wpsight_taxonomy_title', wpsight_listing_loop_title());
// Action hook to add content to title
do_action('wpsight_loop_title_actions');
// Display term description
$term_description = term_description();
if (!empty($term_description)) {
Example #4
0
    function widget($args, $instance)
    {
        extract($args, EXTR_SKIP);
        $title = isset($instance['title']) ? apply_filters('widget_title', strip_tags($instance['title']), $instance, $this->id_base) : false;
        $filter = isset($instance['filter']) ? strip_tags($instance['filter']) : false;
        $effect = isset($instance['effect']) ? $instance['effect'] : 'fade';
        $direction = isset($instance['direction']) ? $instance['direction'] : 'horizontal';
        $timer = isset($instance['timer']) ? (int) $instance['timer'] : 0;
        $prevnext = isset($instance['prevnext']) ? $instance['prevnext'] : true;
        $overlay = isset($instance['overlay']) ? $instance['overlay'] : true;
        $details = isset($instance['details']) ? $instance['details'] : true;
        $teaser = isset($instance['teaser']) ? $instance['teaser'] : true;
        $keynav = isset($instance['keynav']) ? $instance['keynav'] : true;
        $mousenav = isset($instance['mousenav']) ? $instance['mousenav'] : false;
        $random = isset($instance['random']) ? $instance['random'] : false;
        $unlink = isset($instance['unlink']) ? $instance['unlink'] : false;
        $number = isset($instance['number']) ? (int) $instance['number'] : 10;
        $length = isset($instance['length']) ? (int) $instance['length'] : 15;
        /**
         * Only show slider on first page
         * if blog template on front page
         */
        global $page;
        if (isset($page) && $page != 1) {
            return;
        }
        // Create query args
        if ($filter != 'custom') {
            $query_args = array('post_type' => array(wpsight_listing_post_type()), 'posts_per_page' => $number);
            // Add filter to query args if required
            if (!empty($filter)) {
                if ($filter == 'latest-sale') {
                    // Set meta_query
                    $meta_query = array(array('key' => '_price_status', 'value' => 'sale'));
                    $query_args = array_merge($query_args, array('meta_query' => $meta_query));
                } elseif ($filter == 'latest-rent') {
                    // Set meta_query
                    $meta_query = array(array('key' => '_price_status', 'value' => 'rent'));
                    $query_args = array_merge($query_args, array('meta_query' => $meta_query));
                } elseif ($filter == 'latest-new') {
                    // Set meta_query
                    $meta_query = array(array('key' => '_price_status', 'value' => 'new'));
                    $query_args = array_merge($query_args, array('meta_query' => $meta_query));
                } elseif ($filter == 'latest-used') {
                    // Set meta_query
                    $meta_query = array(array('key' => '_price_status', 'value' => 'used'));
                    $query_args = array_merge($query_args, array('meta_query' => $meta_query));
                } else {
                    // Get taxonomy and term from filter (comma-separated value)
                    $get_taxonomy = explode(',', $filter);
                    $taxonomy = $get_taxonomy[0];
                    $term = $get_taxonomy[1];
                    // Set tax_query
                    $tax_query = array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => array($term)));
                    $query_args = array_merge($query_args, array('tax_query' => $tax_query));
                }
            }
        } else {
            // If filter is custom, create meta query (slider => 1)
            $query_args = array('post_type' => array(wpsight_listing_post_type()), 'posts_per_page' => $number, 'meta_query' => array(array('key' => 'slider', 'value' => '1')));
        }
        // Add random order to query args if required
        if ($random == true) {
            $query_args = array_merge($query_args, array('orderby' => 'random'));
        }
        $query_args = apply_filters('wpsight_widget_slider_query_args', $query_args, $args, $instance);
        // Check if transients are active
        $transients = apply_filters('wpsight_transients_queries', false, 'widget', $query_args, $this->id);
        // If query transients are active
        if ($transients === true) {
            // If transient does not exist
            if (false === ($slider = get_transient('wpsight_query_' . $this->id))) {
                // Create listing query
                $slider = new WP_Query($query_args);
                // Set transient for this query
                set_transient('wpsight_query_' . $this->id, $slider, DAY_IN_SECONDS);
            }
            // If query transients are not active
        } else {
            // Create listing query
            $slider = new WP_Query($query_args);
        }
        if ($slider->have_posts()) {
            // Create loop counter
            $counter = 1;
            // Set image size depending on widget area
            if ($id == 'home') {
                $image_size = 'big';
            } elseif ($id == 'sidebar' || $id == 'sidebar-home' || $id == 'sidebar-archive' || $id == 'sidebar-page' || $id == 'sidebar-post' || $id == wpsight_get_sidebar('sidebar-listing') || $id == wpsight_get_sidebar('sidebar-listing-archive')) {
                $image_size = 'post-thumbnail';
            } else {
                $image_size = 'full';
            }
            $image_size = apply_filters('wpsight_widget_listings_slider_image_size', $image_size, $args, $instance);
            // Create widget output
            ?>
			
			<div id="<?php 
            echo wpsight_dashes($this->id);
            ?>
" class="widget widget-slider widget-listings-slider clearfix">
			
				<div class="widget-inner">
        	
        			<?php 
            // Display widget title
            if (!empty($title)) {
                ?>
							
						<div class="title title-widget clearfix">
					
						    <?php 
                echo apply_filters('wpsight_widget_listings_slider_title', '<h2>' . $title . '</h2>', $args, $instance);
                do_action('wpsight_widget_listings_slider_title_actions', $args, $instance);
                ?>
						
						</div><?php 
            }
            // endif $title
            // Convert boolean to strings for Javascript options
            $prevnext = $prevnext == true ? 'true' : 'false';
            $keynav = $keynav == true ? 'true' : 'false';
            $mousenav = $mousenav == true ? 'true' : 'false';
            $random = $random == true ? 'true' : 'false';
            // Correct timer and slideshow = true
            $slideshow = $timer == 0 ? 'false' : 'true';
            $slider_args = array('animation' => '"' . $effect . '",', 'direction' => '"' . $direction . '",', 'slideshow' => "{$slideshow},", 'slideshowSpeed' => "{$timer},", 'animationDuration' => '300,', 'directionNav' => "{$prevnext},", 'controlNav' => 'false,', 'keyboardNav' => "{$keynav},", 'mousewheel' => "{$mousenav},", 'prevText' => '"' . __('Previous', 'wpsight') . '",', 'nextText' => '"' . __('Next', 'wpsight') . '",', 'pausePlay' => 'false,', 'pauseText' => '"' . __('Pause', 'wpsight') . '",', 'playText' => '"' . __('Play', 'wpsight') . '",', 'randomize' => "{$random},", 'animationLoop' => 'true,', 'pauseOnAction' => 'true,', 'pauseOnHover' => 'true');
            $slider_args = apply_filters('wpsight_widget_listings_slider_options_args', $slider_args, $args, $instance);
            ?>
					
					<script type="text/javascript">
					jQuery(document).ready(function($){
					    $(function(){
					    	$('.flexslider').flexslider({
					    		<?php 
            foreach ($slider_args as $k => $v) {
                echo $k . ': ' . $v . "\n";
            }
            ?>
							});
					    });	            
					});
					</script>
					
					<?php 
            /**
             * Set fixed height on slider container
             * to avoid layout jump on load
             */
            $img = wpsight_get_image_size($image_size);
            $height = $img['size']['h'];
            ?>
        			
        			<div class="flexslider height-<?php 
            echo $height;
            ?>
">
        			
					  	<ul class="slides">
					  	
					  		<?php 
            // Loop through posts
            while ($slider->have_posts()) {
                $slider->the_post();
                // Check if slider_embed is active
                $slider_embed = get_post_meta(get_the_ID(), 'slider_embed', true);
                if (!empty($slider_embed)) {
                    echo '<li>' . wp_kses_post($slider_embed) . '</li>';
                } elseif (has_post_thumbnail()) {
                    ?>
					  				
					  				<li>
					  					<?php 
                    if ($unlink == false) {
                        echo '<a href="' . get_permalink() . '">' . get_the_post_thumbnail(get_the_ID(), $image_size, array('alt' => get_the_title(), 'title' => get_the_title())) . '</a>';
                    } else {
                        echo get_the_post_thumbnail(get_the_ID(), $image_size, array('alt' => get_the_title(), 'title' => get_the_title()));
                    }
                    if ($overlay == true) {
                        ?>
					  						<div class="overlay<?php 
                        if ($teaser == false) {
                            echo ' no-teaser';
                        }
                        ?>
">
					  							<?php 
                        // Action hook to add content before overlay title
                        do_action('wpsight_widget_listings_slider_title_before', $args, $instance);
                        ?>
					  							<h3>
					  								<?php 
                        if ($unlink == false) {
                            echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a>';
                        } else {
                            echo get_the_title();
                        }
                        ?>
					  							</h3>
					  							<?php 
                        // Action hook to add content after overlay title
                        do_action('wpsight_widget_listings_slider_title_after', $args, $instance);
                        if ($teaser == true) {
                            if ($unlink == false) {
                                wpsight_the_excerpt(get_the_ID(), true, $length);
                            } else {
                                echo wpsight_format_content(get_the_content(false));
                            }
                            // Action hook to add content after overlay teaser
                            do_action('wpsight_widget_listings_slider_teaser_after', $args, $instance);
                        }
                        ?>
					  						</div>
					  					<?php 
                    }
                    ?>
					  				</li>
					  				
					  				<?php 
                }
                // endif has_post_thumbnail()
            }
            // endwhile have_posts()
            ?>
					  	</ul>
					  	
					</div><!-- .flexslider -->
				
				</div><!-- .widget-inner -->
				
			</div><!-- .widget-slider --><?php 
        }
        // endif have_posts()
    }
Example #5
0
    function widget($args, $instance)
    {
        extract($args, EXTR_SKIP);
        $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
        $cat = $instance['cat'];
        if (!($number = (int) $instance['number'])) {
            $number = 1;
        } else {
            if ($number < 1) {
                $number = 1;
            } else {
                if ($number > 20) {
                    $number = 20;
                }
            }
        }
        if (!($length = (int) $instance['length'])) {
            $length = 25;
        } else {
            if ($length < 1) {
                $length = 25;
            }
        }
        $width = isset($instance['width']) ? $instance['width'] : 'full';
        // Correct width
        if ($width == wpsight_get_span('big') && ($id == 'home-top' || $id == 'home-bottom' || $id == 'ffooter')) {
            $width = wpsight_get_span('full');
        }
        if (($width == wpsight_get_span('full') || $width == wpsight_get_span('half')) && $id == 'home') {
            $width = wpsight_get_span('big');
        }
        // Check widget width
        if ($width != 'full') {
            $widget_width = $width;
        } else {
            $widget_width = '';
            if ($id == 'home-top' || $id == 'home-bottom' || $id == 'ffooter') {
                $clear = ' clearfix';
            }
        }
        if ($id == 'sidebar' || $id == 'sidebar-home' || $id == 'home' && ($width == 'span12' || $width == 'full')) {
            $widget_width = '';
            $clear = ' clearfix';
        }
        // Create query args
        $query_args = array('post_type' => array('post'), 'cat' => $cat, 'posts_per_page' => $number, 'post_status' => 'publish', 'ignore_sticky_posts' => 1);
        $query_args = apply_filters('wpsight_widget_latest_query_args', $query_args, $args, $instance);
        // Check if transients are active
        $transients = apply_filters('wpsight_transients_queries', false, 'widget', $query_args, $this->id);
        // If query transients are active
        if ($transients === true) {
            // If transient does not exist
            if (false === ($latest = get_transient('wpsight_query_' . $this->id))) {
                // Create listing query
                $latest = new WP_Query($query_args);
                // Set transient for this query
                set_transient('wpsight_query_' . $this->id, $latest, DAY_IN_SECONDS);
            }
            // If query transients are not active
        } else {
            // Create listing query
            $latest = new WP_Query($query_args);
        }
        if ($latest->have_posts()) {
            // Create loop counter
            $counter = 1;
            ?>
		
			<div id="<?php 
            echo wpsight_dashes($this->id);
            ?>
-wrap" class="widget-wrap widget-latest-wrap">
			
				<div id="<?php 
            echo wpsight_dashes($this->id);
            ?>
" class="widget widget-latest row">
				
					<?php 
            // Display widget title
            if (!empty($title)) {
                ?>
						
					<div class="title title-widget clearfix">
		
					    <?php 
                echo apply_filters('wpsight_widget_latest_title', '<h2>' . $title . '</h2>', $args, $instance);
                do_action('wpsight_widget_latest_title_actions', $args, $instance);
                ?>
					
					</div>
		
					<?php 
            }
            // endif $title
            // Begin to loop through posts
            while ($latest->have_posts()) {
                // Set up post data
                $latest->the_post();
                $clear = '';
                // Add .clear to post class with if madness
                if (WPSIGHT_LAYOUT == 'four') {
                    if ($id == 'home-top' || $id == 'home-bottom' || $id == 'ffooter') {
                        if ($width == 'span3') {
                            if ($counter == 1 || ($counter - 1) % 4 == 0) {
                                $clear = ' clear';
                            } else {
                                $clear = '';
                            }
                        } elseif ($width == 'span6') {
                            if ($counter == 1 || $counter % 2 != 0) {
                                $clear = ' clear';
                            } else {
                                $clear = '';
                            }
                        }
                    } elseif ($id == 'home') {
                        if ($width == 'span3') {
                            if ($counter == 1 || ($counter - 1) % 3 == 0) {
                                $clear = ' clear';
                            } else {
                                $clear = '';
                            }
                        }
                    } elseif ($id == 'sidebar' || $id == 'sidebar-home' || $id == wpsight_get_sidebar('sidebar-listing') || $id == 'sidebar-post' || $id == 'sidebar-page' || $id == wpsight_get_sidebar('sidebar-listing-archive')) {
                        $widget_width = 'span3';
                        $clear = ' clear';
                    }
                } else {
                    if ($id == 'home-top' || $id == 'home-bottom' || $id == 'ffooter') {
                        if ($width == 'span4') {
                            if ($counter == 1 || ($counter - 1) % 3 == 0) {
                                $clear = ' clear';
                            } else {
                                $clear = '';
                            }
                        } elseif ($width == 'span6') {
                            if ($counter == 1 || $counter % 2 != 0) {
                                $clear = ' clear';
                            } else {
                                $clear = '';
                            }
                        }
                    } elseif ($id == 'home') {
                        if ($width == 'span4') {
                            if ($counter == 1 || $counter % 2 != 0) {
                                $clear = ' clear';
                            } else {
                                $clear = '';
                            }
                        }
                    } elseif ($id == 'sidebar' || $id == 'sidebar-home' || $id == wpsight_get_sidebar('sidebar-listing') || $id == 'sidebar-post' || $id == 'sidebar-page' || $id == wpsight_get_sidebar('sidebar-listing-archive')) {
                        $widget_width = 'span4';
                        $clear = ' clear';
                    }
                }
                ?>
						    
						    <div <?php 
                post_class($widget_width . $clear . ' clearfix');
                ?>
>
						    
						    	<div class="widget-inner">
						        
						    		<?php 
                // Action hook before post title (widget)
                do_action('wpsight_widget_post_title_before', $width, $id);
                ?>
						    		
						    		<h3 class="post-title">
    									<a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title_attribute();
                ?>
" rel="bookmark">
    										<?php 
                // Action hook post title inside
                do_action('wpsight_widget_post_title_inside', $width, $id);
                the_title();
                ?>
    									</a>
    								</h3>
						    		    
						    		<?php 
                // Action hook after post title (widget)
                do_action('wpsight_widget_post_title_after', $width, $id);
                // Action hook before post content (widget)
                do_action('wpsight_widget_post_content_before', $width, $id);
                ?>
						        		
						    		<div class="post-teaser">
						    			<?php 
                wpsight_the_excerpt(get_the_ID(), true, $length);
                ?>
						        	</div>
						        	
						        	<?php 
                // Action hook after post content (widget)
                do_action('wpsight_widget_post_content_after', $width, $id);
                ?>
						        	
						        </div><!-- .widget-inner -->
						        			
						    </div><!-- .post.<?php 
                the_ID();
                ?>
 --><?php 
                // Increase loop counter
                $counter++;
            }
            // endwhile have_posts()
            ?>
				
				</div><!-- .widget -->
			
			</div><!-- .widget-wrap --><?php 
        }
        // endif have_posts()
        // Reset query
        wp_reset_query();
    }
Example #6
0
 */
// Set up post data
the_post();
?>
    		
<div <?php 
post_class('clearfix');
?>
>

	<?php 
// Action hook before listing content
do_action('wpsight_listing_widgets_before');
if (is_active_sidebar(wpsight_get_sidebar('listing')) && !post_password_required()) {
    // Single listing widgets
    dynamic_sidebar(wpsight_get_sidebar('listing'));
} else {
    // Enable some default widgets
    the_widget('wpSight_Listing_Title', 'title_favorites=1&title_print=1');
    if (!post_password_required()) {
        the_widget('wpSight_Listing_Image');
        the_widget('wpSight_Listing_Description', 'title=' . __('Description', 'wpsight'));
    } else {
        the_content();
    }
}
// endif is_active_sidebar()
// Action hook before listing content
do_action('wpsight_listing_widgets_after');
?>
    			
Example #7
0
function wpsight_do_listing_image($widget_width = '', $widget_location = '', $map = false)
{
    // Get post id
    $post_id = get_the_ID();
    if (empty($post_id)) {
        return;
    }
    // Don't show when password required
    if (post_password_required()) {
        return;
    }
    // Go on if there is a featured image
    if (has_post_thumbnail(get_the_ID())) {
        if (!empty($widget_width)) {
            // In case of a widget (lastest properties)
            $image_size = wpsight_get_layout_image('size_widget');
            $image_align = wpsight_get_layout_image('align_widget');
            // Set image size
            if ($widget_width == wpsight_get_span('half')) {
                $image_size = 'half';
            }
            if ($widget_width == wpsight_get_span('big')) {
                $image_size = 'big';
            }
            if ($widget_width == wpsight_get_span('full')) {
                $image_size = 'full';
            }
            if ($widget_width == wpsight_get_span('small') || $widget_location == 'sidebar' || $widget_location == 'sidebar-home' || $widget_location == 'sidebar-page' || $widget_location == 'sidebar-post' || $widget_location == wpsight_get_sidebar('sidebar-listing') || $widget_location == wpsight_get_sidebar('sidebar-listing-archive')) {
                $image_size = 'post-thumbnail';
            }
            // Remove image align
            $image_align = 'none';
            // Limit images to box width and remove align
            if ($widget_width == wpsight_get_span('half') && ($image_size == 'half' || $image_size == 'big' || $image_size == 'full')) {
                $image_align = 'none';
            }
            if (($widget_width == 'full' || $widget_width == wpsight_get_span('big')) && ($image_size == 'full' || $image_size == 'big') && $widget_location == 'home') {
                $image_align = 'none';
            }
            if ($widget_location == 'sidebar' || $widget_location == 'sidebar-home' || $widget_width == wpsight_get_span('small')) {
                $image_align = 'none';
            }
        } else {
            // Not in a widget but on archive pages
            $image_size = wpsight_get_layout_image('size_archive_listings');
            $image_align = wpsight_get_layout_image('align_archive_listings');
            // Get archive layout
            $archive_layout = wpsight_get_archive_layout('listing');
            // Correct archive layout depending on sidebars
            if (($archive_layout == wpsight_get_span('half') || $archive_layout == wpsight_get_span('full')) && is_active_sidebar(wpsight_get_sidebar('sidebar-listing-archive'))) {
                $archive_layout = wpsight_get_span('big');
            }
            if ($archive_layout == wpsight_get_span('big') && !is_active_sidebar(wpsight_get_sidebar('sidebar-listing-archive'))) {
                $archive_layout = wpsight_get_span('full');
            }
            // Limit images to box width and remove align
            if ($archive_layout == wpsight_get_span('small')) {
                $image_size = 'post-thumbnail';
            }
            if ($archive_layout == wpsight_get_span('half')) {
                $image_size = 'half';
            }
            if ($archive_layout == wpsight_get_span('big')) {
                $image_size = 'big';
            }
            if ($archive_layout == wpsight_get_span('full')) {
                $image_size = 'full';
            }
        }
        // Filter image size
        $image_size = apply_filters('wpsight_do_listing_image_size', $image_size);
        // Filter image align
        $image_align = apply_filters('wpsight_do_listing_image_align', $image_align);
        // Create optional image overlay
        $overlay = apply_filters('wpsight_listing_image_overlay', false);
        // Remove link for favorites
        $remove = is_page_template('page-tpl-favorites.php') && empty($widget_location) ? '<span id="' . get_the_ID() . '" class="favorites-remove" title="' . __('Remove', 'wpsight') . '">' . __('Remove', 'wpsight') . '</span>' : '';
        // Limit image size on properties map
        if (is_page_template('page-tpl-map.php') || $map === true) {
            $image_size = 'post-thumbnail';
        }
        // Fincally output post image
        $image = '<div class="post-image listing-image align' . $image_align . '"><a href="' . get_permalink($post_id) . '">' . get_the_post_thumbnail($post_id, $image_size, array('alt' => the_title_attribute('echo=0'), 'title' => the_title_attribute('echo=0'))) . $overlay . $remove . '</a></div><!-- .post-image -->' . "\n";
        echo $image = preg_replace('/\\s+/', ' ', $image);
    }
}
Example #8
0
 function wpsight_archive_listing_class($counter, $parent_id = '')
 {
     $archive_layout = wpsight_get_archive_layout('listing');
     $post_class = $archive_layout;
     if (WPSIGHT_LAYOUT == 'four') {
         if (is_active_sidebar(wpsight_get_sidebar('sidebar-listing-archive'))) {
             // Respect full width layout
             if (is_singular() && get_post_meta($parent_id, '_layout', true) == 'full-width' && !is_page_template('page-tpl-listings.php') && !is_page_template('page-tpl-properties.php') && !is_page_template('page-tpl-favorites.php')) {
                 // Correct column width depending on layout
                 if ($archive_layout == 'span9') {
                     $archive_layout = 'span12';
                 }
                 if ($archive_layout == 'span3') {
                     if ($counter == 1 || $counter % 4 + 1 == 2) {
                         $post_class = $post_class . ' clear';
                     }
                 } elseif ($archive_layout == 'span6') {
                     if ($counter == 1 || $counter % 2 != 0) {
                         $post_class = $post_class . ' clear';
                     }
                 } elseif ($archive_layout == 'span12') {
                     $post_class = 'clearfix';
                 }
             } else {
                 // Correct column width depending on layout
                 if ($archive_layout == 'span6' || $archive_layout == 'span12') {
                     $archive_layout = 'span9';
                 }
                 if ($archive_layout == 'span3') {
                     $n = get_post_meta($parent_id, '_layout', true) == 'full-width' ? 4 : 3;
                     if ($counter == 1 || $counter % $n + 1 == 2) {
                         $post_class = $post_class . ' clear';
                     }
                 } elseif ($archive_layout == 'span9') {
                     $post_class = 'span9 clear';
                 }
             }
         } else {
             // Correct column width depending on layout
             if ($archive_layout == 'span9') {
                 $archive_layout = 'span12';
             }
             if ($archive_layout == 'span3') {
                 if ($counter == 1 || $counter % 4 + 1 == 2) {
                     $post_class = $post_class . ' clear';
                 }
             } elseif ($archive_layout == 'span6') {
                 if ($counter == 1 || $counter % 2 != 0) {
                     $post_class = $post_class . ' clear';
                 }
             } elseif ($archive_layout == 'span12') {
                 $post_class = 'span12';
             }
         }
     } else {
         if (is_active_sidebar(wpsight_get_sidebar('sidebar-listing-archive'))) {
             // Respect full width layout
             if (is_singular() && get_post_meta($parent_id, '_layout', true) == 'full-width' && !is_page_template('page-tpl-listings.php') && !is_page_template('page-tpl-properties.php') && !is_page_template('page-tpl-favorites.php')) {
                 // Correct column width depending on layout
                 if ($archive_layout == 'span9') {
                     $archive_layout = 'span12';
                 }
                 if ($archive_layout == 'span3') {
                     if ($counter == 1 || $counter % 4 + 1 == 2) {
                         $post_class = $post_class . ' clear';
                     }
                 } elseif ($archive_layout == 'span6') {
                     if ($counter == 1 || $counter % 2 != 0) {
                         $post_class = $post_class . ' clear';
                     }
                 } elseif ($archive_layout == 'span12') {
                     $post_class = 'clearfix';
                 }
             } else {
                 // Correct column width depending on layout
                 if ($archive_layout == 'span6' || $archive_layout == 'span12') {
                     $archive_layout = 'span8';
                 }
                 if ($archive_layout == 'span4') {
                     if (get_post_meta($parent_id, '_layout', true) == 'full-width' && $counter % 3 - 1 == 0 || get_post_meta($parent_id, '_layout', true) != 'full-width' && $counter % 2 != 0 || $counter == 1) {
                         $post_class = $post_class . ' clear';
                     }
                 } elseif ($archive_layout == 'span8') {
                     $post_class = 'span8 clear';
                 }
             }
         } else {
             // Correct column width depending on layout
             if ($archive_layout == 'span8') {
                 $archive_layout = 'span12';
             }
             if ($archive_layout == 'span4') {
                 if ($counter == 1 || $counter % 3 - 1 == 0) {
                     $post_class = $post_class . ' clear';
                 }
             } elseif ($archive_layout == 'span6') {
                 if ($counter == 1 || $counter % 2 != 0) {
                     $post_class = $post_class . ' clear';
                 }
             } elseif ($archive_layout == 'span12') {
                 $post_class = 'span12';
             }
         }
     }
     return $post_class;
 }
Example #9
0
    function widget($args, $instance)
    {
        if (is_single() && get_post_type() == wpsight_listing_post_type()) {
            extract($args, EXTR_SKIP);
            $title = isset($instance['title']) ? strip_tags($instance['title']) : false;
            $display = isset($instance['display']) ? $instance['display'] : 'thumbs';
            $effect = isset($instance['slider_effect']) ? $instance['slider_effect'] : 'fade';
            $timer = isset($instance['slider_timer']) ? (int) $instance['slider_timer'] : 0;
            $prevnext = isset($instance['slider_prevnext']) ? $instance['slider_prevnext'] : true;
            $links = isset($instance['gallery_links']) ? $instance['gallery_links'] : false;
            // Optional exclude
            $exclude_featured = isset($instance['exclude_featured']) ? $instance['exclude_featured'] : false;
            $exclude_images = isset($instance['exclude_images']) ? preg_replace(array('/[^\\d,]/', '/(?<=,),+/', '/^,+/', '/,+$/'), '', $instance['exclude_images']) : false;
            // Optional include
            $include_images = get_post_meta(get_the_ID(), 'gallery_include', true);
            $include = preg_replace(array('/[^\\d,]/', '/(?<=,),+/', '/^,+/', '/,+$/'), '', $include_images);
            // Create exclude
            $exclude = false;
            if ($exclude_featured) {
                $exclude = 'featured';
            }
            if ($exclude_images) {
                $exclude = $exclude_images;
            }
            // Create prevnext
            $prevnext = $prevnext ? 'true' : 'false';
            // Remove links
            $links = $links ? 'false' : 'true';
            $do_shortcode_args = array('exclude' => $exclude, 'include' => $include, 'effect' => $effect, 'timer' => $timer, 'prevnext' => $prevnext, 'link' => $links);
            // Correct size depending on widget area
            if ($args['id'] == wpsight_get_sidebar('sidebar-listing') || $args['id'] == 'sidebar') {
                $do_shortcode_args = array_merge(array('size' => 'small'), $do_shortcode_args);
            }
            $do_shortcode_args = apply_filters('wpsight_listing_gallery_shortcode_args', $do_shortcode_args, $args, $instance);
            // Set up $shortcode_args for shortcode
            $shortcode_args = '';
            foreach ($do_shortcode_args as $k => $v) {
                if ($do_shortcode_args[$k]) {
                    $shortcode_args .= ' ' . $k . '="' . $v . '"';
                }
            }
            // Reduce margin top if title empty
            $margin = empty($title) ? ' style="margin-top:-10px"' : '';
            // Create listing gallery
            $remove_links = isset($remove_links) ? $remove_links : false;
            $listing_gallery = '';
            if ($display == 'thumbs') {
                // Apply image_gallery shortcode
                $listing_gallery .= do_shortcode('[image_gallery' . $shortcode_args . $remove_links . ']');
            } else {
                // Apply image_slider shortcode
                $listing_gallery .= do_shortcode('[image_slider' . $shortcode_args . $remove_links . ']');
            }
            // Stop if no images
            if (empty($listing_gallery)) {
                return;
            }
            ?>
        	
        	<div id="<?php 
            echo wpsight_dashes($this->id);
            ?>
" class="listing-gallery section clearfix clear"<?php 
            echo $margin;
            ?>
>
        		
				<?php 
            // Display title if exists
            if (!empty($title)) {
                ?>
						
						<div class="title clearfix">    
        	    	        <h2><?php 
                echo apply_filters('widget_title', $title, $instance, $this->id_base);
                ?>
</h2>
        	    	        <?php 
                // Action hook listing gallery title inside
                do_action('wpsight_listing_gallery_title_inside', $args, $instance);
                ?>
    	
        	    	    </div>
						
					<?php 
            }
            echo apply_filters('wpsight_widget_listing_gallery', $listing_gallery, $args, $instance);
            ?>
				    
		    </div><!-- .listing-gallery --><?php 
        }
    }
Example #10
0
    function widget($args, $instance)
    {
        extract($args, EXTR_SKIP);
        $title = isset($instance['title']) ? apply_filters('widget_title', strip_tags($instance['title']), $instance, $this->id_base) : false;
        $filter = isset($instance['filter']) ? strip_tags($instance['filter']) : false;
        if (!($number = (int) $instance['number'])) {
            $number = 1;
        } else {
            if ($number < 1) {
                $number = 1;
            }
        }
        if (!($length = (int) $instance['length'])) {
            $length = 25;
        } else {
            if ($length < 1) {
                $length = 25;
            }
        }
        $width = isset($instance['width']) ? $instance['width'] : wpsight_get_span('small');
        // Correct width
        if ($width == wpsight_get_span('big') && ($id == 'home-top' || $id == 'home-bottom' || $id == 'ffooter')) {
            $width = wpsight_get_span('full');
        }
        if (($width == wpsight_get_span('full') || $width == wpsight_get_span('half')) && $id == 'home') {
            $width = wpsight_get_span('big');
        }
        // Check widget width
        if ($width != 'full') {
            $widget_width = $width;
        } else {
            $widget_width = '';
            if ($id == 'home-top' || $id == 'home-bottom' || $id == 'ffooter') {
                $clear = ' clearfix';
            }
        }
        if ($id == 'sidebar' || $id == 'sidebar-home' || $id == 'home' && ($width == 'span12' || $width == 'full')) {
            $widget_width = '';
            $clear = ' clearfix';
        }
        // Create query args
        $query_args = array('post_type' => array('listing'), 'posts_per_page' => $number);
        // Add filter to query args if required
        if (!empty($filter)) {
            if ($filter == 'latest-sale') {
                // Set meta_query
                $meta_query = array(array('key' => '_price_status', 'value' => 'sale'));
                $query_args = array_merge($query_args, array('meta_query' => $meta_query));
            } elseif ($filter == 'latest-rent') {
                // Set meta_query
                $meta_query = array(array('key' => '_price_status', 'value' => 'rent'));
                $query_args = array_merge($query_args, array('meta_query' => $meta_query));
            } elseif ($filter == 'latest-new') {
                // Set meta_query
                $meta_query = array(array('key' => '_price_status', 'value' => 'new'));
                $query_args = array_merge($query_args, array('meta_query' => $meta_query));
            } elseif ($filter == 'latest-used') {
                // Set meta_query
                $meta_query = array(array('key' => '_price_status', 'value' => 'used'));
                $query_args = array_merge($query_args, array('meta_query' => $meta_query));
            } else {
                // Get taxonomy and term from filter (comma-separated value)
                $get_taxonomy = explode(',', $filter);
                $taxonomy = $get_taxonomy[0];
                $term = $get_taxonomy[1];
                // Set tax_query
                $tax_query = array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => array($term)));
                $query_args = array_merge($query_args, array('tax_query' => $tax_query));
            }
        }
        $query_args = apply_filters('wpsight_widget_listings_latest_query_args', $query_args, $args, $instance);
        // Check if transients are active
        $transients = apply_filters('wpsight_transients_queries', false, 'widget', $query_args, $this->id);
        // If query transients are active
        if ($transients === true) {
            // If transient does not exist
            if (false === ($latest = get_transient('wpsight_query_' . $this->id)) || isset($query_args['orderby']) && $query_args['orderby'] == 'rand') {
                // Create listing query
                $latest = new WP_Query($query_args);
                // Set transient for this query
                set_transient('wpsight_query_' . $this->id, $latest, DAY_IN_SECONDS);
            }
            // If query transients are not active
        } else {
            // Create listing query
            $latest = new WP_Query($query_args);
        }
        if ($latest->have_posts()) {
            // Create loop counter
            $counter = 1;
            ?>
		
			<div id="<?php 
            echo wpsight_dashes($this->id);
            ?>
-wrap" class="widget-wrap widget-latest-wrap">
			
				<div id="<?php 
            echo wpsight_dashes($this->id);
            ?>
" class="widget widget-latest widget-latest-listings row"><?php 
            // Display widget title
            if (!empty($title)) {
                ?>
						
						<div class="title title-widget clearfix">
						
						    <?php 
                echo apply_filters('wpsight_widget_listings_latest_title', '<h2>' . $title . '</h2>', $args, $instance);
                do_action('wpsight_widget_listings_latest_title_actions', $args, $instance);
                ?>
						
						</div><?php 
            }
            // endif $title
            // Begin to loop through posts
            while ($latest->have_posts()) {
                // Set up post data
                $latest->the_post();
                $clear = '';
                // Add .clear to post class with if madness
                if (WPSIGHT_LAYOUT == 'four') {
                    if ($id == 'home-top' || $id == 'home-bottom' || $id == 'ffooter') {
                        if ($width == 'span3') {
                            if ($counter == 1 || ($counter - 1) % 4 == 0) {
                                $clear = ' clear';
                            } else {
                                $clear = '';
                            }
                        } elseif ($width == 'span6') {
                            if ($counter == 1 || $counter % 2 != 0) {
                                $clear = ' clear';
                            } else {
                                $clear = '';
                            }
                        }
                    } elseif ($id == 'home') {
                        if ($width == 'span3') {
                            if ($counter == 1 || ($counter - 1) % 3 == 0) {
                                $clear = ' clear';
                            } else {
                                $clear = '';
                            }
                        }
                    } elseif ($id == 'sidebar' || $id == 'sidebar-home' || $id == wpsight_get_sidebar('sidebar-listing') || $id == 'sidebar-post' || $id == 'sidebar-page' || $id == wpsight_get_sidebar('sidebar-listing-archive')) {
                        $widget_width = 'span3';
                        $clear = ' clear';
                    }
                } else {
                    if ($id == 'home-top' || $id == 'home-bottom' || $id == 'ffooter') {
                        if ($width == 'span4') {
                            if ($counter == 1 || ($counter - 1) % 3 == 0) {
                                $clear = ' clear';
                            } else {
                                $clear = '';
                            }
                        } elseif ($width == 'span6') {
                            if ($counter == 1 || $counter % 2 != 0) {
                                $clear = ' clear';
                            } else {
                                $clear = '';
                            }
                        }
                    } elseif ($id == 'home') {
                        if ($width == 'span4') {
                            if ($counter == 1 || $counter % 2 != 0) {
                                $clear = ' clear';
                            } else {
                                $clear = '';
                            }
                        }
                    } elseif ($id == 'sidebar' || $id == 'sidebar-home' || $id == wpsight_get_sidebar('sidebar-listing') || $id == 'sidebar-post' || $id == 'sidebar-page' || $id == wpsight_get_sidebar('sidebar-listing-archive')) {
                        $widget_width = 'span4';
                        $clear = ' clear';
                    }
                }
                ?>
					    
					    <div <?php 
                post_class($widget_width . $clear . ' clearfix');
                ?>
>
					    
					    	<div class="widget-inner">
					        
					    		<?php 
                // Action hook before listing title (widget)
                do_action('wpsight_widget_listing_title_before', $width, $id);
                ?>
					    		
					    		<h3 class="post-title">
    				    			<a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title_attribute();
                ?>
" rel="bookmark">
    				    				<?php 
                // Action hook listing title inside (widget)
                do_action('wpsight_widget_listing_title_inside', $width, $id);
                the_title();
                ?>
    				    			</a>
    				    		</h3>
					    		    
					    		<?php 
                // Action hook after listing title (widget)
                do_action('wpsight_widget_listing_title_after', $width, $id);
                // Action hook before listing content (widget)
                do_action('wpsight_widget_listing_content_before', $width, $id);
                ?>
					        		
					    		<div class="post-teaser">
					    			<?php 
                wpsight_the_excerpt(get_the_ID(), true, $length);
                ?>
					        	</div>
					        	
					        	<?php 
                // Action hook after listing content (widget)
                do_action('wpsight_widget_listing_content_after', $width, $id);
                ?>
					        	
					        </div><!-- .widget-inner -->
					        			
					    </div><!-- .post-<?php 
                the_ID();
                ?>
 --><?php 
                // Increase loop counter
                $counter++;
            }
            // endwhile have_posts()
            ?>
				
				</div><!-- .widget -->
			
			</div><!-- .widget-wrap --><?php 
        }
        // endif have_posts()
        // Reset query
        wp_reset_query();
    }
Example #11
0
    function widget($args, $instance)
    {
        if (is_listing_single() && has_post_thumbnail(get_the_ID())) {
            extract($args, EXTR_SKIP);
            $title = isset($instance['title']) ? strip_tags($instance['title']) : false;
            // Set image info
            $thumbnail = get_post(get_post_thumbnail_id());
            $thumbnail_alt = get_post_meta(get_post_thumbnail_id(), '_wp_attachment_image_alt', true);
            // Get image caption
            $caption = $thumbnail->post_excerpt ? $thumbnail->post_excerpt : false;
            // Get image alt text
            $alt = $thumbnail_alt ? $thumbnail_alt : get_the_title();
            // Get image description
            $description = $thumbnail->post_content ? $thumbnail->post_content : get_the_title();
            ?>
        	
        	<div id="<?php 
            echo wpsight_dashes($this->id);
            ?>
" class="listing-image section clearfix clear">
        		
				<?php 
            // Display title if exists
            if (!empty($title)) {
                ?>
						
						<div class="title clearfix">    
        	    	        <h2><?php 
                echo apply_filters('widget_title', $title, $instance, $this->id_base);
                ?>
</h2>
        	    	        <?php 
                // Action hook listing description title inside
                do_action('wpsight_listing_image_title_inside', $args, $instance);
                ?>
    	
        	    	    </div>
						
					<?php 
            }
            // If in sidebar display smaller image
            $args['id'] = isset($args['id']) ? $args['id'] : false;
            $wpsight_thumb = $args['id'] == wpsight_get_sidebar('sidebar-listing') ? 'post-thumbnail' : 'big';
            // Set full width image
            if (get_post_meta(get_the_ID(), '_layout', true) == 'full-width') {
                $wpsight_thumb = 'full';
            }
            // Set full width image
            if (!is_active_sidebar(wpsight_get_sidebar('sidebar-listing'))) {
                $wpsight_thumb = 'full';
            }
            // Display featured image
            $listing_image = apply_filters('wpsight_widget_listing_image', get_the_post_thumbnail(get_the_ID(), $wpsight_thumb, array('alt' => $alt, 'title' => $description)), $args, $instance);
            // Wrap if caption
            if ($caption) {
                $listing_image = '<div class="wp-caption alignnone">' . $listing_image . '<p class="wp-caption-text">' . $caption . '</p>' . '</div><!-- .wp-caption -->';
            }
            echo $listing_image;
            ?>
				
			</div><!-- .listing-image --><?php 
        }
    }