Kirki_Control_Code   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 4
c 3
b 1
f 0
dl 0
loc 12
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A content_template() 0 5 1
1
<?php
2
/**
3
 * Customizer Control: code.
4
 *
5
 * Creates a new custom control.
6
 * Custom controls accept raw HTML/JS.
7
 *
8
 * @package     Kirki
9
 * @subpackage  Controls
10
 * @copyright   Copyright (c) 2017, Aristeides Stathopoulos
11
 * @license    https://opensource.org/licenses/MIT
12
 * @since       1.0
13
 */
14
15
// @codingStandardsIgnoreFile Generic.Files.OneClassPerFile.MultipleFound Generic.Classes.DuplicateClassName.Found
16
17
// Exit if accessed directly.
18
if ( ! defined( 'ABSPATH' ) ) {
19
	exit;
20
}
21
22
/**
23
 * Show warning if old WordPress.
24
 */
25
if ( ! class_exists( 'WP_Customize_Code_Editor_Control' ) ) {
26
	/**
27
	 * Adds a warning message instead of the control.
28
	 */
29
	class Kirki_Control_Code extends Kirki_Control_Base {
30
31
		/**
32
		 * The message.
33
		 *
34
		 * @since 3.0.21
35
		 */
36
		protected function content_template() {
37
			?>
38
			<div class="notice notice-error" data-type="error"><div class="notification-message">
39
				<?php esc_html_e( 'Please update your WordPress installation to a version newer than 4.9 to access the code control.', 'kirki' ); ?>
40
			</div></div>
41
			<?php
42
		}
43
	}
44
} else {
45
46
	/**
47
	 * Adds a "code" control, alias of the WP_Customize_Code_Editor_Control class.
48
	 */
49
	class Kirki_Control_Code extends WP_Customize_Code_Editor_Control {
50
51
		/**
52
		 * Whitelisting the "required" argument.
53
		 *
54
		 * @since 3.0.17
55
		 * @access public
56
		 * @var array
57
		 */
58
		public $required = array();
59
60
		/**
61
		 * Refresh the parameters passed to the JavaScript via JSON.
62
		 *
63
		 * @see WP_Customize_Control::to_json()
64
		 */
65
		public function to_json() {
66
67
			// Get the basics from the parent class.
68
			parent::to_json();
69
70
			// Required.
71
			$this->json['required'] = $this->required;
72
		}
73
	}
74
}
75