|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Handles the reset buttons on sections. |
|
4
|
|
|
* |
|
5
|
|
|
* @package Kirki |
|
6
|
|
|
* @category Modules |
|
7
|
|
|
* @author Aristeides Stathopoulos |
|
8
|
|
|
* @copyright Copyright (c) 2017, Aristeides Stathopoulos |
|
9
|
|
|
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT |
|
10
|
|
|
* @since 3.0.0 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* The Kirki_Modules_Reset object. |
|
15
|
|
|
*/ |
|
16
|
|
|
class Kirki_Modules_Reset { |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* The object instance. |
|
20
|
|
|
* |
|
21
|
|
|
* @static |
|
22
|
|
|
* @access private |
|
23
|
|
|
* @since 3.0.0 |
|
24
|
|
|
* @var object |
|
25
|
|
|
*/ |
|
26
|
|
|
private static $instance; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Constructor. |
|
30
|
|
|
* |
|
31
|
|
|
* @access protected |
|
32
|
|
|
*/ |
|
33
|
|
|
protected function __construct() { |
|
34
|
|
|
add_action( 'customize_controls_enqueue_scripts', array( $this, 'customize_controls_enqueue_scripts' ), 20 ); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Gets an instance of this object. |
|
39
|
|
|
* Prevents duplicate instances which avoid artefacts and improves performance. |
|
40
|
|
|
* |
|
41
|
|
|
* @static |
|
42
|
|
|
* @access public |
|
43
|
|
|
* @since 3.0.0 |
|
44
|
|
|
* @return object |
|
45
|
|
|
*/ |
|
46
|
|
|
public static function get_instance() { |
|
47
|
|
|
if ( ! self::$instance ) { |
|
48
|
|
|
self::$instance = new self(); |
|
49
|
|
|
} |
|
50
|
|
|
return self::$instance; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Enqueue scripts |
|
55
|
|
|
* |
|
56
|
|
|
* @access public |
|
57
|
|
|
* @since 3.0.0 |
|
58
|
|
|
*/ |
|
59
|
|
|
public function customize_controls_enqueue_scripts() { |
|
60
|
|
|
|
|
61
|
|
|
$translation_strings = apply_filters( 'kirki/l10n', array( |
|
62
|
|
|
/* translators: Icon followed by reset label. */ |
|
63
|
|
|
'reset-with-icon' => sprintf( esc_attr__( '%s Reset', 'kirki' ), '<span class="dashicons dashicons-update"></span><span class="label">' ) . '</span>', |
|
64
|
|
|
) ); |
|
65
|
|
|
// Enqueue the reset script. |
|
66
|
|
|
wp_enqueue_script( 'kirki-set-setting-value', trailingslashit( Kirki::$url ) . 'modules/reset/set-setting-value.js', array( 'jquery', 'customize-base', 'customize-controls' ) ); |
|
67
|
|
|
wp_enqueue_script( 'kirki-reset', trailingslashit( Kirki::$url ) . 'modules/reset/reset.js', array( 'jquery', 'customize-base', 'customize-controls', 'kirki-set-setting-value' ) ); |
|
68
|
|
|
wp_localize_script( 'kirki-reset', 'kirkiResetButtonLabel', $translation_strings ); |
|
69
|
|
|
wp_enqueue_style( 'kirki-reset', trailingslashit( Kirki::$url ) . 'modules/reset/reset.css', null ); |
|
70
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|