blic static function get_post_types() { $post_types = []; foreach ( Helper::get_accessible_post_types() as $post_type ) { if ( ! Helper::get_settings( "sitemap.pt_{$post_type}_html_sitemap" ) ) { continue; } $post_types[] = $post_type; } /** * Filter: 'rank_math/sitemap/html_sitemap_post_types' - Allow changing the post types to be included in the HTML sitemap. * * @var array $post_types The post types to be included in the HTML sitemap. */ return apply_filters( 'rank_math/sitemap/html_sitemap_post_types', $post_types ); } /** * Check if author sitemap should be shown or not. */ private function should_show_author_sitemap() { $show = Helper::get_settings( 'sitemap.authors_html_sitemap' ); if ( ! $show ) { return false; } $disable_author_archives = Helper::get_settings( 'titles.disable_author_archives' ); if ( $disable_author_archives ) { return false; } $robots = Helper::get_settings( 'titles.author_robots' ); if ( is_array( $robots ) && in_array( 'noindex', $robots, true ) ) { return false; } return true; } /** * Get taxonomies to be included in the HTML sitemap. * * @return array */ public static function get_taxonomies() { $taxonomies = []; foreach ( Helper::get_accessible_taxonomies() as $taxonomy ) { if ( ! Helper::get_settings( "sitemap.tax_{$taxonomy->name}_html_sitemap" ) ) { continue; } $taxonomies[ $taxonomy->name ] = $taxonomy; } /** * Filter: 'rank_math/sitemap/html_sitemap_taxonomies' - Allow changing the taxonomies to be included in the HTML sitemap. * * @var array $taxonomies The taxonomies to be included in the HTML sitemap. */ return apply_filters( 'rank_math/sitemap/html_sitemap_taxonomies', $taxonomies ); } /** * Show sitemap on a page (after content). * * @param mixed $content The page content. */ public function show_on_page( $content ) { if ( ! is_page() ) { return $content; } if ( ! is_main_query() || ! in_the_loop() ) { return $content; } $post_id = get_the_ID(); if ( (int) Helper::get_settings( 'sitemap.html_sitemap_page' ) !== $post_id ) { return $content; } return $content . $this->get_output(); } /** * Shortcode callback. */ public function shortcode() { return $this->get_output(); } }