get( 'Version' ); $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; $base = $suffix ? 'assets/css/style.min.css' : 'style.css'; wp_enqueue_style( 'vestibule-style', get_theme_file_uri( $base ), array(), $version ); wp_enqueue_script( 'vestibule-script', get_theme_file_uri( 'assets/js/vestibule.js' ), array( 'wp-i18n' ), $version, array( 'in_footer' => true, 'strategy' => 'defer', ) ); wp_set_script_translations( 'vestibule-script', 'vestibule', get_template_directory() . '/languages' ); } add_action( 'wp_enqueue_scripts', 'vestibule_assets' ); /** * The two values of a light-dark() colour from the palette, or null. * * @param string $slug Palette slug. * @return array|null [ light, dark ]. */ function vestibule_light_dark( $slug ) { $sets = wp_get_global_settings( array( 'color', 'palette' ) ); $palette = array(); foreach ( array( 'custom', 'theme' ) as $origin ) { if ( ! empty( $sets[ $origin ] ) && is_array( $sets[ $origin ] ) ) { $palette = array_merge( $palette, $sets[ $origin ] ); } } foreach ( $palette as $entry ) { if ( isset( $entry['slug'], $entry['color'] ) && $entry['slug'] === $slug ) { if ( preg_match( '/^light-dark\(\s*([^,]+)\s*,\s*(.+)\)$/i', trim( $entry['color'] ), $m ) ) { return array( trim( $m[1] ), trim( $m[2] ) ); } return array( $entry['color'], $entry['color'] ); } } return null; } /** * Head: light first for everyone; a remembered dark choice is applied before paint. The browser chrome colour, font preloads. */ function vestibule_head() { $ground = vestibule_light_dark( 'ground' ); if ( $ground && preg_match( '/^(#[0-9a-f]{3,8}|rgba?\(.+\))$/i', $ground[0] ) && preg_match( '/^(#[0-9a-f]{3,8}|rgba?\(.+\))$/i', $ground[1] ) ) { printf( '' . "\n", esc_attr( $ground[0] ), esc_attr( $ground[1] ) ); } foreach ( array( 'newsreader-normal', 'inter' ) as $font ) { printf( '' . "\n", esc_url( get_theme_file_uri( 'assets/fonts/' . $font . '.woff2' ) ) ); } wp_print_inline_script_tag( '(function(){try{var t=localStorage.getItem("vestibule-theme");if(t){document.documentElement.setAttribute("data-theme",t);var m=document.querySelector("meta[name=theme-color]");if(m&&m.getAttribute("data-"+t))m.setAttribute("content",m.getAttribute("data-"+t));}}catch(e){}})();' ); } add_action( 'wp_head', 'vestibule_head', 1 ); /** * Pattern categories. */ function vestibule_pattern_categories() { register_block_pattern_category( 'vestibule-sections', array( 'label' => __( 'Vestibule sections', 'vestibule' ), 'description' => __( 'One section each: hero, booking, sound familiar, about, sessions, stories, how it works, questions, notes, closing.', 'vestibule' ), ) ); register_block_pattern_category( 'vestibule-parts', array( 'label' => __( 'Vestibule parts', 'vestibule' ), 'description' => __( 'The header and the footer.', 'vestibule' ), ) ); register_block_pattern_category( 'vestibule-pages', array( 'label' => __( 'Vestibule front pages', 'vestibule' ), 'description' => __( 'A whole front page for a career coach, ready to make your own.', 'vestibule' ), ) ); } add_action( 'init', 'vestibule_pattern_categories' ); /** * Block styles. */ function vestibule_block_styles() { register_block_style( 'core/group', array( 'name' => 'card', 'label' => __( 'Card', 'vestibule' ), ) ); register_block_style( 'core/group', array( 'name' => 'ground', 'label' => __( 'On the ground', 'vestibule' ), ) ); register_block_style( 'core/group', array( 'name' => 'accent', 'label' => __( 'Accent', 'vestibule' ), ) ); register_block_style( 'core/group', array( 'name' => 'tile', 'label' => __( 'Tile', 'vestibule' ), ) ); register_block_style( 'core/paragraph', array( 'name' => 'lead', 'label' => __( 'Lead', 'vestibule' ), ) ); register_block_style( 'core/paragraph', array( 'name' => 'muted', 'label' => __( 'Muted', 'vestibule' ), ) ); register_block_style( 'core/paragraph', array( 'name' => 'number', 'label' => __( 'Number', 'vestibule' ), ) ); register_block_style( 'core/paragraph', array( 'name' => 'arrow', 'label' => __( 'Arrow link', 'vestibule' ), ) ); register_block_style( 'core/list', array( 'name' => 'rows', 'label' => __( 'Rows', 'vestibule' ), ) ); register_block_style( 'core/list', array( 'name' => 'steps', 'label' => __( 'Steps', 'vestibule' ), ) ); register_block_style( 'core/details', array( 'name' => 'faq', 'label' => __( 'Questions', 'vestibule' ), ) ); register_block_style( 'core/button', array( 'name' => 'accent', 'label' => __( 'Accent', 'vestibule' ), ) ); register_block_style( 'core/button', array( 'name' => 'small', 'label' => __( 'Small', 'vestibule' ), ) ); register_block_style( 'core/button', array( 'name' => 'icon', 'label' => __( 'Icon', 'vestibule' ), ) ); register_block_style( 'core/paragraph', array( 'name' => 'name-tag', 'label' => __( 'Name tag', 'vestibule' ), ) ); register_block_style( 'core/quote', array( 'name' => 'testimonial', 'label' => __( 'Testimonial', 'vestibule' ), ) ); } add_action( 'init', 'vestibule_block_styles' ); /** * Whether the Zoom Scheduler block (Jetpack) is available. * * @return bool */ function vestibule_has_zoom_block() { return WP_Block_Type_Registry::get_instance()->is_registered( 'jetpack/zoom-scheduler' ); } /** * The comment form title is a second-level heading, so the heading order of a note stays in step. * * @param array $defaults Comment form defaults. * @return array */ function vestibule_comment_form( $defaults ) { $defaults['title_reply_before'] = '

'; $defaults['title_reply_after'] = '

'; $defaults['title_reply'] = __( 'Leave a reply', 'vestibule' ); /* translators: %s: author of the comment being replied to */ $defaults['title_reply_to'] = __( 'Reply to %s', 'vestibule' ); $defaults['label_submit'] = __( 'Post comment', 'vestibule' ); return $defaults; } add_filter( 'comment_form_defaults', 'vestibule_comment_form' ); /** * More notes under a note leaves out the note being read. * The query block marked vst-more-query names its id here; its post template then skips the current note. * * @param array $parsed_block The block about to render. * @return array */ function vestibule_more_notes_mark( $parsed_block ) { if ( 'core/query' === $parsed_block['blockName'] && isset( $parsed_block['attrs']['className'], $parsed_block['attrs']['queryId'] ) && false !== strpos( (string) $parsed_block['attrs']['className'], 'vst-more-query' ) ) { $GLOBALS['vestibule_more_query_id'] = $parsed_block['attrs']['queryId']; } return $parsed_block; } add_filter( 'render_block_data', 'vestibule_more_notes_mark' ); /** * Leaves the current note out of the marked query. * * @param array $query Query vars of a query loop. * @param WP_Block $block The post template block. * @return array */ function vestibule_more_notes_skip_current( $query, $block ) { if ( is_singular( 'post' ) && isset( $GLOBALS['vestibule_more_query_id'], $block->context['queryId'] ) && $block->context['queryId'] === $GLOBALS['vestibule_more_query_id'] ) { $query['post__not_in'] = array_merge( isset( $query['post__not_in'] ) ? (array) $query['post__not_in'] : array(), array( get_queried_object_id() ) ); } return $query; } add_filter( 'query_loop_block_query_vars', 'vestibule_more_notes_skip_current', 10, 2 );