| 1 | <?php |
|---|
| 2 | // ====================================== >>> atw_show_posts_shortcode <<< ====================================== |
|---|
| 3 | |
|---|
| 4 | function atw_show_posts_shortcode( $args = '' ) { |
|---|
| 5 | /* implement [weaver_show_posts] */ |
|---|
| 6 | |
|---|
| 7 | /* DOC NOTES: |
|---|
| 8 | CSS styling: The group of posts will be wrapped with a <div> with a class called |
|---|
| 9 | .wvr-show-posts. You can add an additional class to that by providing a 'class=classname' option |
|---|
| 10 | (without the leading '.' used in the actual CSS definition). You can also provide inline styling |
|---|
| 11 | by providing a 'style=value' option where value is whatever styling you need, each terminated |
|---|
| 12 | with a semi-colon (;). |
|---|
| 13 | |
|---|
| 14 | The optional header is in a <div> called .wvr_show_posts_header. You can add an additional class |
|---|
| 15 | name with 'header_class=classname'. You can provide inline styling with 'header_style=value'. |
|---|
| 16 | |
|---|
| 17 | .wvr-show-posts .hentry {margin-top: 0px; margin-right: 0px; margin-bottom: 40px; margin-left: 0px;} |
|---|
| 18 | .widget-area .wvr-show-posts .hentry {margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;} |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | $opts = array( |
|---|
| 22 | /* formatting options */ |
|---|
| 23 | 'cols' => '1', // display posts in 1 to 3 columns |
|---|
| 24 | 'excerpt_length' => '', // excerpt length |
|---|
| 25 | 'hide_bottom_info' => '', // hide bottom info line |
|---|
| 26 | 'hide_featured_image' => '', // hide featured image - FI is displayed by default |
|---|
| 27 | 'hide_title' => '', // hide the title? |
|---|
| 28 | 'hide_top_info' => '', // hide the top info line |
|---|
| 29 | 'show' => '', // show: title | excerpt | full | titlelist | title_featured |
|---|
| 30 | 'show_avatar' => false, // show the author avatar |
|---|
| 31 | 'more_msg' => '', // replacement for Continue Reading excerpt message |
|---|
| 32 | 'use_paging' => false, // Use paging when displaying multiple posts |
|---|
| 33 | 'no_top_clear' => false // prevent emitting clear:both |
|---|
| 34 | ); |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | $slider = ''; |
|---|
| 38 | $filter = ''; |
|---|
| 39 | if ( isset( $args['slider'] ) ) { |
|---|
| 40 | $slider = $args['slider']; |
|---|
| 41 | unset( $args['slider'] ); |
|---|
| 42 | |
|---|
| 43 | if ( ! function_exists( 'atw_slider_installed' ) ) { |
|---|
| 44 | return '<strong>ERROR with [show_posts slider="' . $slider . '"]: Weaver Slider Plugin not installed.</strong>'; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | if ( $slider == '' || atw_posts_get_slider_opt( 'name', $slider ) == '' ) { |
|---|
| 48 | return '<strong>ERROR with [show_posts slider="' . $slider . '"]: You must specify a valid slider name.</strong>'; |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | $filter = atw_posts_get_slider_opt( 'selected_slider_filter', $slider ); |
|---|
| 52 | if ( $filter == '' ) { |
|---|
| 53 | $filter = 'default'; |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | if ( atw_posts_get_filter_opt( 'slug', $filter ) != $filter ) { |
|---|
| 57 | return '<strong>ERROR with [show_posts slider="' . $slider . '"]: Filter (' . $filter . ') is not a defined filter.</strong>'; |
|---|
| 58 | } |
|---|
| 59 | $params = atw_posts_get_filter_params( $filter ); |
|---|
| 60 | if ( $params != '' ) { // they specified a $filter via slider, so wipe out everything else |
|---|
| 61 | unset( $args ); |
|---|
| 62 | $args = shortcode_parse_atts( $params ); |
|---|
| 63 | $args['use_paging'] = false; // use_paging breaks sliders |
|---|
| 64 | } else { |
|---|
| 65 | $filter = ''; |
|---|
| 66 | } |
|---|
| 67 | } elseif ( isset( $args['filter'] ) ) { |
|---|
| 68 | $filter = $args['filter']; |
|---|
| 69 | $params = atw_posts_get_filter_params( $filter ); |
|---|
| 70 | if ( $params != '' ) { // they specified a $filter arg, so use it and wipe out anything else... |
|---|
| 71 | unset( $args ); |
|---|
| 72 | $args = shortcode_parse_atts( $params ); |
|---|
| 73 | } else { |
|---|
| 74 | $filter = ''; |
|---|
| 75 | } |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | $qargs = atw_posts_get_qargs( $args, $opts ); |
|---|
| 80 | |
|---|
| 81 | extract( shortcode_atts( $opts, $args ) ); // setup local vars |
|---|
| 82 | |
|---|
| 83 | if ( $show == 'titlelist' && $slider ) { |
|---|
| 84 | $show = 'title'; |
|---|
| 85 | } // cheap fix... |
|---|
| 86 | |
|---|
| 87 | // set transient opts for these options |
|---|
| 88 | |
|---|
| 89 | atw_trans_set( 'showposts', true ); // global to see if we are in this function |
|---|
| 90 | |
|---|
| 91 | atw_trans_set( 'show', $show ); // this will always be set - but '' (blank) implies 'full' for built-in, but not Weaver/Aspen settings for them |
|---|
| 92 | |
|---|
| 93 | if ( $hide_title != '' ) { |
|---|
| 94 | atw_trans_set( 'hide_title', true ); |
|---|
| 95 | } |
|---|
| 96 | if ( $hide_top_info != '' ) { |
|---|
| 97 | atw_trans_set( 'hide_top_info', true ); |
|---|
| 98 | } |
|---|
| 99 | if ( $hide_bottom_info != '' ) { |
|---|
| 100 | atw_trans_set( 'hide_bottom_info', true ); |
|---|
| 101 | } |
|---|
| 102 | if ( $hide_featured_image != '' ) { |
|---|
| 103 | atw_trans_set( 'hide_featured_image', true ); |
|---|
| 104 | } |
|---|
| 105 | if ( isset( $args['show_avatar'] ) ) { // need this weirdness for Aspen/Weaver compatibility (not set means use global setting) |
|---|
| 106 | if ( $show_avatar ) { |
|---|
| 107 | atw_trans_set( 'show_avatar', true ); |
|---|
| 108 | } else { |
|---|
| 109 | atw_trans_set( 'show_avatar', 'no' ); |
|---|
| 110 | } |
|---|
| 111 | } |
|---|
| 112 | if ( $more_msg != '' ) { |
|---|
| 113 | atw_trans_set( 'more_msg', $more_msg ); |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | $ourposts = new WP_Query( apply_filters( 'atw_show_posts_wp_query', $qargs, $args ) ); |
|---|
| 118 | |
|---|
| 119 | /* now start the content */ |
|---|
| 120 | $class = ''; |
|---|
| 121 | if ( $filter != '' ) { |
|---|
| 122 | $class = ' atw-show-posts-filter-' . $filter; |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | $content = ''; |
|---|
| 126 | $tail = ''; |
|---|
| 127 | |
|---|
| 128 | if ( $slider == '' ) { |
|---|
| 129 | $content = ''; |
|---|
| 130 | if ( ! $no_top_clear ) { |
|---|
| 131 | $content = '<div style="clear:both;"></div>'; |
|---|
| 132 | } |
|---|
| 133 | $content .= '<div class="atw-show-posts' . $class . '">'; |
|---|
| 134 | $tail = "</div><!-- show_posts -->\n"; |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | ob_start(); |
|---|
| 138 | |
|---|
| 139 | if ( $slider && function_exists( 'atw_slider_installed' ) && atw_posts_get_slider_opt( 'content_type', $slider ) == 'images' ) { |
|---|
| 140 | atw_slider_do_gallery( $ourposts, $slider ); |
|---|
| 141 | // reset stuff |
|---|
| 142 | wp_reset_query(); |
|---|
| 143 | wp_reset_postdata(); |
|---|
| 144 | atw_trans_clear_all(); |
|---|
| 145 | $content .= ob_get_clean(); // get the output |
|---|
| 146 | |
|---|
| 147 | return $content; |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | $slide_li_begin = ''; |
|---|
| 151 | $slide_li_end = ''; |
|---|
| 152 | |
|---|
| 153 | if ( $slider ) { |
|---|
| 154 | $style = ''; |
|---|
| 155 | |
|---|
| 156 | $slide_li_begin = '<div class="atwk-slide"><div class="slide-content slide-post"' . $style . '>' . "\n"; |
|---|
| 157 | $slide_li_end = "\n</div></div><!-- slide-content slide-post -->\n"; |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | // add excerpt filter here |
|---|
| 161 | if ( $excerpt_length != '' ) { |
|---|
| 162 | $GLOBALS['atw_show_posts_excerpt_length'] = $excerpt_length; |
|---|
| 163 | add_filter( 'excerpt_length', 'atw_posts_excerpt_length_filter', 20 ); // user our excerpt filter early to override others |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | |
|---|
| 167 | if ( $show == 'titlelist' ) { |
|---|
| 168 | echo '<ul>'; |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | $posts_out = 0; |
|---|
| 172 | $col = 0; |
|---|
| 173 | if ( ! $ourposts->have_posts() ) { |
|---|
| 174 | echo apply_filters( 'wvr_show_posts_no_posts', __( 'No posts found.', 'atw_showposts' )); |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | if ( WEAVER_SHOWPOSTS_TEMPLATE && atw_posts_get_filter_opt( 'post_template', $filter ) ) { |
|---|
| 178 | require_once( dirname( __FILE__ ) . '/atw-posts-template.php' ); |
|---|
| 179 | } // NOW - load the template code |
|---|
| 180 | |
|---|
| 181 | while ( $ourposts->have_posts() ) { |
|---|
| 182 | $ourposts->the_post(); |
|---|
| 183 | $posts_out ++; |
|---|
| 184 | |
|---|
| 185 | echo $slide_li_begin; |
|---|
| 186 | |
|---|
| 187 | // aspen_per_post_style(); |
|---|
| 188 | if ( $show == 'titlelist' ) { |
|---|
| 189 | ?> |
|---|
| 190 | <li><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr( __( 'Permalink to %s', 'show-posts' ) ), |
|---|
| 191 | the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></li> |
|---|
| 192 | <?php |
|---|
| 193 | } else { |
|---|
| 194 | switch ( $cols ) { |
|---|
| 195 | case 2: |
|---|
| 196 | $col++; |
|---|
| 197 | $style = ''; |
|---|
| 198 | if ( ( $col % 2 ) == 1 ) { // force stuff to be even |
|---|
| 199 | $style = ' style="clear:left;"'; |
|---|
| 200 | } |
|---|
| 201 | echo( '<div class="atw-content-2-col atw-cf"' . $style . '>' . "\n" ); |
|---|
| 202 | atw_show_content( $slider, $filter ); |
|---|
| 203 | echo( "</div> <!-- atw-content-2-col -->\n" ); |
|---|
| 204 | |
|---|
| 205 | break; |
|---|
| 206 | case 3: |
|---|
| 207 | $col++; |
|---|
| 208 | $style = ''; |
|---|
| 209 | if ( ( $col % 3 ) == 1 ) { // force stuff to be even |
|---|
| 210 | $style = ' style="clear:left;"'; |
|---|
| 211 | } |
|---|
| 212 | echo( '<div class="atw-content-3-col atw-cf"' . $style . '>' . "\n" ); |
|---|
| 213 | atw_show_content( $slider, $filter ); |
|---|
| 214 | echo( "</div> <!-- atw-content-3-col -->\n" ); |
|---|
| 215 | |
|---|
| 216 | break; |
|---|
| 217 | case 1: |
|---|
| 218 | default: |
|---|
| 219 | atw_show_content( $slider, $filter ); |
|---|
| 220 | break; |
|---|
| 221 | } // end switch $cols |
|---|
| 222 | } |
|---|
| 223 | |
|---|
| 224 | echo $slide_li_end; |
|---|
| 225 | |
|---|
| 226 | } // end loop |
|---|
| 227 | if ( $show == 'titlelist' ) { |
|---|
| 228 | echo "</ul>\n"; |
|---|
| 229 | } |
|---|
| 230 | |
|---|
| 231 | // unhook excerpt filter here |
|---|
| 232 | if ( $excerpt_length != '' ) { |
|---|
| 233 | unset( $GLOBALS['atw_show_posts_excerpt_length'] ); |
|---|
| 234 | remove_filter( 'excerpt_length', 'atw_posts_excerpt_length_filter', 20 ); // user our excerpt filter early to override others |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | if ( $use_paging ) { |
|---|
| 238 | if ( ! $no_top_clear ) { |
|---|
| 239 | echo '<div style="clear:both;"></div>'; |
|---|
| 240 | } |
|---|
| 241 | |
|---|
| 242 | ?> |
|---|
| 243 | <div id="atw-show-posts-navigation" class="atw-post-nav"> |
|---|
| 244 | <?php |
|---|
| 245 | $big = 999999; |
|---|
| 246 | echo paginate_links( array( |
|---|
| 247 | 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|---|
| 248 | 'format' => '?paged=%#%', |
|---|
| 249 | 'current' => max( 1, $qargs['paged'] ), |
|---|
| 250 | 'total' => $ourposts->max_num_pages, |
|---|
| 251 | ) ); |
|---|
| 252 | ?> |
|---|
| 253 | </div> |
|---|
| 254 | <?php |
|---|
| 255 | } |
|---|
| 256 | $content .= ob_get_clean(); // get the output |
|---|
| 257 | |
|---|
| 258 | // get posts |
|---|
| 259 | |
|---|
| 260 | $content .= $tail; |
|---|
| 261 | |
|---|
| 262 | |
|---|
| 263 | // reset stuff |
|---|
| 264 | wp_reset_query(); |
|---|
| 265 | wp_reset_postdata(); |
|---|
| 266 | atw_trans_clear_all(); |
|---|
| 267 | |
|---|
| 268 | return $content; |
|---|
| 269 | } |
|---|
| 270 | |
|---|
| 271 | // =================================== >>> atw_posts_excerpt_length_filter <<< ========================= |
|---|
| 272 | |
|---|
| 273 | function atw_posts_excerpt_length_filter( $length ) { |
|---|
| 274 | $val = $GLOBALS['atw_show_posts_excerpt_length']; |
|---|
| 275 | if ( $val > 0 || $val === '0' ) { |
|---|
| 276 | return $val; |
|---|
| 277 | } |
|---|
| 278 | if ( $length != 0 ) { |
|---|
| 279 | return $length; |
|---|
| 280 | } else { |
|---|
| 281 | return 40; |
|---|
| 282 | } |
|---|
| 283 | } |
|---|
| 284 | |
|---|
| 285 | // ====================================== >>> atw_show_content <<< ====================================== |
|---|
| 286 | |
|---|
| 287 | function atw_show_content( $slider, $filter = '' ) { |
|---|
| 288 | |
|---|
| 289 | $cur_post_id = get_the_ID(); |
|---|
| 290 | |
|---|
| 291 | /* We have to do our own sticky processing because WP is_sticky() will not work because we are in our own WP_Query, |
|---|
| 292 | * and will thus never be on the home page which is one of the tests in the core is_sticky() |
|---|
| 293 | */ |
|---|
| 294 | |
|---|
| 295 | $sticky = is_sticky( $cur_post_id ); |
|---|
| 296 | |
|---|
| 297 | do_action( 'atw_show_sliders_post_pager', $slider ); |
|---|
| 298 | |
|---|
| 299 | $saved_the_content_filter_key = atw_save_the_content_filters(); |
|---|
| 300 | |
|---|
| 301 | if ( ( ! atw_posts_getopt( 'ignore_aspen_weaver' ) && ( atw_posts_is_wvrx() || atw_posts_is_wii() ) ) |
|---|
| 302 | || ( atw_posts_getopt( 'use_native_theme_templates' ) && atw_posts_theme_has_templates() ) |
|---|
| 303 | ) { |
|---|
| 304 | |
|---|
| 305 | if ( $sticky ) { |
|---|
| 306 | echo '<div class="sticky">'; |
|---|
| 307 | } |
|---|
| 308 | |
|---|
| 309 | if ( atw_posts_is_wvrx() ) { |
|---|
| 310 | get_template_part( 'templates/content', get_post_format() ); |
|---|
| 311 | } elseif ( function_exists( 'twentysixteen_setup' ) ) { // custom support for twentysixteen |
|---|
| 312 | get_template_part( 'template-parts/content', get_post_format() ); |
|---|
| 313 | } else { |
|---|
| 314 | get_template_part( 'content', get_post_format() ); |
|---|
| 315 | } |
|---|
| 316 | |
|---|
| 317 | if ( $sticky ) { |
|---|
| 318 | echo '</div>'; |
|---|
| 319 | } |
|---|
| 320 | echo "<div style='clear:both;'></div>\n"; |
|---|
| 321 | atw_restore_the_content_filters( $saved_the_content_filter_key ); |
|---|
| 322 | |
|---|
| 323 | return; |
|---|
| 324 | } |
|---|
| 325 | |
|---|
| 326 | if ( WEAVER_SHOWPOSTS_TEMPLATE ) { |
|---|
| 327 | $template = atw_posts_get_filter_opt( 'post_template', $filter ); |
|---|
| 328 | |
|---|
| 329 | if ( $template != '' ) { |
|---|
| 330 | atw_posts_do_template( $slider, $template ); |
|---|
| 331 | atw_restore_the_content_filters( $saved_the_content_filter_key ); |
|---|
| 332 | |
|---|
| 333 | return; |
|---|
| 334 | } |
|---|
| 335 | } |
|---|
| 336 | |
|---|
| 337 | |
|---|
| 338 | $add_class = 'atw-post'; |
|---|
| 339 | if ( $sticky ) { |
|---|
| 340 | $add_class .= ' sticky'; |
|---|
| 341 | } |
|---|
| 342 | ?> |
|---|
| 343 | <article id="post-<?php the_ID(); ?>" <?php post_class( $add_class ); ?>> |
|---|
| 344 | <header class="atw-entry-header"> |
|---|
| 345 | <?php |
|---|
| 346 | if ( ! atw_trans_get( 'hide_title' ) ) { // ========== TITLE |
|---|
| 347 | ?> |
|---|
| 348 | <hgroup class="atw-entry-hdr"><h2 class="atw-entry-title"> |
|---|
| 349 | <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr( __( 'Permalink to %s', 'show-posts' ) ), |
|---|
| 350 | the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a> |
|---|
| 351 | </h2></hgroup> |
|---|
| 352 | |
|---|
| 353 | <?php |
|---|
| 354 | } |
|---|
| 355 | |
|---|
| 356 | if ( ! atw_trans_get( 'hide_top_info' ) ) { // ============ TOP META |
|---|
| 357 | ?> |
|---|
| 358 | <div class="atw-entry-meta"> |
|---|
| 359 | <div class="atw-entry-meta-icons"> |
|---|
| 360 | <?php |
|---|
| 361 | |
|---|
| 362 | 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' ), |
|---|
| 363 | esc_url( get_permalink() ), |
|---|
| 364 | esc_attr( get_the_time() ), |
|---|
| 365 | esc_attr( get_the_date( 'c' ) ), |
|---|
| 366 | esc_html( get_the_date() ), |
|---|
| 367 | esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), |
|---|
| 368 | sprintf( esc_attr( __( 'View all posts by %s', 'show-posts' ) ), get_the_author() ), |
|---|
| 369 | esc_html( get_the_author() ) |
|---|
| 370 | ); |
|---|
| 371 | |
|---|
| 372 | if ( atw_trans_get( 'show_avatar' ) != '' && atw_trans_get( 'show_avatar' ) != 'no' ) { |
|---|
| 373 | echo ' ' . get_avatar( get_the_author_meta( 'user_email' ), 22, null, 'avatar' ); |
|---|
| 374 | } |
|---|
| 375 | ?> |
|---|
| 376 | </div><!-- .atw-entry-meta-icons --> |
|---|
| 377 | </div><!-- .atw-entry-meta --> |
|---|
| 378 | <?php |
|---|
| 379 | } |
|---|
| 380 | ?> |
|---|
| 381 | </header><!-- .atw-entry-header --> |
|---|
| 382 | <?php |
|---|
| 383 | if ( atw_trans_get( 'show' ) == 'title' ) { |
|---|
| 384 | echo '</article><!-- #post-' . get_the_ID() . '-->'; |
|---|
| 385 | atw_restore_the_content_filters( $saved_the_content_filter_key ); |
|---|
| 386 | |
|---|
| 387 | return; |
|---|
| 388 | } |
|---|
| 389 | |
|---|
| 390 | if ( atw_trans_get( 'show' ) == 'title_featured' ) { |
|---|
| 391 | |
|---|
| 392 | if ( get_post_thumbnail_id() ) { |
|---|
| 393 | //$image = wp_get_attachment_image_src( get_post_thumbnail_id( ), 'thumbnail' ); // (url, width, height) |
|---|
| 394 | //$href = $image[0]; |
|---|
| 395 | $href = get_permalink(); |
|---|
| 396 | ?> |
|---|
| 397 | <p class='atw-featured-image'><a href="<?php echo $href; ?>"><?php esc_url( the_post_thumbnail( 'thumbnail' ) ); ?></a></p> |
|---|
| 398 | <?php |
|---|
| 399 | } |
|---|
| 400 | echo '</article><!-- #post-' . get_the_ID() . '-->'; |
|---|
| 401 | atw_restore_the_content_filters( $saved_the_content_filter_key ); |
|---|
| 402 | |
|---|
| 403 | return; |
|---|
| 404 | } |
|---|
| 405 | |
|---|
| 406 | if ( atw_trans_get( 'show' ) == 'excerpt' ) { // =================== EXCERPT |
|---|
| 407 | ?> |
|---|
| 408 | <div class="atw-entry-summary atw-cf"> |
|---|
| 409 | <?php |
|---|
| 410 | atw_show_post_content( $slider ); |
|---|
| 411 | ?> |
|---|
| 412 | </div><!-- .atw-entry-summary --> |
|---|
| 413 | <?php |
|---|
| 414 | } else { // ================== FULL CONTENT |
|---|
| 415 | ?> |
|---|
| 416 | <div class="atw-entry-content atw-cf"> |
|---|
| 417 | <?php |
|---|
| 418 | atw_show_post_content( $slider ); |
|---|
| 419 | ?> |
|---|
| 420 | </div><!-- .atw-entry-content --> |
|---|
| 421 | <?php |
|---|
| 422 | } |
|---|
| 423 | |
|---|
| 424 | if ( ! atw_trans_get( 'hide_bottom_info' ) ) { // ================= BOTTOM META |
|---|
| 425 | ?> |
|---|
| 426 | |
|---|
| 427 | <footer class="atw-entry-utility"> |
|---|
| 428 | <div class="atw-entry-meta-icons"> |
|---|
| 429 | <?php |
|---|
| 430 | $categories_list = get_the_category_list( __( ', ', 'show-posts' ) ); |
|---|
| 431 | if ( $categories_list ) { ?> |
|---|
| 432 | <span class="cat-links"> |
|---|
| 433 | <?php |
|---|
| 434 | echo $categories_list; |
|---|
| 435 | ?> |
|---|
| 436 | </span> |
|---|
| 437 | <?php |
|---|
| 438 | } // End if categories |
|---|
| 439 | $tags_list = get_the_tag_list( '', __( ', ', 'show-posts' ) ); |
|---|
| 440 | if ( $tags_list ) { |
|---|
| 441 | ?> |
|---|
| 442 | <span class="tag-links"> |
|---|
| 443 | <?php |
|---|
| 444 | echo $tags_list; |
|---|
| 445 | ?> |
|---|
| 446 | </span> |
|---|
| 447 | <?php |
|---|
| 448 | } // End if $tags_list |
|---|
| 449 | if ( comments_open() ) { |
|---|
| 450 | ?> |
|---|
| 451 | <span class="comments-link"> |
|---|
| 452 | <?php |
|---|
| 453 | comments_popup_link( __( 'Leave a reply', 'show-posts' ), |
|---|
| 454 | __( '<b>1</b> Reply', 'show-posts' ), |
|---|
| 455 | __( '<b>%</b> Replies', 'show-posts' ), |
|---|
| 456 | 'leave-reply' ); |
|---|
| 457 | ?> |
|---|
| 458 | |
|---|
| 459 | </span> |
|---|
| 460 | <div style="clear:both;"></div> |
|---|
| 461 | <?php |
|---|
| 462 | } // End if comments_open() |
|---|
| 463 | ?> |
|---|
| 464 | </div><!-- .entry-meta-icons --> |
|---|
| 465 | </footer><!-- .atw-entry-utility --> |
|---|
| 466 | <?php |
|---|
| 467 | } |
|---|
| 468 | edit_post_link( __( 'Edit', 'show-posts' ), '<span class="atw-edit-link">', '</span>' ); |
|---|
| 469 | ?> |
|---|
| 470 | </article><!-- #post-<?php the_ID(); ?> --> |
|---|
| 471 | |
|---|
| 472 | <?php |
|---|
| 473 | atw_restore_the_content_filters( $saved_the_content_filter_key ); |
|---|
| 474 | } |
|---|
| 475 | |
|---|
| 476 | function atw_save_the_content_filters() { |
|---|
| 477 | global $wp_filter, $wp_current_filter; |
|---|
| 478 | |
|---|
| 479 | $tag = 'the_content'; |
|---|
| 480 | if ( empty( $wp_filter ) || empty( $wp_current_filter ) || ! in_array( $tag, $wp_current_filter ) ) { |
|---|
| 481 | return false; |
|---|
| 482 | } |
|---|
| 483 | |
|---|
| 484 | return key( $wp_filter[ $tag ] ); |
|---|
| 485 | } |
|---|
| 486 | |
|---|
| 487 | function atw_restore_the_content_filters( $key = false ) { |
|---|
| 488 | global $wp_filter; |
|---|
| 489 | $tag = 'the_content'; |
|---|
| 490 | if ( $key !== false ) { |
|---|
| 491 | reset( $wp_filter[ $tag ] ); |
|---|
| 492 | while ( key( $wp_filter[ $tag ] ) !== $key ) { |
|---|
| 493 | if ( next( $wp_filter[ $tag ] ) === false ) { |
|---|
| 494 | break; |
|---|
| 495 | } |
|---|
| 496 | } |
|---|
| 497 | } |
|---|
| 498 | } |
|---|
| 499 | |
|---|
| 500 | // ====================================== >>> atw_show_post_content <<< ====================================== |
|---|
| 501 | |
|---|
| 502 | function atw_show_post_content( $slider ) { |
|---|
| 503 | // display a post - show thumbnail, link to full size image |
|---|
| 504 | if ( ! atw_trans_get( 'hide_featured_image' ) && get_post_thumbnail_id() ) { |
|---|
| 505 | //$image = wp_get_attachment_image_src( get_post_thumbnail_id( ), 'full' ); // (url, width, height) |
|---|
| 506 | //$href = $image[0]; |
|---|
| 507 | $href = get_permalink(); |
|---|
| 508 | ?> |
|---|
| 509 | <span class='atw-featured-image'><a href="<?php echo $href; ?>"><?php the_post_thumbnail( 'thumbnail' ); ?></a></span> |
|---|
| 510 | <?php |
|---|
| 511 | } |
|---|
| 512 | |
|---|
| 513 | $content = ''; |
|---|
| 514 | |
|---|
| 515 | if ( $slider && function_exists( 'atw_slider_set_pager_image' ) ) { |
|---|
| 516 | $image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' ); // (url, width, height) |
|---|
| 517 | $href = $image[0]; |
|---|
| 518 | if ( ! $href ) { |
|---|
| 519 | $content = get_the_content( $more ); |
|---|
| 520 | } |
|---|
| 521 | |
|---|
| 522 | } |
|---|
| 523 | |
|---|
| 524 | $more = atw_trans_get( 'more_msg' ); |
|---|
| 525 | if ( $more == '' ) { |
|---|
| 526 | $more = 'Continue Reading...'; |
|---|
| 527 | } // we always want to show continue reading even if theme sets it to '' |
|---|
| 528 | |
|---|
| 529 | if ( atw_trans_get( 'show' ) == 'excerpt' ) { |
|---|
| 530 | the_excerpt( $more ); |
|---|
| 531 | } elseif ( $content != '' ) { |
|---|
| 532 | echo $content; |
|---|
| 533 | } else { |
|---|
| 534 | // atw_show_post_the_content( $more ); |
|---|
| 535 | atw_show_post_the_content( $more ); |
|---|
| 536 | |
|---|
| 537 | } |
|---|
| 538 | } |
|---|
| 539 | |
|---|
| 540 | // ====================================== >>> atw_show_post_content <<< ====================================== |
|---|
| 541 | function atw_show_post_the_content( $more ) { |
|---|
| 542 | // use this to support nested the_content filters - slight modification of the WP the_content() |
|---|
| 543 | |
|---|
| 544 | $content = get_the_content( $more, false ); |
|---|
| 545 | |
|---|
| 546 | $content = do_shortcode( $content ); // try applying shortcodes before the_content filter |
|---|
| 547 | |
|---|
| 548 | $content = apply_filters( 'the_content', $content ); |
|---|
| 549 | //$content = str_replace( ']]>', ']]>', $content ); |
|---|
| 550 | echo $content; |
|---|
| 551 | } |
|---|