Skip to content

Commit

Permalink
Adds excerpt size to widget, fixes #35
Browse files Browse the repository at this point in the history
  • Loading branch information
picandocodigo committed Jan 18, 2013
1 parent f8f6cac commit 993f45e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
3 changes: 3 additions & 0 deletions include/ListCategoryPostsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function widget($args, $instance) {
$dateformat = ($instance['dateformat']) ? $instance['dateformat'] : get_option('date_format');
$showdate = ($instance['show_date'] == 'on') ? 'yes' : 'no';
$showexcerpt = ($instance['show_excerpt'] == 'on') ? 'yes' : 'no';
$excerptsize = (empty($instance['excerpt_size']) ? 55 : $instance['excerpt_size']);
$showauthor = ($instance['show_author'] == 'on') ? 'yes' : 'no';
$showcatlink = ($instance['show_catlink'] == 'on') ? 'yes' : 'no';
$thumbnail = ($instance['thumbnail'] == 'on') ? 'yes' : 'no';
Expand All @@ -44,6 +45,7 @@ function widget($args, $instance) {
'dateformat' => $dateformat,
'template' => 'default',
'excerpt' => $showexcerpt,
'excerpt_size' => $excerptsize,
'exclude' => $exclude,
'excludeposts' => $excludeposts,
'offset' => $offset,
Expand Down Expand Up @@ -72,6 +74,7 @@ function update($new_instance, $old_instance) {
$instance['dateformat'] = strip_tags($new_instance['dateformat']);
$instance['show_date'] = strip_tags($new_instance['show_date']);
$instance['show_excerpt'] = strip_tags($new_instance['show_excerpt']);
$instance['excerpt_size'] = strip_tags($new_instance['excerpt_size']);
$instance['show_author'] = strip_tags($new_instance['show_author']);
$instance['show_catlink'] = strip_tags($new_instance['show_catlink']);
$instance['show_catlink'] = strip_tags($new_instance['show_catlink']);
Expand Down
46 changes: 33 additions & 13 deletions include/lcp_widget_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'show_date'=>'',
'show_author'=>'',
'show_excerpt'=>'',
'excerpt_size' =>'',
'exclude'=>'',
'excludeposts'=>'',
'thumbnail' =>'',
Expand All @@ -20,6 +21,7 @@
'morelink' =>''
);
$instance = wp_parse_args( (array) $instance, $default);

$title = strip_tags($instance['title']);
$limit = strip_tags($instance['limit']);
$orderby = strip_tags($instance['orderby']);
Expand All @@ -32,9 +34,11 @@
$showcatlink = strip_tags($instance['show_catlink']);
$categoryid = strip_tags($instance['categoryid']);
$showexcerpt = strip_tags($instance['show_excerpt']);
$excerptsize = strip_tags($instance['excerpt_size']);
$thumbnail = strip_tags($instance['thumbnail']);
$thumbnail_size = strip_tags($instance['thumbnail_size']);
$morelink = strip_tags($instance['morelink']);

?>

<p>
Expand Down Expand Up @@ -162,28 +166,44 @@
</p>

<p>
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['show_date'], true ); ?>
name="<?php echo $this->get_field_name( 'show_date' ); ?>" /> <?php _e("Date", 'list-category-posts')?>
<input class="checkbox" type="checkbox"
<?php checked( (bool) $instance['show_date'], true ); ?>
name="<?php echo $this->get_field_name( 'show_date' ); ?>" />
<?php _e("Date", 'list-category-posts')?>
</p>
<p>
<input class="checkbox" input type="checkbox"
<?php checked( (bool) $instance['show_author'], true ); ?>
name="<?php echo $this->get_field_name( 'show_author' ); ?>" />
<?php _e("Author", 'list-category-posts')?>
</p>
<p>
<input class="checkbox" input type="checkbox" <?php checked( (bool) $instance['show_author'], true ); ?>
name="<?php echo $this->get_field_name( 'show_author' ); ?>" /> <?php _e("Author", 'list-category-posts')?>
<input class="checkbox" input type="checkbox"
<?php checked( (bool) $instance['show_catlink'], true ); ?>
name="<?php echo $this->get_field_name( 'show_catlink' ); ?>" />
<?php _e("Link to category", 'list-category-posts')?>
</p>
<p>
<input class="checkbox" input type="checkbox" <?php checked( (bool) $instance['show_catlink'], true ); ?>
name="<?php echo $this->get_field_name( 'show_catlink' ); ?>" /> <?php _e("Link to category", 'list-category-posts')?>
<input class="checkbox" input type="checkbox"
<?php checked( (bool) $instance['show_excerpt'], true ); ?>
name="<?php echo $this->get_field_name( 'show_excerpt' ); ?>" />
<?php _e("Excerpt", 'list-category-posts')?>
</p>
<p>
<input class="checkbox" input type="checkbox" <?php checked( (bool) $instance['show_excerpt'], true ); ?>
name="<?php echo $this->get_field_name( 'show_excerpt' ); ?>" /> <?php _e("Excerpt", 'list-category-posts')?>
<label for="<?php echo $this->get_field_id('excerpt_size'); ?>">
<?php _e("Excerpt size", 'list-category-posts')?>:
</label>
<br/>
<input class="widefat" id="<?php echo $this->get_field_id('excerpt_size'); ?>"
name="<?php echo $this->get_field_name('excerpt_size'); ?>" type="text"
value="<?php echo esc_attr($excerptsize); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('morelink'); ?>">
<?php _e("More link", 'list-category-posts')?>:
<?php _e("More link", 'list-category-posts')?>:
</label>
<br/>
<input class="widefat" id="<?php echo $this->get_field_id('morelink'); ?>"
name="<?php echo $this->get_field_name('morelink'); ?>" type="text"
<input class="widefat" id="<?php echo $this->get_field_id('morelink'); ?>"
name="<?php echo $this->get_field_name('morelink'); ?>" type="text"
value="<?php echo esc_attr($morelink); ?>" />
</p>

</p>

0 comments on commit 993f45e

Please sign in to comment.