/
_widget.php
53 lines (46 loc) · 1005 Bytes
/
_widget.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
/**
* @package inc2734/wp-awesome-widgets
* @author inc2734
* @license GPL-2.0+
*/
use Inc2734\WP_Awesome_Widgets\App\View;
if ( ! is_singular() ) {
return;
}
if ( ! is_post_type_hierarchical( get_post_type() ) ) {
return;
}
$founder_id = get_the_ID();
$ancestors = get_post_ancestors( get_the_ID() );
if ( $ancestors ) {
$founder_id = end( $ancestors );
}
if ( $instance['display-only-have-descendants'] ) {
$descendants_query = new \WP_Query(
array(
'post_type' => get_post_type(),
'posts_per_page' => 50,
'post_parent' => $founder_id,
'ignore_sticky_posts' => true,
'no_found_rows' => true,
'suppress_filters' => false,
'orderby' => array(
'menu_order' => 'ASC',
'ID' => 'DESC',
),
)
);
if ( ! $descendants_query->have_posts() ) {
return;
}
}
View::render(
'local-nav',
null,
array(
'widget_args' => $widget_args,
'instance' => $instance,
'founder_id' => $founder_id,
)
);