add_section( 'aics_heading_design', array( 'title' => __( '見出しデザイン設定', 'ai-creative-studio' ), 'priority' => 45, 'description' => __( 'H1〜H6見出しのデザインをカスタマイズします。', 'ai-creative-studio' ), ) ); // H1 見出し設定 $wp_customize->add_setting( 'aics_h1_color', array( 'default' => '#1f2937', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'aics_h1_color', array( 'label' => __( 'H1 文字色', 'ai-creative-studio' ), 'section' => 'aics_heading_design', 'settings' => 'aics_h1_color', ) ) ); $wp_customize->add_setting( 'aics_h1_padding_left', array( 'default' => '0', 'sanitize_callback' => 'absint', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'aics_h1_padding_left', array( 'label' => __( 'H1 左余白(px)', 'ai-creative-studio' ), 'section' => 'aics_heading_design', 'type' => 'number', 'input_attrs' => array( 'min' => 0, 'max' => 100, 'step' => 1, ), ) ); $wp_customize->add_setting( 'aics_h1_padding_right', array( 'default' => '0', 'sanitize_callback' => 'absint', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'aics_h1_padding_right', array( 'label' => __( 'H1 右余白(px)', 'ai-creative-studio' ), 'section' => 'aics_heading_design', 'type' => 'number', 'input_attrs' => array( 'min' => 0, 'max' => 100, 'step' => 1, ), ) ); // H2 見出し設定 $wp_customize->add_setting( 'aics_h2_color', array( 'default' => '#1f2937', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'aics_h2_color', array( 'label' => __( 'H2 文字色', 'ai-creative-studio' ), 'section' => 'aics_heading_design', 'settings' => 'aics_h2_color', ) ) ); $wp_customize->add_setting( 'aics_h2_padding_left', array( 'default' => '0', 'sanitize_callback' => 'absint', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'aics_h2_padding_left', array( 'label' => __( 'H2 左余白(px)', 'ai-creative-studio' ), 'section' => 'aics_heading_design', 'type' => 'number', 'input_attrs' => array( 'min' => 0, 'max' => 100, 'step' => 1, ), ) ); $wp_customize->add_setting( 'aics_h2_padding_right', array( 'default' => '0', 'sanitize_callback' => 'absint', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'aics_h2_padding_right', array( 'label' => __( 'H2 右余白(px)', 'ai-creative-studio' ), 'section' => 'aics_heading_design', 'type' => 'number', 'input_attrs' => array( 'min' => 0, 'max' => 100, 'step' => 1, ), ) ); // H3 見出し設定 $wp_customize->add_setting( 'aics_h3_color', array( 'default' => '#374151', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'aics_h3_color', array( 'label' => __( 'H3 文字色', 'ai-creative-studio' ), 'section' => 'aics_heading_design', 'settings' => 'aics_h3_color', ) ) ); $wp_customize->add_setting( 'aics_h3_padding_left', array( 'default' => '0', 'sanitize_callback' => 'absint', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'aics_h3_padding_left', array( 'label' => __( 'H3 左余白(px)', 'ai-creative-studio' ), 'section' => 'aics_heading_design', 'type' => 'number', 'input_attrs' => array( 'min' => 0, 'max' => 100, 'step' => 1, ), ) ); $wp_customize->add_setting( 'aics_h3_padding_right', array( 'default' => '0', 'sanitize_callback' => 'absint', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'aics_h3_padding_right', array( 'label' => __( 'H3 右余白(px)', 'ai-creative-studio' ), 'section' => 'aics_heading_design', 'type' => 'number', 'input_attrs' => array( 'min' => 0, 'max' => 100, 'step' => 1, ), ) ); // H4 見出し設定 $wp_customize->add_setting( 'aics_h4_color', array( 'default' => '#374151', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'aics_h4_color', array( 'label' => __( 'H4 文字色', 'ai-creative-studio' ), 'section' => 'aics_heading_design', 'settings' => 'aics_h4_color', ) ) ); $wp_customize->add_setting( 'aics_h4_padding_left', array( 'default' => '0', 'sanitize_callback' => 'absint', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'aics_h4_padding_left', array( 'label' => __( 'H4 左余白(px)', 'ai-creative-studio' ), 'section' => 'aics_heading_design', 'type' => 'number', 'input_attrs' => array( 'min' => 0, 'max' => 100, 'step' => 1, ), ) ); $wp_customize->add_setting( 'aics_h4_padding_right', array( 'default' => '0', 'sanitize_callback' => 'absint', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'aics_h4_padding_right', array( 'label' => __( 'H4 右余白(px)', 'ai-creative-studio' ), 'section' => 'aics_heading_design', 'type' => 'number', 'input_attrs' => array( 'min' => 0, 'max' => 100, 'step' => 1, ), ) ); // H5 見出し設定 $wp_customize->add_setting( 'aics_h5_color', array( 'default' => '#4b5563', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'aics_h5_color', array( 'label' => __( 'H5 文字色', 'ai-creative-studio' ), 'section' => 'aics_heading_design', 'settings' => 'aics_h5_color', ) ) ); // H6 見出し設定 $wp_customize->add_setting( 'aics_h6_color', array( 'default' => '#4b5563', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'aics_h6_color', array( 'label' => __( 'H6 文字色', 'ai-creative-studio' ), 'section' => 'aics_heading_design', 'settings' => 'aics_h6_color', ) ) ); } add_action( 'customize_register', 'aics_heading_customize_register' ); /** * 見出しデザインのCSS出力 */ function aics_heading_customizer_css() { // H1設定取得 $h1_color = get_theme_mod( 'aics_h1_color', '#1f2937' ); $h1_padding_left = get_theme_mod( 'aics_h1_padding_left', 0 ); $h1_padding_right = get_theme_mod( 'aics_h1_padding_right', 0 ); // H2設定取得 $h2_color = get_theme_mod( 'aics_h2_color', '#1f2937' ); $h2_padding_left = get_theme_mod( 'aics_h2_padding_left', 0 ); $h2_padding_right = get_theme_mod( 'aics_h2_padding_right', 0 ); // H3設定取得 $h3_color = get_theme_mod( 'aics_h3_color', '#374151' ); $h3_padding_left = get_theme_mod( 'aics_h3_padding_left', 0 ); $h3_padding_right = get_theme_mod( 'aics_h3_padding_right', 0 ); // H4設定取得 $h4_color = get_theme_mod( 'aics_h4_color', '#374151' ); $h4_padding_left = get_theme_mod( 'aics_h4_padding_left', 0 ); $h4_padding_right = get_theme_mod( 'aics_h4_padding_right', 0 ); // H5, H6設定取得 $h5_color = get_theme_mod( 'aics_h5_color', '#4b5563' ); $h6_color = get_theme_mod( 'aics_h6_color', '#4b5563' ); $custom_css = " /* 見出しデザインカスタマイズ */ .entry-content h1, .page-content h1 { color: {$h1_color}; padding-left: {$h1_padding_left}px; padding-right: {$h1_padding_right}px; } .entry-content h2, .page-content h2 { color: {$h2_color}; padding-left: {$h2_padding_left}px; padding-right: {$h2_padding_right}px; } .entry-content h3, .page-content h3 { color: {$h3_color}; padding-left: {$h3_padding_left}px; padding-right: {$h3_padding_right}px; } .entry-content h4, .page-content h4 { color: {$h4_color}; padding-left: {$h4_padding_left}px; padding-right: {$h4_padding_right}px; } .entry-content h5, .page-content h5 { color: {$h5_color}; } .entry-content h6, .page-content h6 { color: {$h6_color}; } "; wp_add_inline_style( 'aics-style', $custom_css ); } add_action( 'wp_enqueue_scripts', 'aics_heading_customizer_css' );