-
Notifications
You must be signed in to change notification settings - Fork 2
/
front-page-customizer.php
72 lines (58 loc) · 1.47 KB
/
front-page-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
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* Register Front Page Manger option with the WordPress Customizer
*
*/
class FPM_Genesis_Customizer extends Genesis_Customizer_Base {
/**
* Settings field.
*/
public $settings_field = 'genesis-settings';
/**
*
*/
public function register( $wp_customize ) {
$this->front_page( $wp_customize );
}
private function front_page( $wp_customize ) {
$wp_customize->add_section(
'front_page_manager',
array(
'title' => 'Front Page Manager',
'priority' => 10,
)
);
$wp_customize->add_setting(
$this->get_field_name( 'front_page_select' ),
array(
'default' => $this->get_field_name( 'front_page_select' ),
'type' => 'option',
)
);
$wp_customize->add_control(
'genesis_front_page_select',
array(
'label' => __( 'Select Front Page', 'front-page-manager' ),
'section' => 'front_page_manager',
'settings' => $this->get_field_name( 'front_page_select' ),
'type' => 'select',
'choices' => fpm_get_templates_for_customizer(),
)
);
}
}
add_action( 'init', 'fpm_genesis_customizer_init' );
/**
*
*/
function fpm_genesis_customizer_init() {
new FPM_Genesis_Customizer;
}
function fpm_get_templates_for_customizer() {
$templates = array();
foreach ( (array) glob( get_stylesheet_directory() . "/front-page*.php" ) as $template ) {
$templates[] = str_replace( get_stylesheet_directory() . '/', '', $template );
}
$templates = array_combine( $templates, $templates );
return $templates;
}