Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Condence code and add custom taxonomy support for archive descriptions. #128

Closed
wants to merge 3 commits into from

4 participants

@wpdevco

Any reason term_description() isn't preferred?

@mfields
  • I think that moving to term_description() makes sense here.
  • term_description() should probably only be called if is_category(), is_tag(), or is_tax() returns true.
  • The html element containing the description should not contain the class entry-content. This is reserved for post objects. I think the best class name to use here would be term-description.
  • There is no need to use parens with the echo construct.
  • Your patch removed the tag_archive_meta and category_archive_meta filters from the theme. I'm OK with this, but I'm not sure how everyone else feels about these. I think they are out of place -> It's rare that we allow html to be filtered in this manner. IMHO the filters provided by sanitize_term_field() in core should be enough to modify the output of the term description.
@wpdevco

Updated everything except sanitize_term_field(). To be perfectly honest, not sure how that would work.

@mfields

Cool! RE: sanitize_term_field() this was not something that needed to be included. I was mainly pointing out that the current filters in _s are not really necessary because there is a core-supported way to modify the output of term_description().

@obenland obenland commented on the diff
archive.php
((5 lines not shown))
- // show an optional category description
- $category_description = category_description();
- if ( ! empty( $category_description ) )
- echo apply_filters( 'category_archive_meta', '<div class="taxonomy-description">' . $category_description . '</div>' );
-
- } elseif ( is_tag() ) {
- // show an optional tag description
- $tag_description = tag_description();
- if ( ! empty( $tag_description ) )
- echo apply_filters( 'tag_archive_meta', '<div class="taxonomy-description">' . $tag_description . '</div>' );
- }
+ // show optional term description
+ if ( is_category() || is_tag() || is_tax() )
+ $term_description = term_description();
+ if ( ! empty( $term_description ) )
+ echo '<div class="term-description">' . $term_description . '</div>';
@obenland Owner

The if ( is_category() || is_tag() || is_tax() ) should be wrapped in {} (or use the if: endif; syntax), as indentation suggests.
Currently we'd run into an undefined variable notice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mfields

I'm going to work on this one next.

@obenland
Owner

@mfields Any news here?

@ianstewart
Owner

This still seems like a good idea. :)

@obenland obenland closed this pull request from a commit
@obenland obenland _s: Add custom taxonomy support for term descriptions in taxonomy
archives.

We don't even have to check for a context before printing the
description, `term_description()` does all the heavy lifting for us.

Props @jasondpx. Fixes #128.
3a5afef
@obenland obenland closed this in 3a5afef
@marksantiago marksantiago referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 12 deletions.
  1. +5 −12 archive.php
  2. +2 −0  inc/template-tags.php
View
17 archive.php
@@ -52,18 +52,11 @@
?>
</h1>
<?php
- if ( is_category() ) {
- // show an optional category description
- $category_description = category_description();
- if ( ! empty( $category_description ) )
- echo apply_filters( 'category_archive_meta', '<div class="taxonomy-description">' . $category_description . '</div>' );
-
- } elseif ( is_tag() ) {
- // show an optional tag description
- $tag_description = tag_description();
- if ( ! empty( $tag_description ) )
- echo apply_filters( 'tag_archive_meta', '<div class="taxonomy-description">' . $tag_description . '</div>' );
- }
+ // show optional term description
+ if ( is_category() || is_tag() || is_tax() )
+ $term_description = term_description();
+ if ( ! empty( $term_description ) )
+ echo '<div class="term-description">' . $term_description . '</div>';
@obenland Owner

The if ( is_category() || is_tag() || is_tax() ) should be wrapped in {} (or use the if: endif; syntax), as indentation suggests.
Currently we'd run into an undefined variable notice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
?>
</header><!-- .page-header -->
View
2  inc/template-tags.php
@@ -105,9 +105,11 @@ function _s_comment( $comment, $args, $depth ) {
<div class="comment-content"><?php comment_text(); ?></div>
+ <?php if ( get_option( 'thread_comments' ) == 1 ) : ?>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div><!-- .reply -->
+ <?php endif; ?>
</article><!-- #comment-## -->
<?php
Something went wrong with that request. Please try again.