Permalink
Browse files

Adds excerpt size to widget, fixes #35

  • Loading branch information...
1 parent f8f6cac commit 993f45e79490a0f678ef8ab6abed07736cf3e005 @picandocodigo committed Jan 18, 2013
Showing with 36 additions and 13 deletions.
  1. +3 −0 include/ListCategoryPostsWidget.php
  2. +33 −13 include/lcp_widget_form.php
@@ -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';
@@ -44,6 +45,7 @@ function widget($args, $instance) {
'dateformat' => $dateformat,
'template' => 'default',
'excerpt' => $showexcerpt,
+ 'excerpt_size' => $excerptsize,
'exclude' => $exclude,
'excludeposts' => $excludeposts,
'offset' => $offset,
@@ -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']);
@@ -12,6 +12,7 @@
'show_date'=>'',
'show_author'=>'',
'show_excerpt'=>'',
+ 'excerpt_size' =>'',
'exclude'=>'',
'excludeposts'=>'',
'thumbnail' =>'',
@@ -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']);
@@ -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>
@@ -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.