post_content; if ( ! empty( $post_obj->post_excerpt ) ) { $source_content = $post_obj->post_excerpt; } $source_content = preg_replace( '`\[[^\]]*\]`', '', $source_content ); $trimmed_content = wp_trim_words( $source_content, $length, '…' ); return $trimmed_content; } endif; /** * Add a pingback url auto-discovery header for singularly identifiable articles. */ function blog_cafe_pingback_header() { if ( is_singular() && pings_open() ) { echo ''; } } add_action( 'wp_head', 'blog_cafe_pingback_header' ); /** * Get an array of post id and title. * */ function blog_cafe_get_post_choices() { $choices = array( '' => esc_html__( '--Select Post--', 'blog-cafe' ) ); $args = array( 'numberposts' => -1, ); $posts = get_posts( $args ); foreach ( $posts as $post ) { $id = $post->ID; $title = $post->post_title; $choices[ $id ] = $title; } return $choices; } if( !function_exists( 'blog_cafe_get_page_choices' ) ) : /* * Function to get pages */ function blog_cafe_get_page_choices() { $pages = get_pages(); $page_list = array(); $page_list[0] = esc_html__( '--Select Page--', 'blog-cafe' ); foreach( $pages as $page ){ $page_list[ $page->ID ] = $page->post_title; } return $page_list; } endif; /** * Get an array of cat id and title. * */ if( !function_exists( 'blog_cafe_get_post_cat_choices' ) ) : /* * Function to get categories */ function blog_cafe_get_post_cat_choices() { $categories = get_terms( 'category' ); $choices = array('' => esc_html__( '--Select Category--', 'blog-cafe' )); foreach( $categories as $category ) { $choices[$category->term_id] = $category->name; } return $choices; } endif; /** * Checks to see if we're on the homepage or not. */ function blog_cafe_is_frontpage() { return ( is_front_page() && ! is_home() ); } /** * Checks to see if Static Front Page is set to "Your latest posts". */ function blog_cafe_is_latest_posts() { return ( is_front_page() && is_home() ); } /** * Checks to see if Static Front Page is set to "Posts page". */ function blog_cafe_is_frontpage_blog() { return ( is_home() && ! is_front_page() ); } /** * Checks to see if the current page displays any kind of post listing. */ function blog_cafe_is_page_displays_posts() { return ( blog_cafe_is_frontpage_blog() || is_search() || is_archive() || blog_cafe_is_latest_posts() ); } /** * Shows a breadcrumb for all types of pages. This is a wrapper function for the Breadcrumb_Trail class, * which should be used in theme templates. * * @since 1.0.0 * @access public * @param array $args Arguments to pass to Breadcrumb_Trail. * @return void */ function blog_cafe_breadcrumb( $args = array() ) { $breadcrumb = apply_filters( 'breadcrumb_trail_object', null, $args ); if ( ! is_object( $breadcrumb ) ) $breadcrumb = new Breadcrumb_Trail( $args ); return $breadcrumb->trail(); } /** * Pagination in archive/blog/search pages. */ function blog_cafe_posts_pagination() { $archive_pagination = get_theme_mod( 'blog_cafe_archive_pagination_type', 'numeric' ); if ( 'disable' === $archive_pagination ) { return; } if ( 'numeric' === $archive_pagination ) { the_posts_pagination( array( 'prev_text' => blog_cafe_get_icon_svg( 'menu_icon_up' ), 'next_text' => blog_cafe_get_icon_svg( 'menu_icon_up' ), ) ); } elseif ( 'older_newer' === $archive_pagination ) { the_posts_navigation( array( 'prev_text' => blog_cafe_get_icon_svg( 'menu_icon_up' ) . ''. esc_html__( 'Older', 'blog-cafe' ) .'', 'next_text' => ''. esc_html__( 'Newer', 'blog-cafe' ) .'' . blog_cafe_get_icon_svg( 'menu_icon_up' ), ) ); } } /** * Get an array of google fonts. * */ function blog_cafe_font_choices() { $font_family_arr = array(); $font_family_arr[''] = esc_html__( '--Default--', 'blog-cafe' ); // Make the request $request = wp_remote_get( get_theme_file_uri( 'assets/js/webfonts.json' ) ); if( is_wp_error( $request ) ) { return false; // Bail early } // Retrieve the data $body = wp_remote_retrieve_body( $request ); $data = json_decode( $body ); if ( ! empty( $data ) ) { foreach ( $data->items as $items => $fonts ) { $family_str_arr = explode( ' ', $fonts->family ); $family_value = implode( '-', array_map( 'strtolower', $family_str_arr ) ); $font_family_arr[ $family_value ] = $fonts->family; } } return apply_filters( 'blog_cafe_font_choices', $font_family_arr ); } // Add auto p to the palces where get_the_excerpt is being called. add_filter( 'get_the_excerpt', 'wpautop' ); if ( ! class_exists( 'WP_Customize_Control' ) ) { return null; } class blog_cafe_Range_Value_Control extends WP_Customize_Control { public $type = 'range-value'; /** * Enqueue scripts/styles. * * @since 3.4.0 */ public function enqueue() { wp_enqueue_script( 'blog-cafe-customizer-range', get_template_directory_uri() . '/assets/js/customizer-range.js', array( 'jquery' ), rand(), true ); } /** * Render the control's content. * * @author soderlind * @version 1.2.0 */ public function render_content() { ?>