Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Mathias committed Feb 4, 2013
1 parent a7a9509 commit d1d7c2c
Show file tree
Hide file tree
Showing 8 changed files with 301 additions and 48 deletions.
7 changes: 6 additions & 1 deletion include/CatList.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,12 @@ public function get_excerpt($single){
endif;

$excerpt_length = intval($this->params['excerpt_size']);
return wp_trim_words($lcp_excerpt, $excerpt_length);
if (function_exists('wp_trim_words')):
return wp_trim_words($lcp_excerpt, $excerpt_length);
else:
$exc_lim = intval($excerpt_length);
return mb_substr($lcp_excerpt, 0, $exc_lim) . '...';
endif;
else:
return null;
endif;
Expand Down
110 changes: 88 additions & 22 deletions include/CatListDisplayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private function build_output($tag){
}

/**
* This function should be overriden for template system.
* This function should be overriden for template system.
* @param post $single
* @param HTML tag to display $tag
* @return string
Expand All @@ -100,35 +100,102 @@ private function lcp_build_post($single, $tag){
$class = " class = current ";
endif;
$lcp_display_output = '<'. $tag . $class . '>';
$lcp_display_output .=
$this->get_post_title($single, $this->params['title_tag'],
$this->params['title_class']);
$lcp_display_output .=
$this->get_comments($single, $this->params['comments_tag'],
$this->params['comments_class']) . ' ';

$lcp_display_output .=
$this->get_date($single, $this->params['date_tag'],
$this->params['date_class']) . ' ';

$lcp_display_output .=
$this->get_author($single, $this->params['author_tag'],
$this->params['author_class']) . ' ';

if (isset($this->params['customfield_display'])) :

if (!empty($this->params['title_tag'])):
if (!empty($this->params['title_class'])):
$lcp_display_output .= $this->get_post_title($single,
$this->params['title_tag'],
$this->params['title_class']);
else:
$lcp_display_output .= $this->get_post_title($single, $this->params['title_tag']);
endif;
else:
$lcp_display_output .= $this->get_post_title($single) . ' ';
endif;

// Coments count
if (!empty($this->params['comments_tag'])):
if (!empty($this->params['comments_class'])):
$lcp_display_output .= $this->get_comments($single,
$this->params['comments_tag'],
$this->params['comments_class']);
else:
$lcp_display_output .= $this->get_comments($single, $this->params['comments_tag']);
endif;
else:
$lcp_display_output .= $this->get_comments($single);
endif;

// Date
if (!empty($this->params['date_tag'])):
if (!empty($this->params['date_class'])):
$lcp_display_output .= $this->get_date($single,
$this->params['date_tag'],
$this->params['date_class']);
else:
$lcp_display_output .= $this->get_date($single, $this->params['date_tag']);
endif;
else:
$lcp_display_output .= $this->get_date($single);
endif;

// Author
if (!empty($this->params['author_tag'])):
if (!empty($this->params['author_class'])):
$lcp_display_output .= $this->get_author($single,
$this->params['author_tag'],
$this->params['author_class']);
else:
$lcp_display_output .= $this->get_author($single, $this->params['author_tag']);
endif;
else:
$lcp_display_output .= $this->get_author($single);
endif;


if (!empty($this->params['customfield_display'])) :
$lcp_display_output .=
$this->get_custom_fields($this->params['customfield_display'],
$single->ID);
endif;

$lcp_display_output .= $this->get_thumbnail($single);

$lcp_display_output .= $this->get_content($single, $this->params['content_tag'], $this->params['content_class']);
if (!empty($this->params['content_tag'])):
if (!empty($this->params['content_class'])):
$lcp_display_output .= $this->get_content($single,
$this->params['content_tag'],
$this->params['content_class']);
else:
$lcp_display_output .= $this->get_content($single, $this->params['content_tag']);
endif;
else:
$lcp_display_output .= $this->get_content($single);
endif;

if (!empty($this->params['excerpt_tag'])):
if (!empty($this->params['excerpt_class'])):
$lcp_display_output .= $this->get_excerpt($single,
$this->params['excerpt_tag'],
$this->params['excerpt_class']);
else:
$lcp_display_output .= $this->get_excerpt($single, $this->params['excerpt_tag']);
endif;
else:
$lcp_display_output .= $this->get_excerpt($single);
endif;

$lcp_display_output .= $this->get_excerpt($single, $this->params['excerpt_tag'], $this->params['excerpt_class']);;
if (!empty($this->params['posts_morelink'])) :
$href = 'href="'.get_permalink($single->ID) . '"';
$class = "";
if (!empty($this->params['posts_morelink_class'])) :
$class = 'class="' . $this->params['posts_morelink_class'] . '" ';
endif;
$readmore = $this->params['posts_morelink'];
$lcp_display_output .= ' <a ' . $href . ' ' . $class . ' >' . $readmore . '</a>';
endif;

$lcp_display_output .= '</' . $tag . '>';

return $lcp_display_output;
}

Expand Down Expand Up @@ -167,8 +234,7 @@ private function get_excerpt($single, $tag = null, $css_class = null){
}

private function get_thumbnail($single, $tag = null){
if ( isset($this->params['thumbnail_class']) &&
$this->params['thumbnail_class'] != '' ) :
if ( !empty($this->params['thumbnail_class']) ) :
$lcp_thumb_class = $this->params['thumbnail_class'];
$info = $this->catlist->get_thumbnail($single, $lcp_thumb_class);
else:
Expand Down
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
54 changes: 37 additions & 17 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 @@ -94,10 +98,10 @@
</label> <br/>
<select id="<?php echo $this->get_field_id('orderby'); ?>"
name="<?php echo $this->get_field_name('orderby'); ?>" type="text" >
<?php $lcp_orders = array("date" => "Date",
"title" => "Post title",
"author" => "Author",
"rand" => "Random");
<?php $lcp_orders = array("date" => __("Date", "list-category-posts"),
"title" => __("Post title", "list-category-posts"),
"author" => __("Author", "list-category-posts"),
"rand" => __("Random", "list-category-posts"));
foreach ($lcp_orders as $key=>$value):
$option = '<option value="' . $key . '" ';
if ($orderby == $key):
Expand Down Expand Up @@ -162,28 +166,44 @@
</p>

<p>
<input class="checkbox" type="checkbox" <?php checked($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($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($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($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>
Binary file added languages/list-category-posts_sk_SK.mo
Binary file not shown.
Loading

0 comments on commit d1d7c2c

Please sign in to comment.