Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions classes/widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ public function update( $new_instance, $old_instance ) {

$instance['excerpt'] = isset( $new_instance['excerpt'] ) ? (bool) $new_instance['excerpt'] : false;
$instance['length'] = intval( $new_instance['length'] );
$instance['author'] = isset( $new_instance['author'] ) ? (bool) $new_instance['author'] : false;
$instance['author_link'] = isset( $new_instance['author_link'] ) ? (bool) $new_instance['author_link'] : false;
$instance['category_list'] = isset( $new_instance['category_list'] ) ? (bool) $new_instance['category_list'] : false;
$instance['date'] = isset( $new_instance['date'] ) ? (bool) $new_instance['date'] : false;
$instance['date_relative'] = isset( $new_instance['date_relative'] ) ? (bool) $new_instance['date_relative'] : false;
$instance['date_modified'] = isset( $new_instance['date_modified'] ) ? (bool) $new_instance['date_modified'] : false;
Expand Down
29 changes: 25 additions & 4 deletions includes/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,35 +244,56 @@
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'readmore_text' ); ?>" name="<?php echo $this->get_field_name( 'readmore_text' ); ?>" type="text" value="<?php echo strip_tags( $instance['readmore_text'] ); ?>" />
</p>

<p>
<input id="<?php echo $this->get_field_id( 'comment_count' ); ?>" name="<?php echo $this->get_field_name( 'comment_count' ); ?>" type="checkbox" <?php checked( $instance['comment_count'] ); ?> />
<label for="<?php echo $this->get_field_id( 'comment_count' ); ?>">
<?php _e( 'Display Comment Count', 'recent-posts-widget-extended' ); ?>
</label>
</p>

<p>
<input id="<?php echo $this->get_field_id( 'author' ); ?>" name="<?php echo $this->get_field_name( 'author' ); ?>" type="checkbox" <?php checked( $instance['author'] ); ?> />
<label for="<?php echo $this->get_field_id( 'author' ); ?>">
<?php _e( 'Display Author', 'recent-posts-widget-extended' ); ?>
</label>
</p>

<p>
<input id="<?php echo $this->get_field_id( 'author_link' ); ?>" name="<?php echo $this->get_field_name( 'author_link' ); ?>" type="checkbox" <?php checked( $instance['author_link'] ); ?> />
<label for="<?php echo $this->get_field_id( 'author_link' ); ?>">
<?php _e( 'Link to Author Page', 'recent-posts-widget-extended' ); ?>
</label>
</p>

<p>
<input id="<?php echo $this->get_field_id( 'category_list' ); ?>" name="<?php echo $this->get_field_name( 'category_list' ); ?>" type="checkbox" <?php checked( $instance['category_list'] ); ?> />
<label for="<?php echo $this->get_field_id( 'category_list' ); ?>">
<?php _e( 'Display Categories', 'recent-posts-widget-extended' ); ?>
</label>
</p>

<p>
<input id="<?php echo $this->get_field_id( 'date' ); ?>" name="<?php echo $this->get_field_name( 'date' ); ?>" type="checkbox" <?php checked( $instance['date'] ); ?> />
<label for="<?php echo $this->get_field_id( 'date' ); ?>">
<?php _e( 'Display Date', 'recent-posts-widget-extended' ); ?>
</label>
</p>

<p>
<input id="<?php echo $this->get_field_id( 'date_modified' ); ?>" name="<?php echo $this->get_field_name( 'date_modified' ); ?>" type="checkbox" <?php checked( $instance['date_modified'] ); ?> />
<label for="<?php echo $this->get_field_id( 'date_modified' ); ?>">
<?php _e( 'Display Modification Date', 'recent-posts-widget-extended' ); ?>
</label>
</p>

<p>
<input id="<?php echo $this->get_field_id( 'date_relative' ); ?>" name="<?php echo $this->get_field_name( 'date_relative' ); ?>" type="checkbox" <?php checked( $instance['date_relative'] ); ?> />
<label for="<?php echo $this->get_field_id( 'date_relative' ); ?>">
<?php _e( 'Use Relative Date. eg: 5 days ago', 'recent-posts-widget-extended' ); ?>
</label>
</p>


</div>

Expand Down
15 changes: 15 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ function rpwe_get_default_args() {
'thumb_width' => 45,
'thumb_default' => 'http://placehold.it/45x45/f0f0f0/ccc',
'thumb_align' => 'rpwe-alignleft',
'author' => false,
'author_link' => false,
'category_list' => false,
'date' => true,
'date_relative' => false,
'date_modified' => false,
Expand Down Expand Up @@ -169,6 +172,18 @@ function rpwe_get_recent_posts( $args = array() ) {

$html .= '<h3 class="rpwe-title"><a href="' . esc_url( get_permalink() ) . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'recent-posts-widget-extended' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark">' . esc_attr( get_the_title() ) . '</a></h3>';

if ( $args['author'] ) :
if ( $args['author_link'] ) :
$html .= '<a href="'.get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ).'" class="rpwe-author author vcard"><span class="fn">'.esc_html(get_the_author()).'</span></a>';
else :
$html .= '<span class="rpwe-author author vcard"><span class="fn">'.esc_html(get_the_author()).'</span></span>';
endif;
endif;

if ( $args['category_list'] ) :
$html .= get_the_category_list();
endif;

if ( $args['date'] ) :
$date = get_the_date();
if ( $args['date_relative'] ) :
Expand Down