-
Notifications
You must be signed in to change notification settings - Fork 1
/
generator.php
58 lines (45 loc) · 825 Bytes
/
generator.php
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
53
54
55
56
57
58
<?php
class JET_FRLP_Generator extends \Jet_Engine\Forms\Generators\Base {
/**
* Returns generator ID
*
* @return string
*/
public function get_id() {
return 'jet_related_posts';
}
/**
* Returns generator name
*
* @return string
*/
public function get_name() {
return 'Related Posts';
}
/**
* Returns generated options list
*
* @return array
*/
public function generate( $field ) {
$result = array();
if ( empty( $field ) ) {
return $result;
}
$post_id = get_the_ID();
if ( ! $post_id ) {
return $result;
}
$posts = get_post_meta( $post_id, $field, false );
if ( empty( $posts ) ) {
return $result;
}
foreach ( $posts as $post ) {
$result[] = array(
'value' => $post,
'label' => get_the_title( $post ),
);
}
return $result;
}
}