Make WordPress Themes

source: multisport/1.2.3/inc/customizer.php

Last change on this file was 109260, checked in by themedropbox, 7 years ago

New version of MultiSport - 1.2.3

File size: 4.4 KB
Line 
1<?php
2
3if ( ! function_exists( 'multisport_customize_register' ) ) :
4        /**
5         * Add postMessage support for site title and description for the Theme Customizer.
6         *
7         */
8        function multisport_customize_register( $wp_customize ) {
9
10                /**
11                 * Add Footer Section
12                 */
13                $wp_customize->add_section(
14                        'multisport_footer_section',
15                        array(
16                                'title'       => __( 'Footer', 'multisport' ),
17                                'capability'  => 'edit_theme_options',
18                        )
19                );
20               
21                // Add Footer Copyright Text
22                $wp_customize->add_setting(
23                        'multisport_footer_copyright',
24                        array(
25                            'default'           => '',
26                            'sanitize_callback' => 'sanitize_text_field',
27                        )
28                );
29
30                $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'multisport_footer_copyright',
31                array(
32                    'label'          => __( 'Copyright Text', 'multisport' ),
33                    'section'        => 'multisport_footer_section',
34                    'settings'       => 'multisport_footer_copyright',
35                    'type'           => 'text',
36                    )
37                )
38                );
39
40                /**
41             * Add Animations Section
42             */
43            $wp_customize->add_section(
44                'multisport_animations_display',
45                array(
46                    'title'       => __( 'Animations', 'multisport' ),
47                    'capability'  => 'edit_theme_options',
48                )
49            );
50
51            // Add display Animations option
52            $wp_customize->add_setting(
53                    'multisport_animations_display',
54                    array(
55                            'default'           => 1,
56                            'sanitize_callback' => 'multisport_sanitize_checkbox',
57                    )
58            );
59
60            $wp_customize->add_control( new WP_Customize_Control( $wp_customize,
61                                'multisport_animations_display',
62                                    array(
63                                        'label'          => __( 'Enable Animations', 'multisport' ),
64                                        'section'        => 'multisport_animations_display',
65                                        'settings'       => 'multisport_animations_display',
66                                        'type'           => 'checkbox',
67                                    )
68                                )
69            );
70
71            /**
72                 * Add Slider Section
73                 */
74                $wp_customize->add_section(
75                        'multisport_slider_section',
76                        array(
77                                'title'       => __( 'Slider', 'multisport' ),
78                                'capability'  => 'edit_theme_options',
79                        )
80                );
81
82                $wp_customize->add_setting(
83                                'multisport_slider_display',
84                                array(
85                                                'default'           => 0,
86                                                'sanitize_callback' => 'multisport_sanitize_checkbox',
87                                )
88                );
89
90                $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'multisport_slider_display',
91                                                                array(
92                                                                        'label'          => __( 'Display Slider on a Static Front Page', 'multisport' ),
93                                                                        'section'        => 'multisport_slider_section',
94                                                                        'settings'       => 'multisport_slider_display',
95                                                                        'type'           => 'checkbox',
96                                                                )
97                                                        )
98                );
99               
100                for ($i = 1; $i <= 3; ++$i) {
101               
102                        $slideImageId = 'multisport_slide'.$i.'_image';
103                        $defaultSliderImagePath = get_template_directory_uri().'/images/slider/'.$i.'.jpg';
104                       
105                        // Add Slide Background Image
106                        $wp_customize->add_setting( $slideImageId,
107                                array(
108                                        'default' => $defaultSliderImagePath,
109                                        'sanitize_callback' => 'multisport_sanitize_url'
110                                )
111                        );
112
113                        $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, $slideImageId,
114                                        array(
115                                                'label'          => sprintf( esc_html__( 'Slide #%s Image', 'multisport' ), $i ),
116                                                'section'        => 'multisport_slider_section',
117                                                'settings'   => $slideImageId,
118                                        ) 
119                                )
120                        );
121                }
122        }
123endif; // multisport_customize_register
124add_action( 'customize_register', 'multisport_customize_register' );
125
126if ( ! function_exists( 'multisport_sanitize_checkbox' ) ) :
127        /**
128         * Sanitization callback for 'checkbox' type controls. This callback sanitizes `$checked`
129         * as a boolean value, either TRUE or FALSE.
130         *
131         * @param bool $checked Whether the checkbox is checked.
132         * @return bool Whether the checkbox is checked.
133         */
134        function multisport_sanitize_checkbox( $checked ) {
135                // Boolean check.
136                return ( ( isset( $checked ) && true == $checked ) ? true : false );
137        }
138endif; // multisport_sanitize_checkbox
139
140if ( ! function_exists( 'multisport_sanitize_url' ) ) :
141
142        function multisport_sanitize_url( $url ) {
143                return esc_url_raw( $url );
144        }
145
146endif; // multisport_sanitize_url
Note: See TracBrowser for help on using the repository browser.