function is_portfolio_item_liked($post_id, $is_gallery_item = FALSE) { global $post; if (!$post) { $post = get_post($post_id); } $status = 0; if ($post) { if ($is_gallery_item) { $portfolio_options = get_gallery_options(); } else { $portfolio_options = get_portfolio_options(); } extract($portfolio_options); $post_likes = get_portfolio_item_likes($post_id); $arr_key = ''; $session_id = session_id(); $ip = $_SERVER['REMOTE_ADDR']; switch ($like_logging_method) { case 'cookie': $arr_key = $session_id; if (!$post_likes[$session_id]) { $status = -1; } else { $status = 1; } break; default: $arr_key = $ip; if (!isset($post_likes[$ip])) { $status = -1; } else { $status = 1; } } if (!defined("LABORATOR_LIKE_ARR_KEY")) { define("LABORATOR_LIKE_ARR_KEY", $arr_key); } } return $status; }
<?php global $portfolio_rows; $post_id = get_the_ID(); # Vars $portfolio_options = get_portfolio_options(); extract($portfolio_options); $portfolio_mult = 4; $portfolio_rows = $portfolio_rows ? $portfolio_rows : 2; $posts_per_page = $portfolio_mult * $portfolio_rows; # Get Portfolio Items $query_arr = array('post_type' => 'portfolio', 'posts_per_page' => $posts_per_page, 'post__not_in' => array($post_id), 'order' => 'DESC', 'orderby' => 'date'); $portfolio_items = new WP_Query($query_arr); ?> <?php if ($portfolio_items->have_posts()) { ?> <!-- portfolio (index block) --> <div class="container white_block index_portfolio_env double_bottom_margin"> <!-- block title --> <div class="ten columns potfolio_title_block"> <h2 class="block_title"> <i class="portfolio"></i> <?php echo _x('箱子', 'latest portfolio items (homepage)', TD); ?> </h2>
function endless_scroll_get_results() { global $wpdb; $page = $_REQUEST['page']; $portfolio_category = $_REQUEST['portfolio_category']; $post_id = $_REQUEST['page_id']; $post = get_post($post_id); $post_type = $_REQUEST['post_type']; if ($post) { $portfolio_options = get_portfolio_options($post_id); if ($post_type == 'gallery') { $portfolio_options = get_gallery_options($post_id); } extract($portfolio_options); $arr = array('post_type' => $post_type, 'paged' => $page, 'posts_per_page' => $items_per_page); if ($portfolio_category) { $arr['portfolio-category'] = $portfolio_category; } $portfolio_items = new WP_Query($arr); while ($portfolio_items->have_posts()) { $portfolio_items->the_post(); global $post; $post_id = $post->ID; $title = get_the_title(); if ($post_type == 'gallery') { $thumbnail_size = ''; switch ($columns) { case 2: $thumbnail_size = 'portfolio-thumb-4'; $post_thumbnail = get_the_post_thumbnail($post_id, $thumbnail_size, "portfolio-item-{$post_id}"); break; case 3: $thumbnail_size = 'portfolio-thumb-3'; $post_thumbnail = get_the_post_thumbnail($post_id, $thumbnail_size, "portfolio-item-{$post_id}"); break; default: $thumbnail_size = 'portfolio-thumb-1'; $post_thumbnail = get_the_post_thumbnail($post_id, $thumbnail_size, "portfolio-item-{$post_id}"); } # [Alternative] If there is no post thumnail attached, check for other attachments inside the post if (!$post_thumbnail) { $other_attachment = reset(get_children(array('post_parent' => $post_id, 'post_type' => 'attachment', 'posts_per_page' => 1, 'orderby' => 'menu_order', 'order' => 'ASC'))); $post_thumbnail = wp_get_attachment_image($other_attachment->ID, $thumbnail_size); $post_thumbnail = preg_replace('/width=.[0-9]+.|height=.[0-9]+./', '', $post_thumbnail); } $album_date = get_post_meta($post_id, 'album_date', TRUE); $album_place = get_post_meta($post_id, 'album_place', TRUE); if ($album_date) { $album_date = strtotime($album_date); $album_date = date("d F Y", $album_date); } $album_second_line = $album_date . ($album_date && $album_place ? ' - ' : '') . $album_place . ' '; ?> <!-- portfolio entry --> <div class="portfolio_entry_item <?php echo $columns == 3 ? 'one-third column' : ($columns == 2 ? 'eight columns' : 'four columns'); ?> "> <div class="portfolio_entry<?php echo !$gallery_bottom_titles ? ' no_titles' : ''; ?> " data-filter="" data-row-1="<?php echo esc_attr($title); ?> " data-row-2="<?php echo esc_attr($album_second_line); ?> "> <a href="<?php the_permalink(); ?> " class="image portfolio_hover gallery_hover"> <?php echo $post_thumbnail; ?> </a> <?php if ($gallery_bottom_titles) { ?> <!-- item title --> <div class="meta"> <a href="<?php the_permalink(); ?> " class="title"><?php the_title(); ?> </a> <div class="right_panel"> <span class="category gallery_category"><?php echo $album_second_line; ?> </span> <?php if ($allow_likes) { ?> <a href="#" data-id="<?php echo $post_id; ?> " data-nonce="<?php echo wp_create_nonce('LaboratorLikeGalleryItem'); ?> " data-is-gallery-item="1" class="like<?php echo is_portfolio_item_liked($post_id) == 1 ? ' liked' : ''; ?> ">Like</a> <?php } ?> </div> </div> <!-- end: item title --> <?php } ?> </div> </div> <!-- end: portfolio entry --> <?php } else { $post_categories = get_the_terms($post_id, 'portfolio-category'); if (!$post_categories) { $post_categories = array(); } $thumbnail_size = ''; switch ($columns) { case 2: $thumbnail_size = 'portfolio-thumb-4'; $post_thumbnail = get_the_post_thumbnail($post_id, $thumbnail_size, "portfolio-item-{$post_id}"); break; case 3: $thumbnail_size = 'portfolio-thumb-3'; $post_thumbnail = get_the_post_thumbnail($post_id, $thumbnail_size, "portfolio-item-{$post_id}"); break; default: $thumbnail_size = 'portfolio-thumb-1'; $post_thumbnail = get_the_post_thumbnail($post_id, $thumbnail_size, "portfolio-item-{$post_id}"); } # [Alternative] If there is no post thumnail attached, check for other attachments inside the post if (!$post_thumbnail) { $other_attachment = reset(get_children(array('post_parent' => $post_id, 'post_type' => 'attachment', 'posts_per_page' => 1, 'orderby' => 'menu_order', 'order' => 'ASC'))); $post_thumbnail = wp_get_attachment_image($other_attachment->ID, $thumbnail_size); $post_thumbnail = preg_replace('/width=.[0-9]+.|height=.[0-9]+./', '', $post_thumbnail); } # Category Slugs $cslugs = array(); $cnames = array(); foreach ($post_categories as $cat_term) { array_push($cslugs, $cat_term->slug); array_push($cnames, $cat_term->name); } ?> <!-- portfolio entry --> <div class="portfolio_entry_item <?php echo $columns == 3 ? 'one-third column' : ($columns == 2 ? 'eight columns' : 'four columns'); ?> "> <div class="portfolio_entry<?php echo !$portfolio_bottom_titles ? ' no_titles' : ''; ?> " data-filter="<?php echo implode(' ', $cslugs); ?> " data-row-1="<?php echo esc_attr($title); ?> " data-row-2="<?php echo esc_attr(implode(', ', $cnames)); ?> "> <a href="<?php the_permalink(); ?> " class="image portfolio_hover"> <?php echo $post_thumbnail; ?> </a> <?php if ($portfolio_bottom_titles) { ?> <!-- item title --> <div class="meta"> <a href="<?php the_permalink(); ?> " class="title"><?php the_title(); ?> </a> <div class="right_panel"> <span class="category"><?php echo implode(', ', $cnames); ?> </span> <?php if ($allow_likes) { ?> <a href="#" data-id="<?php echo $post_id; ?> " data-nonce="<?php echo wp_create_nonce('LaboratorLikePortfolioItem'); ?> " class="like<?php echo is_portfolio_item_liked($post_id) == 1 ? ' liked' : ''; ?> ">Like</a> <?php } ?> </div> </div> <!-- end: item title --> <?php } else { ?> <?php if ($allow_likes) { ?> <a href="#" data-id="<?php echo $post_id; ?> " data-nonce="<?php echo wp_create_nonce('LaboratorLikePortfolioItem'); ?> " class="like<?php echo is_portfolio_item_liked($post_id) == 1 ? ' liked' : ''; ?> "><?php _e('Like'); ?> </a> <?php } ?> <?php } ?> </div> </div> <!-- end: portfolio entry --> <?php } } die; } }
/** * Kolor * * Theme by: Art Ramadani * Developed by: Arlind Nushi * * www.laborator.co * * Template Name: Portfolio */ global $wp, $wp_query, $wp_rewrite, $query_string, $post_id; $query_string_arr = wp_parse_args($query_string); $post_id = $page_id = get_the_ID(); # Vars $portfolio_options = get_portfolio_options($page_id); $slider_items = get_posts(array('post_type' => 'attachment', 'post_parent' => $post_id, 'orderby' => 'menu_order', 'order' => 'ASC')); # Use External Post Images if ($external_slider_post_id = get_post_meta($post_id, 'external_slider_post_id', TRUE)) { $slider_items = get_posts(array('post_type' => 'attachment', 'post_parent' => $external_slider_post_id, 'orderby' => 'menu_order', 'order' => 'ASC')); } $slider_items_count = count($slider_items); extract($portfolio_options); $posts_per_page = $items_per_page; $paged = isset($query_string_arr['paged']) ? $query_string_arr['paged'] : 1; $paged = $paged > 1 ? $paged : 1; # Get Portfolio Items $query_arr = array('post_type' => 'portfolio', 'posts_per_page' => $posts_per_page, 'paged' => $paged); # Get From Category if (!isset($_GET['show_all']) && isset($_GET['category']) && (($browse_category = $_GET['category']) || ($browse_category = $query_string_arr['portfolio-category']))) { $query_arr['portfolio-category'] = $browse_category;