} else {
        weaverx_edit_link();
    }
}
//weaverx_edit_link();
echo "\n<!-- PwP: End Page content -->\n";
$top_of_pwp = ob_get_clean();
// now get the top sidebar, etc.
// Now, the posts
global $wp_query;
$old_query = $wp_query;
$args = array('ignore_sticky_posts' => false, 'orderby' => 'date', 'order' => 'DESC', 'paged' => $paged);
$filter = weaverx_get_per_page_value('_pp_post_filter');
// ATW Show Posts filter
if (function_exists('atw_showposts_installed') && $filter != '') {
    $params = atw_posts_get_filter_params($filter);
    if ($params != '') {
        // they specified a $filter arg, so use it and wipe out anything else...
        $fargs = shortcode_parse_atts($params);
    } else {
        $fargs = '';
    }
    $qargs = atw_posts_get_qargs($fargs, array());
    $wp_query = new WP_Query(apply_filters('weaverx_pwp_wp_query', $qargs));
    // reuse $wp_query to make paging work
} else {
    $args = weaverx_setup_post_args($args);
    // setup custom fields for this page
    $wp_query = new WP_Query(apply_filters('weaverx_pwp_wp_query', $args));
    // reuse $wp_query to make paging work
}
function atw_posts_showposts_admin()
{
    // admin for style options...
    ?>
   <h2 style="color:blue;">Weaver Show Posts</h2>
    <form method="post" enctype="multipart/form-data">
        <input type="hidden" name="atw_posts_save_showposts_opts" value="Show Posts Options Saved" />
<?php 
    atw_posts_nonce_field('atw_posts_save_showposts_opts');
    ?>
<label><span style="color:blue;font-weight:bold; font-size: larger;"><b>Show Posts - [show_posts filter=filter-name]</b></span></label>
<br />
<p>
    The Weaver <code>[show_posts]</code> shortcode allows you to display posts on your pages or in a text widget
    in the sidebar. You can specify a large number of filtering options to select a specific set of posts to show.
</p>

<p>
    The recommended way to display posts is to specify all the filter selection options on the <em>Filter</em> tab, and use the
    <strong>[show_posts filter=filter-name]</strong> form of the shortcode. You can also specify the options manually.
</p>
<p><span style="font-size:120%;font-weight:bold;">Shortcodes, using current <em>Filter</em> settings:</span> - You can Copy/Paste these.
<table>
    <tr><td>Shortcode using filter name:&nbsp;&nbsp;</td><td><strong>[show_posts filter=<?php 
    echo atw_posts_getopt('current_filter');
    ?>
]</strong>
    &nbsp;&nbsp;- You can also use the "Add [show_posts]" button on the Page/Post Editor.</td></tr>
    <tr><td>Shortcode using parameters:&nbsp;&nbsp; </td><td><strong>[show_posts
<?php 
    $params = atw_posts_get_filter_params();
    // define in atw-runtime-lib.php
    echo $params;
    ?>
]</strong></td></tr></table>
</p>

<p>
<h3>Summary of all parameters for [show_posts] shortcode, shown with default values:</h3>
<table style="padding-left:25px;">
    <tr><td>cols=1</td><td>display posts in 1 to 3 columns</td></tr>
    <tr><td>filter=''</td><td>use named filter - all other parameters ignored when filter specified </td></tr>
    <tr><td>hide_bottom_info=false</td><td>hide bottom info line </td></tr>
    <tr><td>hide_featured_image=false</td><td>hide featured image - FI is displayed by default </td></tr>
    <tr><td>hide_title=false</td><td>hide the title </td></tr>
    <tr><td>hide_top_info=false</td><td>hide the top info line </td></tr>
    <tr><td>show=full</td><td>show: title | excerpt | full | titlelist | title_featured </td></tr>
    <tr><td>show_avatar=false</td><td>show the author avatar </td></tr>
    <tr><td>more_msg="New More Message"&nbsp;&nbsp;</td><td>replacement for Continue Reading excerpt message </td></tr>
    <tr><td>use_paging=false</td><td>Use paging when displaying multiple posts </td></tr>
	<tr><td>no_top_clear=false</td><td>Prevents "clear:both" at beginning of posts display.</td></tr>
    <tr><td>category_name=list</td><td>list of categories by slug</td></tr>
    <tr><td>post_ids</td><td>list of posts by IDs</td></tr>
    <tr><td>post_slug</td><td>single post by specified post slug name</td></tr>
    <tr><td>WP_Query args</td><td>Any standard <a href="http://codex.wordpress.org/Class_Reference/WP_Query" alt="WP_Query Codex Entry" target="_blank">WP_Query</a> argument (not including those needing array()).
    <br />
    Using these options directly requires fairly advanced technical understanding, and is intended for advanced users.
    </td></tr>
</table>
<br />

You don't need to supply every option when you add the <code>[show_posts]</code> to your own content.
You can wrap the parameter values with double or single quotation marks if you want, but they aren't needed
unless the value has a space (e.g., the more_msg example).</p>

<hr />
<p style = "display:inline;padding-left:2.5em;text-indent:-1.7em;"><label><input type="checkbox" name='textWidgetShortcodes' id='textWidgetShortcodes'
        <?php 
    checked(atw_posts_getopt('textWidgetShortcodes'));
    ?>
 >&nbsp;
        Enable [shortcode] support for the Text Widget. Some themes and plugins already support this, but this allows you
        to add [show_posts] or [show_slider] directly into the standard Text Widget.</label></p>
<br />
<br />

<?php 
    atw_posts_save_showposts_button();
    ?>
    </form>
<?php 
}
function atw_posts_select_filter()
{
    $current_filter = atw_posts_getopt('current_filter');
    ?>

<h3><u>Select Filter</u></h3>


<!-- ** Current Filter ** -->

<div class="filter-section">
    <div class="filter-title">&bull; Current Filter: <em style="font-size:150%;color:#CC2323;"><?php 
    echo atw_posts_get_filter_opt('name');
    ?>
</em>
    <span class="filter-title-description">Select a filter to define or edit </span></div>
<?php 
    $filters = atw_posts_getopt('filters');
    $cur_slug = '';
    $cur_name = '';
    echo '<table><tr><td><strong>Select Filter: </strong></td><td><select name="selected_filter" onchange="this.form.submit()">';
    foreach ($filters as $filter => $val) {
        // display dropdown of available filters
        if ($filter == $current_filter) {
            $cur_slug = $filter;
            $cur_name = $val['name'];
            echo '<option value="' . $filter . '" selected="selected">' . $val['name'] . ' (' . $filter . ')</option>';
        } else {
            echo '<option value="' . $filter . '">' . $val['name'] . ' (' . $filter . ')</option>';
        }
    }
    echo '</select>';
    ?>

    &nbsp;&nbsp;&larr; <input class="button" type="submit" onclick="return confirm('This will clear all current filter settings. The filter will also be deleted unless it is the Default filter. Are you sure?')"
                           name="atw_posts_delete_filter" value="Clear/Delete Current Filter"/></td></tr>
    <tr><td>&nbsp;</td><td><span style="padding-left:20px;"></span></span><textarea cols=32 rows=1 placeholder="Enter name for new/duplicate filter" maxlength=64 name="filter_name"></textarea>
    &nbsp;&nbsp;&larr;&nbsp;<input class="button" type="submit" name="atw_posts_new_filter" value="Create New Filter"/>
	<em>-or-</em> <input class="button" type="submit" name="atw_posts_duplicate_filter" value="Duplicate Current Filter"/></td></tr></table>
<?php 
    $time = date('Y-m-d-Hi');
    echo "<div style='margin-top:6px;'>\n";
    atw_posts_download_link('<strong>Save Settings</strong> for current filter <strong>' . $cur_name . '</strong>.', $cur_slug, 'filter', $time);
    ?>
</div>
	<input style="margin-left:8em;" class="download-link" type="submit" name="atw_posts_restore_filter" value="Restore Filter" />
	<span style="border:1px solid #CCC;width:400px;padding:2px;"><input name="post_uploaded" type="file" /></span>
	<input type="hidden" name="uploadit" value="yes" />- Upload file to restore a filter
<br /><br />
    <div style="clear:both;"></div>
    <div class="filter-title">&bull; Native Theme Support <span class="filter-title-description">Interaction with native theme. Options apply to all filters, but not to image sliders.</span></div>
    <div class="filter-opts">

<?php 
    $native = false;
    if (!atw_posts_is_generic()) {
        atw_posts_form_checkbox('ignore_aspen_weaver', 'Disable automatic post display integration with Weaver II/Weaver Xtreme Themes.');
        $native = true;
    }
    $has_templates = atw_posts_theme_has_templates();
    if ($has_templates) {
        atw_posts_form_checkbox('use_native_theme_templates', "<strong>Use Current Theme's Native Post Display</strong> - Native post display capability detected.\n            You will need to try this option to see if it works or properly or not.<br />");
        $native = true;
    }
    if (!$native) {
        ?>
           <span style="display:inline;padding-left:2.5em;text-indent:-1.7em;"></span>
        <em>Sorry, your theme does not seem to have native support for displaying posts from this plugin.</em> You
        can add custom CSS rules on the "Style" tab to make posts better match your current theme.<br /><br />
<?php 
    }
    ?>
    </div>


    <div class="filter-title">&bull; [show_posts] Shortcode
    <span class="filter-title-description">Copy/Paste either of these shortcodes to display posts in your content</span></div>

<table>
    <tr><td>Shortcode using filter name:&nbsp;&nbsp;</td><td><strong>[show_posts filter=<?php 
    echo $current_filter;
    ?>
]</strong>
    &nbsp;&nbsp;- You can also use the "Add [show_posts]" button on the Page/Post Editor.</td></tr>
    <tr><td>Shortcode using parameters:&nbsp;&nbsp; </td><td><strong>[show_posts
<?php 
    $params = atw_posts_get_filter_params();
    // define in atw-runtime-lib.php
    echo $params;
    ?>
]</strong></td></tr></table>
</div>

<?php 
    atw_posts_nonce_field('atw_posts_set_to_filter');
    atw_posts_nonce_field('atw_posts_delete_filter');
    atw_posts_nonce_field('atw_posts_new_filter');
    atw_posts_nonce_field('atw_posts_duplicate_filter');
    atw_posts_nonce_field('atw_posts_restore_filter');
}
function atw_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;}
    */
    $opts = array('cols' => '1', 'excerpt_length' => '', 'hide_bottom_info' => '', 'hide_featured_image' => '', 'hide_title' => '', 'hide_top_info' => '', 'show' => '', 'show_avatar' => false, 'more_msg' => '', 'use_paging' => false, 'no_top_clear' => false);
    $slider = '';
    $filter = '';
    if (isset($args['slider'])) {
        $slider = $args['slider'];
        unset($args['slider']);
        if (!function_exists('atw_slider_installed')) {
            return '<strong>ERROR with [show_posts slider="' . $slider . '"]: Weaver Slider Plugin not installed.</strong>';
        }
        if ($slider == '' || atw_posts_get_slider_opt('name', $slider) == '') {
            return '<strong>ERROR with [show_posts slider="' . $slider . '"]: You must specify a valid slider name.</strong>';
        }
        $filter = atw_posts_get_slider_opt('selected_slider_filter', $slider);
        if ($filter == '') {
            $filter = 'default';
        }
        if (atw_posts_get_filter_opt('slug', $filter) != $filter) {
            return '<strong>ERROR with [show_posts slider="' . $slider . '"]: Filter (' . $filter . ') is not a defined filter.</strong>';
        }
        $params = atw_posts_get_filter_params($filter);
        if ($params != '') {
            // they specified a $filter via slider, so wipe out everything else
            unset($args);
            $args = shortcode_parse_atts($params);
            $args['use_paging'] = false;
            // use_paging breaks sliders
        } else {
            $filter = '';
        }
    } else {
        if (isset($args['filter'])) {
            $filter = $args['filter'];
            $params = atw_posts_get_filter_params($filter);
            if ($params != '') {
                // they specified a $filter arg, so use it and wipe out anything else...
                unset($args);
                $args = shortcode_parse_atts($params);
            } else {
                $filter = '';
            }
        }
    }
    $qargs = atw_posts_get_qargs($args, $opts);
    extract(shortcode_atts($opts, $args));
    // setup local vars
    if ($show == 'titlelist' && $slider) {
        $show = 'title';
    }
    // cheap fix...
    // set transient opts for these options
    atw_trans_set('showposts', true);
    // global to see if we are in this function
    atw_trans_set('show', $show);
    // this will always be set - but '' (blank) implies 'full' for built-in, but not Weaver/Aspen settings for them
    if ($hide_title != '') {
        atw_trans_set('hide_title', true);
    }
    if ($hide_top_info != '') {
        atw_trans_set('hide_top_info', true);
    }
    if ($hide_bottom_info != '') {
        atw_trans_set('hide_bottom_info', true);
    }
    if ($hide_featured_image != '') {
        atw_trans_set('hide_featured_image', true);
    }
    if (isset($args['show_avatar'])) {
        // need this weirdness for Aspen/Weaver compatibility (not set means use global setting)
        if ($show_avatar) {
            atw_trans_set('show_avatar', true);
        } else {
            atw_trans_set('show_avatar', 'no');
        }
    }
    if ($more_msg != '') {
        atw_trans_set('more_msg', $more_msg);
    }
    $ourposts = new WP_Query(apply_filters('atw_show_posts_wp_query', $qargs, $args));
    /* now start the content */
    $class = '';
    if ($filter != '') {
        $class = ' atw-show-posts-filter-' . $filter;
    }
    $content = '';
    $tail = '';
    if ($slider == '') {
        $content = '';
        if (!$no_top_clear) {
            $content = '<div style="clear:both;"></div>';
        }
        $content .= '<div class="atw-show-posts' . $class . '">';
        $tail = "</div><!-- show_posts -->\n";
    }
    ob_start();
    if ($slider && function_exists('atw_slider_installed') && atw_posts_get_slider_opt('content_type', $slider) == 'images') {
        atw_slider_do_gallery($ourposts, $slider);
        // reset stuff
        wp_reset_query();
        wp_reset_postdata();
        atw_trans_clear_all();
        $content .= ob_get_clean();
        // get the output
        return $content;
    }
    $slide_li_begin = '';
    $slide_li_end = '';
    if ($slider) {
        $style = '';
        $slide_li_begin = '<div class="atwk-slide"><div class="slide-content slide-post"' . $style . '>' . "\n";
        $slide_li_end = "\n</div></div><!-- slide-content slide-post -->\n";
    }
    // add excerpt filter here
    if ($excerpt_length != '') {
        $GLOBALS['atw_show_posts_excerpt_length'] = $excerpt_length;
        add_filter('excerpt_length', 'atw_posts_excerpt_length_filter', 20);
        // user our excerpt filter early to override others
    }
    if ($show == 'titlelist') {
        echo '<ul>';
    }
    $posts_out = 0;
    $col = 0;
    if (!$ourposts->have_posts()) {
        echo __('No posts found.', 'atw_showposts');
    }
    if (WEAVER_SHOWPOSTS_TEMPLATE && atw_posts_get_filter_opt('post_template', $filter)) {
        require_once dirname(__FILE__) . '/atw-posts-template.php';
    }
    // NOW - load the template code
    while ($ourposts->have_posts()) {
        $ourposts->the_post();
        $posts_out++;
        echo $slide_li_begin;
        // aspen_per_post_style();
        if ($show == 'titlelist') {
            ?>
            <li><a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            printf(esc_attr(__('Permalink to %s', 'show-posts')), the_title_attribute('echo=0'));
            ?>
" rel="bookmark"><?php 
            the_title();
            ?>
</a></li>
    <?php 
        } else {
            switch ($cols) {
                case 2:
                    $col++;
                    $style = '';
                    if ($col % 2 == 1) {
                        // force stuff to be even
                        $style = ' style="clear:left;"';
                    }
                    echo '<div class="atw-content-2-col atw-cf"' . $style . '>' . "\n";
                    atw_show_content($slider, $filter);
                    echo "</div> <!-- atw-content-2-col -->\n";
                    break;
                case 3:
                    $col++;
                    $style = '';
                    if ($col % 3 == 1) {
                        // force stuff to be even
                        $style = ' style="clear:left;"';
                    }
                    echo '<div class="atw-content-3-col atw-cf"' . $style . '>' . "\n";
                    atw_show_content($slider, $filter);
                    echo "</div> <!-- atw-content-3-col -->\n";
                    break;
                case 1:
                default:
                    atw_show_content($slider, $filter);
                    break;
            }
            // end switch $cols
        }
        echo $slide_li_end;
    }
    // end loop
    if ($show == 'titlelist') {
        echo "</ul>\n";
    }
    // unhook excerpt filter here
    if ($excerpt_length != '') {
        unset($GLOBALS['atw_show_posts_excerpt_length']);
        remove_filter('excerpt_length', 'atw_posts_excerpt_length_filter', 20);
        // user our excerpt filter early to override others
    }
    if ($use_paging) {
        if (!$no_top_clear) {
            echo '<div style="clear:both;"></div>';
        }
        ?>
    <div id="atw-show-posts-navigation" class="atw-post-nav">
<?php 
        $big = 999999;
        echo paginate_links(array('base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, $qargs['paged']), 'total' => $ourposts->max_num_pages));
        ?>
    </div>
<?php 
    }
    $content .= ob_get_clean();
    // get the output
    // get posts
    $content .= $tail;
    // reset stuff
    wp_reset_query();
    wp_reset_postdata();
    atw_trans_clear_all();
    return $content;
}