Skip to content

Commit

Permalink
Add option to the Largo Recent Posts widget to toggle hiding the byli…
Browse files Browse the repository at this point in the history
…ne date, defaults to false to match behavior of largo_byline()
  • Loading branch information
benlk committed Oct 25, 2016
1 parent 3ec869f commit f86abf1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions inc/widgets/largo-recent-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ function update( $new_instance, $old_instance ) {
$instance['excerpt_display'] = sanitize_key( $new_instance['excerpt_display'] );
$instance['num_sentences'] = intval( $new_instance['num_sentences'] );
$instance['show_byline'] = ! empty($new_instance['show_byline']);
$instance['hide_byline_date'] = ! empty($new_instance['hide_byline_date']);
$instance['show_top_term'] = ! empty($new_instance['show_top_term']);
$instance['show_icon'] = ! empty($new_instance['show_icon']);
$instance['cat'] = intval( $new_instance['cat'] );
Expand All @@ -156,6 +157,7 @@ function form( $instance ) {
'excerpt_display' => 'num_sentences',
'num_sentences' => 2,
'show_byline' => '',
'hide_byline_date' => '',
'show_top_term' => '',
'show_icon' => '',
'cat' => 0,
Expand All @@ -169,6 +171,7 @@ function form( $instance ) {
$instance = wp_parse_args( (array) $instance, $defaults );
$duplicates = $instance['avoid_duplicates'] ? 'checked="checked"' : '';
$showbyline = $instance['show_byline'] ? 'checked="checked"' : '';
$hidebylinedate = $instance['hide_byline_date'] ? 'checked="checked"' : '';
$show_top_term = $instance['show_top_term'] ? 'checked="checked"' : '';
$show_icon = $instance['show_icon'] ? 'checked="checked"' : '';
?>
Expand Down Expand Up @@ -224,6 +227,10 @@ function form( $instance ) {
<input class="checkbox" type="checkbox" <?php echo $showbyline; ?> id="<?php echo $this->get_field_id( 'show_byline' ); ?>" name="<?php echo $this->get_field_name( 'show_byline' ); ?>" /> <label for="<?php echo $this->get_field_id( 'show_byline' ); ?>"><?php _e( 'Show byline on posts?', 'largo' ); ?></label>
</p>

<p>
<input class="checkbox" type="checkbox" <?php echo $hidebylinedate; ?> id="<?php echo $this->get_field_id( 'hide_byline_date' ); ?>" name="<?php echo $this->get_field_name( 'hide_byline_date' ); ?>" /> <label for="<?php echo $this->get_field_id( 'hide_byline_date' ); ?>"><?php _e( 'Hide the publish date in the byline?', 'largo' ); ?></label>
</p>

<p>
<input class="checkbox" type="checkbox" <?php echo $show_top_term; ?> id="<?php echo $this->get_field_id( 'show_top_term' ); ?>" name="<?php echo $this->get_field_name( 'show_top_term' ); ?>" /> <label for="<?php echo $this->get_field_id( 'show_top_term' ); ?>"><?php _e( 'Show the top term on posts?', 'largo' ); ?></label>
</p>
Expand Down
3 changes: 2 additions & 1 deletion partials/widget-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
largo_maybe_top_term();
}


// the thumbnail image (if we're using one)
if ($thumb == 'small') {
$img_location = $instance['image_align'] != '' ? $instance['image_align'] : 'left';
Expand Down Expand Up @@ -35,7 +36,7 @@

<?php // byline on posts
if ( isset( $instance['show_byline'] ) && $instance['show_byline'] == true) { ?>
<span class="byline"><?php echo largo_byline(false); ?></span>
<span class="byline"><?php echo largo_byline( false, $instance['hide_byline_date'] ); ?></span>
<?php }

// the excerpt
Expand Down

0 comments on commit f86abf1

Please sign in to comment.