-
Notifications
You must be signed in to change notification settings - Fork 44
/
editor-funcs.php
230 lines (204 loc) · 9.72 KB
/
editor-funcs.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php //その他設定に必要な定数や関数
/**
* Cocoon WordPress Theme
* @author: yhira
* @link: https://wp-cocoon.com/
* @license: http://www.gnu.org/licenses/gpl-2.0.html GPL v2 or later
*/
if ( !defined( 'ABSPATH' ) ) exit;
//Gutenbergエディターの有効化
define('OP_GUTENBERG_EDITOR_ENABLE', 'gutenberg_editor_enable');
if ( !function_exists( 'is_gutenberg_editor_enable' ) ):
function is_gutenberg_editor_enable(){
return get_theme_option(OP_GUTENBERG_EDITOR_ENABLE, 1);
}
endif;
//Gutenbergを無効化する場合
if (!is_gutenberg_editor_enable()) {
add_filter('gutenberg_can_edit_post_type', '__return_false');
add_filter('use_block_editor_for_post', '__return_false');
}
add_action('after_setup_theme', 'after_setup_theme_gutenberg_editor_setup');
if ( !function_exists( 'after_setup_theme_gutenberg_editor_setup' ) ):
function after_setup_theme_gutenberg_editor_setup(){
//Gutenbergエディターにワイドボタン表示
add_theme_support( 'align-wide' );
// //ブロックスタイルに読み込み
// add_theme_support( 'wp-block-styles' );
// //埋め込み要素のレスポンシブスタイルを適用する
// add_theme_support( 'responsive-embeds' );
}
endif;
//ビジュアルエディタースタイル
define('OP_VISUAL_EDITOR_STYLE_ENABLE', 'visual_editor_style_enable');
if ( !function_exists( 'is_visual_editor_style_enable' ) ):
function is_visual_editor_style_enable(){
return get_theme_option(OP_VISUAL_EDITOR_STYLE_ENABLE, 1);
}
endif;
//エディター背景色
define('OP_EDITOR_BACKGROUND_COLOR', 'editor_background_color');
if ( !function_exists( 'get_editor_background_color' ) ):
function get_editor_background_color(){
return get_theme_option(OP_EDITOR_BACKGROUND_COLOR);
}
endif;
//エディター文字色
define('OP_EDITOR_TEXT_COLOR', 'editor_text_color');
if ( !function_exists( 'get_editor_text_color' ) ):
function get_editor_text_color(){
return get_theme_option(OP_EDITOR_TEXT_COLOR);
}
endif;
//タグをチェックリストにするか
define('OP_EDITOR_TAG_CHECK_LIST_ENABLE', 'editor_tag_check_list_enable');
if ( !function_exists( 'is_editor_tag_check_list_enable' ) ):
function is_editor_tag_check_list_enable(){
return get_theme_option(OP_EDITOR_TAG_CHECK_LIST_ENABLE);
}
endif;
//ルビボタン有効
define('OP_BLOCK_EDITOR_RUBY_BUTTON_VISIBLE', 'block_editor_ruby_button_visible');
if ( !function_exists( 'is_block_editor_ruby_button_visible' ) ):
function is_block_editor_ruby_button_visible(){
return get_theme_option(OP_BLOCK_EDITOR_RUBY_BUTTON_VISIBLE, 1);
}
endif;
//書式のクリアボタン有効
define('OP_BLOCK_EDITOR_CLEAR_FORMAT_BUTTON_VISIBLE', 'block_editor_clear_format_button_visible');
if ( !function_exists( 'is_block_editor_clear_format_button_visible' ) ):
function is_block_editor_clear_format_button_visible(){
return get_theme_option(OP_BLOCK_EDITOR_CLEAR_FORMAT_BUTTON_VISIBLE, 1);
}
endif;
//ブロックエディターインラインスタイルドロップダウン有効
define('OP_BLOCK_EDITOR_LETTER_STYLE_DROPDOWN_VISIBLE', 'block_editor_letter_style_dropdown_visible');
if ( !function_exists( 'is_block_editor_letter_style_dropdown_visible' ) ):
function is_block_editor_letter_style_dropdown_visible(){
return get_theme_option(OP_BLOCK_EDITOR_LETTER_STYLE_DROPDOWN_VISIBLE, 1);
}
endif;
//ブロックエディターマーカースタイルドロップダウン有効
define('OP_BLOCK_EDITOR_MARKER_STYLE_DROPDOWN_VISIBLE', 'block_editor_marker_style_dropdown_visible');
if ( !function_exists( 'is_block_editor_marker_style_dropdown_visible' ) ):
function is_block_editor_marker_style_dropdown_visible(){
return get_theme_option(OP_BLOCK_EDITOR_MARKER_STYLE_DROPDOWN_VISIBLE, 1);
}
endif;
//ブロックエディターバッジスタイルドロップダウン有効
define('OP_BLOCK_EDITOR_BADGE_STYLE_DROPDOWN_VISIBLE', 'block_editor_badge_style_dropdown_visible');
if ( !function_exists( 'is_block_editor_badge_style_dropdown_visible' ) ):
function is_block_editor_badge_style_dropdown_visible(){
return get_theme_option(OP_BLOCK_EDITOR_BADGE_STYLE_DROPDOWN_VISIBLE, 1);
}
endif;
//ブロックエディター文字サイズスタイルドロップダウン有効
define('OP_BLOCK_EDITOR_FONT_SIZE_STYLE_DROPDOWN_VISIBLE', 'block_editor_font_size_style_dropdown_visible');
if ( !function_exists( 'is_block_editor_font_size_style_dropdown_visible' ) ):
function is_block_editor_font_size_style_dropdown_visible(){
return get_theme_option(OP_BLOCK_EDITOR_FONT_SIZE_STYLE_DROPDOWN_VISIBLE, 1);
}
endif;
//ブロックエディター汎用ショートコードドロップダウン有効
define('OP_BLOCK_EDITOR_GENERAL_SHORTCODE_DROPDOWN_VISIBLE', 'block_editor_general_shortcode_dropdown_visible');
if ( !function_exists( 'is_block_editor_general_shortcode_dropdown_visible' ) ):
function is_block_editor_general_shortcode_dropdown_visible(){
return get_theme_option(OP_BLOCK_EDITOR_GENERAL_SHORTCODE_DROPDOWN_VISIBLE, 1);
}
endif;
//ブロックエディターテンプレートショートコードドロップダウン有効
define('OP_BLOCK_EDITOR_TEMPLATE_SHORTCODE_DROPDOWN_VISIBLE', 'block_editor_template_shortcode_dropdown_visible');
if ( !function_exists( 'is_block_editor_template_shortcode_dropdown_visible' ) ):
function is_block_editor_template_shortcode_dropdown_visible(){
return get_theme_option(OP_BLOCK_EDITOR_TEMPLATE_SHORTCODE_DROPDOWN_VISIBLE, 1);
}
endif;
//ブロックエディターアフィリエイトショートコードドロップダウン有効
define('OP_BLOCK_EDITOR_AFFILIATE_SHORTCODE_DROPDOWN_VISIBLE', 'block_editor_affiliate_shortcode_dropdown_visible');
if ( !function_exists( 'is_block_editor_affiliate_shortcode_dropdown_visible' ) ):
function is_block_editor_affiliate_shortcode_dropdown_visible(){
return get_theme_option(OP_BLOCK_EDITOR_AFFILIATE_SHORTCODE_DROPDOWN_VISIBLE, 1);
}
endif;
//ブロックエディターランキングショートコードドロップダウン有効
define('OP_BLOCK_EDITOR_RANKING_SHORTCODE_DROPDOWN_VISIBLE', 'block_editor_ranking_shortcode_dropdown_visible');
if ( !function_exists( 'is_block_editor_ranking_shortcode_dropdown_visible' ) ):
function is_block_editor_ranking_shortcode_dropdown_visible(){
return get_theme_option(OP_BLOCK_EDITOR_RANKING_SHORTCODE_DROPDOWN_VISIBLE, 1);
}
endif;
//ブロックエディタースタイルブロックオプション有効
define('OP_BLOCK_EDITOR_STYLE_BLOCK_OPTION_VISIBLE', 'block_editor_style_block_option_visible');
if ( !function_exists( 'is_block_editor_style_block_option_visible' ) ):
function is_block_editor_style_block_option_visible(){
return get_theme_option(OP_BLOCK_EDITOR_STYLE_BLOCK_OPTION_VISIBLE, 1);
}
endif;
//拡張カラーパレット色A
define('OP_BLOCK_EDITOR_EXTENDED_PALETTE_COLOR_A', 'block_editor_extended_palette_color_a');
if ( !function_exists( 'get_block_editor_extended_palette_color_a' ) ):
function get_block_editor_extended_palette_color_a(){
$default_color = '#fef4f4';//桜色
$color = get_theme_option(OP_BLOCK_EDITOR_EXTENDED_PALETTE_COLOR_A, $default_color);
return $color ? $color : $default_color;
}
endif;
//拡張カラーパレット色B
define('OP_BLOCK_EDITOR_EXTENDED_PALETTE_COLOR_B', 'block_editor_extended_palette_color_b');
if ( !function_exists( 'get_block_editor_extended_palette_color_b' ) ):
function get_block_editor_extended_palette_color_b(){
$default_color = '#f8f4e6';//象牙色
$color = get_theme_option(OP_BLOCK_EDITOR_EXTENDED_PALETTE_COLOR_B, $default_color);
return $color ? $color : $default_color;
}
endif;
//拡張カラーパレット色C
define('OP_BLOCK_EDITOR_EXTENDED_PALETTE_COLOR_C', 'block_editor_extended_palette_color_c');
if ( !function_exists( 'get_block_editor_extended_palette_color_c' ) ):
function get_block_editor_extended_palette_color_c(){
$default_color = '#eaf4fc';//月白色
$color = get_theme_option(OP_BLOCK_EDITOR_EXTENDED_PALETTE_COLOR_C, $default_color);
return $color ? $color : $default_color;
}
endif;
//拡張カラーパレット色D
define('OP_BLOCK_EDITOR_EXTENDED_PALETTE_COLOR_D', 'block_editor_extended_palette_color_d');
if ( !function_exists( 'get_block_editor_extended_palette_color_d' ) ):
function get_block_editor_extended_palette_color_d(){
$default_color = '#eaedf7';//白菫色色
$color = get_theme_option(OP_BLOCK_EDITOR_EXTENDED_PALETTE_COLOR_D, $default_color);
return $color ? $color : $default_color;
}
endif;
//拡張カラーパレット色E
define('OP_BLOCK_EDITOR_EXTENDED_PALETTE_COLOR_E', 'block_editor_extended_palette_color_e');
if ( !function_exists( 'get_block_editor_extended_palette_color_e' ) ):
function get_block_editor_extended_palette_color_e(){
$default_color = '#e8ecef';//#e8ecef色
$color = get_theme_option(OP_BLOCK_EDITOR_EXTENDED_PALETTE_COLOR_E, $default_color);
return $color ? $color : $default_color;
}
endif;
//拡張カラーパレット色F
define('OP_BLOCK_EDITOR_EXTENDED_PALETTE_COLOR_F', 'block_editor_extended_palette_color_f');
if ( !function_exists( 'get_block_editor_extended_palette_color_f' ) ):
function get_block_editor_extended_palette_color_f(){
$default_color = '#f8fbf8';//白磁色
$color = get_theme_option(OP_BLOCK_EDITOR_EXTENDED_PALETTE_COLOR_F, $default_color);
return $color ? $color : $default_color;
}
endif;
//タイトル等の文字数カウンター表示
define('OP_ADMIN_EDITOR_COUNTER_VISIBLE', 'admin_editor_counter_visible');
if ( !function_exists( 'is_admin_editor_counter_visible' ) ):
function is_admin_editor_counter_visible(){
return get_theme_option(OP_ADMIN_EDITOR_COUNTER_VISIBLE, 1);
}
endif;
//ページ公開前に確認アラートを出す
define('OP_CONFIRMATION_BEFORE_PUBLISH', 'confirmation_before_publish');
if ( !function_exists( 'is_confirmation_before_publish' ) ):
function is_confirmation_before_publish(){
return get_theme_option(OP_CONFIRMATION_BEFORE_PUBLISH, 1);
}
endif;