function wpsight_archive_post_class($counter, $parent_id = '') { if (is_home()) { $archive = 'home'; } elseif (is_category() || is_page_template('page-tpl-blog.php')) { $archive = 'category'; } elseif (is_tag()) { $archive = 'tag'; } elseif (is_author()) { $archive = 'author'; } elseif (is_date()) { $archive = 'date'; } elseif (is_search()) { $archive = 'search'; } else { $archive = 'category'; } $archive_layout = wpsight_get_archive_layout($archive); $post_class = $archive_layout; if (WPSIGHT_LAYOUT == 'four') { if (is_active_sidebar('sidebar') || is_active_sidebar('sidebar-archive')) { // Respect full width layout on blog template if (is_singular() && get_post_meta($parent_id, '_layout', true) == 'full-width') { // 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('sidebar') || is_active_sidebar('sidebar-archive')) { // Respect full width layout on blog template if (is_singular() && get_post_meta($parent_id, '_layout', true) == 'full-width') { // 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 ($counter == 1 || $counter % 2 != 0) { $post_class = $post_class . ' clear'; } } elseif ($archive_layout == 'span8') { $post_class = 'span8'; } } } 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; }
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); } }
function wpsight_do_post_image($widget_width = '', $widget_location = '') { // Get post id $post_id = get_the_ID(); if (empty($post_id)) { return; } // Stop here if images are disabled on single posts if (is_singular() && (wpsight_get_layout_image('show_on_single') == false && !is_page_template('page-tpl-blog.php'))) { return; } // Only show image on first page if multipage post global $page; if ($page != 1 && !is_page_template('page-tpl-blog.php')) { 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 posts) $image_size = wpsight_get_layout_image('size_widget'); $image_align = wpsight_get_layout_image('align_widget'); // 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'; } } elseif (is_singular() && !is_page_template('page-tpl-blog.php')) { // If this is a single post or a static page if (get_post_meta($post_id, '_image_size', true)) { // Respect individual post image settings $image_size = get_post_meta($post_id, '_image_size', true); } else { $image_size = wpsight_get_layout_image('size_single'); } // Set image align depending on layout if (get_post_meta($post_id, '_image_align', true)) { // Respect individual post image settings $image_align = get_post_meta($post_id, '_image_align', true); } else { $image_align = wpsight_get_layout_image('align_single'); } // Remove alignment in some cases if (is_single() && $image_size == 'big' && (is_active_sidebar('sidebar-post') || is_active_sidebar('sidebar')) && get_post_meta($post_id, '_layout', true) != 'full-width') { $image_align = 'none'; } if (is_page() && !is_page_template('page-tpl-blog.php') && $image_size == 'big' && (is_active_sidebar('sidebar-page') || is_active_sidebar('sidebar')) && get_post_meta($post_id, '_layout', true) != 'full-width') { $image_align = 'none'; } if ($image_size == 'full') { $image_align = 'none'; } } else { // Not in a widget nor on a single page but on archive pages $image_size = wpsight_get_layout_image('size_archive'); $image_align = wpsight_get_layout_image('align_archive'); // Set current archive if (is_tag()) { $archive = 'tag'; } elseif (is_author()) { $archive = 'author'; } elseif (is_date()) { $archive = 'date'; } elseif (is_search()) { $archive = 'search'; } else { $archive = 'category'; } // Get archive layout $archive_layout = wpsight_get_archive_layout($archive); // Limit images to box width and remove align if ($image_size == 'big' || $image_size == 'full') { $image_align = 'none'; } if ($archive_layout == wpsight_get_span('small')) { $image_align = 'none'; } } // Create optional image overlay $overlay = apply_filters('wpsight_post_image_overlay', false); // Fincally output post image if (is_singular() && !is_page_template('page-tpl-blog.php') && empty($widget_location)) { // Echo image on single posts and page withouth link tag echo '<div class="post-image align' . $image_align . '">' . get_the_post_thumbnail($post_id, $image_size, array('alt' => the_title_attribute('echo=0'), 'title' => the_title_attribute('echo=0'))) . $overlay . '</div><!-- .post-image -->' . "\n"; } else { echo '<div class="post-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 . '</a></div><!-- .post-image -->' . "\n"; } } }
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; }