';
return $comment_field;
}
}
add_filter('comment_form_field_comment','ct_author_update_comment_field');
// remove allowed tags text after comment form
if( !function_exists('ct_author_remove_comments_notes_after' ) ) {
function ct_author_remove_comments_notes_after( $defaults ) {
$defaults['comment_notes_after'] = '';
return $defaults;
}
}
add_action('comment_form_defaults', 'ct_author_remove_comments_notes_after');
// excerpt handling
if( ! function_exists( 'ct_author_excerpt' ) ) {
function ct_author_excerpt() {
// make post variable available
global $post;
// check for the more tag
$ismore = strpos( $post->post_content, '' );
// get the show full post setting
$show_full_post = get_theme_mod( 'full_post' );
// get user Read More link text
$read_more_text = get_theme_mod( 'read_more_text' );
// use i18n'ed text if empty
if ( empty( $read_more_text ) )
$read_more_text = __( 'Continue reading', 'author' );
// if show full post is on and not on a search results page
if ( ( $show_full_post == 'yes' ) && ! is_search() ) {
// use the read more link if present
if ( $ismore ) {
the_content( wp_kses_post( $read_more_text ) . " " . get_the_title() . "" );
} else {
the_content();
}
}
// use the read more link if present
elseif ( $ismore ) {
the_content( wp_kses_post( $read_more_text ) . " " . get_the_title() . "" );
} // otherwise the excerpt is automatic, so output it
else {
the_excerpt();
}
}
}
// filter the link on excerpts
if( !function_exists('ct_author_excerpt_read_more_link' ) ) {
function ct_author_excerpt_read_more_link( $output ) {
global $post;
// get user Read More link text
$read_more_text = get_theme_mod( 'read_more_text' );
// use i18n'ed text if empty
if ( empty( $read_more_text ) )
$read_more_text = __( 'Continue reading', 'author' );
return $output . "
";
}
}
add_filter('the_excerpt', 'ct_author_excerpt_read_more_link');
// change the length of the excerpts
function ct_author_custom_excerpt_length( $length ) {
$new_excerpt_length = get_theme_mod('excerpt_length');
// if there is a new length set and it's not 15, change it
if( ! empty( $new_excerpt_length ) && $new_excerpt_length != 25 ){
return $new_excerpt_length;
}
// allow 0 to be an option if user wants to remove the excerpt entirely
elseif( $new_excerpt_length === 0 ) {
return 0;
}
else {
return 25;
}
}
add_filter( 'excerpt_length', 'ct_author_custom_excerpt_length', 99 );
// switch [...] to ellipsis on automatic excerpt
if( !function_exists('ct_author_new_excerpt_more' ) ) {
function ct_author_new_excerpt_more( $more ) {
// get user set excerpt length
$new_excerpt_length = get_theme_mod('excerpt_length');
// don't return trailing ellipsis if user removed excerpt
if( $new_excerpt_length === 0 ) {
return '';
} else {
return '…';
}
}
}
add_filter('excerpt_more', 'ct_author_new_excerpt_more');
// turns of the automatic scrolling to the read more link
if( !function_exists('ct_author_remove_more_link_scroll' ) ) {
function ct_author_remove_more_link_scroll( $link ) {
$link = preg_replace( '|#more-[0-9]+|', '', $link );
return $link;
}
}
add_filter( 'the_content_more_link', 'ct_author_remove_more_link_scroll' );
// for displaying featured images
if( !function_exists('ct_author_featured_image' ) ) {
function ct_author_featured_image() {
// get post object
global $post;
// establish featured image var
$featured_image = '';
// if post has an image
if ( has_post_thumbnail( $post->ID ) ) {
if ( is_singular() ) {
$featured_image = '