__( 'Navigation', 'bone' )]; parent::__construct( $id, $name, $ops ); } public function widget( $args, $instance ) { global $post; if ( !is_page() ) return; $res = ""; $parentID = $post->ID; $opt = empty( $instance['option'] ) ? null : $instance['option']; if ( !empty( $instance['title'] ) ) { $res = $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title']; } if ( !$opt || ( $opt && !in_array( 'grandson', $opt ) ) ) { $childs = wp_list_pages(['child_of'=>$parentID, 'title_li'=>'', 'echo'=>0, 'parent'=>$parentID, 'sort_column' => 'menu_order'] ); if ( !$childs ) return; $res .= ""; } else { $childs = wp_list_pages(['child_of'=>$post->post_parent, 'title_li'=>'', 'echo'=>0, 'sort_column' => 'menu_order'] ); if ( !$childs ) return; $res .= ''; } echo $args['before_widget'] . $res . $args['after_widget']; } public function form( $instance ) { $title = empty( $instance['title'] ) ? __( 'Navigation', 'bone' ) : $instance['title']; $type_id = $this->get_field_id( 'option' ); $type_name = $this->get_field_name( 'option' ) . "[]"; $checked = function ( $value ) use ( $instance ) { if ( empty( $instance['option'] ) ) return; if ( in_array( $value, $instance['option'] ) == $value ) echo 'checked'; } ?>