function atw_posts_get_filter_params($filter = '') { if ($filter == '') { $filter = atw_posts_getopt('current_filter'); } $params = ''; $full_opts = array('post_type', 'category_name', 'tag', 'author', 'taxonomy', 'date', 'atw_slider_group', 'wp_query_args'); foreach ($full_opts as $opt) { if (($par = atw_posts_get_filter_opt($opt, $filter)) != '') { $params .= ' ' . esc_textarea($par); } } $val_opts = array('cols', 'excerpt_length', 'more_msg', 'offset', 'order', 'orderby', 'post_ids', 'posts_per_page', 'post_slug', 'show', 'show_sticky_posts', 'no_top_clear'); foreach ($val_opts as $opt) { if (($par = atw_posts_get_filter_opt($opt, $filter)) != '') { if ($opt == 'orderby' && $par == 'date' || $opt == 'order' && $par == 'DESC') { continue; } if ($opt == 'show_sticky_posts') { if ($par) { $params .= ' ' . 'ignore_sticky_posts=0'; } } else { if ($opt == 'more_msg') { $params .= ' ' . $opt . '="' . esc_textarea(addslashes($par)) . '"'; } else { $params .= ' ' . $opt . '=' . esc_textarea($par); } } } } $check_opts = array('hide_bottom_info', 'hide_featured_image', 'hide_title', 'hide_top_info', 'show_avatar', 'use_paging'); foreach ($check_opts as $opt) { if ($par = atw_posts_get_filter_opt($opt, $filter)) { $params .= ' ' . $opt . '=true'; } } return $params; }
function atw_posts_filter_val($id, $desc, $br = '<br />') { ?> <div style = "margin-top:5px;display:inline-block;padding-left:2.5em;text-indent:-1.7em;"><label> <input class="regular-text" type="text" style="width:50px;height:22px;" name="<?php echo $id; ?> " value="<?php echo sanitize_text_field(atw_posts_get_filter_opt($id)); ?> " /> <?php echo $desc . '</label></div>' . $br . "\n"; }
function atw_posts_add_qvalue($qarg, $add) { if ($add == '') { return; } // nothing to add $cur_arg = atw_posts_get_filter_opt($qarg); if ($cur_arg == '') { // first time $val = $qarg . '=' . $add; atw_posts_set_filter_opt($qarg, $val); } else { if (strpos($cur_arg, $qarg . '=') !== 0) { atw_posts_error_msg('Invalid form for query string (' . $qarg . '): ' . $cur_arg . '. Please clear and start over.'); } elseif (strpos($cur_arg, $add) !== false && $add != 'post') { atw_posts_error_msg('Do not add duplicate values to query string: ' . $add . '. Ignored.'); } else { atw_posts_set_filter_opt($qarg, str_replace(' ', '', $cur_arg . ',' . $add)); //atw_posts_save_msg('Filter value field set. Click "Save Filter Options" to save new field value.'); } } }
function atw_posts_set_custom_template() { //<!-- *** Custom Taxonomies *** --> if (!current_user_can('unfiltered_html')) { return; } // don't even show $text = atw_posts_get_filter_opt('post_template'); $rows = 1; if (strlen($text) > 0) { $lines = count(explode(PHP_EOL, $text)); } else { $lines = 0; } if ($lines > 20) { $lines = 18; } if ($lines > 0) { $rows = $lines + 2; } ?> <!-- *** Custom Post *** --> <div class="filter-section"> <div class="filter-title">• Custom Post Template (Advanced Option) <span class="filter-title-description">Define custom template to display posts</span></div> <div class="filter-opts"> <textarea class="filter-text" style="max-width:90%;" cols=100 rows=<?php echo $rows; ?> placeholder="Enter post template" maxlength=2048 name="post_template"><?php echo esc_textarea($text); ?> </textarea></td></tr></table> </div> <div class="filter-description"> <em>This option is intended for advanced users.</em> You can define a completely custom template to display posts. You must read the help file for an explanation of this option. </div> </div> <?php }
function atw_show_content($slider, $filter = '') { $cur_post_id = get_the_ID(); /* We have to do our own sticky processing because WP is_sticky() will not work because we are in our own WP_Query, * and will thus never be on the home page which is one of the tests in the core is_sticky() */ $sticky = is_sticky($cur_post_id); do_action('atw_show_sliders_post_pager', $slider); $saved_the_content_filter_key = atw_save_the_content_filters(); if (!atw_posts_getopt('ignore_aspen_weaver') && (atw_posts_is_wvrx() || atw_posts_is_aspen() || atw_posts_is_wii()) || atw_posts_getopt('use_native_theme_templates') && atw_posts_theme_has_templates()) { if ($sticky) { echo '<div class="sticky">'; } if (atw_posts_is_wvrx()) { get_template_part('templates/content', get_post_format()); } else { if (function_exists('twentysixteen_setup')) { // custom support for twentysixteen get_template_part('template-parts/content', get_post_format()); } else { get_template_part('content', get_post_format()); } } if ($sticky) { echo '</div>'; } echo "<div style='clear:both;'></div>\n"; atw_restore_the_content_filters($saved_the_content_filter_key); return; } if (WEAVER_SHOWPOSTS_TEMPLATE) { $template = atw_posts_get_filter_opt('post_template', $filter); if ($template != '') { atw_posts_do_template($slider, $template); atw_restore_the_content_filters($saved_the_content_filter_key); return; } } $add_class = 'atw-post'; if ($sticky) { $add_class .= ' sticky'; } ?> <article id="post-<?php the_ID(); ?> " <?php post_class($add_class); ?> > <header class="atw-entry-header"> <?php if (!atw_trans_get('hide_title')) { // ========== TITLE ?> <hgroup class="atw-entry-hdr"><h2 class="atw-entry-title"> <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> </h2></hgroup> <?php } if (!atw_trans_get('hide_top_info')) { // ============ TOP META ?> <div class="atw-entry-meta"> <div class="atw-entry-meta-icons"> <?php printf(__('<span class="entry-date"><a href="%1$s" title="%2$s" rel="bookmark"><time datetime="%3$s" pubdate>%4$s</time></a></span> <span class="by-author"><span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'show-posts'), esc_url(get_permalink()), esc_attr(get_the_time()), esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_url(get_author_posts_url(get_the_author_meta('ID'))), sprintf(esc_attr(__('View all posts by %s', 'show-posts')), get_the_author()), esc_html(get_the_author())); if (atw_trans_get('show_avatar') != '' && atw_trans_get('show_avatar') != 'no') { echo ' ' . get_avatar(get_the_author_meta('user_email'), 22, null, 'avatar'); } ?> </div><!-- .atw-entry-meta-icons --> </div><!-- .atw-entry-meta --> <?php } ?> </header><!-- .atw-entry-header --> <?php if (atw_trans_get('show') == 'title') { echo '</article><!-- #post-' . get_the_ID() . '-->'; atw_restore_the_content_filters($saved_the_content_filter_key); return; } if (atw_trans_get('show') == 'title_featured') { if (get_post_thumbnail_id()) { $image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); // (url, width, height) $href = $image[0]; ?> <p class='atw-featured-image'><a href="<?php echo $href; ?> "><?php esc_url(the_post_thumbnail('thumbnail')); ?> </a></p> <?php } echo '</article><!-- #post-' . get_the_ID() . '-->'; atw_restore_the_content_filters($saved_the_content_filter_key); return; } if (atw_trans_get('show') == 'excerpt') { // =================== EXCERPT ?> <div class="atw-entry-summary atw-cf"> <?php atw_show_post_content($slider); ?> </div><!-- .atw-entry-summary --> <?php } else { // ================== FULL CONTENT ?> <div class="atw-entry-content atw-cf"> <?php atw_show_post_content($slider); ?> </div><!-- .atw-entry-content --> <?php } if (!atw_trans_get('hide_bottom_info')) { // ================= BOTTOM META ?> <footer class="atw-entry-utility"> <div class="atw-entry-meta-icons"> <?php $categories_list = get_the_category_list(__(', ', 'show-posts')); if ($categories_list) { ?> <span class="cat-links"> <?php echo $categories_list; ?> </span> <?php } // End if categories $tags_list = get_the_tag_list('', __(', ', 'show-posts')); if ($tags_list) { ?> <span class="tag-links"> <?php echo $tags_list; ?> </span> <?php } // End if $tags_list if (comments_open()) { ?> <span class="comments-link"> <?php comments_popup_link(__('Leave a reply', 'show-posts'), __('<b>1</b> Reply', 'show-posts'), __('<b>%</b> Replies', 'show-posts'), 'leave-reply'); ?> </span><div style="clear:both;"></div> <?php } // End if comments_open() ?> </div><!-- .entry-meta-icons --> </footer><!-- .atw-entry-utility --> <?php } edit_post_link(__('Edit', 'show-posts'), '<span class="atw-edit-link">', '</span>'); ?> </article><!-- #post-<?php the_ID(); ?> --> <?php atw_restore_the_content_filters($saved_the_content_filter_key); }