Completed
Push — develop ( 0031a5...1c79cf )
by Aristeides
02:18
created

Kirki_Field_Editor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
/**
3
 * Override field methods
4
 *
5
 * @package     Kirki
6
 * @subpackage  Controls
7
 * @copyright   Copyright (c) 2017, Aristeides Stathopoulos
8
 * @license     http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
 * @since       2.2.7
10
 */
11
12
/**
13
 * Field overrides.
14
 */
15
class Kirki_Field_Editor extends Kirki_Field {
16
17
	/**
18
	 * Sets the control type.
19
	 *
20
	 * @access protected
21
	 */
22
	protected function set_type() {
23
		global $wp_version;
24
25
		if ( version_compare( $wp_version, '4.8' ) >= 0 ) {
26
			$this->type = 'kirki-editor';
27
			return;
28
		}
29
		// Fallback for older WordPress versions.
30
		$this->type = 'kirki-generic';
31
		$this->choices['element'] = 'textarea';
32
33
	}
34
35
	/**
36
	 * Sets the $sanitize_callback
37
	 *
38
	 * @access protected
39
	 */
40
	protected function set_sanitize_callback() {
41
42
		// If a custom sanitize_callback has been defined,
43
		// then we don't need to proceed any further.
44
		if ( ! empty( $this->sanitize_callback ) ) {
45
			return;
46
		}
47
		$this->sanitize_callback = 'wp_kses_post';
48
49
	}
50
}
51