|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Changes the customizer's branding. |
|
4
|
|
|
* For documentation please see |
|
5
|
|
|
* https://github.com/aristath/kirki/wiki/Styling-the-Customizer |
|
6
|
|
|
* |
|
7
|
|
|
* @package Kirki |
|
8
|
|
|
* @category Modules |
|
9
|
|
|
* @author Aristeides Stathopoulos |
|
10
|
|
|
* @copyright Copyright (c) 2017, Aristeides Stathopoulos |
|
11
|
|
|
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT |
|
12
|
|
|
* @since 3.0.0 |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
// Exit if accessed directly. |
|
16
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
17
|
|
|
exit; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Adds styles to the customizer. |
|
22
|
|
|
*/ |
|
23
|
|
|
class Kirki_Modules_Customizer_Branding { |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* The object instance. |
|
27
|
|
|
* |
|
28
|
|
|
* @static |
|
29
|
|
|
* @access private |
|
30
|
|
|
* @since 3.0.0 |
|
31
|
|
|
* @var object |
|
32
|
|
|
*/ |
|
33
|
|
|
private static $instance; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Constructor. |
|
37
|
|
|
* |
|
38
|
|
|
* @access protected |
|
39
|
|
|
* @since 3.0.0 |
|
40
|
|
|
*/ |
|
41
|
|
|
protected function __construct() { |
|
42
|
|
|
add_action( 'customize_controls_print_scripts', array( $this, 'customize_controls_print_scripts' ) ); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Gets an instance of this object. |
|
47
|
|
|
* Prevents duplicate instances which avoid artefacts and improves performance. |
|
48
|
|
|
* |
|
49
|
|
|
* @static |
|
50
|
|
|
* @access public |
|
51
|
|
|
* @since 3.0.0 |
|
52
|
|
|
* @return object |
|
53
|
|
|
*/ |
|
54
|
|
|
public static function get_instance() { |
|
55
|
|
|
if ( ! self::$instance ) { |
|
56
|
|
|
self::$instance = new self(); |
|
57
|
|
|
} |
|
58
|
|
|
return self::$instance; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Enqueues the script responsible for branding the customizer |
|
63
|
|
|
* and also adds variables to it using the wp_localize_script function. |
|
64
|
|
|
* The actual branding is handled via JS. |
|
65
|
|
|
* |
|
66
|
|
|
* @access public |
|
67
|
|
|
* @since 3.0.0 |
|
68
|
|
|
*/ |
|
69
|
|
|
public function customize_controls_print_scripts() { |
|
70
|
|
|
|
|
71
|
|
|
$config = apply_filters( 'kirki/config', array() ); |
|
72
|
|
|
$vars = array( |
|
73
|
|
|
'logoImage' => '', |
|
74
|
|
|
'description' => '', |
|
75
|
|
|
); |
|
76
|
|
|
if ( isset( $config['logo_image'] ) && '' !== $config['logo_image'] ) { |
|
77
|
|
|
$vars['logoImage'] = esc_url_raw( $config['logo_image'] ); |
|
78
|
|
|
} |
|
79
|
|
|
if ( isset( $config['description'] ) && '' !== $config['description'] ) { |
|
80
|
|
|
$vars['description'] = esc_textarea( $config['description'] ); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
if ( ! empty( $vars['logoImage'] ) || ! empty( $vars['description'] ) ) { |
|
84
|
|
|
wp_register_script( 'kirki-branding', Kirki::$url . '/modules/customizer-branding/branding.js' ); |
|
85
|
|
|
wp_localize_script( 'kirki-branding', 'kirkiBranding', $vars ); |
|
86
|
|
|
wp_enqueue_script( 'kirki-branding' ); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|