OSDN Git Service

WordPressテンプレート使用ショップデモデータ追加。
[magic3/magic3.git] / templates / shop-isle / inc / customizer / customizer.php
1 <?php
2 /**
3  * Customizer
4  *
5  * @package WordPress
6  * @subpackage Shop Isle
7  */
8
9 /**
10  * Register settings and controls for customize
11  *
12  * @since  1.0.0
13  */
14 function shop_isle_customize_register( $wp_customize ) {
15
16         $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
17
18         $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
19
20         $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
21
22         $wp_customize->get_setting( 'background_color' )->default = '';
23
24         $wp_customize->remove_control( 'display_header_text' );
25
26         /* Sections Customizing */
27
28         $wp_customize->add_panel(
29                 'shop_isle_front_page_sections', array(
30                         'priority' => 42,
31                         'title'    => esc_html__( 'Frontpage sections', 'shop-isle' ),
32                 )
33         );
34 }
35 /**
36  * Repeater Sanitization function
37  *
38  * @param string $input Input.
39  * @return mixed|string|void
40  */
41 function shop_isle_sanitize_repeater( $input ) {
42
43         $input_decoded = json_decode( $input, true );
44         $allowed_html  = array(
45                 'br'     => array(),
46                 'em'     => array(),
47                 'strong' => array(),
48                 'a'      => array(
49                         'href'   => array(),
50                         'class'  => array(),
51                         'id'     => array(),
52                         'target' => array(),
53                 ),
54                 'button' => array(
55                         'class' => array(),
56                         'id'    => array(),
57                 ),
58         );
59
60         if ( ! empty( $input_decoded ) ) {
61                 foreach ( $input_decoded as $boxk => $box ) {
62                         foreach ( $box as $key => $value ) {
63                                 if ( $key == 'text' ) {
64                                         $value                          = html_entity_decode( $value );
65                                         $input_decoded[ $boxk ][ $key ] = wp_kses( $value, $allowed_html );
66                                 } else {
67                                         $input_decoded[ $boxk ][ $key ] = wp_kses_post( force_balance_tags( $value ) );
68                                 }
69                         }
70                 }
71
72                 return json_encode( $input_decoded );
73         }
74
75         return $input;
76 }
77
78 /**
79  * Sanitize checkbox output.
80  */
81 function shop_isle_sanitize_checkbox( $input ) {
82         return ( isset( $input ) && true === (bool) $input ? true : false );
83 }
84
85 /**
86  * Enqueue customize preview script.
87  */
88 function shop_isle_wp_themeisle_customize_preview_js() {
89         wp_enqueue_script( 'wp_themeisle_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true );
90 }
91 add_action( 'customize_preview_init', 'shop_isle_wp_themeisle_customize_preview_js' );