|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Custom Sections. |
|
4
|
|
|
* |
|
5
|
|
|
* @package Kirki |
|
6
|
|
|
* @category Modules |
|
7
|
|
|
* @author Aristeides Stathopoulos |
|
8
|
|
|
* @copyright Copyright (c) 2016, Aristeides Stathopoulos |
|
9
|
|
|
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT |
|
10
|
|
|
* @since 3.0.0 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
// Exit if accessed directly. |
|
14
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
15
|
|
|
exit; |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Adds styles to the customizer. |
|
20
|
|
|
*/ |
|
21
|
|
|
class Kirki_Modules_Custom_Sections { |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Constructor. |
|
25
|
|
|
* |
|
26
|
|
|
* @access public |
|
27
|
|
|
* @since 3.0.0 |
|
28
|
|
|
*/ |
|
29
|
|
|
public function __construct() { |
|
30
|
|
|
|
|
31
|
|
|
// Register the new section types. |
|
32
|
|
|
add_filter( 'kirki/section_types', array( $this, 'set_section_types' ) ); |
|
33
|
|
|
|
|
34
|
|
|
// Include the section-type files. |
|
35
|
|
|
add_action( 'customize_register', array( $this, 'include_sections' ) ); |
|
36
|
|
|
|
|
37
|
|
|
// Enqueue styles & scripts. |
|
38
|
|
|
add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scrips' ), 999 ); |
|
39
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Add the custom section types. |
|
44
|
|
|
* |
|
45
|
|
|
* @access public |
|
46
|
|
|
* @since 3.0.0 |
|
47
|
|
|
* @param array $section_types The registered section-types. |
|
48
|
|
|
* @return array |
|
49
|
|
|
*/ |
|
50
|
|
|
public function set_section_types( $section_types ) { |
|
51
|
|
|
|
|
52
|
|
|
$new_types = array( |
|
53
|
|
|
'kirki-default' => 'Kirki_Sections_Default_Section', |
|
54
|
|
|
'kirki-expanded' => 'Kirki_Sections_Expanded_Section', |
|
55
|
|
|
); |
|
56
|
|
|
return array_merge( $section_types, $new_types ); |
|
57
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Include the custom-section classes. |
|
62
|
|
|
* |
|
63
|
|
|
* @access public |
|
64
|
|
|
* @since 3.0.0 |
|
65
|
|
|
*/ |
|
66
|
|
|
public function include_sections() { |
|
67
|
|
|
|
|
68
|
|
|
$folder_path = dirname( __FILE__ ) . '/sections/'; |
|
69
|
|
|
|
|
70
|
|
|
$section_types = apply_filters( 'kirki/section_types', array() ); |
|
71
|
|
|
|
|
72
|
|
|
foreach ( $section_types as $id => $class ) { |
|
73
|
|
|
if ( ! class_exists( $class ) ) { |
|
74
|
|
|
$path = wp_normalize_path( $folder_path . 'class-kirki-sections-' . $id . '-section.php' ); |
|
75
|
|
|
if ( file_exists( $path ) ) { |
|
76
|
|
|
include_once $path; |
|
77
|
|
|
continue; |
|
78
|
|
|
} |
|
79
|
|
|
$path = str_replace( 'class-kirki-sections-kirki-', 'class-kirki-sections-', $path ); |
|
80
|
|
|
if ( file_exists( $path ) ) { |
|
81
|
|
|
include_once $path; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Enqueues any necessary scripts and styles. |
|
89
|
|
|
* |
|
90
|
|
|
* @access public |
|
91
|
|
|
* @since 3.0.0 |
|
92
|
|
|
*/ |
|
93
|
|
|
public function enqueue_scrips() { |
|
94
|
|
|
|
|
95
|
|
|
wp_enqueue_style( 'kirki-custom-sections', trailingslashit( Kirki::$url ) . 'modules/custom-sections/sections.css' ); |
|
96
|
|
|
wp_enqueue_script( 'kirki-custom-sections', trailingslashit( Kirki::$url ) . 'modules/custom-sections/sections.js', array( 'jquery', 'customize-base', 'customize-controls' ) ); |
|
97
|
|
|
|
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
} |
|
101
|
|
|
|