function yiw_is_portfolio_post_type($pt = false) { $portfolios = yiw_portfolios(); if (!$pt) { $pt = get_post_type(); } if (isset($portfolios[$pt])) { return true; } return false; }
function form($instance) { global $icons_name, $fxs, $easings; /* Impostazioni di default del widget */ $defaults = array('title' => 'Featured Projects', 'project_n_items' => 4, 'project_speed_fx' => 200, 'project_post_type' => ''); $categories = get_categories('hide_empty=1&orderby=name'); $wp_cats = array(); foreach ($categories as $category_list) { $wp_cats[$category_list->category_nicename] = $category_list->cat_name; } $instance = wp_parse_args((array) $instance, $defaults); ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> ">Title: <input type="text" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo $instance['title']; ?> " class="widefat" /> </label> </p> <p> <label for="<?php echo $this->get_field_id('project_post_type'); ?> ">Portfolio: <select id="<?php echo $this->get_field_id('project_post_type'); ?> " name="<?php echo $this->get_field_name('project_post_type'); ?> "> <option></option> <?php $portfolios = yiw_portfolios(); foreach ($portfolios as $post_type => $the_) { $select = ''; if ($instance['project_post_type'] == $post_type) { $select = ' selected="selected"'; } echo "<option value=\"{$post_type}\"{$select}>{$the_['title']}</option>\n"; } ?> </select> </label> </p> <p> <label for="<?php echo $this->get_field_id('project_n_items'); ?> ">Items: <select id="<?php echo $this->get_field_id('project_n_items'); ?> " name="<?php echo $this->get_field_name('project_n_items'); ?> "> <?php for ($i = 1; $i <= 20; $i++) { $select = ''; if ($instance['project_n_items'] == $i) { $select = ' selected="selected"'; } echo "<option value=\"{$i}\"{$select}>{$i}</option>\n"; } ?> </select> </label> </p> <p> <label for="<?php echo $this->get_field_id('project_speed_fx'); ?> ">Speed Animation (ms): <input type="text" id="<?php echo $this->get_field_id('project_speed_fx'); ?> " name="<?php echo $this->get_field_name('project_speed_fx'); ?> " value="<?php echo $instance['project_speed_fx']; ?> " size="4" /> </label> </p> <?php }
<?php /** * @package WordPress * @subpackage Sheeva * @since Impero 1.0 */ /* Template Name: Portfolio */ global $yiw_portfolio; $yiw_portfolio = yiw_portfolios(); $post_type = yiw_get_portfolio_post_type(); $portfolio_type = !get_post_meta(get_the_ID(), 'portfolio_type', true) ? isset($yiw_portfolio[$post_type]['layout']) ? $yiw_portfolio[$post_type]['layout'] : '' : get_post_meta(get_the_ID(), 'portfolio_type', true); $portfolio_types = array('no_sidebar' => array('3cols', 'slider', 'big_image'), 'sidebar' => array('full_desc', 'filterable')); // enqueue necessary scripts if ($portfolio_type == 'filterable') { wp_enqueue_script('jquery-quicksand', get_template_directory_uri() . "/js/jquery.quicksand.js", array('jquery')); } get_header(); $layout_type = in_array($portfolio_type, $portfolio_types['no_sidebar']) ? 'sidebar-no' : yiw_layout_page(); if ($portfolio_type == 'full_desc') { get_template_part('single', 'portfolio'); die; } $cat_params = array('hide_empty' => FALSE, 'title_li' => ''); $cats = get_terms($yiw_portfolio[$post_type]['tax'], $cat_params); $_active_title = get_post_meta($post->ID, '_show_title_page', true); ?>
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $project_post_types = isset($instance['project_post_type']) ? $instance['project_post_type'] : 'portfolio'; echo $before_widget; echo $before_title . $title . $after_title; $portfolios = yiw_portfolios(); echo '<ul id="gallery_categories_widget">'; //echo ' <li class="segment-1"><a data-value="all" href="' . get_permalink( yiw_get_pageID_by_pagename( 'portfolio' ) ) . '">'.__('All', 'yiw').'</a></li>'; if (!is_tax() && !is_single()) { echo ' <li class="segment-1"><a data-value="all" href="#">' . __('All', 'yiw') . '</a></li>'; } $cat_params = array('hide_empty' => FALSE, 'title_li' => ''); $cats = get_terms(sanitize_title($portfolios[$project_post_types]['tax']), $cat_params); foreach ($cats as $cat) { if (!is_object($cat) && empty($cat)) { continue; } if (isset($cat->count) && $cat->count > 0) { $url = is_tax() || is_single() ? get_term_link($cat, $portfolios[$project_post_types]['tax']) : '#'; ?> <li class="segment-<?php echo $cat->term_id; ?> "><a href="<?php echo $url; ?> " data-value="<?php echo $cat->slug; ?> "><?php echo $cat->name; ?> </a></li><?php } else { ?> <li><?php echo $cat->name; ?> </li><?php } } echo '</ul>'; echo $after_widget; }