forked from devinsays/customizer-background-control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
executable file
·69 lines (60 loc) · 2.11 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Register customizer panels, sections, settings, and controls.
*
* @since 1.0.0
* @access public
* @param object $wp_customize
* @return void
*/
function customize_background_control_customize_register_example( $wp_customize ) {
// Add a custom background panel for testing.
$wp_customize->add_section( 'custom_background_section', array(
'priority' => 5,
'title' => esc_html__( 'Custom Background Example', 'customizer-background-control' )
) );
// Registers example_background settings
$wp_customize->add_setting( 'example_background_image_url', array(
'sanitize_callback' => 'esc_url'
) );
$wp_customize->add_setting( 'example_background_image_id', array(
'sanitize_callback' => 'absint'
) );
$wp_customize->add_setting( 'example_background_repeat', array(
'default' => 'no-repeat',
'sanitize_callback' => 'sanitize_text_field'
) );
$wp_customize->add_setting( 'example_background_size', array(
'default' => 'auto',
'sanitize_callback' => 'sanitize_text_field'
) );
$wp_customize->add_setting( 'example_background_attach', array(
'default' => 'scroll',
'sanitize_callback' => 'sanitize_text_field'
) );
$wp_customize->add_setting( 'example_background_position', array(
'default' => 'center-center',
'sanitize_callback' => 'sanitize_text_field'
) );
// Registers example_background control
$wp_customize->add_control(
new Customize_Custom_Background_Control(
$wp_customize,
'example_background',
array(
'label' => esc_html__( 'Example Background', 'customizer-background-control' ),
'section' => 'custom_background_section',
// Tie a setting (defined via `$wp_customize->add_setting()`) to the control.
'settings' => array(
'image_url' => 'example_background_image_url',
'image_id' => 'example_background_image_id',
'repeat' => 'example_background_repeat', // Use false to hide the field
'size' => 'example_background_size',
'position' => 'example_background_position',
'attach' => 'example_background_attach'
)
)
)
);
}
add_action( 'customize_register', 'customize_background_control_customize_register_example' );