Completed
Push — master ( ed32be...1a3fa2 )
by Joro
14:27 queued 04:32
created

Oembed_Field   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A admin_enqueue_scripts() 0 3 1
A to_json() 0 9 1
1
<?php
2
3
namespace Carbon_Fields\Field;
4
5
/**
6
 * Oembed field class.
7
 */
8
class Oembed_Field extends Field {
9
10
	/**
11
	 * Enqueue scripts and styles in admin
12
	 * Called once per field type
13
	 */
14
	public static function admin_enqueue_scripts() {
15
		wp_enqueue_script( 'wp-api' );
16
	}
17
18
	/**
19
	 * Returns an array that holds the field data, suitable for JSON representation.
20
	 *
21
	 * @param bool $load  Should the value be loaded from the database or use the value from the current instance.
22
	 * @return array
23
	 */
24
	public function to_json( $load ) {
25
		$field_data = parent::to_json( $load );
26
27
		$field_data = array_merge( $field_data, array(
28
			'value' => $this->get_value(),
29
		) );
30
31
		return $field_data;
32
	}
33
}
34