';
// Add expand/collapse button.
$toggle_button_classes = 'page-item-toggler';
if ( $this->show_collapsed() ) {
$toggle_button_classes .= ' is-collapsed';
}
if ( $this->show_collapsed() ) {
$aria_attributes = 'aria-label="Expand" aria-expanded="false"';
} else {
$aria_attributes = 'aria-label="Collapse" aria-expanded="true"';
}
$toggle_button = sprintf(
'
',
$toggle_button_classes,
( $has_children ? '' : 'disabled' ),
$aria_attributes
);
$output .= $toggle_button;
// Add container for page title and new subpage links.
$output .= '
';
// Add page title link
$title_link = sprintf(
'
%s',
esc_url( (string) get_permalink( $page->ID ) ),
apply_filters( 'the_title', $page->post_title, $page->ID )
);
$output .= $title_link;
// Add 'new subpage' link.
if ( is_user_member_of_blog() && current_user_can( 'publish_pages' ) ) {
$editor_page_url = Navigation\Urls::get_editor_page_url();
$new_page_link = $editor_page_url .
( wp_parse_url( $editor_page_url, PHP_URL_QUERY ) ? '&' : '?' ) .
'parent_post=' . $page->ID;
$label = _x( 'New subpage', 'create sub page', 'p2020' );
$output .= sprintf(
'
%s',
$new_page_link,
$label,
$label,
);
}
// Close item links container.
$output .= '
';
// Close item line container.
$output .= '
';
}
}