Skip to content

Commit

Permalink
initial implementation of "read more" tag (not completed)
Browse files Browse the repository at this point in the history
issue #93
It is already working, but there are some limitation yet which will be fixed in further commits.
  • Loading branch information
Michael Burtscher committed Nov 12, 2015
1 parent 3db2797 commit 2d55a10
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion includes/sc_event-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private function html_event( &$event, &$a, $single_day_only=false ) {
$out .= '<div class="event-cat">'.esc_attr($this->categories->convert_db_string($event->categories)).'</div>';
}
if( $this->is_visible( $a['show_details'] ) ) {
$out .= '<div class="event-details">'.$this->db->truncate(do_shortcode(wpautop($event->details)), $a['details_length'], $this->single_event).'</div>';
$out .= $this->get_details($event, $a);
}
$out .= '</div>
</li>';
Expand Down Expand Up @@ -382,6 +382,29 @@ private function get_cat_filter($cat_filter, $actual_cat) {
}
}

private function get_details(&$event, &$a) {
global $more;
// check and handle the read more tag if available
$more_link_text = __('(more&hellip;)');
if(preg_match('/<!--more(.*?)?-->/', $event->details, $matches)) {
$part = explode($matches[0], $event->details, 2);
if(!empty($matches[1])) {
$more_link_text = strip_tags(wp_kses_no_null(trim($matches[1])));
}
if(isset($_GET['more'])) {
$details = $part[0].'<span id="more-'.$event->id.'"></span>'.$part[1];
}
else {
$details = apply_filters('the_content_more_link', $part[0].'<a href="'.add_query_arg('more', $event->id, get_permalink()).'#more-'.$event->id.'" class="more-link">'.$more_link_text.'</a>');
}
}
else {
$details = $event->details;
}
$details = '<div class="event-details">'.$this->db->truncate(do_shortcode(wpautop($details)), $a['details_length'], $this->single_event).'</div>';
return $details;
}

private function get_url( &$a ) {
if( '' !== $a['url_to_page'] ) {
// use given url
Expand Down

0 comments on commit 2d55a10

Please sign in to comment.