-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
156 lines (137 loc) · 3.85 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
/**
* @copyright (C) Copyright Bobbing Wide 2023-2024
* tt4ai functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package tt4ai
* @since tt4ai v0.0.1
*/
/**
* Register block styles.
*/
/**
* Register custom block styles
*
* @since Twenty Twenty-Four 1.0
* @return void
*/
function tt4ai_block_styles() {
register_block_style(
'core/paragraph',
array(
'name' =>'aiprompt',
'label' =>__( 'AI prompt', 'tt4ai' ),
/*
* Styles for
'inline_style'=>"
.is-style-aiprompt:before {
content: '';
width: 1.5rem;
height: 3rem;
background: var(--wp--preset--color--contrast-2, currentColor);
clip-path: path('M11.93.684v8.039l5.633-5.633 1.216 1.23-5.66 5.66h8.04v1.737H13.2l5.701 5.701-1.23 1.23-5.742-5.742V21h-1.737v-8.094l-5.77 5.77-1.23-1.217 5.743-5.742H.842V9.98h8.162l-5.701-5.7 1.23-1.231 5.66 5.66V.684h1.737Z');
display: block;
}"
*/
)
);
register_block_style(
'core/paragraph',
array(
'name' =>'airesponse',
'label' =>__( 'AI response', 'tt4ai' ),
/*
* Styles variation for post terms
* https://github.com/WordPress/gutenberg/issues/24956
*/
)
);
register_block_style(
'core/paragraph',
array(
'name' =>'revisedprompt',
'label' =>__( 'Revised prompt', 'tt4ai' ),
)
);
register_block_style(
'core/group',
array(
'name' =>'aiprompt',
'label' =>__( 'AI prompt', 'tt4ai' ),
/*
* Styles variation for post terms
* https://github.com/WordPress/gutenberg/issues/24956
*/
)
);
register_block_style(
'core/group',
array(
'name' =>'airesponse',
'label' =>__( 'AI response', 'tt4ai' ),
/*
* Styles variation for post terms
* https://github.com/WordPress/gutenberg/issues/24956
*/
)
);
}
add_action( 'init', 'tt4ai_block_styles' );
/**
* Enqueue block stylesheets.
*/
if ( ! function_exists( 'tt4ai_block_stylesheets' ) ) :
/**
* Enqueue custom block stylesheets
*
* @since Twenty Twenty-Four 1.0
* @return void
*/
function tt4ai_block_stylesheets() {
/**
* The wp_enqueue_block_style() function allows us to enqueue a stylesheet
* for a specific block. These will only get loaded when the block is rendered
* (both in the editor and on the front end), improving performance
* and reducing the amount of data requested by visitors.
*
* See https://make.wordpress.org/core/2021/12/15/using-multiple-stylesheets-per-block/ for more info.
*/
wp_enqueue_block_style(
'core/paragraph',
array(
'handle' => 'tt4ai-paragraph-style-aiprompt',
'src' => get_theme_file_uri( 'css/paragraph-aiprompt.css' ),
'ver' => wp_get_theme( get_template() )->get( 'Version' ),
'path' => get_theme_file_path( 'css/paragraph-aiprompt.css' ),
)
);
}
endif;
add_action( 'init', 'tt4ai_block_stylesheets' );
/**
* Expand shortcodes in the Query loop.
*/
/**
* Filters the rendered shortcode block.
*
* @param $content
* @param $parsed_block
* @param $block
* @return mixed|string
*/
function tt4ai_render_block_core_shortcode( $content, $parsed_block, $block ) {
//echo $content;
bw_trace2();
$content = do_shortcode( $content );
return $content;
}
add_filter( 'render_block_core/shortcode', 'tt4ai_render_block_core_shortcode', 10, 3, );
add_filter( 'render_block_core/paragraph', 'tt4ai_render_block_core_shortcode', 10, 3, );
add_filter( 'render_block_core/post-excerpt', 'tt4ai_render_block_core_post_excerpt', 10, 3 );
add_filter( 'get_the_excerpt', 'tt4ai_get_the_excerpt', 999, 2);
remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
remove_action( 'embed_head', 'wp_print_styles', 20 );
require_once __DIR__ . '/includes/block-overrides.php';
require_once __DIR__ . '/includes/oik-fields-custom-formatting.php';