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 https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support( 'post-thumbnails' ); // This theme uses wp_nav_menu() in one location. register_nav_menus( [ 'menu-1' => esc_html__( 'Top', 'muzeum' ), 'menu-2' => esc_html__( 'Primary', 'muzeum' ), ] ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', [ 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script', ] ); // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'muzeum_custom_background_args', [ 'default-color' => '#ffffff', 'default-image' => get_template_directory_uri() . '/static/img/whitenoise-360x370.png', ] ) ); // Add theme support for selective refresh for widgets. add_theme_support( 'customize-selective-refresh-widgets' ); /** * Add support for core custom logo. * * @link https://codex.wordpress.org/Theme_Logo */ add_theme_support( 'custom-logo', [ 'height' => 250, 'width' => 250, 'flex-width' => true, 'flex-height' => true, ] ); } endif; add_action( 'after_setup_theme', 'muzeum_setup' ); /** * Set the content width in pixels, based on the theme's design and stylesheet. * * Priority 0 to make it available to lower priority callbacks. * * @global int $content_width */ function muzeum_content_width() { $GLOBALS['content_width'] = apply_filters( 'muzeum_content_width', 640 ); } add_action( 'after_setup_theme', 'muzeum_content_width', 0 ); /** * Register widget area. * * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar */ function muzeum_widgets_init() { register_sidebar( [ 'name' => esc_html__( 'Sidebar', 'muzeum' ), 'id' => 'sidebar-1', 'description' => esc_html__( 'Add widgets here.', 'muzeum' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ] ); register_sidebar( [ 'name' => __( 'Footer 1', 'muzeum' ), 'id' => 'sidebar-2', 'description' => __( 'Add widgets here to appear in your footer.', 'muzeum' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ] ); register_sidebar( [ 'name' => __( 'Footer 2', 'muzeum' ), 'id' => 'sidebar-3', 'description' => __( 'Add widgets here to appear in your footer.', 'muzeum' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ] ); } add_action( 'widgets_init', 'muzeum_widgets_init' ); /** * Enqueue scripts and styles. */ function muzeum_scripts() { wp_enqueue_style( 'muzeum-style', get_stylesheet_uri(), [], MUZEUM_VERSION ); wp_style_add_data( 'muzeum-style', 'rtl', 'replace' ); // Load Ionicons font wp_enqueue_script( 'muzeum-ionicons-module', get_template_directory_uri() . '/static/js/ionicons/ionicons.esm.js', [], '5.2.3', true ); wp_enqueue_script( 'muzeum-ionicons', get_template_directory_uri() . '/static/js/ionicons/ionicons.js', [], '5.2.3', true ); wp_enqueue_script( 'muzeum-navigation', get_template_directory_uri() . '/static/js/navigation.js', [], MUZEUM_VERSION, true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'muzeum_scripts' ); // Append type="module" to Ionicons module script function muzeum_add_type_module_attribute( $tag, $handle ) { if ( $handle !== 'muzeum-ionicons-module' ) { return $tag; } // add type='module' script attribute $new_tag = str_replace( ' src', " type='module' src", $tag ); return $new_tag; } add_filter( 'script_loader_tag', 'muzeum_add_type_module_attribute', 10, 2 ); /** * Implement the Custom Header feature. */ require get_template_directory() . '/inc/custom-header.php'; /** * Custom template tags for this theme. */ require get_template_directory() . '/inc/template-tags.php'; /** * Customizer additions. */ require get_template_directory() . '/inc/customizer/customizer.php'; /** * Load Jetpack compatibility file. */ if ( defined( 'JETPACK__VERSION' ) ) { require get_template_directory() . '/inc/jetpack.php'; } /** * Add option to add site logo from the customizer * * @since WordPress 4.5 */ function muzeum_the_logo() { $show_default_logo = get_theme_mod( 'show_default_logo', 1 ); // shim for wp versions older than 4.5 if ( ! function_exists( 'the_custom_logo' ) ) { return; } // Display the default theme logo if no logo is specified if ( ! has_custom_logo() ) : // if user did not remove the default theme logo if ( $show_default_logo || is_customize_preview() ) : muzeum_default_logo_markup($show_default_logo); endif; else : // allow the user to upload cutom logo and replace the theme logo the_custom_logo(); if(is_customize_preview()){ muzeum_default_logo_markup($show_default_logo); } endif; } /** * The Html for the default site logo * Keep the html for the Customizer Live Preview for better UX * @since muzeum 1.1.5 */ function muzeum_default_logo_markup($logo) { ?> $muzeum_prev_arrow . __( ' Older posts', 'muzeum' ), 'next_text' => __( 'Newer posts', 'muzeum' ) . $muzeum_next_arrow, 'screen_reader_text' => __( 'Posts navigation', 'muzeum' ), ] ); } /* Post navigation in single.php */ function muzeum_the_post_navigation() { $muzeum_prev_arrow = ( is_rtl() ? '→' : '←' ); $muzeum_next_arrow = ( is_rtl() ? '←' : '→' ); the_post_navigation( [ 'prev_text' => '' . $muzeum_prev_arrow . ' %title', 'next_text' => '%title ' . '' . $muzeum_next_arrow . '', 'screen_reader_text' => __( 'Posts navigation', 'muzeum' ), ] ); } /* Show the correct icon on post archives */ function muzeum_archive_page_icon() { if ( is_category() ) { return ''; } elseif ( is_tag() ) { return ''; } elseif ( is_author() ) { return ''; } } /** * Replaces "[...]" (appended to automatically generated excerpts) with ... and * a 'Continue reading' link. * * @since muzeum 1.0.0 * * @param string $link Link to single post/page. * @return string 'Continue reading' link prepended with an ellipsis. */ function muzeum_excerpt_more( $link ) { if ( is_admin() ) { return $link; } $link = sprintf( '', esc_url( get_permalink( get_the_ID() ) ), /* translators: %s: Name of current post */ sprintf( __( 'Read the full post %1$s"%2$s"', 'muzeum' ), ( is_rtl() ? '←' : '→' ), esc_html( get_the_title( get_the_ID() ) ) ) ); return ' … ' . $link; } add_filter( 'excerpt_more', 'muzeum_excerpt_more' ); /* Add search list item to top menu bar */ function muzeum_add_search_box( $items, $args ) { // stop execution if it is not the top menu if ( $args->theme_location !== 'menu-1' ) { return $items; } ob_start(); ?> urlencode( implode( '|', $fonts ) ), 'subset' => urlencode( $subsets ), ]; if ( $fonts ) { $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); } return esc_url_raw( $fonts_url ); } /** * Add preconnect for Google Fonts for performance * * @since muzeum 1.0.0 * * @param array $urls URLs to print for resource hints. * @param string $relation_type The relation type the URLs are printed. * @return array $urls URLs to print for resource hints. */ function muzeum_resource_hints( $urls, $relation_type ) { if ( wp_style_is( 'muzeum-fonts', 'queue' ) && 'preconnect' === $relation_type ) { $urls[] = [ 'href' => 'https://fonts.gstatic.com', 'crossorigin', ]; } return $urls; } add_filter( 'wp_resource_hints', 'muzeum_resource_hints', 10, 2 ); /** * Enqueue fonts */ function muzeum_fonts() { // Add google fonts wp_enqueue_style( 'muzeum-custom-fonts', muzeum_fonts_url(), [], null ); } add_action( 'wp_enqueue_scripts', 'muzeum_fonts' ); /** * Add very simple breadcrumps to posts and pages * * @since v.1.0.0 */ function muzeum_breadcrumbs() { if ( is_front_page() ) { return; } ?> '; } } add_action( 'wp_head', 'muzeum_fb_open_graph' );