/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title']); $tagline = apply_filters('enlightenment_custom_query_widget_tagline', $instance['tagline']); echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } if (!empty($tagline)) { echo enlightenment_open_tag('div', 'tagline') . wpautop($tagline) . enlightenment_close_tag('div'); } $query = array(); if ('sticky_posts' == $instance['query']) { $query['post__in'] = get_option('sticky_posts'); } elseif ('post_type_archive' == $instance['query']) { $query['post_type'] = $instance['post_type']; $query['posts_per_page'] = $instance['posts_per_page']; } elseif ('post_type' == $instance['query']) { $query['post_type'] = $instance['post_type']; $query['p'] = $instance['p']; } elseif ('page' == $instance['query']) { $query['post_type'] = 'page'; $query['page_id'] = $instance['page_id']; } elseif ('pages' == $instance['query']) { $query['post_type'] = 'page'; $query['post__in'] = $instance['pages']; $query['posts_per_page'] = -1; } elseif ('gallery' == $instance['query']) { $query['post_type'] = 'attachment'; $query['post_mime_type'] = 'image'; $query['post__in'] = $instance['images']; $query['post_status'] = 'inherit'; $query['posts_per_page'] = -1; } elseif ('author' == $instance['query']) { $query['author'] = $instance['author']; $query['posts_per_page'] = $instance['posts_per_page']; } elseif ('taxonomy' == $instance['query']) { if ('category' == $instance['taxonomy']) { $instance['taxonomy'] = 'category_name'; } elseif ('post_tag' == $instance['taxonomy']) { $instance['taxonomy'] = 'tag'; } $query[$instance['taxonomy']] = $instance['term']; $query['posts_per_page'] = $instance['posts_per_page']; } $query['ignore_sticky_posts'] = true; global $enlightenment_custom_widget_instance, $enlightenment_custom_lead_posts, $enlightenment_custom_grid; $enlightenment_custom_widget_instance = $instance; $enlightenment_custom_lead_posts = $instance['leading_posts']; $enlightenment_custom_grid = $instance['grid']; echo enlightenment_open_tag('div', 'custom-query-' . $instance['type'] . ' custom-query-' . $instance['query'] . ('slider' == $instance['type'] || 'carousel' == $instance['type'] ? ' flexslider' : '')); $loop_args = array('query_name' => 'custom_query_widget_' . $instance['type'], 'query_args' => $query, 'container_class' => 'custom-entry'); if ('slider' == $instance['type'] || 'carousel' == $instance['type']) { $loop_args['container'] = 'li'; $loop_args['container_class'] .= ' slide'; } echo enlightenment_custom_loop($loop_args); enlightenment_clearfix(); echo enlightenment_close_tag('div'); unset($GLOBALS['enlightenment_custom_widget_instance']); unset($GLOBALS['enlightenment_custom_lead_posts']); unset($GLOBALS['enlightenment_custom_grid']); if ($instance['link_to_archive']) { if ('post_type_archive' == $instance['query']) { if ('post' == $instance['post_type']) { if ('posts' == get_option('show_on_front')) { $link = home_url('/'); } else { $link = get_permalink(get_option('page_for_posts')); } } else { $link = get_post_type_archive_link($instance['post_type']); } } elseif ('author' == $instance['query']) { $link = get_author_posts_url($instance['author']); } elseif ('taxonomy' == $instance['query']) { $link = get_term_link($instance['term'], $instance['taxonomy']); } if (isset($link)) { echo '<a class="custom-archive-permalink" href="' . esc_url($link) . '">' . esc_attr($instance['link_to_archive_label']) . '</a>'; } } echo $args['after_widget']; }
function enlightenment_autor_hcard($args = null) { $defaults = array('container' => 'aside', 'container_class' => 'entry-author', 'title_container' => 'h4', 'avatar_size' => 96, 'title_class' => 'author vcard', 'title_prefix' => __('Written by', 'enlightenment'), 'author_name_container' => 'span', 'author_name_class' => 'fn', 'bio_container' => 'div', 'bio_class' => 'author-bio', 'echo' => true); $defaults = apply_filters('enlightenment_autor_hcard_args', $defaults); $args = wp_parse_args($args, $defaults); global $authordata; if (!is_object($authordata)) { return false; } $output = enlightenment_open_tag($args['container'], $args['container_class']); if ($args['avatar_size']) { $avatar = get_avatar(get_the_author_meta('user_email'), $args['avatar_size']); $output .= apply_filters('enlightenment_autor_hcard_avatar', $avatar, $args); } $output .= enlightenment_open_tag($args['title_container'], $args['title_class']); if ('' != $args['title_prefix']) { $output .= esc_attr($args['title_prefix']) . ' '; } $output .= enlightenment_open_tag($args['author_name_container'], $args['author_name_class']); $output .= sprintf('<a href="%1$s" title="%2$s" rel="author">%3$s</a>', esc_url(get_author_posts_url($authordata->ID, $authordata->user_nicename)), esc_attr(sprintf(__('Posts by %s', 'enlightenment'), get_the_author())), get_the_author()); $output .= enlightenment_close_tag($args['author_name_container']); $output .= enlightenment_close_tag($args['title_container']); $description = enlightenment_open_tag($args['bio_container'], $args['bio_class']); $description .= apply_filters('the_author_description', get_the_author_meta('description'), false); $description .= enlightenment_close_tag($args['bio_container']); $output .= apply_filters('enlightenment_author_bio', $description, $args); $output .= enlightenment_clearfix(array('echo' => false)); $output .= enlightenment_close_tag($args['container']); $output = apply_filters('enlightenment_autor_hcard', $output, $args); if (!$args['echo']) { return $output; } echo $output; }