-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomizer.php
61 lines (56 loc) · 1.65 KB
/
customizer.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
<?php
/**
* Evan Works Theme Customizer
*
* @package evn
*/
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function evn_customize_register( $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial(
'blogname',
array(
'selector' => '.site-title a',
'render_callback' => 'evn_customize_partial_blogname',
)
);
$wp_customize->selective_refresh->add_partial(
'blogdescription',
array(
'selector' => '.site-description',
'render_callback' => 'evn_customize_partial_blogdescription',
)
);
}
}
add_action( 'customize_register', 'evn_customize_register' );
/**
* Render the site title for the selective refresh partial.
*
* @return void
*/
function evn_customize_partial_blogname() {
bloginfo( 'name' );
}
/**
* Render the site tagline for the selective refresh partial.
*
* @return void
*/
function evn_customize_partial_blogdescription() {
bloginfo( 'description' );
}
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function evn_customize_preview_js() {
wp_enqueue_script( 'evn-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), EVN_VERSION, true );
}
add_action( 'customize_preview_init', 'evn_customize_preview_js' );