tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support( 'title-tag' ); /* * Enable support for Post Thumbnails on posts and pages. * * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails */ add_theme_support( 'post-thumbnails' ); // This theme uses wp_nav_menu() in 2 locations. register_nav_menus( array( 'primary' => __( 'Main Menu', 'cafe-blog' ), 'secondary' => __( 'Footer Menu', 'cafe-blog' ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) ); /* * Enable support for Post Formats. * See http://codex.wordpress.org/Post_Formats */ add_theme_support( 'post-formats', array( 'image', 'video', 'audio', 'quote', 'link', 'status', ) ); // Enable support for Custom Logo. See https://codex.wordpress.org/Theme_Logo add_theme_support( 'custom-logo', array( 'width' => 300, 'height' => 100, 'flex-height' => true, 'flex-width' => true, 'header-text' => array( 'site-title', 'site-description' ), ) ); // This theme styles the visual editor with editor-style.css to match the theme style. add_editor_style(); // This theme support for Jetpack Infinite Scroll add_theme_support( 'infinite-scroll', array( 'container' => 'site-content', ) ); // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'freebiescafe_custom_background_args', array( 'default-color' => 'f9f9f9', 'default-image' => '', ) ) ); } add_action( 'after_setup_theme', 'freebiescafe_setup' ); /** * Register widget areas * * @link http://codex.wordpress.org/Function_Reference/register_sidebar */ function freebiescafe_widgets_init() { register_sidebar( array( 'name' => __( 'Sidebar', 'cafe-blog' ), 'id' => 'sidebar-1', 'description' => __( 'Widgets will appear in the left sidebar, below the main navigation.', 'cafe-blog' ), 'before_widget' => '", 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'freebiescafe_widgets_init' ); /** * Enqueue scripts and styles */ function freebiescafe_scripts() { // Load latest css version wp_enqueue_style( 'cafe-blog-style', get_stylesheet_uri(), array(), '1.0.3', 'all' ); // FontAwesome wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css', false, '4.7.0' ); // Fonts wp_enqueue_style( 'google-fonts', 'https://fonts.googleapis.com/css?family=Nunito:300,300i,800%7CPlayfair+Display:700,700i&subset=latin-ext', array(), '1.0.3' ); // Adds JavaScript for responsive videos wp_enqueue_script( 'fitvids-js', get_template_directory_uri() . '/js/jquery.fitvids.js', array( 'jquery' ), '1.1', true ); wp_enqueue_script( 'cafe-blog-custom-js', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), '1.0.3', true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'freebiescafe_scripts' ); /** * "Continue Reading" for excerpts */ function freebiescafe_continue_reading_link() { return '

' . __( 'Continue reading', 'cafe-blog' ) . ''; } /** * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and freebiescafe_continue_reading_link() * To override this in a child theme, remove the filter and add your own * function tied to the excerpt_more filter hook. * * @param string $more * * @return string */ function freebiescafe_auto_excerpt_more( $more ) { if ( is_admin() ) { return $more; } return ' ' . freebiescafe_continue_reading_link(); } add_filter( 'excerpt_more', 'freebiescafe_auto_excerpt_more' ); /** * "Continue Reading" link to custom post excerpts. * * @param string $output * * @retrun string */ function freebiescafe_custom_excerpt_more( $output ) { if ( has_excerpt() && ! is_attachment() && ! is_admin() ) { $output .= freebiescafe_continue_reading_link(); } return $output; } add_filter( 'get_the_excerpt', 'freebiescafe_custom_excerpt_more' ); /** * Related posts * * @param array $args * * @global object $post * @return */ function freebiescafe_related_posts( $args = array() ) { global $post; // default args $args = wp_parse_args( $args, array( 'post_id' => ! empty( $post ) ? $post->ID : '', 'taxonomy' => get_theme_mod( 'freebiescafe_related_posts_setting', 'category' ), 'limit' => 3, 'post_type' => ! empty( $post ) ? $post->post_type : 'post', 'orderby' => 'date', 'order' => 'DESC' ) ); // check taxonomy if ( ! taxonomy_exists( $args['taxonomy'] ) ) { return; } // post taxonomies $taxonomies = wp_get_post_terms( $args['post_id'], $args['taxonomy'], array( 'fields' => 'ids' ) ); if ( empty( $taxonomies ) ) { return; } // query $related_posts = get_posts( array( 'post__not_in' => (array) $args['post_id'], 'post_type' => $args['post_type'], 'tax_query' => array( array( 'taxonomy' => $args['taxonomy'], 'field' => 'term_id', 'terms' => $taxonomies ), ), 'posts_per_page' => $args['limit'], 'orderby' => $args['orderby'], 'order' => $args['order'] ) ); include( locate_template( 'template-parts/related.php', false, false ) ); wp_reset_postdata(); } /** * Posts pagination * * @global object $wp_query * @return */ function freebiescafe_pagination() { global $wp_query; $pagination = array( 'base' => str_replace( 999999999, '%#%', get_pagenum_link( 999999999 ) ), 'format' => '?page=%#%', 'current' => max( 1, get_query_var( 'paged' ) ), 'total' => $wp_query->max_num_pages, 'prev_text' => '«', 'next_text' => '»', 'type' => 'list' ); return paginate_links( $pagination ); } /** * Add a signature in the end of the post content * * @param string $text * * @return string */ function freebiescafe_add_signature( $text ) { if ( ! is_singular( 'post' ) ) { return $text; } $signatureImg = get_theme_mod( 'freebiescafe_signature_image_setting' ); if ( ! empty( $signatureImg ) ) { $text .= '
signature
'; } return $text; } add_filter( 'the_content', 'freebiescafe_add_signature' ); /** * Comment template * * @param object $comment * @param array $args * @param int $depth */ function freebiescafe_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case 'pingback' : case 'trackback' : ?>
  • Pingback:', 'cafe-blog' ); ?>

  • id="li-comment-">
    comment_approved == '0' ) : ?>

    __( 'Reply', 'cafe-blog' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>

    ' . esc_html__( 'Posted in %1$s', 'cafe-blog' ) . '', $categories_list ); // WPCS: XSS OK. } /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list( '', esc_html__( ', ', 'cafe-blog' ) ); if ( $tags_list ) { printf( '·' . esc_html__( ' Tagged %1$s', 'cafe-blog' ) . '', $tags_list ); // WPCS: XSS OK. } } if ( comments_open() ) { $more = sprintf( _n( ' %s Comment', ' %s Comments', get_comments_number(), 'cafe-blog' ), number_format_i18n( get_comments_number() ) ); echo '·'; comments_popup_link( __( 'Leave a comment', 'cafe-blog' ), __( ' 1 Comment', 'cafe-blog' ), $more ); echo ''; } edit_post_link( sprintf( /* translators: %s: Name of current post */ esc_html__( 'Edit %s', 'cafe-blog' ), the_title( '"', '"', false ) ), '·', '' ); } endif; /** * Custom excerpt length * * @param int $length */ function freebiescafe_excerpt_length( $length ) { return 100; } add_filter( 'excerpt_length', 'freebiescafe_excerpt_length' ); /** * Customizer options. */ require get_template_directory() . '/inc/customizer.php';