This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Spurs Theme Customizer |
||
4 | * |
||
5 | * @package spurs |
||
6 | */ |
||
7 | |||
8 | // Exit if accessed directly. |
||
9 | defined( 'ABSPATH' ) || exit; |
||
10 | |||
11 | /** |
||
12 | * Add postMessage support for site title and description for the Theme Customizer. |
||
13 | * |
||
14 | * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
||
15 | */ |
||
16 | if ( ! function_exists( 'spurs_customize_register' ) ) { |
||
17 | /** |
||
18 | * Register basic customizer support. |
||
19 | * |
||
20 | * @param object $wp_customize Customizer reference. |
||
21 | */ |
||
22 | function spurs_customize_register( $wp_customize ) { |
||
23 | $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; |
||
24 | $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; |
||
25 | $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; |
||
26 | } |
||
27 | } |
||
28 | add_action( 'customize_register', 'spurs_customize_register' ); |
||
29 | |||
30 | if ( ! function_exists( 'spurs_theme_customize_register' ) ) { |
||
31 | /** |
||
32 | * Register individual settings through customizer's API. |
||
33 | * |
||
34 | * @param WP_Customize_Manager $wp_customize Customizer reference. |
||
35 | */ |
||
36 | function spurs_theme_customize_register( $wp_customize ) { |
||
37 | |||
38 | // Theme layout settings. |
||
39 | $wp_customize->add_section( |
||
40 | 'spurs_theme_layout_options', |
||
41 | array( |
||
42 | 'title' => __( 'Theme Layout Settings', 'spurs' ), |
||
43 | 'capability' => 'edit_theme_options', |
||
44 | 'description' => __( 'Container width and sidebar defaults', 'spurs' ), |
||
45 | 'priority' => 160, |
||
46 | ) |
||
47 | ); |
||
48 | |||
49 | /** |
||
50 | * Select sanitization function |
||
51 | * |
||
52 | * @param string $input Slug to sanitize. |
||
53 | * @param WP_Customize_Setting $setting Setting instance. |
||
54 | * |
||
55 | * @return string Sanitized slug if it is a valid choice; otherwise, the setting default. |
||
56 | */ |
||
57 | function spurs_theme_slug_sanitize_select( $input, $setting ) { |
||
58 | |||
59 | // input must be a slug: lowercase alphanumeric characters, dashes and underscores are allowed only |
||
60 | $input = sanitize_key( $input ); |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
61 | |||
62 | // get the list of possible select options |
||
63 | $choices = $setting->manager->get_control( $setting->id )->choices; |
||
64 | |||
65 | // return input if valid or return default option |
||
66 | return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); |
||
67 | |||
68 | } |
||
69 | |||
70 | $wp_customize->add_setting( |
||
71 | 'spurs_container_type', |
||
72 | array( |
||
73 | 'default' => 'container', |
||
74 | 'type' => 'theme_mod', |
||
75 | 'sanitize_callback' => 'spurs_theme_slug_sanitize_select', |
||
76 | 'capability' => 'edit_theme_options', |
||
77 | ) |
||
78 | ); |
||
79 | |||
80 | $wp_customize->add_control( |
||
81 | new WP_Customize_Control( |
||
82 | $wp_customize, |
||
83 | 'spurs_container_type', array( |
||
84 | 'label' => __( 'Container Width', 'spurs' ), |
||
85 | 'description' => __( 'Use Bootstrap fixed or fluid container?', 'spurs' ), |
||
86 | 'section' => 'spurs_theme_layout_options', |
||
87 | 'settings' => 'spurs_container_type', |
||
88 | 'type' => 'select', |
||
89 | 'choices' => array( |
||
90 | 'container' => __( 'Fixed-width container', 'spurs' ), |
||
91 | 'container-fluid' => __( 'Full-width container', 'spurs' ), |
||
92 | ), |
||
93 | 'priority' => '10', |
||
94 | ) |
||
95 | ) ); |
||
96 | |||
97 | $wp_customize->add_setting( |
||
98 | 'spurs_sidebar_position', |
||
99 | array( |
||
100 | 'default' => 'none', |
||
101 | 'type' => 'theme_mod', |
||
102 | 'sanitize_callback' => 'sanitize_text_field', |
||
103 | 'capability' => 'edit_theme_options', |
||
104 | ) |
||
105 | ); |
||
106 | |||
107 | $wp_customize->add_control( |
||
108 | new WP_Customize_Control( |
||
109 | $wp_customize, |
||
110 | 'spurs_sidebar_position', array( |
||
111 | 'label' => __( 'Default Sidebar Position', 'spurs' ), |
||
112 | 'description' => __( '<b>Applies to all pages and posts.</b> <br /> |
||
113 | <b>Select:</b> right, left, both, or none. <br /> |
||
114 | <b>Note:</b> you can override on individual pages.', |
||
115 | 'spurs' ), |
||
116 | 'section' => 'spurs_theme_layout_options', |
||
117 | 'settings' => 'spurs_sidebar_position', |
||
118 | 'type' => 'select', |
||
119 | 'sanitize_callback' => 'spurs_theme_slug_sanitize_select', |
||
120 | 'choices' => array( |
||
121 | 'none' => __( 'No sidebar', 'spurs' ), |
||
122 | 'left' => __( 'Left sidebar', 'spurs' ), |
||
123 | 'both' => __( 'Left & Right sidebars', 'spurs' ), |
||
124 | 'right' => __( 'Right sidebar', 'spurs' ), |
||
125 | ), |
||
126 | 'priority' => '20', |
||
127 | ) |
||
128 | ) ); |
||
129 | |||
130 | $wp_customize->add_setting( |
||
131 | 'spurs_pagination', |
||
132 | array( |
||
133 | 'default' => 'pagination', |
||
134 | 'type' => 'theme_mod', |
||
135 | 'sanitize_callback' => 'spurs_theme_slug_sanitize_select', |
||
136 | 'capability' => 'edit_theme_options', |
||
137 | ) |
||
138 | ); |
||
139 | |||
140 | $wp_customize->add_control( |
||
141 | new WP_Customize_Control( |
||
142 | $wp_customize, |
||
143 | 'spurs_pagination', array( |
||
144 | 'label' => __( 'Pagination / Load More', 'spurs' ), |
||
145 | 'description' => __( 'Pagination or Load More for post listing.', 'spurs' ), |
||
146 | 'section' => 'spurs_theme_layout_options', |
||
147 | 'settings' => 'spurs_pagination', |
||
148 | 'type' => 'select', |
||
149 | 'choices' => array( |
||
150 | 'pagination' => __( 'Pagination', 'spurs' ), |
||
151 | 'loadmore' => __( 'Load More', 'spurs' ), |
||
152 | ), |
||
153 | 'priority' => '30', |
||
154 | ) |
||
155 | ) |
||
156 | ); |
||
157 | } |
||
158 | } // endif function_exists( 'spurs_theme_customize_register' ). |
||
159 | add_action( 'customize_register', 'spurs_theme_customize_register' ); |
||
160 | |||
161 | /** |
||
162 | * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. |
||
163 | */ |
||
164 | if ( ! function_exists( 'spurs_customize_preview_js' ) ) { |
||
165 | /** |
||
166 | * Setup JS integration for live previewing. |
||
167 | */ |
||
168 | function spurs_customize_preview_js() { |
||
169 | wp_enqueue_script( |
||
170 | 'spurs_customizer', |
||
171 | get_template_directory_uri() . '/js/customizer.js', |
||
172 | array( 'customize-preview' ), |
||
173 | '20130508', |
||
174 | true |
||
175 | ); |
||
176 | } |
||
177 | } |
||
178 | add_action( 'customize_preview_init', 'spurs_customize_preview_js' ); |
||
179 |