'', 'random-default' => false, 'width' => 1920, 'height' => 120, 'flex-height' => true, 'flex-width' => true, 'default-text-color' => 'fff', 'header-text' => true, 'uploads' => true, 'wp-head-callback' => 'cafe_header_style', 'admin-head-callback' => 'cafe_admin_header_style', ); add_theme_support( 'custom-header', $header_args ); /* Adds background image and color support */ $background_args = array( 'default-color' => 'fff', 'default-image' => '', 'default-repeat' => '', 'default-position-x' => '', 'wp-head-callback' => '_custom_background_cb', 'admin-head-callback' => '', 'admin-preview-callback' => '', ); add_theme_support( 'custom-background', $background_args ); /* Adds RSS feed links to
for posts and comments. */ add_theme_support( 'automatic-feed-links' ); /* * This theme supports all available post formats by default. * See http://codex.wordpress.org/Post_Formats */ add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video', ) ); /* Styles the visual editor with editor-style.css */ add_editor_style(); /* Enable support for Post Thumbnails, and declare two sizes. */ add_theme_support( 'post-thumbnails' ); /* Sets up the content width value based on the theme's design. */ if ( ! isset( $content_width ) ) : $content_width = 690; endif; add_image_size( 'post-featured-image', 752, 9312, false ); /* Register menus of theme */ register_nav_menus( array( 'primary' => __( 'Primary menu in header', 'cafe' ), 'secondary' => __( 'Secondary menu in footer', 'cafe' ), ) ); } /** * Style the site title in the header displayed on the blog. */ function cafe_header_style() { $text_color = get_header_textcolor(); /* If no custom options for text are set, let's bail */ if ( get_theme_support( 'custom-header', 'default-text-color' ) == $text_color ) : return; endif; /* If we get this far, we have custom styles. */ ?> Header admin panel. */ function cafe_admin_header_style() { wp_enqueue_style( 'cafe-admin-header-style', get_template_directory_uri() . '/styles/admin-header.css', false, null ); } /** * Enqueue scripts and styles for the front end. */ function cafe_register_scripts() { /* Add functions realized on script.js */ wp_enqueue_script( 'cafe-main-script', get_template_directory_uri() . '/js/script.js', array( 'jquery' ) ); /* Load the main stylesheet */ wp_enqueue_style( 'cafe-main-style', get_stylesheet_uri() ); /* Load the Internet Explorer specific stylesheet */ wp_enqueue_style( 'cafe-ie-style', get_template_directory_uri() . '/styles/ie78.css', array( 'cafe-main-style' ) ); wp_style_add_data( 'cafe-ie-style', 'conditional', 'lt IE 9' ); /* Load scripts for compatibility html5 with IE */ wp_enqueue_script( 'cafe-html5-script', get_template_directory_uri() . '/js/html5.js' ); /* Load scripts for comments reply */ if ( is_singular() ) { wp_enqueue_script( 'comment-reply' ); } /* Load the elements to localize in scripts */ $script_localization = array( 'choose_file' => __( 'Choose file...', 'cafe' ), 'file_is_not_selected' => __( 'File is not selected.', 'cafe' ), ); /* Localization in scripts */ wp_localize_script( 'cafe-main-script', 'script_loc', $script_localization ); } /** * Add two custom widgets * * 1. Cafe_Recent_Comments (Recent Comments with excerpt) widget class */ class Cafe_Recent_Comments extends WP_Widget { /* Constructor for widget */ public function __construct() { $widget_ops = array( 'classname' => 'cafe_widget_recent_comments', 'description' => __( 'Your site’s most recent comments with excerpts.', 'cafe' ), ); parent::__construct( 'cafe_widget_recent_comments', __( 'Recent Comments with excerpt', 'cafe' ), $widget_ops ); $this->alt_option_name = 'cafe_widget_recent_comments'; if ( is_active_widget( false, false, $this->id_base ) ) : add_action( 'wp_head', array( $this, 'recent_comments_style' ) ); endif; add_action( 'comment_post', array( $this, 'flush_widget_cache' ) ); add_action( 'edit_comment', array( $this, 'flush_widget_cache' ) ); add_action( 'transition_comment_status', array( $this, 'flush_widget_cache' ) ); } /* Style for widget */ function recent_comments_style() { if ( ! current_theme_supports( 'widgets' ) || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) : return; endif; ?> id; endif; if ( isset( $cache[ $args['widget_id'] ] ) ) : echo $cache[ $args['widget_id'] ]; return; endif; $output = ''; /* Title of widget */ $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments', 'cafe' ); $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 2; if ( ! $number ) : $number = 2; endif; /* Get comments list based on the arguments */ $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish', ) ) ); $output .= $args['before_widget']; if ( $title ) : $output .= $args['before_title'] . $title . $args['after_title']; endif; $output .= '' . substr( get_comment( $comment )->comment_content, 0, 40 ) . $commentExcerptEndLineFiller . '
'cafe_widget_recent_posts', 'description' => __( 'Your site’s most recent posts with author and category.', 'cafe' ), ); parent::__construct( 'cafe_widget_recent_posts', __( 'Recent Posts (author and category)', 'cafe' ), $widget_ops ); $this->alt_option_name = 'cafe_widget_recent_posts'; add_action( 'save_post', array( $this, 'flush_widget_cache' ) ); add_action( 'deleted_post', array( $this, 'flush_widget_cache' ) ); add_action( 'switch_theme', array( $this, 'flush_widget_cache' ) ); } /* The output of widget in frontend */ function widget( $args, $instance ) { $cache = wp_cache_get( 'widget_recent_posts', 'widget' ); if ( ! is_array( $cache ) ) : $cache = array(); endif; if ( ! isset( $args['widget_id'] ) ) : $args['widget_id'] = $this->id; endif; if ( isset( $cache[ $args['widget_id'] ] ) ) : echo $cache[ $args['widget_id'] ]; return; endif; ob_start(); /* Title of widget */ $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts', 'cafe' ); $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 2; if ( ! $number ) : $number = 2; endif; $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; $rec_post_request = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, ) ) ); if ( $rec_post_request->have_posts() ) : echo $args['before_widget']; if ( $title ) : echo $args['before_title'] . $title . $args['after_title']; endif; ?> flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset( $alloptions['widget_recent_entries'] ) ) : delete_option( 'widget_recent_entries' ); endif; return $instance; } /* Flush cash for widget */ function flush_widget_cache() { wp_cache_delete( 'widget_recent_posts', 'widget' ); } /* Creating widget back-end */ function form( $instance ) { $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 2; $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false; ?>
id="get_field_id( 'show_date' ); ?>" name="get_field_name( 'show_date' ); ?>" />
__( 'Main Widget Area', 'cafe' ), 'id' => 'sidebar-1', 'description' => __( 'Appears on posts and pages in the sidebar.', 'cafe' ), 'before_widget' => '', 'before_title' => ''; $output .= $caption; $output .= '
'; echo $output; endif; endif; } /** * Page navigation */ function cafe_page_nav() { if ( get_previous_posts_link() || get_next_posts_link() ) : ?> / '; if ( ! is_front_page() ) : echo 'Home '; if ( is_archive() ) : if ( is_category() ) : $this_cat = get_category( get_query_var( 'cat' ), false ); echo $devider . '