PageTemplate.php
952 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
49
50
51
52
<?php
namespace AC\Column\Post;
use AC\Column;
/**
* @since 2.0
*/
class PageTemplate extends Column\Meta {
public function __construct() {
$this->set_type( 'column-page_template' );
$this->set_label( __( 'Page Template', 'codepress-admin-columns' ) );
}
public function get_meta_key() {
return '_wp_page_template';
}
function get_value( $post_id ) {
$template = array_search( $this->get_raw_value( $post_id ), $this->get_page_templates() );
if ( ! $template ) {
return $this->get_empty_char();
}
return $template;
}
function is_valid() {
return $this->get_page_templates() ? true : false;
}
/**
* @return array
*/
public function get_page_templates() {
global $wp_version;
if ( ! function_exists( 'get_page_templates' ) ) {
return [];
}
if ( version_compare( $wp_version, '4.7', '>=' ) ) {
return get_page_templates( null, $this->get_post_type() );
}
return get_page_templates();
}
}