public function widget($args, $instance) { extract($args); // Before Widget echo PHP_EOL . $before_widget; // Display Title $title = apply_filters('widget_title', empty($instance['title']) ? 'Tweets' : $instance['title'], $instance, $this->id_base); if ($title) { echo PHP_EOL . $before_title . $title . $after_title . PHP_EOL; } # Cache Timeout $cache_timeout = 600; # 10 minutes # Items Count $items_count = $instance['items_count']; # Items array (cached) $portfolio_items = get_transient('laborator_portfolio_latest_items'); # Ordering $order_by = $instance['order_by']; $order_type = $instance['order_type'] == 'ASC' ? 'ASC' : 'DESC'; if (!$portfolio_items) { $items_count = $items_count > 0 ? $items_count : 24; $portfolio_items = get_posts(array('post_type' => 'portfolio', 'posts_per_page' => $items_count, 'orderby' => 'date', 'order' => $order_type)); foreach ($portfolio_items as $portfolio_item) { $portfolio_item->views = get_portfolio_item_views($portfolio_item->ID, TRUE); $portfolio_item->likes = get_portfolio_item_likes($portfolio_item->ID, TRUE); } define('LABORATOR_PL_ORDER_TYPE', $order_type); if ($order_by == 'views') { uasort($portfolio_items, array(&$this, 'order_by_views')); } elseif ($order_by == 'likes') { uasort($portfolio_items, array(&$this, 'order_by_likes')); } set_transient('laborator_portfolio_latest_items', $portfolio_items, $cache_timeout); } ?> <div class="portfolio_sneakpeak"> <?php foreach ($portfolio_items as $portfolio_item) { ?> <a href="<?php echo get_permalink($portfolio_item->ID); ?> " class="portfolio_small_item"><?php echo laborator_show_img($portfolio_item->ID, 'min-thumb'); ?> </a> <?php } ?> </div> <?php // After Widget echo $after_widget . PHP_EOL; }
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; }
* * Theme by: Art Ramadani * Developed by: Arlind Nushi * * www.laborator.co * * View Portfolio Item */ global $wpdb; # Post ID $post_id = get_the_ID(); # Set Post Impression (view) portfolio_item_set_impression($post_id); # Vars $portfolio_options = get_portfolio_options(); $portfolio_item_likes = get_portfolio_item_likes($post_id, TRUE); $portfolio_item_views = get_portfolio_item_views($post_id, TRUE); extract($portfolio_options); # Import Required Resources wp_enqueue_script(array('flexslider', 'shadowbox', 'kolor_hover')); wp_enqueue_style(array('flexslider', 'shadowbox')); # Next and Previous post (portfolio item) $prev_posts = $wpdb->get_row("SELECT * FROM {$wpdb->posts} WHERE post_type = 'portfolio' AND post_status = 'publish' AND ID < {$post_id} ORDER BY ID DESC"); $next_posts = $wpdb->get_row("SELECT * FROM {$wpdb->posts} WHERE post_type = 'portfolio' AND post_status = 'publish' AND ID > {$post_id} ORDER BY ID ASC"); $prev_post_link = get_permalink($prev_posts->ID); $next_post_link = get_permalink($next_posts->ID); # Get Portfolio Item Image Gallery $args = array('post_type' => 'attachment', 'numberposts' => null, 'post_status' => null, 'post_parent' => $post_id); $attachments = get_posts($args); // Header get_header();