-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmetaboxes.php
53 lines (49 loc) · 1.47 KB
/
metaboxes.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
<?php
use Queulat\Metabox;
use Queulat\Forms\Node_Factory;
use Queulat\Forms\Element\WP_Gallery;
use Queulat\Forms\Element\Input;
class Post_Metabox extends Metabox
{
public function get_fields() : array
{
return [
Node_Factory::make(
Input::class,
[
'name' => 'video_url',
'label' => 'Video URL',
'properties' => [
'description' => 'Video url (Vimeo and Youtube support), "Video" post format should be selected'
]
]
),
Node_Factory::make(
WP_Gallery::class,
[
'name' => 'gallery',
'label' => 'Image Gallery',
'properties' => [
'description' => '"Gallery" post format should be selected to show gallery on top'
]
]
)
];
}
public function sanitize_data(array $data) : array
{
$sanitized = [];
foreach ($data as $key => $val) {
switch ($key) {
case 'video_url':
$sanitized[$key] = $val;
break;
case 'gallery':
$sanitized[$key] = $val;
break;
}
}
return $sanitized;
}
}
new Post_Metabox('post', 'Post format', 'post', ['context' => 'normal']);