autonomic-block-theme/functions.php
Aadil Ayub 906cf389ae
All checks were successful
continuous-integration/drone/push Build is passing
enqueue block styles css on front-end
2023-08-29 15:57:57 +05:00

33 lines
1.2 KiB
PHP

<?php
add_action('init', 'custom_stylesheet');
function custom_stylesheet() {
wp_register_style( 'custom-styles', get_template_directory_uri() . '/style.css' );
/**
* making sure css from block styles gets loaded on front-end
* TODO: unify both css files into one stylesheet
*/
wp_register_style( 'block-styles', get_theme_file_uri( 'block-styles.css' ) );
}
wp_enqueue_style( 'custom-styles' );
wp_enqueue_style( 'block-styles' );
function autonomic_block_styles() {
/**
* Enable support for block editor styles
* @link https://developer.wordpress.org/themes/basics/theme-functions/#theme-support-in-block-themes
*/
add_theme_support( 'editor-styles' );
add_theme_support( 'wp-block-styles' );
add_editor_style( 'block-styles.css' );
}
add_action( 'after_setup_theme', 'autonomic_block_styles' );
function autonomic_theme_scripts() {
// this is also for block styles
wp_enqueue_script( 'autonomic-block-styles', get_theme_file_uri( '/js/block-styles.js' ), array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post' ), filemtime( get_theme_file_uri( '/js/block-styles.js' ) ));
}
add_action( 'enqueue_block_editor_assets', 'autonomic_theme_scripts' );