FileMeta.php
935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace AC\Column\Media;
use AC\Column;
use AC\Settings;
abstract class FileMeta extends Column\Meta {
public function get_meta_key() {
return '_wp_attachment_metadata';
}
/**
* @return Settings\Column\FileMeta
*/
protected function get_media_setting() {
$setting = $this->get_setting( 'media_meta' );
return $setting instanceof Settings\Column\FileMeta
? $setting
: null;
}
/**
* @return array
*/
public function get_sub_keys() {
return $this->get_media_setting()->get_media_meta_keys();
}
protected function get_metadata_value( array $data, array $keys ) {
$data = ac_helper()->array->get_nested_value( $data, $keys );
return is_scalar( $data )
? $data
: null;
}
public function get_raw_value( $id ) {
$data = $this->get_meta_value( $id, $this->get_meta_key() );
return is_array( $data )
? $this->get_metadata_value( $data, $this->get_sub_keys() )
: null;
}
}