', '' ); else : the_title( '

', '

' ); endif; } function excerpt_length( $length ) { $excerpt_length = consted_get_option( 'excerpt_length_blog' ); if( is_admin() ){ return $length; }else{ if ( absint( $excerpt_length ) > 0 && !is_admin() ) { $length = absint( $excerpt_length ); } } return $length; } /** * @since Blog Expert 1.0.0 * * @param null */ function site_content_type( ){ $type = apply_filters( 'consted_content_type_filter', consted_get_option( 'blog_loop_content_type') ); echo '
'; if( ! is_single() && !is_page()): if ( $type == 'content' ) { the_content(); }else { echo wp_kses_post( get_the_excerpt() ); } else: the_content(); endif; echo '
'; } /** * Adds custom Read More link the_content(). * add_filter( 'the_content_more_link', array( $this,'content_read_more_link' )); * @param string $more "Read more" excerpt string. * @return string (Maybe) modified "read more" excerpt string. */ public function content_read_more_link( $more ) { if ( is_admin() ) return $more; return sprintf( '', esc_url( get_permalink( get_the_ID() ) ), esc_html( consted_get_option( 'read_more_text' ) ) ); } /** * Filter the "read more" excerpt string link to the post. * //add_filter( 'excerpt_more', array( $this,'excerpt_read_more_link' ) ); * @param string $more "Read more" excerpt string. * @return string (Maybe) modified "read more" excerpt string. */ public function excerpt_read_more_link( $more ) { if ( is_admin() ) return $more; if ( ! is_single() ) { $more = sprintf( '', esc_url( get_permalink( get_the_ID() ) ), esc_html( consted_get_option( 'read_more_text' ) ) ); } return $more; } /** * Post Posts Loop Navigation * add_action( 'consted_loop_navigation', $array( $this,'site_loop_navigation' ) ); * @since 1.0.0 */ function site_loop_navigation( $type = '' ) { if( $type == '' ){ $type = apply_filters( 'consted_loop_navigation_filter', get_theme_mod( 'consted_loop_navigation', 'list' ) ); } if( $type == 'default' ): the_posts_navigation( array( 'prev_text' => ''.esc_html__('Previous Posts', 'consted').'', 'next_text' => ''.esc_html__('Next Posts', 'consted').'', 'screen_reader_text' => __('Posts navigation', 'consted') ) ); echo '
'; else: echo '
'; endif; } /** * Change Comment fields location * @since 1.0.0 * @ add_filter( 'comment_form_fields', array( $this,'move_comment_field_to_bottom' ) ); */ function move_comment_field_to_bottom( $fields ) { $comment_field = $fields['comment']; $cookies_field = $fields['cookies']; unset( $fields['comment'] ); unset( $fields['cookies'] ); $fields['comment'] = $comment_field; $fields['cookies'] = $cookies_field; return $fields; } /** * Render post type thumbnail. * * @param $formats = string. */ public function render_thumbnail( $formats = '') { if( empty( $formats ) ) { $formats = get_post_format( get_the_ID() ); } switch ( $formats ) { default: $this->get_image_thumbnail(); break; case 'gallery': $this->get_gallery_thumbnail(); break; case 'audio': $this->get_audio_thumbnail(); break; case 'video': $this->get_video_thumbnail(); break; } } /** * Post formats audio. * * @since 1.0.0 */ public function get_gallery_thumbnail(){ global $post; $html = ''; if( has_block('gallery', $post->post_content) ): $html = '
'; $post_blocks = parse_blocks( $post->post_content ); if( !empty( $post_blocks ) ): $html .= ''; endif; $html .= '
'; elseif ( get_post_gallery() ) : $html = '
'; $html .= ''; $html .= '
'; else: $html .= $this->get_image_thumbnail(); endif; $html = apply_filters( 'consted_shop_gallery_thumbnail', $html ); echo wp_kses( $html, $this->alowed_tags() ); } /** * Post formats audio. * * @since 1.0.0 */ public function get_audio_thumbnail(){ $content = apply_filters( 'the_content', get_the_content() ); $audio = false; $html = ''; $post_thumbnail_url = ''; // Only get audio from the content if a playlist isn't present. if ( false === strpos( $content, 'wp-playlist-script' ) ) { $audio = get_media_embedded_in_content( $content, array( 'audio' ) ); } if ( has_post_thumbnail() ) : $post_thumbnail_id = get_post_thumbnail_id( get_the_ID() ); $post_thumbnail_url = wp_get_attachment_url( $post_thumbnail_id ); endif; // If not a single post, highlight the audio file. if ( ! empty( $audio ) ) { $i = 0; $html = '
'; foreach ( $audio as $audio_html ) : $i++; if( $post_thumbnail_url != "" ) { $html .= '
'; $html .= wp_kses( $audio_html, $this->alowed_tags() ); $html .= '
'; }else{ $html .= wp_kses( $audio_html, $this->alowed_tags() ); } if( $i == 1 ){ break; } endforeach; $html .= '
'; }else { $html .= $this->get_image_thumbnail(); } $html = apply_filters( 'consted_shop_audio_thumbnail', $html ); echo wp_kses( $html, $this->alowed_tags() ); } /** * Post formats video. * * @since 1.0.0 */ public function get_video_thumbnail(){ $content = apply_filters( 'the_content', get_the_content(get_the_ID()) ); $video = false; $html = ''; // Only get video from the content if a playlist isn't present. if ( false === strpos( $content, 'wp-playlist-script' ) ) { $video = get_media_embedded_in_content( $content, array( 'video', 'object', 'embed', 'iframe' ) ); } if ( ! empty( $video ) ) { $html = '
'; $i = 0; foreach ( $video as $video_html ) { $i++; $html .= '
'; $html .= wp_kses( $video_html, $this->alowed_tags() ); $html .= '
'; if( $i == 1 ){ break; } } $html .= '
'; }else { $html .= $this->get_image_thumbnail(); } $html = apply_filters( 'consted_shop_video_thumbnail', $html ); echo wp_kses( $html, $this->alowed_tags() ); } /** * Post formats thumbnail. * * @since 1.0.0 */ public function get_image_thumbnail(){ $html = ''; if ( has_post_thumbnail() ) : $html = '
'; $post_thumbnail_id = get_post_thumbnail_id( get_the_ID() ); $post_thumbnail_url = wp_get_attachment_url( $post_thumbnail_id ); if ( is_singular() ) { $html .= ''; } else { $html .= ''; } $html .= get_the_post_thumbnail( get_the_ID(), 'full' ); $html .=''; $html .= '
'; endif; $html = apply_filters( 'consted_shop_image_thumbnail', $html ); echo wp_kses( $html, $this->alowed_tags() ); } /** * Post Single Posts Navigation * * @since 1.0.0 */ function single_post_navigation( ) { //if( empty(startup_shop_get_option('__single_post_nav')) ){ return false; } $html ='
'; $prevPost = get_previous_post(); if( $prevPost ) : $html .= '
'; $prevthumbnail = get_the_post_thumbnail($prevPost->ID, array(60,60) ); if( $prevthumbnail ){ $html .= '
'. get_previous_post_link('%link',$prevthumbnail). '
'; } $html .='
'.esc_html__('Previous Article','consted').'
'; $html .=get_previous_post_link('%link',"%title"); $html .='
'; $html .= '
'; endif; $nextPost = get_next_post(); if( $nextPost ) : $html .= '
'; $html .='
'.esc_html__('Next Article','consted').'
'; $html .=get_next_post_link('%link',"%title"); $html .='
'; $nextthumbnail = get_the_post_thumbnail($nextPost->ID, array(60,60) ); if( !empty( $nextthumbnail ) ){ $html .= '
'. get_previous_post_link('%link',$nextthumbnail). '
'; } $html .= '
'; endif; $html .='
'; $html = apply_filters( 'consted_single_post_navigation_filter', $html ); echo wp_kses( $html, $this->alowed_tags() ); } private function alowed_tags(){ if( function_exists('consted_alowed_tags') ){ return consted_alowed_tags(); }else{ return array(); } } } $consted_post_related_class = new Consted_Post_Related();