1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Allows fields to collapse. |
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_Collapsible { |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Constructor. |
25
|
|
|
* |
26
|
|
|
* @access public |
27
|
|
|
* @since 3.0.0 |
28
|
|
|
*/ |
29
|
|
|
public function __construct() { |
30
|
|
|
|
31
|
|
|
add_action( 'customize_controls_print_scripts', array( $this, 'customize_controls_print_scripts' ) ); |
32
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Enqueues the script responsible for branding the customizer |
37
|
|
|
* and also adds variables to it using the wp_localize_script function. |
38
|
|
|
* The actual branding is handled via JS. |
39
|
|
|
* |
40
|
|
|
* @access public |
41
|
|
|
* @since 3.0.0 |
42
|
|
|
*/ |
43
|
|
|
public function customize_controls_print_scripts() { |
44
|
|
|
|
45
|
|
|
wp_enqueue_script( 'kirki-collapsible', trailingslashit( Kirki::$url ) . 'modules/collapsible/collapsible.js', array( 'customize-preview' ), false, true ); |
46
|
|
|
wp_enqueue_style( 'kirki-collapsible', trailingslashit( Kirki::$url ) . 'modules/collapsible/collapsible.css' ); |
47
|
|
|
|
48
|
|
|
$collapsible_fields = array(); |
49
|
|
|
$fields = Kirki::$fields; |
50
|
|
|
foreach ( $fields as $field ) { |
51
|
|
|
if ( isset( $field['collapsible'] ) && true === $field['collapsible'] && isset( $field['settings'] ) && isset( $field['label'] ) ) { |
52
|
|
|
$collapsible_fields[ $field['settings'] ] = $field['label']; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
$collapsible_fields = array_unique( $collapsible_fields ); |
56
|
|
|
wp_localize_script( 'kirki-collapsible', 'collapsible', $collapsible_fields ); |
57
|
|
|
|
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|