<?php
/* Prohibit direct script loading */
defined('ABSPATH') || die('No direct script access allowed!');
$html = '';
if (!empty($this->settings_sitemap['wpms_sitemap_pages'])) {
    echo '<div id="menu_source_pages" class="wpms_sitemap_pages"><ul>';
    $pageInc  = '';
    $getPages = $this->getPagesSitemap();
    foreach ($getPages as $value) {
        if (isset($this->settings_sitemap['wpms_html_sitemap_page'])
            && $value->ID !== $this->settings_sitemap['wpms_html_sitemap_page']) {
            if ((get_post_meta($value->ID, '_yoast_wpseo_meta-robots-noindex', true) === '1'
                 && get_post_meta($value->ID, '_yoast_wpseo_sitemap-include', true) !== 'always')
                || (get_post_meta($value->ID, '_yoast_wpseo_sitemap-include', true) === 'never')
                || (get_post_meta($value->ID, '_yoast_wpms_redirect', true) !== '')) {
                continue;
            }
            if ($pageInc === '') {
                $pageInc = $value->ID;
                continue;
            }
            $pageInc .= ', ' . $value->ID;
        }
    }

    if ($pageInc !== '') {
        // phpcs:ignore WordPress.Security.EscapeOutput -- Content escaped in the method wp_list_pages
        echo wp_list_pages(
            array(
                'include'     => $pageInc,
                'title_li'    => '',
                'sort_column' => 'post_title',
                'sort_order'  => 'ASC',
                'echo'        => false
            )
        );
    }

    echo '</ul></div>';
    echo '<div class="holder holder_sitemaps_pages"></div>';
}
