/
functions.php
2089 lines (1931 loc) · 85.6 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
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php //スキンから親テーマの定義済み関数等をオーバーライドして設定の書き換えが可能
if (!defined('ABSPATH')) exit;
// -----------------------------------------------------------------------------
// skin独自のCocoon設定のデフォルト変更など:
// -----------------------------------------------------------------------------
// site_font_size
// font_awesome_5 default
if (!function_exists('get_site_icon_font')) :
function get_site_icon_font()
{
// return get_theme_option(OP_SITE_ICON_FONT, 'font_awesome_5');
return 'font_awesome_5';
}
endif;
// -----------------------------------------------------------------------------
// skin独自のclass追加:
// -----------------------------------------------------------------------------
// body
add_filter('body_class_additional', function ($classes) {
$classes[] = 'skin-grayish';
return $classes;
});
// -----------------------------------------------------------------------------
// skin独自のメニュー追加:
// -----------------------------------------------------------------------------
// グローバルナビの最後にモバイル用検索BOX流用し、入れる
add_filter('wp_nav_menu_items', 'add_header_spsearchform', 10, 2);
if (!function_exists('add_header_spsearchform')) :
function add_header_spsearchform($navi, $args)
{
ob_start();
get_template_part('skins/skin-grayish-topfull/tmp-grayish/cstm-sns-follow-buttons');
get_template_part('skins/skin-grayish-topfull/tmp-grayish/cstm-mobile-search-button');
$searchform = ob_get_contents();
ob_end_clean();
if ($args->theme_location == NAV_MENU_HEADER) {
$navi .= $searchform;
}
return $navi;
}
endif;
// -----------------------------------------------------------------------------
// skin独自のテーマカスタマイザー:
// -----------------------------------------------------------------------------
// radio, select 共通サニタイズ
function skin_grayish_sanitize_select($input, $setting)
{
// $input = sanitize_key($input);
$choices = $setting->manager->get_control($setting->id)->choices;
return (array_key_exists($input, $choices) ? $input : $setting->default);
}
// number
function skin_grayish_sanitize_number_range($number, $setting)
{
$number = absint($number);
$atts = $setting->manager->get_control($setting->id)->input_attrs;
$min = (isset($atts['min']) ? $atts['min'] : $number);
$max = (isset($atts['max']) ? $atts['max'] : $number);
$step = (isset($atts['step']) ? $atts['step'] : 1);
return ($min <= $number && $number <= $max && is_int($number / $step) ? $number : $setting->default);
}
// アルファ値付きカラーコード変換 てがきノートさんのコード参照
function color_code($key_color, $key_opacity)
{
$code_red = hexdec(substr($key_color, 1, 2));
$code_green = hexdec(substr($key_color, 3, 2));
$code_blue = hexdec(substr($key_color, 5, 2));
// $opacity = intval($key_opacity) / 100;
$opacity = $key_opacity;
return 'rgba(' . $code_red . ',' . $code_green . ',' . $code_blue . ',' . $opacity . ')';
}
// 英字フォントとセットになる日本語フォント Cocoon設定のフォントを設定
//フォント 親テーマ all-forms.phpより参考
// $options = array(
// 'hiragino' => __('ヒラギノ角ゴ, メイリオ', THEME_NAME) . __('(デフォルト)', THEME_NAME),
// 'meiryo' => __('メイリオ, ヒラギノ角ゴ', THEME_NAME),
// 'yu_gothic' => __('游ゴシック体, ヒラギノ角ゴ', THEME_NAME),
// 'ms_pgothic' => __('MS Pゴシック, ヒラギノ角ゴ', THEME_NAME),
// 'noto_sans_jp' => __('Noto Sans JP(WEBフォント)', THEME_NAME),
// 'noto_serif_jp' => __('Noto Serif JP(WEBフォント)', THEME_NAME),
// 'mplus_1p' => __('Mplus 1p(WEBフォント)', THEME_NAME),
// 'rounded_mplus_1c' => __('Rounded Mplus 1c(WEBフォント)', THEME_NAME),
// 'kosugi' => __('小杉ゴシック(WEBフォント)', THEME_NAME),
// 'kosugi_maru' => __('小杉丸ゴシック(WEBフォント)', THEME_NAME),
// // 'hannari' => __( 'はんなり明朝(WEBフォント)', THEME_NAME ),
// // 'kokoro' => __( 'こころ明朝(WEBフォント)', THEME_NAME ),
// 'sawarabi_gothic' => __('さわらびゴシック(WEBフォント)', THEME_NAME),
// 'sawarabi_mincho' => __('さわらび明朝(WEBフォント)', THEME_NAME),
// '' => __('指定なし', THEME_NAME),
// );
if (!function_exists('skin_get_site_font_family')) :
function skin_get_site_font_family()
{
// return get_theme_option(OP_SITE_FONT_FAMILY, 'hiragino');
// Cocoon設定のフォント情報をget
$skin_font_set = get_theme_option(OP_SITE_FONT_FAMILY, 'hiragino');
// echo $skin_font_set;
switch ($skin_font_set) {
case 'hiragino':
return 'Meiryo, "Hiragino Kaku Gothic ProN", "Hiragino Sans"';
break;
case 'meiryo':
return 'Meiryo, "Hiragino Kaku Gothic ProN", "Hiragino Sans"';
break;
case 'yu_gothic':
return '"Yu Gothic", Meiryo, "Hiragino Kaku Gothic ProN", "Hiragino Sans"';
break;
case 'ms_pgothic':
return '"MS PGothic", "Hiragino Kaku Gothic ProN", "Hiragino Sans"';
break;
case 'noto_sans_jp':
return '"Noto Sans JP"';
break;
case 'noto_serif_jp':
return '"Noto Serif JP"';
break;
case 'mplus_1p':
return '"M PLUS 1p"';
break;
case 'rounded_mplus_1c':
return '"M PLUS Rounded 1c"';
break;
case 'kosugi':
return '"Kosugi"';
break;
case 'kosugi_maru':
return '"Kosugi Maru"';
break;
case 'sawarabi_gothic':
return '"Sawarabi Gothic"';
break;
case 'sawarabi_mincho':
return '"Sawarabi Mincho"';
break;
default:
return 'Meiryo, "Hiragino Kaku Gothic ProN", "Hiragino Sans"';
}
}
endif;
// Googleフォント読み込みの変更
if (!function_exists('enqueue_skin_grayish_google_fonts')) :
function enqueue_skin_grayish_google_fonts()
{
wp_enqueue_style('skin_grayish-google-fonts', 'https://fonts.googleapis.com/css?family=Roboto+Slab:200,400|Spectral:200,400|Inknut+Antiqua:300,400|Jost:300,400|Lato:300,400|Lora|Montserrat:200,400&display=swap');
}
endif;
add_action('wp_enqueue_scripts', 'enqueue_skin_grayish_google_fonts');
add_action('enqueue_block_editor_assets', 'enqueue_skin_grayish_google_fonts');
// -----------------------------------------------------------------------------
// テーマカスタマイザー タイトル:見出しのGoogleFontの選択を可能に:
// ゆうそうとさんの てがきノートスキン (https://usort.jp/cocoon/)を参考にさせていただきました
// -----------------------------------------------------------------------------
if (!function_exists('skin_grayish_font_customize')) :
function skin_grayish_font_customize($wp_customize)
{
$wp_customize->add_panel(
'font_pat_panel',
array(
'title' => 'skin-grayish: カスタマイズ',
'priority' => 1000,
)
);
$wp_customize->add_section(
'font_pat_section',
array(
'title' => '全体:英字フォント設定',
'panel' => 'font_pat_panel',
'priority' => 1000,
'description' => '<a href="https://cocoon-grayish.na2-factory.com/site-title-set/" target="_blank">英字フォントの適用箇所についてはこちらを参照</a>',
)
);
$wp_customize->add_setting('font_pat_control_radio', array(
'default' => 'font_Montserrat',
'sanitize_callback' => 'skin_grayish_sanitize_select',
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'font_pat_control_radio',
array(
'label' => '英字フォント設定 選択',
'description' => 'ロゴテキスト・グローバルナビメニューや、フロントページ・サイドバーの各見出しに使用する英字フォントを選択できます。※固定ページや投稿のコンテンツは除く。「設定なし」にするとCocoon設定 > 全体設定 > サイトフォント の設定を継承します。',
'section' => 'font_pat_section',
'settings' => 'font_pat_control_radio',
'type' => 'radio',
'choices' => array(
'font_Montserrat' => 'Montserrat(デフォルト)',
'font_Lato' => 'Lato',
'font_InknutAntiqua' => 'Inknut Antiqua(細タイプなし)',
'font_Spectral' => 'Spectral',
'font_Lora' => 'Lora(細タイプなし)',
'font_Jost' => 'Jost',
'font_RobotoSlab' => 'Roboto Slab',
'font_none' => '設定なし',
),
)
)
);
$wp_customize->add_setting('title_font_weight_radio', array(
'default' => 'font_weight_Thin',
'sanitize_callback' => 'skin_grayish_sanitize_select',
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'title_font_weight_radio',
array(
'label' => 'サイトロゴ(テキスト時)のフォント太さ 選択',
'description' => 'ロゴテキストの英字フォントの太さを細(デフォルト)又は普通どちらか選択できます。※フォントによって細いタイプがない場合があります。',
'section' => 'font_pat_section',
'settings' => 'title_font_weight_radio',
'type' => 'radio',
'choices' => array(
'font_weight_Thin' => '細(デフォルト)',
'font_weight_Normal' => '普通',
),
)
)
);
}
endif;
add_action('customize_register', 'skin_grayish_font_customize');
// head内にCSSを追加 英字Google Font
add_action('wp_head', 'skin_grayish_font_css');
if (!function_exists('skin_grayish_font_css')) :
function skin_grayish_font_css()
{
$cocoon_site_font = skin_get_site_font_family();
$style_template = '
<style>
.skin-grayish .navi, .skin-grayish .site-name-text, .skin-grayish .sub-caption, .skin-grayish .mobile-menu-buttons .menu-caption, .skin-grayish .navi-footer, .skin-grayish .menu-drawer, .skin-grayish .logo-menu-button, .skin-grayish .list-new-entries h1, .skin-grayish .list-columns h1, .skin-grayish .list-columns::after, .skin-grayish .related-entry-heading, .skin-grayish .comment-title, .skin-grayish .comment-btn, .skin-grayish .sidebar h3, .skin-grayish .footer h3, .skin-grayish .main-widget-label, .blank-box.bb-tab .bb-label {
font-family: %s;
font-weight: 400;
letter-spacing: 0.1rem;
}
</style>
';
$style_font = '';
if (get_theme_mod('font_pat_control_radio', 'font_Montserrat') === 'font_Montserrat') {
$style_font = '"Montserrat", ' . $cocoon_site_font . ', var(--skin-grayish-default-font), sans-serif';
} elseif (get_theme_mod('font_pat_control_radio', 'font_Montserrat') === 'font_Lato') {
$style_font = '"Lato",' . $cocoon_site_font . ', var(--skin-grayish-default-font), sans-serif';
} elseif (get_theme_mod('font_pat_control_radio', 'font_Montserrat') === 'font_InknutAntiqua') {
$style_font = '"Inknut Antiqua", ' . $cocoon_site_font . ', var(--skin-grayish-default-font), sans-serif';
} elseif (get_theme_mod('font_pat_control_radio', 'font_Montserrat') === 'font_Spectral') {
$style_font = '"Spectral", ' . $cocoon_site_font . ', var(--skin-grayish-default-font), sans-serif';
} elseif (get_theme_mod('font_pat_control_radio', 'font_Montserrat') === 'font_Lora') {
$style_font = '"Lora", ' . $cocoon_site_font . ', var(--skin-grayish-default-font), sans-serif';
} elseif (get_theme_mod('font_pat_control_radio', 'font_Montserrat') === 'font_Jost') {
$style_font = '"Jost", ' . $cocoon_site_font . ', var(--skin-grayish-default-font),sans-serif';
} elseif (get_theme_mod('font_pat_control_radio', 'font_Montserrat') === 'font_RobotoSlab') {
$style_font = '"Roboto Slab", ' . $cocoon_site_font . ', var(--skin-grayish-default-font),sans-serif';
} else {
$style_font = 'inherit';
}
echo sprintf($style_template, $style_font);
}
endif;
// Block Editor編集画面 タブボックスにもカスタマイザーで設定したGoogle Fontを当てる
if (!function_exists('skin_grayish_font_blkeditor')) :
function skin_grayish_font_blkeditor()
{
$cocoon_site_font = skin_get_site_font_family();
$style_template = '
.editor-styles-wrapper .blank-box.bb-tab::before {
font-family: "Font Awesome 5 Free", %s!important;
}
';
$style_template_amazon = '
.editor-styles-wrapper .blank-box.bb-amazon::before {
font-family: "Font Awesome 5 Brands", %s!important;
}
';
$style_font = '';
if (get_theme_mod('font_pat_control_radio', 'font_Montserrat') === 'font_Montserrat') {
$style_font = '"Montserrat", ' . $cocoon_site_font . ', var(--skin-grayish-default-font), sans-serif';
} elseif (get_theme_mod('font_pat_control_radio', 'font_Montserrat') === 'font_Lato') {
$style_font = '"Lato",' . $cocoon_site_font . ', var(--skin-grayish-default-font), sans-serif';
} elseif (get_theme_mod('font_pat_control_radio', 'font_Montserrat') === 'font_InknutAntiqua') {
$style_font = '"Inknut Antiqua", ' . $cocoon_site_font . ', var(--skin-grayish-default-font), sans-serif';
} elseif (get_theme_mod('font_pat_control_radio', 'font_Montserrat') === 'font_Spectral') {
$style_font = '"Spectral", ' . $cocoon_site_font . ', var(--skin-grayish-default-font), sans-serif';
} elseif (get_theme_mod('font_pat_control_radio', 'font_Montserrat') === 'font_Lora') {
$style_font = '"Lora", ' . $cocoon_site_font . ', var(--skin-grayish-default-font), sans-serif';
} elseif (get_theme_mod('font_pat_control_radio', 'font_Montserrat') === 'font_Jost') {
$style_font = '"Jost", ' . $cocoon_site_font . ', var(--skin-grayish-default-font),sans-serif';
} elseif (get_theme_mod('font_pat_control_radio', 'font_Montserrat') === 'font_RobotoSlab') {
$style_font = '"Roboto Slab", ' . $cocoon_site_font . ', var(--skin-grayish-default-font),sans-serif';
} else {
$style_font = 'inherit';
}
// echo sprintf($style_template, $style_font);
$style_fontfamily = sprintf($style_template, $style_font);
wp_add_inline_style('wp-block-editor', $style_fontfamily);
$style_fontfamily_amazon = sprintf($style_template_amazon, $style_font);
wp_add_inline_style('wp-block-editor', $style_fontfamily_amazon);
}
endif;
add_action('enqueue_block_editor_assets', 'skin_grayish_font_blkeditor');
// head内にCSSを追加 タイトルフォントの太さ
add_action('wp_head', 'skin_grayish_titlefont_weight');
if (!function_exists('skin_grayish_titlefont_weight')) :
function skin_grayish_titlefont_weight()
{
$style_template = '
<style>
.skin-grayish .header-in .site-name-text {
font-weight: %s;
}
</style>
';
$style_font_weight = '';
if (get_theme_mod('title_font_weight_radio', 'font_weight_Thin') === 'font_weight_Thin') {
$style_font_weight = '200';
} elseif (get_theme_mod('title_font_weight_radio', 'font_weight_Thin') === 'font_weight_Normal') {
$style_font_weight = '400';
}
echo sprintf($style_template, $style_font_weight);
}
endif;
// -----------------------------------------------------------------------------
// テーマカスタマイザー カラーの変更可能:
// Skin Name: 凸凹(Skin URI: https://kitatarian.com/cocoon/)を参考にさせていただきました
// -----------------------------------------------------------------------------
if (!function_exists('skin_grayish_color_customize')) :
function skin_grayish_color_customize($wp_customize)
{
$wp_customize->add_section(
'color_pat_section',
array(
'title' => '全体:カラー設定',
'panel' => 'font_pat_panel',
'priority' => 2000,
'description' => '<a href="https://cocoon-grayish.na2-factory.com/manual-cstm-th-color/" target="_blank">各カラーの適用箇所についてはこちらを参照</a>',
)
);
//テキストカラー --LtGray_S50
$wp_customize->add_setting('colorpicker_text_gray_S50', array(
'default' => '#535252',
'sanitize_callback' => 'sanitize_hex_color',
));
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'colorpicker_text_gray_S50',
array(
'label' => 'テキストカラー',
'description' => 'メニュー・見出し・本文などのテキストカラーを変更。
<br>※空欄の場合はデフォルト値になります。',
'section' => 'color_pat_section',
'settings' => 'colorpicker_text_gray_S50',
)
)
);
//メイン --LtBlue_T0
$wp_customize->add_setting('colorpicker_main_blue_T0', array(
'default' => '#AAC2D2',
'sanitize_callback' => 'sanitize_hex_color',
));
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'colorpicker_main_blue_T0',
array(
'label' => 'メインアクセント 一番明るい青色',
'description' => 'サイトロゴテキストや各テキストリンクのホバー時の色、<br>フロントページのNewPostの色、<br>カテゴリタイトル下線、<br>サイドバー・ウィジェット見出し下線の色、<br>フッター内アクセント線の色を変更。
<br>※空欄の場合はデフォルト値になります。',
'section' => 'color_pat_section',
'settings' => 'colorpicker_main_blue_T0',
)
)
);
//メイン 薄い青 --LtBlue_T70
$wp_customize->add_setting('colorpicker_main_blue_T70', array(
'default' => '#E6EDF2',
'sanitize_callback' => 'sanitize_hex_color',
));
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'colorpicker_main_blue_T70',
array(
'label' => 'メイン 薄い青色',
'description' => 'グローバルナビの3階層目の背景色、<br>フロントページのMoreボタン、次のページへボタン、タグクラウドのホバー時背景色。
<br>※空欄の場合はデフォルト値になります。',
'section' => 'color_pat_section',
'settings' => 'colorpicker_main_blue_T70',
)
)
);
//メイン 一番薄い青 --LtBlue_T90
$wp_customize->add_setting('colorpicker_main_blue_T90', array(
'default' => '#F7F9FB',
'sanitize_callback' => 'sanitize_hex_color',
));
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'colorpicker_main_blue_T90',
array(
'label' => 'メイン 一番薄い青',
'description' => 'フロントページカテゴリー2つ目の背景色、<br>目次・記事下のSNSボタン背景のストライプの青系、<br>一覧ページのページネーションボタン背景色。
<br>※空欄の場合はデフォルト値になります。',
'section' => 'color_pat_section',
'settings' => 'colorpicker_main_blue_T90',
)
)
);
//サブ 濃い青 --LtBlue_S30
$wp_customize->add_setting('colorpicker_main_blue_S30', array(
'default' => '#778893',
'sanitize_callback' => 'sanitize_hex_color',
));
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'colorpicker_main_blue_S30',
array(
'label' => 'サブ 濃い青',
'description' => 'プロフィールname・投稿の日付・アイコン・本文目次の上下線・目次テキスト・SNSシェア・Follow・アピールエリアのボタン等。
<br>※空欄の場合はデフォルト値になります。',
'section' => 'color_pat_section',
'settings' => 'colorpicker_main_blue_S30',
)
)
);
//サブ もっと濃い青 --LtBlue_S50
$wp_customize->add_setting('colorpicker_main_blue_S50', array(
'default' => '#556169',
'sanitize_callback' => 'sanitize_hex_color',
));
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'colorpicker_main_blue_S50',
array(
'label' => 'サブ もっと濃い青',
'description' => 'カテゴリーラベル背景色・記事内タグの枠線とアイコンの色。
<br>※空欄の場合はデフォルト値になります。',
'section' => 'color_pat_section',
'settings' => 'colorpicker_main_blue_S50',
)
)
);
}
endif;
add_action('customize_register', 'skin_grayish_color_customize');
// head内にCSSを追加 CSS変数の上書き
if (!function_exists('skin_grayish_color_customize_css')) :
function skin_grayish_color_customize_css()
{
if (get_theme_mod('colorpicker_text_gray_S50', '#535252')) {
$text_color = esc_attr(get_theme_mod('colorpicker_text_gray_S50', '#535252'));
} else {
$text_color = '#535252';
}
if (get_theme_mod('colorpicker_main_blue_T0', '#AAC2D2')) {
$main_color = esc_attr(get_theme_mod('colorpicker_main_blue_T0', '#AAC2D2'));
} else {
$main_color = '#AAC2D2';
}
if (get_theme_mod('colorpicker_main_blue_T70', '#E6EDF2')) {
$main_thin_color = esc_attr(get_theme_mod('colorpicker_main_blue_T70', '#E6EDF2'));
} else {
$main_thin_color = '#E6EDF2';
}
if (get_theme_mod('colorpicker_main_blue_T90', '#F7F9FB')) {
$main_exthin_color = esc_attr(get_theme_mod('colorpicker_main_blue_T90', '#F7F9FB'));
} else {
$main_exthin_color = '#F7F9FB';
}
if (get_theme_mod('colorpicker_main_blue_S30', '#778893')) {
$sub_color = esc_attr(get_theme_mod('colorpicker_main_blue_S30', '#778893'));
} else {
$sub_color = '#778893';
}
if (get_theme_mod('colorpicker_main_blue_S50', '#556169')) {
$sub_cattag_color = esc_attr(get_theme_mod('colorpicker_main_blue_S50', '#556169'));
} else {
$sub_cattag_color = '#556169';
}
?>
<style type="text/css">
:root {
--skin-grayish-site-name-txt: <?php echo $text_color ?>;
--skin-grayish-a-wrap-txt: <?php echo $text_color ?>;
--skin-grayish-author-description-txt: <?php echo $text_color ?>;
--skin-grayish-site-main-hover: <?php echo $main_color ?>;
--skin-grayish-site-main-thin: <?php echo $main_thin_color ?>;
--skin-grayish-gradient: <?php echo $main_exthin_color ?>;
--skin-grayish-site-sub-color: <?php echo $sub_color ?>;
--skin-grayish-cat-back: <?php echo $sub_cattag_color ?>;
}
</style>
<?php
}
endif;
add_action('wp_head', 'skin_grayish_color_customize_css');
// Block Editor編集画面にもカスタマイザーで設定したカラーを反映させる
if (!function_exists('skin_grayish_color_customize_blkeditor')) :
function skin_grayish_color_customize_blkeditor()
{
if (get_theme_mod('colorpicker_text_gray_S50', '#535252')) {
$text_color = esc_attr(get_theme_mod('colorpicker_text_gray_S50', '#535252'));
} else {
$text_color = '#535252';
}
if (get_theme_mod('colorpicker_main_blue_T0', '#AAC2D2')) {
$main_color = esc_attr(get_theme_mod('colorpicker_main_blue_T0', '#AAC2D2'));
} else {
$main_color = '#AAC2D2';
}
if (get_theme_mod('colorpicker_main_blue_T70', '#E6EDF2')) {
$main_thin_color = esc_attr(get_theme_mod('colorpicker_main_blue_T70', '#E6EDF2'));
} else {
$main_thin_color = '#E6EDF2';
}
if (get_theme_mod('colorpicker_main_blue_T90', '#F7F9FB')) {
$main_exthin_color = esc_attr(get_theme_mod('colorpicker_main_blue_T90', '#F7F9FB'));
} else {
$main_exthin_color = '#F7F9FB';
}
if (get_theme_mod('colorpicker_main_blue_S30', '#778893')) {
$sub_color = esc_attr(get_theme_mod('colorpicker_main_blue_S30', '#778893'));
} else {
$sub_color = '#778893';
}
if (get_theme_mod('colorpicker_main_blue_S50', '#556169')) {
$sub_cattag_color = esc_attr(get_theme_mod('colorpicker_main_blue_S50', '#556169'));
} else {
$sub_cattag_color = '#556169';
}
$style_template =
'
:root {
--skin-grayish-site-name-txt: %s;
--skin-grayish-a-wrap-txt: %s;
--skin-grayish-author-description-txt: %s;
--skin-grayish-site-main-hover: %s;
--skin-grayish-site-main-thin: %s;
--skin-grayish-gradient: %s;
--skin-grayish-site-sub-color: %s;
--skin-grayish-cat-back: %s;
}
';
$style_textcolor = sprintf($style_template, $text_color, $text_color, $text_color, $main_color, $main_thin_color, $main_exthin_color, $sub_color, $sub_cattag_color);
wp_add_inline_style('wp-block-editor', $style_textcolor);
}
endif;
add_action('enqueue_block_editor_assets', 'skin_grayish_color_customize_blkeditor');
// -----------------------------------------------------------------------------
// テーマカスタマイザー フロントページ設定:ヘッダー
// ナビの高さ・背景色・メインビジュアル白ドットON/OFF選択可能・白オーバーレイの不透明度調整
// スクロールアニメーション ON/OFF
// -----------------------------------------------------------------------------
if (!function_exists('skin_grayish_topmv_dotoverlay_customize')) :
function skin_grayish_topmv_dotoverlay_customize($wp_customize)
{
$wp_customize->add_section(
'topmv_section',
array(
'title' => 'フロントページ設定:ヘッダー',
'panel' => 'font_pat_panel',
'priority' => 4000,
'description' => '<a href="https://cocoon-grayish.na2-factory.com/manual-cstm-pcheader/" target="_blank">グローバルナビの高さ等変更についてはこちらを参照</a><br><br><a href="https://cocoon-grayish.na2-factory.com/manual-top-mv/" target="_blank">メインビジュアルについてはこちらを参照</a><br><br><a href="https://cocoon-grayish.na2-factory.com/manual-pc-menu/" target="_blank">グローバルナビのメニュー作成・SNSフォローボタンについてはこちらを参照</a>',
)
);
//グローバルナビの高さ調整
$wp_customize->add_setting('top_navi_size', array(
'default' => '56',
'sanitize_callback' => 'skin_grayish_sanitize_number_range',
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'top_navi_size',
array(
'label' => '【PC】グローバルナビの高さ',
'description' => 'フロントページのグローバルナビの高さ。56px〜100pxの範囲で変更可能です。
<br>※空欄の場合や、範囲外の値の場合は56pxになります。',
'section' => 'topmv_section',
'settings' => 'top_navi_size',
'type' => 'number',
'input_attrs' => array(
'step' => '1',
'min' => '56',
'max' => '100',
),
)
)
);
//グローバルナビの背景色 --LtGray_T70_A50
$wp_customize->add_setting('top_navibg_colorpicker', array(
'default' => '#E4E4E3',
'sanitize_callback' => 'sanitize_hex_color',
));
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'top_navibg_colorpicker',
array(
'label' => '【PC】グローバルナビの背景色',
'description' => 'グローバルナビの背景色。
<br>※空欄の場合はデフォルト値になります。',
'section' => 'topmv_section',
'settings' => 'top_navibg_colorpicker',
)
)
);
//グローバルナビの背景色 透明度の設定 --LtGray_T70_A50
$wp_customize->add_setting('top_navibg_alpha', array(
'default' => 'top_navibg_alpha_5',
'sanitize_callback' => 'skin_grayish_sanitize_select',
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'top_navibg_alpha',
array(
'label' => '【PC】グローバルナビ背景色の不透明度調整',
'description' => '値が大きくなるほど背景色が濃くなります。',
'section' => 'topmv_section',
'settings' => 'top_navibg_alpha',
'type' => 'select',
'choices' => array(
'top_navibg_alpha_5' => '0.5(デフォルト)',
'top_navibg_alpha_0' => '0(背景色なし)',
'top_navibg_alpha_1' => '0.1',
'top_navibg_alpha_2' => '0.2',
'top_navibg_alpha_3' => '0.3',
'top_navibg_alpha_4' => '0.4',
'top_navibg_alpha_6' => '0.6',
'top_navibg_alpha_7' => '0.7',
'top_navibg_alpha_8' => '0.8',
'top_navibg_alpha_9' => '0.9',
'top_navibg_alpha_10' => '1.0(不透明)',
),
)
)
);
//メインビジュアル ドット
$wp_customize->add_setting('topmv_dot_radio', array(
'default' => 'topmv_dot_On',
'sanitize_callback' => 'skin_grayish_sanitize_select',
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'topmv_dot_radio',
array(
'label' => 'メインビジュアル 白ドットのON/OFF',
'description' => 'メインビジュアルの上に白いドットを重ねるかどうかを選択。解像度が低い画像を使用する場合はON推奨',
'section' => 'topmv_section',
'settings' => 'topmv_dot_radio',
'type' => 'radio',
'choices' => array(
'topmv_dot_On' => 'ON(デフォルト)',
'topmv_dot_Off' => 'OFF',
),
)
)
);
//メインビジュアル 白のオーバーレイ
$wp_customize->add_setting('topmv_whovlay_select', array(
'default' => 'topmv_whoverlay_5',
'sanitize_callback' => 'skin_grayish_sanitize_select',
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'topmv_whovlay_select',
array(
'label' => 'メインビジュアル 白オーバーレイの不透明度調整',
'description' => 'メインビジュアルの上に重ねる白の不透明度を調整。値が大きくなるほど白が濃くなります。',
'section' => 'topmv_section',
'settings' => 'topmv_whovlay_select',
'type' => 'select',
'choices' => array(
'topmv_whoverlay_5' => '0.5(デフォルト)',
'topmv_whoverlay_0' => 'OFF',
'topmv_whoverlay_1' => '0.1',
'topmv_whoverlay_2' => '0.2',
'topmv_whoverlay_3' => '0.3',
'topmv_whoverlay_4' => '0.4',
'topmv_whoverlay_6' => '0.6',
'topmv_whoverlay_7' => '0.7',
'topmv_whoverlay_8' => '0.8',
'topmv_whoverlay_9' => '0.9',
),
)
)
);
//メインビジュアル下のスクロールアニメーション
$wp_customize->add_setting('topmv_scrollanim', array(
'default' => 'topmv_scrollanim_On',
'sanitize_callback' => 'skin_grayish_sanitize_select',
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'topmv_scrollanim',
array(
'label' => 'メインビジュアル下のスクロールアニメーションのON/OFF',
'description' => 'メインビジュアルの下部にあるスクロールを促すアニメーションが不要の場合ここでOFF。PC/SP共通の設定になります。',
'section' => 'topmv_section',
'settings' => 'topmv_scrollanim',
'type' => 'radio',
'choices' => array(
'topmv_scrollanim_On' => 'ON(デフォルト)',
'topmv_scrollanim_Off' => 'OFF',
),
)
)
);
// SNSフォローボタンの表示
$settings_data = array(
array(
'label' => 'X(旧Twitter)フォローボタンを表示',
'setting_name' => 'twitter',
),
array(
'label' => 'Facebook フォローボタンを表示',
'setting_name' => 'facebook',
),
array(
'label' => 'はてブ フォローボタンを表示',
'setting_name' => 'hatena',
),
array(
'label' => 'Instagram フォローボタンを表示',
'setting_name' => 'instagram',
),
array(
'label' => 'Pinterest フォローボタンを表示',
'setting_name' => 'pinterest',
),
array(
'label' => 'YouTube フォローボタンを表示',
'setting_name' => 'youtube',
),
array(
'label' => 'LinkedIn フォローボタンを表示',
'setting_name' => 'linkedin',
),
array(
'label' => 'note フォローボタンを表示',
'setting_name' => 'note',
),
array(
'label' => 'Flickr フォローボタンを表示',
'setting_name' => 'flickr',
),
array(
'label' => 'Amazon欲しい物リスト フォローボタンを表示',
'setting_name' => 'amazon',
),
array(
'label' => 'Twitch フォローボタンを表示',
'setting_name' => 'twitch',
),
array(
'label' => '楽天ROOM フォローボタンを表示',
'setting_name' => 'rakuten',
),
array(
'label' => 'Slack フォローボタンを表示',
'setting_name' => 'slack',
),
array(
'label' => 'GitHub フォローボタンを表示',
'setting_name' => 'github',
),
array(
'label' => 'CodePen フォローボタンを表示',
'setting_name' => 'codepen',
),
array(
'label' => 'TikTok フォローボタンを表示',
'setting_name' => 'tiktok',
),
array(
'label' => 'SoundCloud フォローボタンを表示',
'setting_name' => 'soundcloud',
),
array(
'label' => 'LINE フォローボタンを表示',
'setting_name' => 'line',
),
);
foreach ($settings_data as $data) {
$setting_name = 'snsbtn_select_' . sanitize_title($data['setting_name']);
$wp_customize->add_setting($setting_name, array(
'default' => 'snsbtn_select_Off',
'sanitize_callback' => 'skin_grayish_sanitize_select',
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
$setting_name,
array(
'label' => $data['label'],
'description' => 'プロフィールページでURLを入力している場合、グローバルナビにフォローボタンを表示します。
<br>※フロントページ以外のグローバルナビにも表示されます。',
'section' => 'topmv_section',
'settings' => $setting_name,
'type' => 'select',
'choices' => array(
'snsbtn_select_Off' => 'OFF(デフォルト)',
'snsbtn_select_On' => 'ON',
),
)
)
);
}
}
endif;
add_action('customize_register', 'skin_grayish_topmv_dotoverlay_customize');
// head内にCSSを追加
// グローバルナビの高さ調整
add_action('wp_head', 'skin_grayish_top_header_navisize');
if (!function_exists('skin_grayish_top_header_navisize')) :
function skin_grayish_top_header_navisize()
{
if (get_theme_mod('top_navi_size', '56')) {
?>
<style type="text/css">
:root {
--topHeaderNavisize: <?php echo esc_attr(get_theme_mod('top_navi_size', '56')) . 'px' ?>;
}
</style>
<?php
}
}
endif;
// グローバルナビの背景色
add_action('wp_head', 'skin_grayish_top_header_navibg');
if (!function_exists('skin_grayish_top_header_navibg')) :
function skin_grayish_top_header_navibg()
{
if (get_theme_mod('top_navibg_colorpicker', '#E4E4E3')) {
$hex_navi_bgcolor = esc_attr(get_theme_mod('top_navibg_colorpicker', '#E4E4E3'));
} else {
$hex_navi_bgcolor = '#E4E4E3';
}
$style_opacity = '';
if (get_theme_mod('top_navibg_alpha', 'top_navibg_alpha_5') === 'top_navibg_alpha_5') {
$style_opacity = '0.5';
} elseif (get_theme_mod('top_navibg_alpha', 'top_navibg_alpha_5') === 'top_navibg_alpha_0') {
$style_opacity = '0';
} elseif (get_theme_mod('top_navibg_alpha', 'top_navibg_alpha_5') === 'top_navibg_alpha_1') {
$style_opacity = '0.1';
} elseif (get_theme_mod('top_navibg_alpha', 'top_navibg_alpha_5') === 'top_navibg_alpha_2') {
$style_opacity = '0.2';
} elseif (get_theme_mod('top_navibg_alpha', 'top_navibg_alpha_5') === 'top_navibg_alpha_3') {
$style_opacity = '0.3';
} elseif (get_theme_mod('top_navibg_alpha', 'top_navibg_alpha_5') === 'top_navibg_alpha_4') {
$style_opacity = '0.4';
} elseif (get_theme_mod('top_navibg_alpha', 'top_navibg_alpha_5') === 'top_navibg_alpha_6') {
$style_opacity = '0.6';
} elseif (get_theme_mod('top_navibg_alpha', 'top_navibg_alpha_5') === 'top_navibg_alpha_7') {
$style_opacity = '0.7';
} elseif (get_theme_mod('top_navibg_alpha', 'top_navibg_alpha_5') === 'top_navibg_alpha_8') {
$style_opacity = '0.8';
} elseif (get_theme_mod('top_navibg_alpha', 'top_navibg_alpha_5') === 'top_navibg_alpha_9') {
$style_opacity = '0.9';
} elseif (get_theme_mod('top_navibg_alpha', 'top_navibg_alpha_5') === 'top_navibg_alpha_10') {
$style_opacity = '1.0';
} else {
$style_opacity = '0.5';
}
// hex to dec
$style_rgba = '';
$style_rgba = color_code($hex_navi_bgcolor, $style_opacity);
?>
<style type="text/css">
:root {
--topHeaderNaviBgColor: <?php echo $style_rgba ?>;
}
</style>
<?php
}
endif;
// ドット
add_action('wp_head', 'skin_grayish_topmv_dot');
if (!function_exists('skin_grayish_topmv_dot')) :
function skin_grayish_topmv_dot()
{
$style_template = '
<style>
.body.skin-grayish.front-top-page .header::after {
opacity: %s;
visibility: %s;
}
</style>
';
$style_opacity = '';
if (get_theme_mod('topmv_dot_radio', 'topmv_dot_On') === 'topmv_dot_On') {
$style_opacity = '0.7';
} elseif (get_theme_mod('topmv_dot_radio', 'topmv_dot_On') === 'topmv_dot_Off') {
$style_opacity = '0';
}
$style_visibility = '';
if (get_theme_mod('topmv_dot_radio', 'topmv_dot_On') === 'topmv_dot_On') {
$style_visibility = 'visible';
} elseif (get_theme_mod('topmv_dot_radio', 'topmv_dot_On') === 'topmv_dot_Off') {
$style_visibility = 'hidden';
}
echo sprintf($style_template, $style_opacity, $style_visibility);
}
endif;
// 白オーバーレイ
add_action('wp_head', 'skin_grayish_topmv_whovlay');
if (!function_exists('skin_grayish_topmv_whovlay')) :
function skin_grayish_topmv_whovlay()
{
$style_template = '
<style>
.body.skin-grayish.front-top-page .header::before {
opacity: %s;
visibility: %s;
}
</style>
';
$style_opacity = '';