2023-01-21 12:31:45 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
add_action('init', 'custom_stylesheet');
|
|
|
|
|
|
|
|
function custom_stylesheet() {
|
|
|
|
wp_register_style( 'custom-styles', get_template_directory_uri() . '/style.css' );
|
2023-08-29 10:37:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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' ) );
|
2024-09-11 10:40:59 +00:00
|
|
|
wp_enqueue_style( 'custom-styles' );
|
|
|
|
wp_enqueue_style( 'block-styles' );
|
2023-01-21 12:31:45 +00:00
|
|
|
}
|
2024-09-11 10:40:59 +00:00
|
|
|
add_action( 'after_setup_theme', 'autonomic_block_styles');
|
2023-08-29 10:37:47 +00:00
|
|
|
|
|
|
|
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' );
|
2023-08-29 10:41:54 +00:00
|
|
|
}
|
|
|
|
add_action( 'after_setup_theme', 'autonomic_block_styles' );
|
|
|
|
|
2024-09-11 10:40:59 +00:00
|
|
|
// stage style.css on editor
|
|
|
|
function enqueue_editor_styles() {
|
|
|
|
wp_enqueue_style( 'editor-styles', get_template_directory_uri() . '/editor-style.css' );
|
|
|
|
}
|
|
|
|
add_action( 'enqueue_block_editor_assets', 'enqueue_editor_styles' );
|
|
|
|
|
2023-08-29 10:41:54 +00:00
|
|
|
function autonomic_theme_scripts() {
|
|
|
|
// this is also for block styles
|
2023-08-29 10:53:44 +00:00
|
|
|
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' ) ));
|
2023-08-29 10:41:54 +00:00
|
|
|
}
|
2024-04-01 10:10:14 +00:00
|
|
|
add_action( 'enqueue_block_editor_assets', 'autonomic_theme_scripts' );
|
|
|
|
|
|
|
|
|
|
|
|
// Code for enabling line breaks in post excerpts
|
|
|
|
|
|
|
|
define('EXCERPT_RARELY', '{[}]');
|
|
|
|
define('EXCERPT_BR', nl2br(PHP_EOL));
|
|
|
|
|
|
|
|
function so306588_trim_excerpt_custom($text = '')
|
|
|
|
{
|
|
|
|
add_filter('the_content', 'so306588_trim_excerpt_custom_mark', 6);
|
|
|
|
|
|
|
|
// get through origin filter
|
|
|
|
$text = wp_trim_excerpt($text);
|
|
|
|
|
|
|
|
remove_filter('the_content', 'so306588_trim_excerpt_custom_mark', 6);
|
|
|
|
|
|
|
|
return so306588_trim_excerpt_custom_restore($text);
|
|
|
|
}
|
|
|
|
|
|
|
|
function so306588_trim_excerpt_custom_mark($text)
|
|
|
|
{
|
|
|
|
$text = nl2br($text);
|
|
|
|
return str_replace(EXCERPT_BR, EXCERPT_RARELY, $text);
|
|
|
|
}
|
|
|
|
|
|
|
|
function so306588_trim_excerpt_custom_restore($text)
|
|
|
|
{
|
|
|
|
return str_replace(EXCERPT_RARELY, EXCERPT_BR, $text);
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove default filter
|
|
|
|
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
|
|
|
|
|
|
|
|
// add custom filter
|
|
|
|
add_filter('get_the_excerpt', 'so306588_trim_excerpt_custom');
|