get_theme_modでデフォルト値が反映されない

php

1<?php2//--------------------------------------------------------------3//サニタイズ4//---------------------------------------------------------------5function gogo_sanitize_float_range( $number, $setting ) {6 // 浮動小数点数に変換7 $number = floatval( $number );8 9 // 0〜1の範囲に収める10 $number = max( 0, min( 1, $number ) );11 12 return $number;13}14function gogo_customize_register( $wp_customize ) {15//-----------------------------------------16//カスタマイザー17//-----------------------------------------18$wp_customize->add_panel( 'gogo_customizer_panel', array(19 'title' => __( '子テーマGoGo!の設定', 'theme_slug' ),20 'priority' => 021 22));23//-----------------------------------------------------------------24//フッター固定CTA25//-----------------------------------------------------------------26$wp_customize->add_section( 'cta_customizer', array(27 'title' => __( 'フッター固定CTAの設定', 'theme_slug' ),28 'priority' => 2,29 'panel'=>'gogo_customizer_panel'30 ));31$wp_customize->add_setting(32 'cta_bg',33 array(34 'default' => '#000000',35 'priority' => 1001,36 'sanitize_callback' => 'sanitize_hex_color'37 )38 ); 39 $wp_customize->add_control(40 new WP_Customize_Color_Control(41 $wp_customize,42 'cta_bg',43 array(44 'section' => 'cta_customizer', 45 'settings' => 'cta_bg', 46 'label' => 'フッター固定CTAの背景色',47 )48 )49 );50 $wp_customize->add_setting(51 'cta_bg_opa',52 array(53 'default' => '0.9',54 'priority' => 1001,55 'sanitize_callback' => 'gogo_sanitize_float_range',56 57 )58 ); 59 $wp_customize->add_control(60 'cta_bg_opa',61 array(62 'section' => 'cta_customizer', 63 'settings' => 'cta_bg_opa', 64 'description' =>'0から1まで0.01単位で設定できます<br>0に近くなるほど透明になります',65 'label' => 'フッター固定CTAの背景色の透明度',66 'type' => 'number',67 'input_attrs' => array(68 'min' => 0,69 'max' => 1,70 'step' => 0.01,71 ),72 )73 );74 75 $wp_customize->add_setting(76 'cta_color',77 array(78 'default' => '#ffffff',79 'priority' => 1001,80 'sanitize_callback' => 'sanitize_hex_color'81 )82 ); 83 $wp_customize->add_control(84 new WP_Customize_Color_Control(85 $wp_customize,86 'cta_color',87 array(88 'section' => 'cta_customizer', 89 'settings' => 'cta_color', 90 'label' => 'フッター固定CTAのマイクロコピーの色',91 )92 )93 );94 $wp_customize->add_setting(95 'cta_red',96 array(97 'default' => '#ff3131',98 'priority' => 1001,99 'sanitize_callback' => 'sanitize_hex_color'100 )101 ); 102 $wp_customize->add_control(103 new WP_Customize_Color_Control(104 $wp_customize,105 'cta_red',106 array(107 'section' => 'cta_customizer', 108 'settings' => 'cta_red', 109 'label' => '赤系ボタン',110 )111 )112 );113 $wp_customize->add_setting(114 'cta_blue',115 array(116 'default' => '#0076ff',117 'priority' => 1001,118 'sanitize_callback' => 'sanitize_hex_color'119 )120 ); 121 $wp_customize->add_control(122 new WP_Customize_Color_Control(123 $wp_customize,124 'cta_blue',125 array(126 'section' => 'cta_customizer', 127 'settings' => 'cta_blue', 128 'label' => '青系ボタン',129 )130 )131 );132 $wp_customize->add_setting(133 'cta_green',134 array(135 'default' => '#42d800',136 'priority' => 1001,137 'sanitize_callback' => 'sanitize_hex_color'138 )139 ); 140 $wp_customize->add_control(141 new WP_Customize_Color_Control(142 $wp_customize,143 'cta_green',144 array(145 'section' => 'cta_customizer', 146 'settings' => 'cta_green', 147 'label' => '緑系ボタン',148 )149 )150 );}151 add_action( 'customize_register', 'gogo_customize_register' );

コメントを投稿

0 コメント