'; foreach($terms as $term) { $output .= '
  • '.$term->name.'
  • '; } $output .= ''; return $output; } function recipress_terms($taxonomy, $args = null) { echo get_recipress_terms($taxonomy, $args); } class recipress_terms_widget extends WP_Widget { /** constructor */ function __construct() { parent::WP_Widget( 'recipress_terms', 'Recipress Terms', array( 'description' => 'Output a list or cloud of recipe terms' ) ); } /** @see WP_Widget::widget */ function widget( $args, $instance ) { extract( $args ); $title = apply_filters( 'widget_title', $instance['title'] ); $taxonomy = $instance['taxonomy']; $type = $instance['type']; $the_taxonomy = get_taxonomy($taxonomy); if ($title == '') $title = $the_taxonomy->label; echo $before_widget; echo $before_title . $title . $after_title; if ($type == 'list') { echo get_recipress_terms($taxonomy); } elseif ($type == 'cloud') { wp_tag_cloud('taxonomy='.$taxonomy); } echo $after_widget; } /** @see WP_Widget::update */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['taxonomy'] = $new_instance['taxonomy']; $instance['type'] = $new_instance['type']; return $instance; } /** @see WP_Widget::form */ function form( $instance ) { if ( $instance ) { $title = esc_attr( $instance[ 'title' ] ); $taxonomy = $instance[ 'taxonomy' ]; $type = $instance[ 'type' ]; } else { $title = ''; $taxonomy = 'course'; $type = 'list'; } $taxonomies = recipress_use_taxonomies(); array_unshift($taxonomies, 'ingredient'); foreach ($taxonomies as $tax) { $tax = get_taxonomy($tax); $taxes[] = array( 'id' => $tax->query_var, 'name' => $tax->label ); } ?>


     

    'hasRecipe', 'meta_value' => 'Yes', 'numberposts' => $num ); $recipes = new WP_query($args); if($recipes->have_posts()) : $output = ''; else : $output = '

    No recipes found.

    '; endif; wp_reset_postdata(); return $output; } function recipress_recent($num = '5', $image = 1) { echo get_recipress_recent($num , $image); } class recipress_recent_widget extends WP_Widget { /** constructor */ function __construct() { parent::WP_Widget( 'recipress_recent', 'Recent Recipes', array( 'description' => 'Output a list of recent recipe posts' ) ); } /** @see WP_Widget::widget */ function widget( $args, $instance ) { extract( $args ); $title = apply_filters( 'widget_title', $instance['title'] ); $num = $instance['num']; $image = $instance['image']; if ($title == '') $title = 'Recent Recipes'; echo $before_widget; echo $before_title . $title . $after_title; echo get_recipress_recent($num, $image); echo $after_widget; } /** @see WP_Widget::update */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['num'] = $new_instance['num']; $instance['image'] = $new_instance['image']; return $instance; } /** @see WP_Widget::form */ function form( $instance ) { if ( $instance ) { $title = esc_attr( $instance[ 'title' ] ); $num = $instance[ 'num' ]; $image = $instance[ 'image' ]; } else { $title = ''; $num = 5; $image = 1; } ?>