@@ 720-743 (lines=24) @@ | ||
717 | * @param bool $discover_sitemap Make default sitemap discoverable to robots. |
|
718 | */ |
|
719 | $discover_sitemap = apply_filters( 'jetpack_sitemap_generate', true ); |
|
720 | if ( $discover_sitemap ) { |
|
721 | add_action( 'do_robotstxt', 'jetpack_sitemap_discovery', 5, 0 ); |
|
722 | ||
723 | if ( get_option( 'permalink_structure' ) ) { |
|
724 | /** This filter is documented in modules/sitemaps/sitemaps.php */ |
|
725 | $sitemap = apply_filters( 'jetpack_sitemap_location', home_url( '/sitemap.xml' ) ); |
|
726 | $sitemap = parse_url( $sitemap, PHP_URL_PATH ); |
|
727 | } else { |
|
728 | /** This filter is documented in modules/sitemaps/sitemaps.php */ |
|
729 | $sitemap = apply_filters( 'jetpack_sitemap_location', home_url( '/?jetpack-sitemap=true' ) ); |
|
730 | $sitemap = preg_replace( '/(=.*?)$/i', '', parse_url( $sitemap, PHP_URL_QUERY ) ); |
|
731 | } |
|
732 | ||
733 | // Sitemap XML |
|
734 | if ( preg_match( '#(' . $sitemap . ')$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET[ $sitemap ] ) && 'true' == $_GET[ $sitemap ] ) ) { |
|
735 | // run later so things like custom post types have been registered |
|
736 | add_action( 'init', 'jetpack_print_sitemap', 999 ); |
|
737 | } |
|
738 | ||
739 | // XSLT for sitemap |
|
740 | if ( preg_match( '#(/sitemap\.xsl)$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET['jetpack-sitemap-xsl'] ) && 'true' == $_GET['jetpack-sitemap-xsl'] ) ) { |
|
741 | add_action( 'init', 'jetpack_print_sitemap_xsl' ); |
|
742 | } |
|
743 | } |
|
744 | ||
745 | /** |
|
746 | * Filter whether to make the news sitemap discoverable to robots or not. |
|
@@ 755-778 (lines=24) @@ | ||
752 | * @param bool $discover_news_sitemap Make default news sitemap discoverable to robots. |
|
753 | */ |
|
754 | $discover_news_sitemap = apply_filters( 'jetpack_news_sitemap_generate', true ); |
|
755 | if ( $discover_news_sitemap ) { |
|
756 | add_action( 'do_robotstxt', 'jetpack_news_sitemap_discovery', 5, 0 ); |
|
757 | ||
758 | if ( get_option( 'permalink_structure' ) ) { |
|
759 | /** This filter is documented in modules/sitemaps/sitemaps.php */ |
|
760 | $sitemap = apply_filters( 'jetpack_news_sitemap_location', home_url( '/news-sitemap.xml' ) ); |
|
761 | $sitemap = parse_url( $sitemap, PHP_URL_PATH ); |
|
762 | } else { |
|
763 | /** This filter is documented in modules/sitemaps/sitemaps.php */ |
|
764 | $sitemap = apply_filters( 'jetpack_news_sitemap_location', home_url( '/?jetpack-news-sitemap=true' ) ); |
|
765 | $sitemap = preg_replace( '/(=.*?)$/i', '', parse_url( $sitemap, PHP_URL_QUERY ) ); |
|
766 | } |
|
767 | ||
768 | // News Sitemap XML |
|
769 | if ( preg_match( '#(' . $sitemap . ')$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET[ $sitemap ] ) && 'true' == $_GET[ $sitemap ] ) ) { |
|
770 | // run later so things like custom post types have been registered |
|
771 | add_action( 'init', 'jetpack_print_news_sitemap', 999 ); |
|
772 | } |
|
773 | ||
774 | // XSLT for sitemap |
|
775 | if ( preg_match( '#(/news-sitemap\.xsl)$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET['jetpack-news-sitemap-xsl'] ) && 'true' == $_GET['jetpack-news-sitemap-xsl'] ) ) { |
|
776 | add_action( 'init', 'jetpack_print_news_sitemap_xsl' ); |
|
777 | } |
|
778 | } |
|
779 | } |
|
780 | ||
781 | // Initialize sitemaps once themes can filter the initialization. |