function weaverii_show_posts_shortcode($args = '') { /* implement [weaver_show_posts] */ /* DOC NOTES: CSS styling: The group of posts will be wrapped with a <div> with a class called .wvr-show-posts. You can add an additional class to that by providing a 'class=classname' option (without the leading '.' used in the actual CSS definition). You can also provide inline styling by providing a 'style=value' option where value is whatever styling you need, each terminated with a semi-colon (;). The optional header is in a <div> called .wvr_show_posts_header. You can add an additional class name with 'header_class=classname'. You can provide inline styling with 'header_style=value'. .wvr-show-posts .hentry {margin-top: 0px; margin-right: 0px; margin-bottom: 40px; margin-left: 0px;} .widget-area .wvr-show-posts .hentry {margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;} */ global $more; global $weaverii_cur_post_id; extract(shortcode_atts(array('cats' => '', 'tags' => '', 'author' => '', 'author_id' => '', 'single_post' => '', 'post_type' => '', 'orderby' => 'date', 'sort' => 'DESC', 'number' => '5', 'paged' => false, 'sticky' => false, 'nth' => '0', 'show' => 'full', 'hide_title' => '', 'hide_top_info' => '', 'hide_bottom_info' => '', 'show_featured_image' => '', 'hide_featured_image' => '', 'show_avatar' => '', 'show_bio' => '', 'excerpt_length' => '', 'style' => '', 'class' => '', 'header' => '', 'header_style' => '', 'header_class' => '', 'more_msg' => '', 'left' => '', 'right' => '', 'clear' => ''), $args)); $save_cur_post = $weaverii_cur_post_id; /* Setup query arguments using the supplied args */ $qargs = array('ignore_sticky_posts' => 1); $qargs['orderby'] = $orderby; /* enter opts that have defaults first */ $qargs['order'] = $sort; $qargs['posts_per_page'] = $number; if (!empty($cats)) { $qargs['cat'] = weaverii_cat_slugs_to_ids($cats); } if (!empty($tags)) { $qargs['tag'] = $tags; } if (!empty($single_post)) { $qargs['name'] = $single_post; } if (!empty($author)) { $qargs['author_name'] = $author; } if (!empty($author_id)) { $qargs['author'] = $author_id; } if (!empty($post_type)) { $qargs['post_type'] = $post_type; } if (!empty($sticky) && $sticky) { $qargs['ignore_sticky_posts'] = 0; } weaverii_sc_reset_opts(); weaverii_sc_setopt('showposts', true); // global to see if we are in this function weaverii_sc_setopt('show', $show); // this will always be set if ($hide_title != '') { weaverii_sc_setopt('hide_title', true); } if ($hide_top_info != '') { weaverii_sc_setopt('hide_top_info', true); } if ($hide_bottom_info != '') { weaverii_sc_setopt('hide_bottom_info', true); } if ($show_featured_image != '') { weaverii_sc_setopt('show_featured_image', true); } if ($hide_featured_image != '') { weaverii_sc_setopt('hide_featured_image', true); } if (isset($args['show_avatar'])) { if ($show_avatar) { weaverii_sc_setopt('show_avatar', true); } else { weaverii_sc_setopt('show_avatar', 'no'); } } if ($excerpt_length != '') { weaverii_sc_setopt('excerpt_length', $excerpt_length); } if ($more_msg != '') { weaverii_sc_setopt('more_msg', $more_msg); } if ($paged) { if (get_query_var('paged')) { $qargs['paged'] = get_query_var('paged'); } else { if (get_query_var('page')) { $qargs['paged'] = get_query_var('page'); } else { $qargs['paged'] = 1; } } } $ourposts = new WP_Query(apply_filters('weaver_show_posts_wp_query', $qargs, $args)); // now modify the query using custom fields for this page /* now start the content */ $div_add = ''; if ($left) { $class .= ' weaver-left'; } else { if ($right) { $class .= ' weaver-right'; } } if (!empty($style)) { $div_add = ' style="' . $style . '"'; } $content = '<div class="wvr-show-posts ' . $class . '"' . $div_add . '>'; $h_add = ''; if (!empty($header_style)) { $h_add = ' style="' . $header_style . '"'; } if (!empty($header)) { $content .= '<div class="wvr-show-posts-header ' . $header_class . '"' . $h_add . '>' . $header . '</div>'; } ob_start(); // use built-in weaver code to generate a weaver standard post if ($show == 'titlelist') { echo '<ul>'; } weaverii_post_count_clear(); $posts_out = 0; if ($paged && $ourposts->have_posts()) { // top paging? global $wp_query; $wp_query = $ourposts; weaverii_content_nav('nav-above'); } while ($ourposts->have_posts()) { $ourposts->the_post(); weaverii_post_count_bump(); $weaverii_cur_post_id = get_the_ID(); $posts_out++; if ($nth != 0) { if ($posts_out < $nth) { continue; } if ($posts_out > $nth) { break; } // all done... } // weaverii_per_post_style(); if ($show == 'titlelist') { ?> <li><a href="<?php the_permalink(); ?> " title="<?php printf(esc_attr(__('Permalink to %s', 'weaver-ii')), the_title_attribute('echo=0')); ?> " rel="bookmark"><?php the_title(); ?> </a></li> <?php } else { get_template_part('content', get_post_format()); } } // end loop if ($show == 'titlelist') { echo "</ul>\n"; } if (!empty($show_bio) && get_the_author_meta('description')) { ?> <hr /> <div id="author-info"> <div id="author-avatar"> <?php echo get_avatar(get_the_author_meta('user_email'), apply_filters('weaverii_author_bio_avatar_size', 68)); ?> </div><!-- #author-avatar --> <div id="author-description"> <h2><?php printf(esc_attr__('About %s', 'weaver-ii'), get_the_author()); ?> </h2> <?php the_author_meta('description'); ?> <div id="author-link"> <a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?> " rel="author"> <?php printf(__('View all posts by %s <span class="meta-nav">→</span>', 'weaver-ii'), get_the_author()); ?> </a> </div><!-- #author-link --> </div><!-- #author-description --> </div><!-- #entry-author-info --> <?php } echo "<div class=\"weaver-clear\"></div>\n"; if ($paged && $ourposts->have_posts()) { global $wp_query; $wp_query = $ourposts; weaverii_content_nav('nav-below'); } $content .= ob_get_clean(); // get the output // get posts $content .= '</div><!-- #wvr-show-posts -->'; if ($clear) { $content .= "<div class=\"weaver-clear\"></div>\n"; } wp_reset_query(); wp_reset_postdata(); $weaverii_cur_post_id = $save_cur_post; weaverii_sc_reset_opts(); // done, clear for other shortcodes return $content; }
function weaveriip_feed_shortcode($args = '') { /* implement [weaver_feed feed='ur'] shortcode */ extract(shortcode_atts(array('feed' => '#', 'show_sitename' => true, 'show_content' => true, 'excerpt' => false, 'trusted' => false, 'title_style' => '', 'items' => 10), $args)); $err_msg = '[weaver_feed] invalid values provided.'; $show_sitename = weaveriip_tf($show_sitename); $show_content = weaveriip_tf($show_content); $excerpt = weaveriip_tf($excerpt); weaverii_sc_reset_opts(); weaverii_sc_setopt('more_msg', '<br />Click Article Title for full article at original site.'); if ($title_style != '') { $title_style = 'style=' . weaveriip_bracket($title_style, '"', '"'); } $ent_title = '<header class="entry-header"><div class="entry-hdr"><h2 class="entry-title" ' . $title_style . '>'; while (stristr($feed, 'http') != $feed) { // strip anything before http $feed = substr($feed, 1); } if (empty($feed)) { return $err_msg; } // self-url destruction sequence if ($feed == site_url() || $feed == home_url()) { return '[weaver_feed] - feed must not be own site.'; } $rss = fetch_feed($feed); $sitedesc = ''; $sitelink = ''; if (!is_wp_error($rss)) { $sitedesc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset')))); $sitetitle = esc_html(strip_tags($rss->get_title())); $sitelink = esc_url(strip_tags($rss->get_permalink())); while (stristr($sitelink, 'http') != $sitelink) { $sitelink = substr($sitelink, 1); } } else { if (is_admin() || current_user_can('edit_theme_options')) { $err_msg = '<p>' . sprintf(__('<strong>RSS Error</strong>: %s', 'weaver-ii'), $rss->get_error_message()) . '</p>'; } return $err_msg; } if (empty($sitetitle)) { $sitetitle = empty($sitedesc) ? __('Unknown Feed', 'weaver-ii') : $sitedesc; } $feed = esc_url(strip_tags($feed)); if ($sitetitle) { $imgurl = apply_filters('weaverii-social-dir', weaverii_relative_url('includes/pro/social/1/')) . 'rss.png'; $sitetitle = '<h2 class="entry-title feed-title">' . '<a href="' . $feed . '" title="' . esc_attr(__('Syndicate this content', 'weaver-ii')) . '" target="_blank"><img src="' . $imgurl . '" height="16" width="16" alt="RSS" /></a> ' . "<a href='{$sitelink}' title='{$sitedesc}' target='_blank'>{$sitetitle}</a></h2>"; } $out = "<div class='weaver-feed'> <!-- *********************************************** -->\n"; if ($show_sitename) { $out .= $sitetitle . "\n"; // add a title for whole feed } $items = (int) $items; if ($items < 1 || 20 < $items) { $items = 10; } if (!$rss->get_item_quantity()) { $out .= '<p>' . __('An error has occurred; the feed is probably down. Try again later.', 'weaver-ii') . '</p></div>'; $rss->__destruct(); unset($rss); return $out; } $rss_items = $rss->get_items(0, $items); // +++++++++++ feed article loop ++++++++++++ foreach ($rss_items as $item) { $out .= '<article class="post type-post hentry category-uncategorized post-feed">' . "\n"; $link = $item->get_link(); while (stristr($link, 'http') != $link) { $link = substr($link, 1); } $link = esc_url(strip_tags($link)); $title = esc_attr(strip_tags($item->get_title())); if (empty($title)) { $title = __('Untitled', 'weaver-ii'); } $desc = @html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset')); if (!$trusted) { $desc = str_replace(array("\n", "\r"), ' ', esc_attr(strip_tags($desc))); } if ($excerpt) { $desc = wp_html_excerpt($desc, 300); // Append ellipsis. Change existing [...] to […]. if ('[...]' == substr($desc, -5)) { $desc = substr($desc, 0, -5) . '[…]'; } elseif ('[…]' != substr($desc, -10)) { $desc .= ' […]'; } } if (!$trusted) { $desc = esc_html($desc); } $date = ''; $date = $item->get_date('U'); if ($date) { $date = date_i18n(get_option('date_format'), $date); } $author = $item->get_author(); if (is_object($author)) { $author = $author->get_name(); $author = esc_html(strip_tags($author)); } else { $author = ''; } if ($link == '') { $link = '#'; } $out .= $ent_title . '<a href="' . $link . '" title="Permalink to ' . $title . '">' . $title . "</a></h2></div>\n"; // now match logic for posted_on $out .= weaveriip_posted_on_code($date, $author) . "</header> <!-- entry-header -->\n"; if ($show_content) { $out .= "<div class='entry-content'>\n" . $desc . "\n</div> <!-- entry-content -->\n"; } $out .= "</article> <!-- post-feed -->\n"; } $out .= "</div> <!-- weaver-feed -->\n"; $rss->__destruct(); unset($rss); weaverii_sc_reset_opts(); return $out; }
function atw_trans_set($opt, $val) { $GLOBALS['aspen_temp_opts'][$opt] = $val; if (function_exists('weaverii_sc_setopt')) { weaverii_sc_setopt($opt, $val); } }