TopicForum.php
1007 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
<?php
namespace ACP\ThirdParty\bbPress\Editing;
use AC;
use ACP\Editing;
use ACP\Helper\Select;
class TopicForum extends Editing\Model implements Editing\PaginatedOptions {
public function get_view_settings() {
return [
'type' => 'select2_dropdown',
'ajax_populate' => true,
'multiple' => false,
'clear_button' => true,
];
}
public function get_paginated_options( $s, $paged, $id = null ) {
$entities = new Select\Entities\Post( [
's' => $s,
'paged' => $paged,
'post_type' => 'forum',
] );
return new AC\Helper\Select\Options\Paginated(
$entities,
new Select\Formatter\PostTitle( $entities )
);
}
public function get_edit_value( $id ) {
$forum_id = get_post_meta( $id, '_bbp_forum_id', true );
$post = get_post( $forum_id );
if ( ! $post ) {
return false;
}
return [
$post->ID => $post->post_title,
];
}
public function save( $id, $value ) {
return update_post_meta( $id, '_bbp_forum_id', $value );
}
}