get( 'Version' ) ); wp_style_add_data( 'upsidenowbasic-style', 'path', get_theme_file_path( $src ) ); // Skip-link styles. Normally emitted by WordPress core alongside its // auto-injected skip link, which this theme removes (see below), so the // custom skip link in every template still needs them. wp_add_inline_style( 'upsidenowbasic-style', '.skip-link.screen-reader-text{border:0;clip:rect(1px,1px,1px,1px);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute !important;width:1px;word-wrap:normal !important;}' . '.skip-link.screen-reader-text:focus{background-color:#eee;clip:auto !important;clip-path:none;color:#444;display:block;font-size:1em;height:auto;left:5px;line-height:normal;padding:15px 23px 14px;text-decoration:none;top:5px;width:auto;z-index:100000;}' ); } endif; add_action( 'wp_enqueue_scripts', 'upsidenowbasic_enqueue_styles' ); // Front-end scripts used by the theme's patterns and template parts. if ( ! function_exists( 'upsidenowbasic_theme_scripts' ) ) : /** * Lists the theme's front-end scripts and the markup each one needs. * * Each script is only loaded on pages whose rendered blocks contain one of * its markers, so pages without that pattern or part load nothing extra. * * @since upsidenowbasic 3.2 * * @return array */ function upsidenowbasic_theme_scripts() { return array( 'upsidenowbasic-scroll-reveal' => array( 'file' => 'assets/js/scroll-reveal.js', 'markers' => array( 'scrollblock', 'statbox' ), ), 'upsidenowbasic-counters' => array( 'file' => 'assets/js/counters.js', 'markers' => array( 'counter-number' ), ), 'upsidenowbasic-countdown' => array( 'file' => 'assets/js/countdown.js', 'markers' => array( 'id="cd-w"' ), ), 'upsidenowbasic-announcement-bar' => array( 'file' => 'assets/js/announcement-bar.js', 'markers' => array( 'id="announcementBar"' ), ), ); } endif; // Enqueues a theme script when a rendered block contains its markup. if ( ! function_exists( 'upsidenowbasic_enqueue_block_scripts' ) ) : /** * Enqueues theme scripts for the blocks being rendered. * * Block themes render the page body before wp_head(), so scripts enqueued * here are printed in the footer as normal. * * @since upsidenowbasic 3.2 * * @param string $block_content The rendered block content. * @return string The unchanged block content. */ function upsidenowbasic_enqueue_block_scripts( $block_content ) { if ( is_admin() || '' === $block_content ) { return $block_content; } foreach ( upsidenowbasic_theme_scripts() as $handle => $script ) { if ( wp_script_is( $handle, 'enqueued' ) ) { continue; } foreach ( $script['markers'] as $marker ) { if ( false !== strpos( $block_content, $marker ) ) { wp_enqueue_script( $handle, get_theme_file_uri( $script['file'] ), array(), wp_get_theme()->get( 'Version' ), array( 'in_footer' => true, 'strategy' => 'defer', ) ); break; } } } return $block_content; } endif; add_filter( 'render_block', 'upsidenowbasic_enqueue_block_scripts' ); // Registers custom block styles. if ( ! function_exists( 'upsidenowbasic_block_styles' ) ) : /** * Registers custom block styles. * * @since upsidenowbasic 1.0 * * @return void */ function upsidenowbasic_block_styles() { register_block_style( 'core/list', array( 'name' => 'checkmark-list', 'label' => __( 'Checkmark', 'upsidenowbasic' ), 'inline_style' => ' ul.is-style-checkmark-list { list-style-type: "\2713"; } ul.is-style-checkmark-list li { padding-inline-start: 1ch; }', ) ); } endif; add_action( 'init', 'upsidenowbasic_block_styles' ); // Removes the WordPress core auto-injected block template skip link. // Every template provides its own skip link. if ( ! function_exists( 'upsidenowbasic_remove_core_skip_link' ) ) : /** * Unhooks the core "Skip to content" link for block templates. * * @since upsidenowbasic 1.0 * * @return void */ function upsidenowbasic_remove_core_skip_link() { // Unhooking either action makes core skip inserting its skip link // (see _block_template_add_skip_link() / wp_enqueue_block_template_skip_link()). remove_action( 'wp_footer', 'the_block_template_skip_link' ); remove_action( 'wp_enqueue_scripts', 'wp_enqueue_block_template_skip_link' ); } endif; add_action( 'init', 'upsidenowbasic_remove_core_skip_link' ); add_filter( 'register_block_type_args', function( $args, $block_type ) { if ( 'core/group' === $block_type && isset( $args['attributes']['align'] ) ) { $args['attributes']['align']['default'] = 'wide'; } return $args; }, 10, 2 );