-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomizer.php
More file actions
110 lines (101 loc) · 3.79 KB
/
Copy pathcustomizer.php
File metadata and controls
110 lines (101 loc) · 3.79 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* Informer Theme Customizer
*
* @package Informer
*/
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function theme_informer_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';
/************** Remove sections and panel *************/
$wp_customize->remove_section( 'static_front_page' );
$wp_customize->remove_section( 'custom_css' );
$wp_customize->remove_section( 'header_image' );
$wp_customize->remove_section( 'background_image' );
$wp_customize->remove_section( 'colors' );
$wp_customize->remove_panel('widgets');
if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial( 'blogname', array(
'selector' => '.site-title a',
'render_callback' => 'theme_informer_customize_partial_blogname',
) );
$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
'selector' => '.site-description',
'render_callback' => 'theme_informer_customize_partial_blogdescription',
) );
}
/**************************** Own customizer option *******************************/
$wp_customize->add_section('pjl-message-section', array(
'title' => 'Rubrik Meddelande'
));
$wp_customize->add_setting('pjl-message-show', array(
'default' => 'No'
));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'pjl-message-show-control', array(
'label' => 'Visa detta meddelande',
'section' => 'pjl-message-section',
'settings' => 'pjl-message-show',
'type' => 'select',
'choices' => array('No' => 'Nej', 'Yes' => 'Ja')
)));
$wp_customize->add_setting('pjl-message-headline', array(
'default' => 'Meddelande - rubrik'
));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'pjl-message-headline-control', array(
'label' => 'Rubrik',
'section' => 'pjl-message-section',
'settings' => 'pjl-message-headline'
)));
$wp_customize->add_setting('pjl-message-txt', array(
'default' => 'Meddelande paragraf'
));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'pjl-message-text-control', array(
'label' => 'Brödtext',
'section' => 'pjl-message-section',
'settings' => 'pjl-message-txt',
'type' => 'textarea'
)));
$wp_customize->add_setting('pjl-message-link');
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'pjl-message-link-control', array(
'label' => 'Länk',
'section' => 'pjl-message-section',
'settings' => 'pjl-message-link',
'type' => 'dropdown-pages'
)));
$wp_customize->add_setting('pjl-message-img');
$wp_customize->add_control( new WP_Customize_Cropped_Image_Control($wp_customize, 'pjl-message-img-control', array(
'label' => 'Bild',
'section' => 'pjl-message-section',
'settings' => 'pjl-message-img',
)));
}
add_action( 'customize_register', 'theme_informer_customize_register' );
/**
* Render the site title for the selective refresh partial.
*
* @return void
*/
function theme_informer_customize_partial_blogname() {
bloginfo( 'name' );
}
/**
* Render the site tagline for the selective refresh partial.
*
* @return void
*/
function theme_informer_customize_partial_blogdescription() {
bloginfo( 'description' );
}
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function theme_informer_customize_preview_js() {
wp_enqueue_script( 'theme-informer-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true );
}
add_action( 'customize_preview_init', 'theme_informer_customize_preview_js' );