-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategory_dropdown_block.php
64 lines (63 loc) · 1.5 KB
/
category_dropdown_block.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
59
60
61
62
63
64
<?php
if ( function_exists( 'register_block_type' ) ) {
// Hook server side rendering into render callback
register_block_type(
'gcs/wp-category-dropdown', [
'render_callback' => 'wp_cat_dropdown_callback',
'attributes' => array(
'align' => array(
'type' => 'string',
'default' => '',
),
'orderby' => array(
'type' => 'string',
'default' => 'name',
),
'order' => array(
'type' => 'string',
'default' => 'asc',
),
'showcount' => array(
'type' => 'boolean',
'default' => true,
),
'hierarchical' => array(
'type' => 'boolean',
'default' => true,
),
'hide_empty' => array(
'type' => 'boolean',
'default' => true,
),
'category' => array(
'type' => 'string',
'default' => 'category',
),
'exclude' => array(
'type' => 'array',
'default' => [],
),
'include' => array(
'type' => 'array',
'default' => [],
),
'default_option_text' => array(
'type' => 'string',
'default' => __('Parent Category', GCSCD_TXT_DOMAIN),
),
'default_option_sub' => array(
'type' => 'string',
'default' => __('Child Category', GCSCD_TXT_DOMAIN),
),
)
]
);
};
function wp_cat_dropdown_callback($attributes){
$align = $attributes['align'];
$categories = '<div class="align'.esc_attr($align).'">';
$categories .= wpcd_child_category_dropdown($attributes);
$categories .= '</div>';
return $categories;
}
?>