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

Kirki_Field_Editor   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 4
lcom 2
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set_type() 0 12 2
A set_sanitize_callback() 0 10 2
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