'', 'default-repeat' => 'repeat', 'default-position-x' => 'center', 'default-attachment' => 'scroll', 'admin-head-callback' => '', 'admin-preview-callback' => '' )); add_theme_support( 'custom-background', $defaults ); /** * Add theme support for site logo * * Since wordpress 4.5 */ if( 4.5 <= ( float )get_bloginfo( 'version' ) ){ add_theme_support( 'custom-logo', array( 'flex-width' => true, 'flex-height' => false, 'width' => 250, 'height' => 50, 'header-text' => array( 'site-title', 'site-description' ), ) ); } /** * 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' ); // Add Foodland's custom image sizes add_image_size( 'foodland-slider', 450, 315, true ); // Used for Featured slider add_image_size( 'foodland-featured-content', 336, 224, true ); // used in Featured Content add_image_size( 'foodland-promotional-page',570, 380, true ); // Used in Promotional headline page thumbnail image add_image_size( 'foodland-staff-member-image',250, 240, true ); // Used in staff member images //Archive Images add_image_size( 'foodland-archive-left-right', 480, 318, true ); // used in Archive Left/Right image if( class_exists( 'jetpack' ) ){ add_theme_support( 'nova_menu_item' ); // add theme support for food items. add_image_size( 'foodland-nova-archive',570, 500, true ); // Used in Nova Menu Archive page images } /** * This theme uses wp_nav_menu() in one location. */ register_nav_menus( array( 'primary' => __( 'Primary Menu', 'foodland' ), ) ); /** * Enable support for Post Formats */ add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) ); /** * Setup Editor style */ add_editor_style( 'css/editor-style.css' ); /** * Setup title support for theme * Supported from WordPress version 4.1 onwards * More Info: https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/ */ add_theme_support( 'title-tag' ); // Gutenberg support add_theme_support( 'editor-color-palette', array( array( 'name' => esc_html__( 'Blue', 'foodland' ), 'slug' => 'blue', 'color' => '#2c7dfa', ), array( 'name' => esc_html__( 'Green', 'foodland' ), 'slug' => 'green', 'color' => '#7ed221', ), array( 'name' => esc_html__( 'Golden', 'foodland' ), 'slug' => 'golden', 'color' => '#ce9b23', ), array( 'name' => esc_html__( 'Black', 'foodland' ), 'slug' => 'black', 'color' => '#2f3633', ), array( 'name' => esc_html__( 'Grey', 'foodland' ), 'slug' => 'grey', 'color' => '#82868b', ), )); add_theme_support( 'align-wide' ); add_theme_support( 'editor-font-sizes', array( array( 'name' => esc_html__( 'small', 'foodland' ), 'shortName' => esc_html__( 'S', 'foodland' ), 'size' => 12, 'slug' => 'small' ), array( 'name' => esc_html__( 'regular', 'foodland' ), 'shortName' => esc_html__( 'M', 'foodland' ), 'size' => 16, 'slug' => 'regular' ), array( 'name' => esc_html__( 'larger', 'foodland' ), 'shortName' => esc_html__( 'L', 'foodland' ), 'size' => 36, 'slug' => 'larger' ), array( 'name' => esc_html__( 'huge', 'foodland' ), 'shortName' => esc_html__( 'XL', 'foodland' ), 'size' => 48, 'slug' => 'huge' ) )); add_theme_support('editor-styles'); add_theme_support( 'wp-block-styles' ); } endif; // foodland_setup add_action( 'after_setup_theme', 'foodland_setup' ); /** * Enqueue scripts and styles * * @uses wp_register_script, wp_enqueue_script, wp_register_style, wp_enqueue_style, wp_localize_script * @action wp_enqueue_scripts * * @since Foodland 0.2 */ function foodland_scripts() { $options = foodland_get_theme_options(); $web_fonts_stylesheet = 'https://fonts.googleapis.com/css?family=Roboto'; wp_register_style( 'foodland-web-font', $web_fonts_stylesheet, false, null ); $foodland_deps = array( 'foodland-web-font' ); /** * Adds JavaScript to pages with the comment form to support * sites with threaded comments (when in use). */ if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } //For genericons wp_enqueue_style( 'foodland-genericons', get_template_directory_uri() . '/css/genericons.min.css', false, '3.4.1' ); //For Meanmenu wp_enqueue_style( 'foodland-meanmenu', get_template_directory_uri() . '/css/meanmenu.min.css', false, '3.4.1' ); // blocks wp_enqueue_style( 'foodland-blocks', get_template_directory_uri() . '/css/blocks.css' ); // enqueue styles required for the theme wp_enqueue_style( 'foodland-style', get_stylesheet_uri(), $foodland_deps, FOODLAND_THEME_VERSION ); // Enqueue scripts required for the theme wp_enqueue_script( 'skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.min.js', array(), '20130115', true ); // Enqueue meanmenu wp_enqueue_script( 'jquery-meanmenu', get_template_directory_uri() . '/js/jquery.meanmenu.min.js', array('jquery'), '20130115', true ); /** * Loads up Scroll Up script */ wp_enqueue_script( 'jquery-scrollup', get_template_directory_uri() . '/js/foodland-scrollup.min.js', array( 'jquery' ), '20160309', true ); /** * Loads up fit vids */ wp_enqueue_script( 'jquery-fitvids', get_template_directory_uri() . '/js/fitvids.min.js', array( 'jquery' ), '1.1', true ); /** * Loads up html5.min for IE support */ wp_enqueue_script( 'html5', get_template_directory_uri() . '/js/html5.min.js' ); wp_script_add_data( 'html5', 'conditional', 'lt IE 9' ); /** * Loads up Cycle JS */ if( $options['featured_slider_option'] != 'disabled' ) { // Load cycle2.css wp_enqueue_style( 'cycle2-style', get_template_directory_uri() . '/css/cycle2.min.css' ); // Load cycle2.min.js wp_enqueue_script( 'jquery-cycle2', get_template_directory_uri() . '/js/jquery-cycle2.min.js', array( 'jquery' ), '2.1.6', true ); // Load cycle2-carousel.min.js wp_enqueue_script( 'jquery-cycle2-carousel', get_template_directory_uri() . '/js/jquery-cycle2-carousel.min.js', array( 'jquery-cycle2' ), false , true ); } /** * Enqueue custom script for foodland. */ wp_enqueue_script( 'foodland-custom-scripts', get_template_directory_uri() . '/js/foodland-custom-scripts.min.js', array( 'jquery' ), null ); } add_action( 'wp_enqueue_scripts', 'foodland_scripts' ); /** * Enqueue editor styles for Gutenberg * * @since Foodland 1.0.0 */ function foodland_block_editor_styles() { // Block styles. wp_enqueue_style( 'foodland-block-editor-style', get_theme_file_uri( '/css/editor-blocks.css' ) ); } add_action( 'enqueue_block_editor_assets', 'foodland_block_editor_styles' ); /** * Recommended plugins */ require_once get_template_directory() . '/lib/class-tgm-plugin-activation.php'; require_once get_template_directory() . '/inc/tgm.php'; /** * Default Options. */ require get_template_directory() . '/inc/default-options.php'; /** * Custom Header. */ require get_template_directory() . '/inc/custom-header.php'; /** * Structure for foodland */ require get_template_directory() . '/inc/structure.php'; /** * Customizer additions. */ require get_template_directory() . '/inc/customizer-includes/customizer.php'; /** * Custom Menus */ require get_template_directory() . '/inc/menus.php'; /** * Load Slider file. */ require get_template_directory() . '/inc/featured-slider.php'; /** * Load promotional headline file. */ require get_template_directory() . '/inc/promotional-headline.php'; /** * Load Special product if jetpack plugin is active */ if( class_exists( 'jetpack' ) ){ require get_template_directory() . '/inc/todays-special.php'; } /** * Load Featured Content. */ require get_template_directory() . '/inc/featured-content.php'; /** * Load Team members */ require get_template_directory() . '/inc/team-members.php'; /** * Load custom template for nova resturant jetpack. */ if ( class_exists( 'Nova_Restaurant' ) ) { require get_template_directory() . '/inc/custom-jetpack-template.php'; } /** * Load Widgets and Sidebars */ require get_template_directory() . '/inc/widget-includes/widgets-core.php'; /** * Load Social Icons */ require get_template_directory() . '/inc/social-icons.php'; /** * Returns the options array for foodland. * @uses get_theme_mod * * @since Foodland 0.2 */ function foodland_get_theme_options() { $foodland_default_options = foodland_get_default_theme_options(); return array_merge( $foodland_default_options , get_theme_mod( 'foodland_theme_options', $foodland_default_options ) ) ; } /** * Flush out all transients * * @uses delete_transient * * @action customize_save, foodland_customize_preview (see foodland_customizer function: foodland_customize_preview) * * @since Foodland 0.2 */ function foodland_flush_transients(){ delete_transient( 'foodland_featured_slider' ); delete_transient( 'foodland_promotional_headline' ); delete_transient( 'foodland_featured_content' ); delete_transient( 'foodland_special_product' ); delete_transient( 'foodland_team_members' ); delete_transient( 'foodland_footer_content' ); delete_transient( 'foodland_custom_css' ); delete_transient( 'foodland_featured_image' ); delete_transient( 'foodland_social_icons' ); delete_transient( 'foodland_post_total_category' ); //Add foodland default themes if there is no values if ( !get_theme_mod('foodland_theme_options') ) { set_theme_mod( 'foodland_theme_options', foodland_get_default_theme_options() ); } } add_action( 'customize_save', 'foodland_flush_transients' ); /** * Flush out category transients * * @uses delete_transient * * @action edit_category * * @since Foodland 0.2 */ function foodland_flush_category_transients(){ delete_transient( 'foodland_post_total_category' ); } add_action( 'edit_category', 'foodland_flush_category_transients' ); /** * Flush out post related transients * * @uses delete_transient * * @action save_post * * @since Foodland 0.2 */ function foodland_flush_post_transients(){ delete_transient( 'foodland_featured_slider' ); delete_transient( 'foodland_promotional_headline' ); delete_transient( 'foodland_special_product' ); delete_transient( 'foodland_featured_content' ); delete_transient( 'foodland_featured_image' ); delete_transient( 'foodland_post_total_category' ); } add_action( 'save_post', 'foodland_flush_post_transients' ); if ( ! function_exists( 'foodland_custom_css' ) ) : /** * Enqueue Custon CSS * * @uses set_transient, wp_head, wp_enqueue_style * * @action wp_enqueue_scripts * * @since Foodland 0.2 */ function foodland_custom_css() { //foodland_flush_transients(); $options = foodland_get_theme_options(); $defaults = foodland_get_default_theme_options(); if ( ( !$foodland_custom_css = get_transient( 'foodland_custom_css' ) ) ) { $foodland_custom_css =''; // Header Color Options if( $defaults[ 'site_title_tagline_color' ] != get_header_textcolor() ) { $foodland_custom_css .= "#masthead .site-title a, .site-description{ color: #". get_header_textcolor() ."; }". "\n"; } // Header Navigation menu if( $defaults[ 'header_nav_menu_color' ] != $options[ 'header_nav_menu_color' ] ){ $foodland_custom_css .= "#site-navigation ul li a{ color: ". $options['header_nav_menu_color'] ."; }" . "\n"; } $css = ''; // Check if the custom CSS feature of 4.7 exists if ( function_exists( 'wp_update_custom_css_post' ) ) { // Migrate any existing theme CSS to the core option added in WordPress 4.7. if( !empty( $options['custom_css'] ) ) $css = $options['custom_css']; if ( $css ) { $core_css = wp_get_custom_css(); // Preserve any CSS already added to the core option. $return = wp_update_custom_css_post( $core_css . $css ); if ( ! is_wp_error( $return ) ) { // Remove the old theme_mod, so that the CSS is stored in only one place moving forward. $options['custom_css'] = ''; set_theme_mod( 'foodland_theme_options', $options ); } } } else { // Back-compat for WordPress < 4.7. if ( isset( $options['custom_css'] ) ) { $foodland_custom_css .= $options['custom_css']; } } set_transient( 'foodland_custom_css', htmlspecialchars_decode( $foodland_custom_css ), 86940 ); } wp_add_inline_style( 'foodland-style', $foodland_custom_css ); } endif; //foodland_custom_css add_action( 'wp_enqueue_scripts', 'foodland_custom_css', 10 ); if ( ! function_exists( 'foodland_content_nav' ) ) : /** * Display navigation to next/previous pages when applicable * * @since Foodland 0.2 */ function foodland_content_nav( $nav_id ) { global $wp_query, $post; // Don't print empty markup on single pages if there's nowhere to navigate. if ( is_single() ) { $previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true ); $next = get_adjacent_post( false, '', false ); if ( ! $next && ! $previous ) return; } // Don't print empty markup in archives if there's only one page. if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) ) { return; } $options = foodland_get_theme_options(); $nav_class = ( is_single() ) ? 'site-navigation post-navigation' : 'site-navigation paging-navigation'; ?> comment_type || 'trackback' == $comment->comment_type ) : ?>