function display($args, $instance = false) { if (is_array($instance)) { $instance = $instance['number']; } if (!$instance || !is_numeric($instance) || 1 > $instance) { return; } extract($args); $parent_type = $this->options[$instance]['parent'] ? $this->options[$instance]['parent'] : 'all'; $parent_id = pp_is_project() && $parent_type == 'sub' ? pp_get_project_data(0, 'id') : 0; if ($parent_id === false) { return; } $categories = pp_get_projects($parent_id); if (!$categories) { return; } $walker = new Walker_Category(); echo $before_widget; if ($parent_type == 'sub' && $parent_id !== 0) { $title = __('Sub-projects', 'prologue-projects'); } else { $title = __('Projects', 'prologue-projects'); } $title = $this->options[$instance]['title'] ? $this->options[$instance]['title'] : $title; echo $before_title; echo $title; echo $after_title; echo '<ul>'; echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, array('style' => 'list'))); echo '</ul>'; echo $after_widget; }
function pp_the_projects($before = 'Projects: ', $sep = ', ', $after = '') { $terms = get_the_terms(0, 'category'); if (is_wp_error($terms)) { return; } if (empty($terms)) { return; } $term_links = array(); foreach ($terms as $term) { if (!pp_is_project($term->term_id)) { continue; } $link = get_term_link($term, 'category'); if (is_wp_error($link)) { continue; } $term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>'; } if (!count($term_links)) { return; } echo $before . join($sep, $term_links) . $after; }
// if have_posts ?> </div> </div> <div id="pp-sidebar"> <ul> <?php dynamic_sidebar('pp-sidebar-top'); if ($is_front_page) { dynamic_sidebar('pp-home-sidebar'); } ?> <?php if (pp_is_project()) { if (!dynamic_sidebar('pp-project-sidebar-' . pp_get_project_data(0, 'id'))) { dynamic_sidebar('pp-project-sidebar-default'); } ?> <li id="pp-widget-project-feeds-<?php echo pp_get_project_data(0, 'id'); ?> " class="widget pp-project-sidebar pp-project-sidebar-<?php echo pp_get_project_data(0, 'id'); ?> pp-widget-project-feeds"><?php pp_project_feeds(); ?> </li> <?php