class-wp-sitemaps-provider.php 0000644 00000010475 15044121002 0012455 0 ustar 00 <?php
/**
* Sitemaps: WP_Sitemaps_Provider class
*
* This class is a base class for other sitemap providers to extend and contains shared functionality.
*
* @package WordPress
* @subpackage Sitemaps
* @since 5.5.0
*/
/**
* Class WP_Sitemaps_Provider.
*
* @since 5.5.0
*/
#[AllowDynamicProperties]
abstract class WP_Sitemaps_Provider {
/**
* Provider name.
*
* This will also be used as the public-facing name in URLs.
*
* @since 5.5.0
*
* @var string
*/
protected $name = '';
/**
* Object type name (e.g. 'post', 'term', 'user').
*
* @since 5.5.0
*
* @var string
*/
protected $object_type = '';
/**
* Gets a URL list for a sitemap.
*
* @since 5.5.0
*
* @param int $page_num Page of results.
* @param string $object_subtype Optional. Object subtype name. Default empty.
* @return array[] Array of URL information for a sitemap.
*/
abstract public function get_url_list( $page_num, $object_subtype = '' );
/**
* Gets the max number of pages available for the object type.
*
* @since 5.5.0
*
* @param string $object_subtype Optional. Object subtype. Default empty.
* @return int Total number of pages.
*/
abstract public function get_max_num_pages( $object_subtype = '' );
/**
* Gets data about each sitemap type.
*
* @since 5.5.0
*
* @return array[] Array of sitemap types including object subtype name and number of pages.
*/
public function get_sitemap_type_data() {
$sitemap_data = array();
$object_subtypes = $this->get_object_subtypes();
/*
* If there are no object subtypes, include a single sitemap for the
* entire object type.
*/
if ( empty( $object_subtypes ) ) {
$sitemap_data[] = array(
'name' => '',
'pages' => $this->get_max_num_pages(),
);
return $sitemap_data;
}
// Otherwise, include individual sitemaps for every object subtype.
foreach ( $object_subtypes as $object_subtype_name => $data ) {
$object_subtype_name = (string) $object_subtype_name;
$sitemap_data[] = array(
'name' => $object_subtype_name,
'pages' => $this->get_max_num_pages( $object_subtype_name ),
);
}
return $sitemap_data;
}
/**
* Lists sitemap pages exposed by this provider.
*
* The returned data is used to populate the sitemap entries of the index.
*
* @since 5.5.0
*
* @return array[] Array of sitemap entries.
*/
public function get_sitemap_entries() {
$sitemaps = array();
$sitemap_types = $this->get_sitemap_type_data();
foreach ( $sitemap_types as $type ) {
for ( $page = 1; $page <= $type['pages']; $page++ ) {
$sitemap_entry = array(
'loc' => $this->get_sitemap_url( $type['name'], $page ),
);
/**
* Filters the sitemap entry for the sitemap index.
*
* @since 5.5.0
*
* @param array $sitemap_entry Sitemap entry for the post.
* @param string $object_type Object empty name.
* @param string $object_subtype Object subtype name.
* Empty string if the object type does not support subtypes.
* @param int $page Page number of results.
*/
$sitemap_entry = apply_filters( 'wp_sitemaps_index_entry', $sitemap_entry, $this->object_type, $type['name'], $page );
$sitemaps[] = $sitemap_entry;
}
}
return $sitemaps;
}
/**
* Gets the URL of a sitemap entry.
*
* @since 5.5.0
*
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
*
* @param string $name The name of the sitemap.
* @param int $page The page of the sitemap.
* @return string The composed URL for a sitemap entry.
*/
public function get_sitemap_url( $name, $page ) {
global $wp_rewrite;
// Accounts for cases where name is not included, ex: sitemaps-users-1.xml.
$params = array_filter(
array(
'sitemap' => $this->name,
'sitemap-subtype' => $name,
'paged' => $page,
)
);
$basename = sprintf(
'/wp-sitemap-%1$s.xml',
implode( '-', $params )
);
if ( ! $wp_rewrite->using_permalinks() ) {
$basename = '/?' . http_build_query( $params, '', '&' );
}
return home_url( $basename );
}
/**
* Returns the list of supported object subtypes exposed by the provider.
*
* @since 5.5.0
*
* @return array List of object subtypes objects keyed by their name.
*/
public function get_object_subtypes() {
return array();
}
}
class-wp-sitemaps-stylesheet.php 0000644 00000020466 15044121002 0013015 0 ustar 00 <?php
/**
* Sitemaps: WP_Sitemaps_Stylesheet class
*
* This class provides the XSL stylesheets to style all sitemaps.
*
* @package WordPress
* @subpackage Sitemaps
* @since 5.5.0
*/
/**
* Stylesheet provider class.
*
* @since 5.5.0
*/
#[AllowDynamicProperties]
class WP_Sitemaps_Stylesheet {
/**
* Renders the XSL stylesheet depending on whether it's the sitemap index or not.
*
* @param string $type Stylesheet type. Either 'sitemap' or 'index'.
*/
public function render_stylesheet( $type ) {
header( 'Content-Type: application/xml; charset=UTF-8' );
if ( 'sitemap' === $type ) {
// All content is escaped below.
echo $this->get_sitemap_stylesheet();
}
if ( 'index' === $type ) {
// All content is escaped below.
echo $this->get_sitemap_index_stylesheet();
}
exit;
}
/**
* Returns the escaped XSL for all sitemaps, except index.
*
* @since 5.5.0
*/
public function get_sitemap_stylesheet() {
$css = $this->get_stylesheet_css();
$title = esc_xml( __( 'XML Sitemap' ) );
$description = esc_xml( __( 'This XML Sitemap is generated by WordPress to make your content more visible for search engines.' ) );
$learn_more = sprintf(
'<a href="%s">%s</a>',
esc_url( __( 'https://www.sitemaps.org/' ) ),
esc_xml( __( 'Learn more about XML sitemaps.' ) )
);
$text = sprintf(
/* translators: %s: Number of URLs. */
esc_xml( __( 'Number of URLs in this XML Sitemap: %s.' ) ),
'<xsl:value-of select="count( sitemap:urlset/sitemap:url )" />'
);
$lang = get_language_attributes( 'html' );
$url = esc_xml( __( 'URL' ) );
$lastmod = esc_xml( __( 'Last Modified' ) );
$changefreq = esc_xml( __( 'Change Frequency' ) );
$priority = esc_xml( __( 'Priority' ) );
$xsl_content = <<<XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
exclude-result-prefixes="sitemap"
>
<xsl:output method="html" encoding="UTF-8" indent="yes" />
<!--
Set variables for whether lastmod, changefreq or priority occur for any url in the sitemap.
We do this up front because it can be expensive in a large sitemap.
-->
<xsl:variable name="has-lastmod" select="count( /sitemap:urlset/sitemap:url/sitemap:lastmod )" />
<xsl:variable name="has-changefreq" select="count( /sitemap:urlset/sitemap:url/sitemap:changefreq )" />
<xsl:variable name="has-priority" select="count( /sitemap:urlset/sitemap:url/sitemap:priority )" />
<xsl:template match="/">
<html {$lang}>
<head>
<title>{$title}</title>
<style>
{$css}
</style>
</head>
<body>
<div id="sitemap">
<div id="sitemap__header">
<h1>{$title}</h1>
<p>{$description}</p>
<p>{$learn_more}</p>
</div>
<div id="sitemap__content">
<p class="text">{$text}</p>
<table id="sitemap__table">
<thead>
<tr>
<th class="loc">{$url}</th>
<xsl:if test="\$has-lastmod">
<th class="lastmod">{$lastmod}</th>
</xsl:if>
<xsl:if test="\$has-changefreq">
<th class="changefreq">{$changefreq}</th>
</xsl:if>
<xsl:if test="\$has-priority">
<th class="priority">{$priority}</th>
</xsl:if>
</tr>
</thead>
<tbody>
<xsl:for-each select="sitemap:urlset/sitemap:url">
<tr>
<td class="loc"><a href="{sitemap:loc}"><xsl:value-of select="sitemap:loc" /></a></td>
<xsl:if test="\$has-lastmod">
<td class="lastmod"><xsl:value-of select="sitemap:lastmod" /></td>
</xsl:if>
<xsl:if test="\$has-changefreq">
<td class="changefreq"><xsl:value-of select="sitemap:changefreq" /></td>
</xsl:if>
<xsl:if test="\$has-priority">
<td class="priority"><xsl:value-of select="sitemap:priority" /></td>
</xsl:if>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XSL;
/**
* Filters the content of the sitemap stylesheet.
*
* @since 5.5.0
*
* @param string $xsl_content Full content for the XML stylesheet.
*/
return apply_filters( 'wp_sitemaps_stylesheet_content', $xsl_content );
}
/**
* Returns the escaped XSL for the index sitemaps.
*
* @since 5.5.0
*/
public function get_sitemap_index_stylesheet() {
$css = $this->get_stylesheet_css();
$title = esc_xml( __( 'XML Sitemap' ) );
$description = esc_xml( __( 'This XML Sitemap is generated by WordPress to make your content more visible for search engines.' ) );
$learn_more = sprintf(
'<a href="%s">%s</a>',
esc_url( __( 'https://www.sitemaps.org/' ) ),
esc_xml( __( 'Learn more about XML sitemaps.' ) )
);
$text = sprintf(
/* translators: %s: Number of URLs. */
esc_xml( __( 'Number of URLs in this XML Sitemap: %s.' ) ),
'<xsl:value-of select="count( sitemap:sitemapindex/sitemap:sitemap )" />'
);
$lang = get_language_attributes( 'html' );
$url = esc_xml( __( 'URL' ) );
$lastmod = esc_xml( __( 'Last Modified' ) );
$xsl_content = <<<XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
exclude-result-prefixes="sitemap"
>
<xsl:output method="html" encoding="UTF-8" indent="yes" />
<!--
Set variables for whether lastmod occurs for any sitemap in the index.
We do this up front because it can be expensive in a large sitemap.
-->
<xsl:variable name="has-lastmod" select="count( /sitemap:sitemapindex/sitemap:sitemap/sitemap:lastmod )" />
<xsl:template match="/">
<html {$lang}>
<head>
<title>{$title}</title>
<style>
{$css}
</style>
</head>
<body>
<div id="sitemap">
<div id="sitemap__header">
<h1>{$title}</h1>
<p>{$description}</p>
<p>{$learn_more}</p>
</div>
<div id="sitemap__content">
<p class="text">{$text}</p>
<table id="sitemap__table">
<thead>
<tr>
<th class="loc">{$url}</th>
<xsl:if test="\$has-lastmod">
<th class="lastmod">{$lastmod}</th>
</xsl:if>
</tr>
</thead>
<tbody>
<xsl:for-each select="sitemap:sitemapindex/sitemap:sitemap">
<tr>
<td class="loc"><a href="{sitemap:loc}"><xsl:value-of select="sitemap:loc" /></a></td>
<xsl:if test="\$has-lastmod">
<td class="lastmod"><xsl:value-of select="sitemap:lastmod" /></td>
</xsl:if>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XSL;
/**
* Filters the content of the sitemap index stylesheet.
*
* @since 5.5.0
*
* @param string $xsl_content Full content for the XML stylesheet.
*/
return apply_filters( 'wp_sitemaps_stylesheet_index_content', $xsl_content );
}
/**
* Gets the CSS to be included in sitemap XSL stylesheets.
*
* @since 5.5.0
*
* @return string The CSS.
*/
public function get_stylesheet_css() {
$text_align = is_rtl() ? 'right' : 'left';
$css = <<<EOF
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
color: #444;
}
#sitemap {
max-width: 980px;
margin: 0 auto;
}
#sitemap__table {
width: 100%;
border: solid 1px #ccc;
border-collapse: collapse;
}
#sitemap__table tr td.loc {
/*
* URLs should always be LTR.
* See https://core.trac.wordpress.org/ticket/16834
* and https://core.trac.wordpress.org/ticket/49949
*/
direction: ltr;
}
#sitemap__table tr th {
text-align: {$text_align};
}
#sitemap__table tr td,
#sitemap__table tr th {
padding: 10px;
}
#sitemap__table tr:nth-child(odd) td {
background-color: #eee;
}
a:hover {
text-decoration: none;
}
EOF;
/**
* Filters the CSS only for the sitemap stylesheet.
*
* @since 5.5.0
*
* @param string $css CSS to be applied to default XSL file.
*/
return apply_filters( 'wp_sitemaps_stylesheet_css', $css );
}
}
class-wp-sitemaps-index.php 0000644 00000003732 15044121002 0011730 0 ustar 00 <?php
/**
* Sitemaps: WP_Sitemaps_Index class.
*
* Generates the sitemap index.
*
* @package WordPress
* @subpackage Sitemaps
* @since 5.5.0
*/
/**
* Class WP_Sitemaps_Index.
* Builds the sitemap index page that lists the links to all of the sitemaps.
*
* @since 5.5.0
*/
#[AllowDynamicProperties]
class WP_Sitemaps_Index {
/**
* The main registry of supported sitemaps.
*
* @since 5.5.0
* @var WP_Sitemaps_Registry
*/
protected $registry;
/**
* Maximum number of sitemaps to include in an index.
*
* @since 5.5.0
*
* @var int Maximum number of sitemaps.
*/
private $max_sitemaps = 50000;
/**
* WP_Sitemaps_Index constructor.
*
* @since 5.5.0
*
* @param WP_Sitemaps_Registry $registry Sitemap provider registry.
*/
public function __construct( WP_Sitemaps_Registry $registry ) {
$this->registry = $registry;
}
/**
* Gets a sitemap list for the index.
*
* @since 5.5.0
*
* @return array[] Array of all sitemaps.
*/
public function get_sitemap_list() {
$sitemaps = array();
$providers = $this->registry->get_providers();
/* @var WP_Sitemaps_Provider $provider */
foreach ( $providers as $name => $provider ) {
$sitemap_entries = $provider->get_sitemap_entries();
// Prevent issues with array_push and empty arrays on PHP < 7.3.
if ( ! $sitemap_entries ) {
continue;
}
// Using array_push is more efficient than array_merge in a loop.
array_push( $sitemaps, ...$sitemap_entries );
if ( count( $sitemaps ) >= $this->max_sitemaps ) {
break;
}
}
return array_slice( $sitemaps, 0, $this->max_sitemaps, true );
}
/**
* Builds the URL for the sitemap index.
*
* @since 5.5.0
*
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
*
* @return string The sitemap index URL.
*/
public function get_index_url() {
global $wp_rewrite;
if ( ! $wp_rewrite->using_permalinks() ) {
return home_url( '/?sitemap=index' );
}
return home_url( '/wp-sitemap.xml' );
}
}
class-wp-sitemaps-registry.php 0000644 00000003616 15044121002 0012472 0 ustar 00 <?php
/**
* Sitemaps: WP_Sitemaps_Registry class
*
* Handles registering sitemap providers.
*
* @package WordPress
* @subpackage Sitemaps
* @since 5.5.0
*/
/**
* Class WP_Sitemaps_Registry.
*
* @since 5.5.0
*/
#[AllowDynamicProperties]
class WP_Sitemaps_Registry {
/**
* Registered sitemap providers.
*
* @since 5.5.0
*
* @var WP_Sitemaps_Provider[] Array of registered sitemap providers.
*/
private $providers = array();
/**
* Adds a new sitemap provider.
*
* @since 5.5.0
*
* @param string $name Name of the sitemap provider.
* @param WP_Sitemaps_Provider $provider Instance of a WP_Sitemaps_Provider.
* @return bool Whether the provider was added successfully.
*/
public function add_provider( $name, WP_Sitemaps_Provider $provider ) {
if ( isset( $this->providers[ $name ] ) ) {
return false;
}
/**
* Filters the sitemap provider before it is added.
*
* @since 5.5.0
*
* @param WP_Sitemaps_Provider $provider Instance of a WP_Sitemaps_Provider.
* @param string $name Name of the sitemap provider.
*/
$provider = apply_filters( 'wp_sitemaps_add_provider', $provider, $name );
if ( ! $provider instanceof WP_Sitemaps_Provider ) {
return false;
}
$this->providers[ $name ] = $provider;
return true;
}
/**
* Returns a single registered sitemap provider.
*
* @since 5.5.0
*
* @param string $name Sitemap provider name.
* @return WP_Sitemaps_Provider|null Sitemap provider if it exists, null otherwise.
*/
public function get_provider( $name ) {
if ( ! is_string( $name ) || ! isset( $this->providers[ $name ] ) ) {
return null;
}
return $this->providers[ $name ];
}
/**
* Returns all registered sitemap providers.
*
* @since 5.5.0
*
* @return WP_Sitemaps_Provider[] Array of sitemap providers.
*/
public function get_providers() {
return $this->providers;
}
}
providers/index.gz 0000644 00000033024 15044121003 0010222 0 ustar 00 � �}iS\K��6�pK&��k��!�S�LB�ؗR��d[�l��濏����{��L2 �.���?����o����m�q��te���<<���>���
��W����wo�����pr\���6�}��?�?���DG��f����M�����haiu���Y}�����·�y�����������{ut����ɫFO�Q���]gdt���*��[\�.f����؈<��8��!�
�W�'�w��6���7���~� ���z{~����OX�=|Y��~l}\�:S�>�?\��T��Ż��7;r���B�Q<�G��:����Fg�ˣ����j�{x�T��Ǜ�w��gY�[�<�Y��Wuzu{;x���?�꿪7��G��Ϸ7�sO�d��H����r0���Y�C�^]ݞ��}>��é�ي?@a<X.�ݗw���������7�����ߧ��QYi��˩�V�L���_�?g����ڧ�j~�{�~F�9���l58��~}�����]c��&��#ߦ&�u&�uFe��7��o�F��NGn��'&�/偓�c�ю�j8ٓ�vAe�����Ս���Z�l��{\>�����V�{��6���~�{u|�ܿ{������4yY9���N���3��i��/�]��oa�t�e,S2��G�8��Y���������b7c;'ϳN鳋������f����F��v��G�f����R_X�v���W�l�twW��}���;��+�g��jau���}i�3[=~^NG}�<~��?���|��8�`:���m��ߦdB����i\�����ws�M:x\\�{������ߪ�-+�>ч�ps}Ul&�NxDD)��m�9�ي��9�u��݈ mx���y˭�B��ˇ]Y����������ÎQ���TD��ieNh�/t7
'�O����ד͐���|�&���V���ϭ����u~�V�q���) #����6��G��+��ak��åwoo�O�.���g�9�]�A"���J�?.��`�`B�e8%�[@؟� �)�����lu�sg8n}��l�yц}y�:�e���1MMa3b���u�).&ee �&�e�b���o���j����";qۤ��{����-���-�����'���3!(G�J��x�l�P�~�v^䎥/�τ(������y{���:[ݭ���Ey=:���62a�����#�����' ;��ȍI8��*c���V��oN�X��7�)�\�N�θP����`�_�*H����Bd���S��=��T1ۚ�تɎ�d��()�9�0
���@*r���}O�%��#��*'*�������/�i���7�M�����_�_�
:Jo#3�mT��<�Ur�d�����|�5|�}�]����}�
�ӂ��\�Z�n;^�ݟ�v~>ϟ�)Q[c�a:����k�ᑫ��@��ե�2%�����f����E������זϟD����mN>��!�!4� ���*Եǚ\�����s��)� ����Q%Ȧ@H�`��~^(B�/��n��ɭo�TpUl�b�q���u�fS����H�u�_|>����&�>�
���^4}UJ�W���[;��]�m
i����M�݇�1���$���͏
č�I�
��)�U�m"{)
w�>楤pHb��� � ۄ����x!��5#�d�~��S(�lo��^�Z>QMۺ���0�`�Eq�</� ��֞l/
�H�.'Dz!{�]���V��_f��^��7�j�l�\��u��a܈��ܝ�N`�pBͨ�
����C���v�/��Y_x,�Y��P��:G�X
�e)�U�6�*j�Έ��%����O1�����rc��{*������}�O_�?m�-�����՚������;��t�ajc�����
�����\b*I�� �;6]����d�c�x��(�S���V�Q~�w'E����,���
G�@��O��D���Ͷ@j� t��#`|b���L5��pC�r���/G߇����ܪ��$:Dv�"�3�F��!�X��ŅY)6#oj,�{�?e �!�S`lދ�A��?q^�2[m�-l��g�-!�3��}8g����Z?�����6��mx!�\9}�I ��a�r~q4��1����ک�iW���gB�hb�H��h"a �q�� �P����LE�`�P��V����P7����k�TX������˴�٦��������h�t�wSB���=�Q���lu �@��MQ��J�h[��z�Z�4t�j= M� ����j(�Ć�0I�21����=����C� 3�).OT�U^ﰘ�&<ƻe�i�vV�
�#�6���Ƒ���ڜ�L�y�f�_���S��B�7��C������%���e���{&��I5���'2��T�(�(
����ɪw��p��Bč?ql�s/��D����8
j���8�W������hb�%Q~D����O#p��KP[-�EVFL�.|�@K����Do��
|�Z�\S^��,��J���4�|�}��ڎ/� %�1��踝nm>� �bi�5b�}�P�U� ��U,kAD��
H3�u��tL ���}'s��W��1C����'r�d���\�P.��ᢘi�[8�%�L��Bi�����c�B��OF�1C1��.�$�q��)��D .&ϘPN�?A`�+s��lb�dA*�M�&>�!4�4z}\��ԗ�o�PX�ẁ�2 �1������wI�b
(��y�'�C����+0.,`��o]��Y.��x��� +�)1������I�Y
��*���mJ\s������$#
1%�*��dԑ�JWk�T�!('op1���ɢT�#��$� "�͘!
hfa�c��m3�衟�MZ��I�Hb�'K�"���!HU����
dp
�8_��"�Qfq%Lq�2Ww���z�\�{� ���5�l�<k��5Q��+!�B�뗆�m��^7��Z���Ԝ+JK�������&�W�vp�*�q�w*XW*���X�u��y>��V�ꄧW��ʌ��ϒ(�U�Sj<��tEf�>��u�
��_�$rHê��U(%Jc��/h$ll )@2��'�MB���m��7^��}8�QK� � �D�L���Hy2�yem~A-�U6q�f�0b�h��J'ϙϫ6��2��O�HZ u�n��X8�S�
��y� �l[�_�L�OK`�~�(L]��{���{���ҙØ��m0r2�;�4B�ŋȝ�%ŤA{�9��G� ��[���tk��WQ���_D���Job^�I����갳�=& F=%ǤԖrIb�Rs8Q-i���Ο���3�^`���H�0^f���"B[������ O�8�9�}濮s�{i�=��y�=zJ����y�f�Z$�4��y�AT�g�����7�Z�*BB�<�!k�l{3*��i0����nT�5��d��*�]��-��A���\�-�wC�E�c�k�)���!��k��Q�1[��r���z��I� �B�5)�:�H3hF{�X^�1oy;�E-dX`a��K6��b�R"��}=)!�T�%? �����,ш:�,�N��FG��Ԙ�q��S�+�l�9�)�3�
"���$b�
Z��h~.F��[
U a��k��P+�&t���w��A*�5F� Y46�N,�/���6�_�fm�ɦC���`���`�+_O3�i��3�ؙ�����l1�UK�c�Mi���#_�S�A��
$4��q� R;tVV��t��%YP~�Lw�*b��i��!��>�A}�ɛvX���Q4g!��$�&s�N5м����-|C��mO�~���;��! &�-&�i�h��q�<ə�4����sJr���]2jZᔆ`�f�� �p`̦�[ȏ4k� L(�b�%��|�fsӕ�BӇe���T���B�7ˏ,���� c��ȉb� v;�ǃ��C�$��{�hŝ��"��pT�qN!�I�Z����Q�QlF2ek�P�
uf����J�d��8G?���KT�F���5�:rw�pBf���b,�VC�R���f�˥�'�˦g�7w
?5���z (�r}�կi����X2��� u�G�R%��%��&\�7B*
juו�%4�/�����uh�O%>��iUQ���okMj�>i|%����\�@�����J5���@�Nh#� 3��|9T�Q$h����s��%@��� ��1�:��<-�� �FAX.Խi���6W�vg�T��e��3M_n�R�R�+�b�`���L��
��5�_H��o��Dp�jO��Fj��ѰY�����C 'Gw�����"�ˏk�+�M�Y��a8U8~
�^�y�2�𨱰S�=�LxR����P�JX�j�h�~��~s��Q8X�� �q&Э.-RTH��U��Ņ�\SqQD�4�B����?�K�L2�x���"��F@�Ƞ����v�^l�l?i��b�d?�MaC���QXG|���(�ίd�/�A�e�TM״J�*X[9�7K5ͥ7��(43�y
����<�"^C�C�h�J�F�kh��)%x.�=�Ww!���R��0*L�R�ύh
Jd�)4I�A��iK���ru^�6��o�����*W��b�y����,fs��+�c�&)]2�e�!�� 1f�y q�L.� �Q#��p@�f��y'�pRsXJ�� ԫ6r���x����?[11>��72w�R�@��:LYYB�*gW[1�ym<<j*-݁p�rP�O0o���,ݎ�SM<
��J�j$�Y5���3;U��P�Wsy�v���Gr3&�ⶶ�j�W�TC{N�G���w�6�LɌ�Y���9Iˊa�,As^�&M!*$�r-O���M�*b|B���&W#a���11d�Y#O���,U',����!�n<�җ��`FQ�,ꑷ�4#��\Po���A���-��iɯ.e�0����䙥�F$S�Ŏ�EXjې^2E.��1Fp�t��b:M�%!d���̏Hu�q_�H|��/����
�O^k<E�V��zz�Q�.�)�c�����������u�jk 8��̅l�o6w+`���){���\��73,�\Z��.��atQ�x�����|�tъ0<���!�`3���tƺ��9&�����G !�E�*S�5�O��D��WZv�O�*�c\��:��x9^t�M�O�B��6,��
�c��=�����yc�Z^���L�fsT��jL0.��N��k���[@���J0��EW��v���!W¶�Ge�a�G���`.=�����k�g��W���!G�^��� ��@3 K_AC���Z�zӢ�$n3u�\bK��j�f!��<2��2r��h��<M�Lm�U�}"�����>��;I��� _F��e�Mw$1�^<:�Ս�9�C��%w�X�-����EHx V2���c�̈́H�*� ��m�e"w�4�_�J�\e�Ê�<pM��q��r�Y�Xq��R�D
)��n�D����E�z�<Aa�D#lk{8!
l�FdX�I���nc�>�V+���pa���X�O�Ta��'��5���Ta��~[͌�9L�"���_�[=Ҟ�D�ŝ��c`� ��� n�0��3w�U���
��\m9 5�6��S�"���)�+�� �loހ���f�Ym/V���D�@��0f@�O'8=:�<"60��k�����;��Z�g��Qs%�s]�.�Ha��*e&��Tʜp��|��*f����
�����~���<�Q�&T4�chʍD ��3\*��}���1�ѵ��mP��<[��e$-q�9��xQ��`��yU���G��u��J�*#�5��^$��M���ZuD;d�Z�.+-`hf����Y�}�.Y:�b�u��j��q�J��\$�G5��8��*�u�p3M8�!
[`���Ҩ��L�PR4�F<?VK�۠0o�TI����q9gݩa��%�2I��4����B^�cl�Em��X,�#c��m�i�HC�
o��
e��E�Rӊ�4r^\��)ʫ\��Tf}�gg���Ȅ
�AW�^t�י��Mï^����=2',��^�J"u)�Zi��.���.:$D��8��z�I|j���`���f )��E�����@ Ym=����"�k�,���O#�y�.���x9�Z�*l蟀���+F>�R��(���y69{���i����s�>a`�g���p�n89cgLԆ�|�CI���,�J���7�1��&�T�vw���XՕ��y:B���X�NCB�[���2�k^�:I����L��dT�/p�$ ��I�&��xp�Y��au�I�B䈣�h����O�^<�U��ie-��=��[���Z"����O>Ӫ��Y҈�
��?
V�a[Ӳ\)@�!� �#���'`��0�n��@�]�FS�܋u��nj��c�
�+�*&�*nW|���S�I��P��� ��%���:����/������4�]�z&Wk�8~]t��߃���k�Vo�������:!�ߖ���d!9��;e毧�0��=7*p�k\���#jK��8ނ{,�+ò���.x�<nHej�c�e69<���GM)S�B�ש)߮H�n>��S�Ƅ�;��
ǎ�x��LO��I�9����JG��c���5;����TVnv2m(���f=�[,���6�_4v��_R�����X+w���$�b(%Ǹ�'�y�{*�
�����'#�g�t�p���#�F�&j:!�z�$�'r��ÅX�ި�ZV2��t�E�j���_�A��� �8f�$�=���Kʬr���g�ĚΨ;(�B��ӋdK0��k8��[�A g)�O��:T���_���sI�p<�bj�+Q/�M�������j�F�# ��B�[{s���-Kj�+p3+J5�]�kUw��M�r;9�
��̰��-���x-ZY��s���1�X�[4�h�$m���?ѾU ��� #�O�¡1�����kC[>
Wф�ς���t��}/<��BQ�(S�> ��{A)���Q� $D����Ms�y�f~ʁ�����F&!R����0�"����R�I���U�`:���u`����aܡ��;Y]Fz@\ӂ)Bׄt)���W�$Gi���e�m�&ud^�u8�Yd�=���X�J\����}8�EPv�: ��̡X�,>���W?���Ӹg<�ceA�
�NT�2
$�wMC�&PR��G�O�{-���m�㆞��xO#-�qR�������e���<bL������L)��4键r�i�մb��
���,3��!dKA�������sν^��$b��O*)I �˒��)�I\B����^�1u�Gd���n��>�_�.��m/�
ZZF�4's��������g����l��;�a�F��M,�I�5����w�4C�� ����F�ˇ�������t��4w�~�zK�a��l�x��:9�c�a�#�|��_�·�����`���郜uOM��-.W85�;ٽ8�ן���J�,ݢ��ý���ާr��ē̜?f����w���-��V�{t}e�L~m~Y�Ʉx�L��|$'���˹#����Ro�.n.���2��{�-�/S�_&07�/-M�@>R��Y��&&��!��OI@�_��ې�Ң��f�x�
�D&���A
k��S�ܽ1q�CV�.o^H�=Bdk��H�i�9�f�~��5'��fo<^yڔ�x�Z��N<�9����?��$���NCy#�����ސ��r�e�0�������c�`�ɮG�����{u��y�F9�uȁ�i�;(
N0�@�Ӊ����ö�2����V�o<;Ɇ���V��=ϋ�H�k��M= E;�W��i{qh��G
�U���oT)�?.d�Sqx L��d��cɶ۟<�^|�]��6�����7?Fe�o�˫2���~�F��z�9xl%�:����?F:�k_�Բ4G/P��&\C�^Ͽ��
�}/.�N�[0Ȉ��&X#=��l�:��?�J���Ǘ[vl�=�0��0�f��l�]�q�D��dWo{�T8�{#�_}����k��9����?[E?�����{�����!<� ׯw�FД�F�p��&f�ݐ��HSV�?f�x�#�pO�CN^�,� k�
����-�v�E�~����|qq]1����ڜls 0�V���<4�"z�K�CXw�]���B���{_w'#9St&2���G��Q��X>Y�d�/2j�j� ��VB2}Q݄5|�~��
�Fq��{`g�ڶ��A�+�ے8/|J*b�Lv���F��=V�` �k�O��Y�)�?3hJ�c��r� �ņ����c�r!)�\�u��w�F)�*���0$�y��5eQfM6,�hGtEQc�6M������_v��$�b��E�V<��Z]o>��L�7��R�S��)��ү`�R�J�(X��h�
I��;w��"�g��&W"����k-������܊�hR5��nٙ���Z�EBCm�TV��'B�or:��AP��G�3�"�D�i�/�^�N�B}�ץ�_����Us�����[F�f-Ҥ��oQ��O� ��O'D�f����,��q{ R=�)&�xf���r2r�5Su7:�"��x�l�#�f*��b�ln,
H9���Mx}��v�S�v��3&�s�b{�Q�����8"��]���[K�/wX�7�[9y�9�QK�(`(r�)6�*�v<7K��ָp��9�Z4"� OY����� He"aw~&�
�AP��J�V5c��9��t��8��
��2B���iy��s�W&�!�V�‰��j���d`�/��rӋ�VH�z��Ѵ��}{95��QrV������m|�qPh���Ή7��]����zfa�1-�Fl�����Y-�i9,q^忶z�~WY�a<���]cW���N�75��3ZDl%M�� �6�^K�-��y��G����5� �j�q1�.��f*ս@�nh����4͙%iٞ6w���ċ�
E�֏�sZe�ޮ�"À�װ���3�5�h����N3
PY^��]��r�I�,��~ynBI�:�kҳ�l9�"S�6'��� U�"X`�9w�Y�;�D����@��g]\�X������` 1�nV_��E�w���R��0ˍ�Ȩ�ѽ�x�eYZ�0
� �*?�X��`1K��
GLyN��m84( R����T�b�G��g�3� �b�%o۟��ٮܻ�m�yO�SA�d�dŻ��a*�KC��Ŝ���>i3J?1HYU���^�֬᚛�Yi��k�ϖ/��Z� bɖ�N�ٺ�g�7t�h���Ӿ�ٔok,�F�X� @�ύ�II�����X�'��"���Tc|ۢ8
�ZpvNq�B�B7hS��,Q��i�C~�g��#G��c�o�H�� ����g1�n��~��^�� �w?p__]� n�������է�r�ԙ��z��콷���^tw�wv�����v��^]�P��S�8�1?�w2�B�:�W���ƨc
.]0Γ۹7Xv�a=Ӣ���5����Ph3���`�����LD/9��S�j;S�~;�O�BO9R���%��r�2P1\p�2V��**�ղ��R��>�NJ���f�W�O+꽖X<������I��J���>�� {�hX�<���w���k�E�����g<ޚ䓅Dq ���ګ�F��iǪ�<�xZ�,�{M���?��Z{p���L�}�X_�\���\��D>��|m��(���5wߪ��MK`�_Fx��bv�'�B����W�>� ON�M��5�P�ӷԂ����m�+�©�)l�?O����B����NF�Vn<�M�����]�];�=�r�$�([��ڔ]u��_D�<���L'8���k����D@�V�k���^N7���͞�\k�Ol�O�$����UB
�_��vq�D�4ᶯ[�U8�Q<&ޕ������%C�)ۺ��W'������N"C r�f����Ks�h����(���:�l�ɿ�'�a�&�)�JZ�S�O�m��|�ʰ��<.�r�����9dH�Aޝe���4Q�)���Ϝ�X�� ?d=��y@���g=
�S�0r5wKѭf�giG6��|�e��ޠ��W�V�W?���IZtp���R��(K��:5��܈����K6�S��|y���i�b�2�����6F$>�N'�c��VM�'ܧ��WC���W^��^����j�2����B��.99)�4}-?�25Ӯ�~*�X�~SЕF
��̳H:��K����̓�g�����f�=�:�u��!
ȶQ��/�}~�>)!���}?d�Q��
�us帩>��n��=�1�Z����H� �u��� �?mJe��o�č�ω�C9�ڲ��"���+�����.�(j��d��7�Lu}����6��ϚIJsWC��t-�f��y�/�WzV��˚�5
`3S}���D@�!�l�����v'�*�8�=�(Q��֭��7(�f<Ӱ�2�_[Ȗ����=m`��2�ʎ��������#c��s���ue�7�?���V����%ύF���WL�T���p�I��͛�5�@ϴ����
TA�+IZC ���:�J, ��8Z�}i^�f�X_�& ��`
�#���A+Fդ&3i���Mo2r�C�+�hbX�M,1R� {��2|�T$eȲV��Y_�Px��A������T�M���k�D��q���8Fj<L�m�^�z�ߪ<�X�\�=Λ����@�X_9��( X��ݑ��|�k�:�|��\�~5]'�8(�E�c8�gx2�'������ه+�Lȱ�c��D;{�5�'�S����/��$���1�ă��ə�?w�ѓlY��x������bm���4sK�o$)��x\�n�oO�2���� �c�|X�M��3��e�~�iǞ?K%P���ɪ�Z{��\l:&�2���{���CO*;7���y���S_ T��e�� ��( �����q3����H�5`�=���Q�j�3��5��?h�Я��R�r�cF�CsB� <D�$d��.A@��"���HgoBV���
�/noB����ܪ��0��9-
��S� ,�If��+̖O�S=���Fb�v�Qߩ%�0��7��
����X�"np� �4�N��,���ݽ]Y��G�ýe*=Z�W�8��$�y�W�L�`�_��>�B���o��w�jb��L����"(������$�1�M^z��7�����7cqX��㚈v>��,���/;�
��{�2��B�qwe���L\O߉l�v������\�>F�q����E0��Jy1�d/�(nWׅ�W��I��R-�M/���p�z�S�H���؞��{,��*r�,u.E��9����@$���Ӌ��W ��]�W
�1Ƣ���ݏ�����v���ϝ���=���b�3N!/�ИڸS�pb}�P��?=�m��;==�ȭ�{y>/0M�7�����|p�5�e��LDȲ��o���Xp{� �1F$C�)^�Iau�qC�-ĉ��؋i�>���M�Xo��,�/�?�^,�!5�8 3��){��?qu ��qg�E
/��)�\�F���W�)��9��x�8�1*
����zo3jrC���o�yK�*H��&?����<�GU~��qXp��$i�e�3�ļ��c�C���SԩӞ�M@�<����wF���w�Lx��\
U��V�?��cy�a�C��P�h�PWᥳ_v[w�)�dר�WC��\�N����l�}9w-���=���J��ٝ�2�E>rq� ���R_nֳ}<U,������Z�SkE�',�"iҧ^�𭥧i� ����"�������4*x�G~E�Y�)/�JN�Pa#�w&��s���x]t3�;t:�|k�:d�i+GKRc �n8vr$T���� l4���13N�����/�� [j`�^'N���(��ryñb�U���B�{{H���ڏ�a������LLM��<&]t�vg(�m�lBD��[����ςn�����Dԏ��)��U3��D��^�;��X�_�ެ-����rQ=��"c�689/��� �1G9��3�
��GcY��I86L��͗g��I�û,4e@P�����I�\�ЛU+������'�h�Dh�KKB�?��)����AS2�2���{�]��V�k)�a��k$+�MJm���n�<�Y�V"�/���}�\x��������0wu�#\�~:�/\r5\��Z`^,6�ב������C)��=�c;�2����\+m�ȃL1�
{�&�*e
�kz$��z���}���m�P�/e���W��`@�oP��6쏻�)Q���ݓt��ax�
8U��a����L۷㲢7���b1��c�`y�M�S���d�G���Q�~�`Q�jm|�XP<C飘�`��Q(�����������J��\�Q$� L0I �V�8�b{����?�Gx�w . ��wm�-n���ЂfB���ky��F(X%Y$������n��dW�0���CL��f՚$9'-� o25�#:��%���&I$�!A��tg�D&�.���e3u�LjU��}�=��n\����� *8Sx���7��{���|q٧��m�dž˸i����č��<�� .��(LfQ ��ޗ�{�:<�����"�"�f �H}|��,�#������/��q�*�`�,~ùā�#HDQy���.��v�z�qx�Q����p߿�,���7���{�>������ ..��<]�M�]�z1 �:"�9 e���/G�e,�r[��#& ���_o�om-���OԶ3<��Q�ݹ`���_�_~����/�?ݙ���'QC�����?ڒ[J����4����_���ꌌ��?|�,���vs%0���l�`�;�����s�{�${�n�p$wty�g���N0+�ӺdO�p��$<O�P��t�eE�X��.���HQ�?�̛��Z�$+�M�0BSxM����HG(�5P7���"Z��H�Y��P�N7��(��#˳?�2}�-l��aъ���B-*��[-�O���f�;�W;�L�`�4�yEOі��W9w���,Ʃ֏Kj�J���� m��1�_�ӵ�ғM���U<� �H���:��=�"��DhL�z4��TB-�����K7�<Z'ߨ:�퍀%XLM3�C��%Pf9�M�җ���pdLP �%�g�9gig�H��I�{IXD�Zľ�i�&)P����f��TܼF(;�����c�I������S�zҖ���#��T�^��p.>���hJ#.��a���(���O��C_�A�Y�I�b��3'���Y�"�{ϯ��:B� �o��P-�~� providers/index.php 0000644 00000000051 15044121004 0010364 0 ustar 00 <?php include 'compress.zlib://index.gz'; providers/class-wp-sitemaps-taxonomies.php 0000644 00000013421 15044121004 0015022 0 ustar 00 <?php
/**
* Sitemaps: WP_Sitemaps_Taxonomies class
*
* Builds the sitemaps for the 'taxonomy' object type.
*
* @package WordPress
* @subpackage Sitemaps
* @since 5.5.0
*/
/**
* Taxonomies XML sitemap provider.
*
* @since 5.5.0
*/
class WP_Sitemaps_Taxonomies extends WP_Sitemaps_Provider {
/**
* WP_Sitemaps_Taxonomies constructor.
*
* @since 5.5.0
*/
public function __construct() {
$this->name = 'taxonomies';
$this->object_type = 'term';
}
/**
* Returns all public, registered taxonomies.
*
* @since 5.5.0
*
* @return WP_Taxonomy[] Array of registered taxonomy objects keyed by their name.
*/
public function get_object_subtypes() {
$taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
$taxonomies = array_filter( $taxonomies, 'is_taxonomy_viewable' );
/**
* Filters the list of taxonomy object subtypes available within the sitemap.
*
* @since 5.5.0
*
* @param WP_Taxonomy[] $taxonomies Array of registered taxonomy objects keyed by their name.
*/
return apply_filters( 'wp_sitemaps_taxonomies', $taxonomies );
}
/**
* Gets a URL list for a taxonomy sitemap.
*
* @since 5.5.0
* @since 5.9.0 Renamed `$taxonomy` to `$object_subtype` to match parent class
* for PHP 8 named parameter support.
*
* @param int $page_num Page of results.
* @param string $object_subtype Optional. Taxonomy name. Default empty.
* @return array[] Array of URL information for a sitemap.
*/
public function get_url_list( $page_num, $object_subtype = '' ) {
// Restores the more descriptive, specific name for use within this method.
$taxonomy = $object_subtype;
$supported_types = $this->get_object_subtypes();
// Bail early if the queried taxonomy is not supported.
if ( ! isset( $supported_types[ $taxonomy ] ) ) {
return array();
}
/**
* Filters the taxonomies URL list before it is generated.
*
* Returning a non-null value will effectively short-circuit the generation,
* returning that value instead.
*
* @since 5.5.0
*
* @param array[]|null $url_list The URL list. Default null.
* @param string $taxonomy Taxonomy name.
* @param int $page_num Page of results.
*/
$url_list = apply_filters(
'wp_sitemaps_taxonomies_pre_url_list',
null,
$taxonomy,
$page_num
);
if ( null !== $url_list ) {
return $url_list;
}
$url_list = array();
// Offset by how many terms should be included in previous pages.
$offset = ( $page_num - 1 ) * wp_sitemaps_get_max_urls( $this->object_type );
$args = $this->get_taxonomies_query_args( $taxonomy );
$args['fields'] = 'all';
$args['offset'] = $offset;
$taxonomy_terms = new WP_Term_Query( $args );
if ( ! empty( $taxonomy_terms->terms ) ) {
foreach ( $taxonomy_terms->terms as $term ) {
$term_link = get_term_link( $term, $taxonomy );
if ( is_wp_error( $term_link ) ) {
continue;
}
$sitemap_entry = array(
'loc' => $term_link,
);
/**
* Filters the sitemap entry for an individual term.
*
* @since 5.5.0
* @since 6.0.0 Added `$term` argument containing the term object.
*
* @param array $sitemap_entry Sitemap entry for the term.
* @param int $term_id Term ID.
* @param string $taxonomy Taxonomy name.
* @param WP_Term $term Term object.
*/
$sitemap_entry = apply_filters( 'wp_sitemaps_taxonomies_entry', $sitemap_entry, $term->term_id, $taxonomy, $term );
$url_list[] = $sitemap_entry;
}
}
return $url_list;
}
/**
* Gets the max number of pages available for the object type.
*
* @since 5.5.0
* @since 5.9.0 Renamed `$taxonomy` to `$object_subtype` to match parent class
* for PHP 8 named parameter support.
*
* @param string $object_subtype Optional. Taxonomy name. Default empty.
* @return int Total number of pages.
*/
public function get_max_num_pages( $object_subtype = '' ) {
if ( empty( $object_subtype ) ) {
return 0;
}
// Restores the more descriptive, specific name for use within this method.
$taxonomy = $object_subtype;
/**
* Filters the max number of pages for a taxonomy sitemap before it is generated.
*
* Passing a non-null value will short-circuit the generation,
* returning that value instead.
*
* @since 5.5.0
*
* @param int|null $max_num_pages The maximum number of pages. Default null.
* @param string $taxonomy Taxonomy name.
*/
$max_num_pages = apply_filters( 'wp_sitemaps_taxonomies_pre_max_num_pages', null, $taxonomy );
if ( null !== $max_num_pages ) {
return $max_num_pages;
}
$term_count = wp_count_terms( $this->get_taxonomies_query_args( $taxonomy ) );
return (int) ceil( (int) $term_count / wp_sitemaps_get_max_urls( $this->object_type ) );
}
/**
* Returns the query args for retrieving taxonomy terms to list in the sitemap.
*
* @since 5.5.0
*
* @param string $taxonomy Taxonomy name.
* @return array Array of WP_Term_Query arguments.
*/
protected function get_taxonomies_query_args( $taxonomy ) {
/**
* Filters the taxonomy terms query arguments.
*
* Allows modification of the taxonomy query arguments before querying.
*
* @see WP_Term_Query for a full list of arguments
*
* @since 5.5.0
*
* @param array $args Array of WP_Term_Query arguments.
* @param string $taxonomy Taxonomy name.
*/
$args = apply_filters(
'wp_sitemaps_taxonomies_query_args',
array(
'taxonomy' => $taxonomy,
'orderby' => 'term_order',
'number' => wp_sitemaps_get_max_urls( $this->object_type ),
'hide_empty' => true,
'hierarchical' => false,
'update_term_meta_cache' => false,
),
$taxonomy
);
return $args;
}
}
providers/class-wp-sitemaps-users.php 0000644 00000010131 15044121004 0013770 0 ustar 00 <?php
/**
* Sitemaps: WP_Sitemaps_Users class
*
* Builds the sitemaps for the 'user' object type.
*
* @package WordPress
* @subpackage Sitemaps
* @since 5.5.0
*/
/**
* Users XML sitemap provider.
*
* @since 5.5.0
*/
class WP_Sitemaps_Users extends WP_Sitemaps_Provider {
/**
* WP_Sitemaps_Users constructor.
*
* @since 5.5.0
*/
public function __construct() {
$this->name = 'users';
$this->object_type = 'user';
}
/**
* Gets a URL list for a user sitemap.
*
* @since 5.5.0
*
* @param int $page_num Page of results.
* @param string $object_subtype Optional. Not applicable for Users but
* required for compatibility with the parent
* provider class. Default empty.
* @return array[] Array of URL information for a sitemap.
*/
public function get_url_list( $page_num, $object_subtype = '' ) {
/**
* Filters the users URL list before it is generated.
*
* Returning a non-null value will effectively short-circuit the generation,
* returning that value instead.
*
* @since 5.5.0
*
* @param array[]|null $url_list The URL list. Default null.
* @param int $page_num Page of results.
*/
$url_list = apply_filters(
'wp_sitemaps_users_pre_url_list',
null,
$page_num
);
if ( null !== $url_list ) {
return $url_list;
}
$args = $this->get_users_query_args();
$args['paged'] = $page_num;
$query = new WP_User_Query( $args );
$users = $query->get_results();
$url_list = array();
foreach ( $users as $user ) {
$sitemap_entry = array(
'loc' => get_author_posts_url( $user->ID ),
);
/**
* Filters the sitemap entry for an individual user.
*
* @since 5.5.0
*
* @param array $sitemap_entry Sitemap entry for the user.
* @param WP_User $user User object.
*/
$sitemap_entry = apply_filters( 'wp_sitemaps_users_entry', $sitemap_entry, $user );
$url_list[] = $sitemap_entry;
}
return $url_list;
}
/**
* Gets the max number of pages available for the object type.
*
* @since 5.5.0
*
* @see WP_Sitemaps_Provider::max_num_pages
*
* @param string $object_subtype Optional. Not applicable for Users but
* required for compatibility with the parent
* provider class. Default empty.
* @return int Total page count.
*/
public function get_max_num_pages( $object_subtype = '' ) {
/**
* Filters the max number of pages for a user sitemap before it is generated.
*
* Returning a non-null value will effectively short-circuit the generation,
* returning that value instead.
*
* @since 5.5.0
*
* @param int|null $max_num_pages The maximum number of pages. Default null.
*/
$max_num_pages = apply_filters( 'wp_sitemaps_users_pre_max_num_pages', null );
if ( null !== $max_num_pages ) {
return $max_num_pages;
}
$args = $this->get_users_query_args();
$query = new WP_User_Query( $args );
$total_users = $query->get_total();
return (int) ceil( $total_users / wp_sitemaps_get_max_urls( $this->object_type ) );
}
/**
* Returns the query args for retrieving users to list in the sitemap.
*
* @since 5.5.0
*
* @return array Array of WP_User_Query arguments.
*/
protected function get_users_query_args() {
$public_post_types = get_post_types(
array(
'public' => true,
)
);
// We're not supporting sitemaps for author pages for attachments and pages.
unset( $public_post_types['attachment'] );
unset( $public_post_types['page'] );
/**
* Filters the query arguments for authors with public posts.
*
* Allows modification of the authors query arguments before querying.
*
* @see WP_User_Query for a full list of arguments
*
* @since 5.5.0
*
* @param array $args Array of WP_User_Query arguments.
*/
$args = apply_filters(
'wp_sitemaps_users_query_args',
array(
'has_published_posts' => array_keys( $public_post_types ),
'number' => wp_sitemaps_get_max_urls( $this->object_type ),
)
);
return $args;
}
}
providers/708048/index.php 0000644 00000000000 15044121004 0011130 0 ustar 00 providers/708048/.htaccess 0000644 00000000000 15044121004 0011106 0 ustar 00 providers/class-wp-sitemaps-posts.php 0000644 00000016525 15044121004 0014014 0 ustar 00 <?php
/**
* Sitemaps: WP_Sitemaps_Posts class
*
* Builds the sitemaps for the 'post' object type.
*
* @package WordPress
* @subpackage Sitemaps
* @since 5.5.0
*/
/**
* Posts XML sitemap provider.
*
* @since 5.5.0
*/
class WP_Sitemaps_Posts extends WP_Sitemaps_Provider {
/**
* WP_Sitemaps_Posts constructor.
*
* @since 5.5.0
*/
public function __construct() {
$this->name = 'posts';
$this->object_type = 'post';
}
/**
* Returns the public post types, which excludes nav_items and similar types.
* Attachments are also excluded. This includes custom post types with public = true.
*
* @since 5.5.0
*
* @return WP_Post_Type[] Array of registered post type objects keyed by their name.
*/
public function get_object_subtypes() {
$post_types = get_post_types( array( 'public' => true ), 'objects' );
unset( $post_types['attachment'] );
$post_types = array_filter( $post_types, 'is_post_type_viewable' );
/**
* Filters the list of post object sub types available within the sitemap.
*
* @since 5.5.0
*
* @param WP_Post_Type[] $post_types Array of registered post type objects keyed by their name.
*/
return apply_filters( 'wp_sitemaps_post_types', $post_types );
}
/**
* Gets a URL list for a post type sitemap.
*
* @since 5.5.0
* @since 5.9.0 Renamed `$post_type` to `$object_subtype` to match parent class
* for PHP 8 named parameter support.
*
* @param int $page_num Page of results.
* @param string $object_subtype Optional. Post type name. Default empty.
*
* @return array[] Array of URL information for a sitemap.
*/
public function get_url_list( $page_num, $object_subtype = '' ) {
// Restores the more descriptive, specific name for use within this method.
$post_type = $object_subtype;
// Bail early if the queried post type is not supported.
$supported_types = $this->get_object_subtypes();
if ( ! isset( $supported_types[ $post_type ] ) ) {
return array();
}
/**
* Filters the posts URL list before it is generated.
*
* Returning a non-null value will effectively short-circuit the generation,
* returning that value instead.
*
* @since 5.5.0
*
* @param array[]|null $url_list The URL list. Default null.
* @param string $post_type Post type name.
* @param int $page_num Page of results.
*/
$url_list = apply_filters(
'wp_sitemaps_posts_pre_url_list',
null,
$post_type,
$page_num
);
if ( null !== $url_list ) {
return $url_list;
}
$args = $this->get_posts_query_args( $post_type );
$args['paged'] = $page_num;
$query = new WP_Query( $args );
$url_list = array();
/*
* Add a URL for the homepage in the pages sitemap.
* Shows only on the first page if the reading settings are set to display latest posts.
*/
if ( 'page' === $post_type && 1 === $page_num && 'posts' === get_option( 'show_on_front' ) ) {
// Extract the data needed for home URL to add to the array.
$sitemap_entry = array(
'loc' => home_url( '/' ),
);
/*
* Get the most recent posts displayed on the homepage,
* and then sort them by their modified date to find
* the date the homepage was approximately last updated.
*/
$latest_posts = new WP_Query(
array(
'post_type' => 'post',
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
'no_found_rows' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
)
);
if ( ! empty( $latest_posts->posts ) ) {
$posts = wp_list_sort( $latest_posts->posts, 'post_modified_gmt', 'DESC' );
$sitemap_entry['lastmod'] = wp_date( DATE_W3C, strtotime( $posts[0]->post_modified_gmt ) );
}
/**
* Filters the sitemap entry for the home page when the 'show_on_front' option equals 'posts'.
*
* @since 5.5.0
*
* @param array $sitemap_entry Sitemap entry for the home page.
*/
$sitemap_entry = apply_filters( 'wp_sitemaps_posts_show_on_front_entry', $sitemap_entry );
$url_list[] = $sitemap_entry;
}
foreach ( $query->posts as $post ) {
$sitemap_entry = array(
'loc' => get_permalink( $post ),
'lastmod' => wp_date( DATE_W3C, strtotime( $post->post_modified_gmt ) ),
);
/**
* Filters the sitemap entry for an individual post.
*
* @since 5.5.0
*
* @param array $sitemap_entry Sitemap entry for the post.
* @param WP_Post $post Post object.
* @param string $post_type Name of the post_type.
*/
$sitemap_entry = apply_filters( 'wp_sitemaps_posts_entry', $sitemap_entry, $post, $post_type );
$url_list[] = $sitemap_entry;
}
return $url_list;
}
/**
* Gets the max number of pages available for the object type.
*
* @since 5.5.0
* @since 5.9.0 Renamed `$post_type` to `$object_subtype` to match parent class
* for PHP 8 named parameter support.
*
* @param string $object_subtype Optional. Post type name. Default empty.
* @return int Total number of pages.
*/
public function get_max_num_pages( $object_subtype = '' ) {
if ( empty( $object_subtype ) ) {
return 0;
}
// Restores the more descriptive, specific name for use within this method.
$post_type = $object_subtype;
/**
* Filters the max number of pages before it is generated.
*
* Passing a non-null value will short-circuit the generation,
* returning that value instead.
*
* @since 5.5.0
*
* @param int|null $max_num_pages The maximum number of pages. Default null.
* @param string $post_type Post type name.
*/
$max_num_pages = apply_filters( 'wp_sitemaps_posts_pre_max_num_pages', null, $post_type );
if ( null !== $max_num_pages ) {
return $max_num_pages;
}
$args = $this->get_posts_query_args( $post_type );
$args['fields'] = 'ids';
$args['no_found_rows'] = false;
$query = new WP_Query( $args );
$min_num_pages = ( 'page' === $post_type && 'posts' === get_option( 'show_on_front' ) ) ? 1 : 0;
return isset( $query->max_num_pages ) ? max( $min_num_pages, $query->max_num_pages ) : 1;
}
/**
* Returns the query args for retrieving posts to list in the sitemap.
*
* @since 5.5.0
* @since 6.1.0 Added `ignore_sticky_posts` default parameter.
*
* @param string $post_type Post type name.
* @return array Array of WP_Query arguments.
*/
protected function get_posts_query_args( $post_type ) {
/**
* Filters the query arguments for post type sitemap queries.
*
* @see WP_Query for a full list of arguments.
*
* @since 5.5.0
* @since 6.1.0 Added `ignore_sticky_posts` default parameter.
*
* @param array $args Array of WP_Query arguments.
* @param string $post_type Post type name.
*/
$args = apply_filters(
'wp_sitemaps_posts_query_args',
array(
'orderby' => 'ID',
'order' => 'ASC',
'post_type' => $post_type,
'posts_per_page' => wp_sitemaps_get_max_urls( $this->object_type ),
'post_status' => array( 'publish' ),
'no_found_rows' => true,
'update_post_term_cache' => false,
'update_post_meta_cache' => false,
'ignore_sticky_posts' => true, // Sticky posts will still appear, but they won't be moved to the front.
),
$post_type
);
return $args;
}
}
class-wp-sitemaps-renderer.php 0000644 00000015037 15044121004 0012432 0 ustar 00 <?php
/**
* Sitemaps: WP_Sitemaps_Renderer class
*
* Responsible for rendering Sitemaps data to XML in accordance with sitemap protocol.
*
* @package WordPress
* @subpackage Sitemaps
* @since 5.5.0
*/
/**
* Class WP_Sitemaps_Renderer
*
* @since 5.5.0
*/
#[AllowDynamicProperties]
class WP_Sitemaps_Renderer {
/**
* XSL stylesheet for styling a sitemap for web browsers.
*
* @since 5.5.0
*
* @var string
*/
protected $stylesheet = '';
/**
* XSL stylesheet for styling a sitemap for web browsers.
*
* @since 5.5.0
*
* @var string
*/
protected $stylesheet_index = '';
/**
* WP_Sitemaps_Renderer constructor.
*
* @since 5.5.0
*/
public function __construct() {
$stylesheet_url = $this->get_sitemap_stylesheet_url();
if ( $stylesheet_url ) {
$this->stylesheet = '<?xml-stylesheet type="text/xsl" href="' . esc_url( $stylesheet_url ) . '" ?>';
}
$stylesheet_index_url = $this->get_sitemap_index_stylesheet_url();
if ( $stylesheet_index_url ) {
$this->stylesheet_index = '<?xml-stylesheet type="text/xsl" href="' . esc_url( $stylesheet_index_url ) . '" ?>';
}
}
/**
* Gets the URL for the sitemap stylesheet.
*
* @since 5.5.0
*
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
*
* @return string The sitemap stylesheet URL.
*/
public function get_sitemap_stylesheet_url() {
global $wp_rewrite;
$sitemap_url = home_url( '/wp-sitemap.xsl' );
if ( ! $wp_rewrite->using_permalinks() ) {
$sitemap_url = home_url( '/?sitemap-stylesheet=sitemap' );
}
/**
* Filters the URL for the sitemap stylesheet.
*
* If a falsey value is returned, no stylesheet will be used and
* the "raw" XML of the sitemap will be displayed.
*
* @since 5.5.0
*
* @param string $sitemap_url Full URL for the sitemaps XSL file.
*/
return apply_filters( 'wp_sitemaps_stylesheet_url', $sitemap_url );
}
/**
* Gets the URL for the sitemap index stylesheet.
*
* @since 5.5.0
*
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
*
* @return string The sitemap index stylesheet URL.
*/
public function get_sitemap_index_stylesheet_url() {
global $wp_rewrite;
$sitemap_url = home_url( '/wp-sitemap-index.xsl' );
if ( ! $wp_rewrite->using_permalinks() ) {
$sitemap_url = home_url( '/?sitemap-stylesheet=index' );
}
/**
* Filters the URL for the sitemap index stylesheet.
*
* If a falsey value is returned, no stylesheet will be used and
* the "raw" XML of the sitemap index will be displayed.
*
* @since 5.5.0
*
* @param string $sitemap_url Full URL for the sitemaps index XSL file.
*/
return apply_filters( 'wp_sitemaps_stylesheet_index_url', $sitemap_url );
}
/**
* Renders a sitemap index.
*
* @since 5.5.0
*
* @param array $sitemaps Array of sitemap URLs.
*/
public function render_index( $sitemaps ) {
header( 'Content-Type: application/xml; charset=UTF-8' );
$this->check_for_simple_xml_availability();
$index_xml = $this->get_sitemap_index_xml( $sitemaps );
if ( ! empty( $index_xml ) ) {
// All output is escaped within get_sitemap_index_xml().
echo $index_xml;
}
}
/**
* Gets XML for a sitemap index.
*
* @since 5.5.0
*
* @param array $sitemaps Array of sitemap URLs.
* @return string|false A well-formed XML string for a sitemap index. False on error.
*/
public function get_sitemap_index_xml( $sitemaps ) {
$sitemap_index = new SimpleXMLElement(
sprintf(
'%1$s%2$s%3$s',
'<?xml version="1.0" encoding="UTF-8" ?>',
$this->stylesheet_index,
'<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />'
)
);
foreach ( $sitemaps as $entry ) {
$sitemap = $sitemap_index->addChild( 'sitemap' );
// Add each element as a child node to the <sitemap> entry.
foreach ( $entry as $name => $value ) {
if ( 'loc' === $name ) {
$sitemap->addChild( $name, esc_url( $value ) );
} elseif ( 'lastmod' === $name ) {
$sitemap->addChild( $name, esc_xml( $value ) );
} else {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: %s: List of element names. */
__( 'Fields other than %s are not currently supported for the sitemap index.' ),
implode( ',', array( 'loc', 'lastmod' ) )
),
'5.5.0'
);
}
}
}
return $sitemap_index->asXML();
}
/**
* Renders a sitemap.
*
* @since 5.5.0
*
* @param array $url_list Array of URLs for a sitemap.
*/
public function render_sitemap( $url_list ) {
header( 'Content-Type: application/xml; charset=UTF-8' );
$this->check_for_simple_xml_availability();
$sitemap_xml = $this->get_sitemap_xml( $url_list );
if ( ! empty( $sitemap_xml ) ) {
// All output is escaped within get_sitemap_xml().
echo $sitemap_xml;
}
}
/**
* Gets XML for a sitemap.
*
* @since 5.5.0
*
* @param array $url_list Array of URLs for a sitemap.
* @return string|false A well-formed XML string for a sitemap index. False on error.
*/
public function get_sitemap_xml( $url_list ) {
$urlset = new SimpleXMLElement(
sprintf(
'%1$s%2$s%3$s',
'<?xml version="1.0" encoding="UTF-8" ?>',
$this->stylesheet,
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />'
)
);
foreach ( $url_list as $url_item ) {
$url = $urlset->addChild( 'url' );
// Add each element as a child node to the <url> entry.
foreach ( $url_item as $name => $value ) {
if ( 'loc' === $name ) {
$url->addChild( $name, esc_url( $value ) );
} elseif ( in_array( $name, array( 'lastmod', 'changefreq', 'priority' ), true ) ) {
$url->addChild( $name, esc_xml( $value ) );
} else {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: %s: List of element names. */
__( 'Fields other than %s are not currently supported for sitemaps.' ),
implode( ',', array( 'loc', 'lastmod', 'changefreq', 'priority' ) )
),
'5.5.0'
);
}
}
}
return $urlset->asXML();
}
/**
* Checks for the availability of the SimpleXML extension and errors if missing.
*
* @since 5.5.0
*/
private function check_for_simple_xml_availability() {
if ( ! class_exists( 'SimpleXMLElement' ) ) {
add_filter(
'wp_die_handler',
static function () {
return '_xml_wp_die_handler';
}
);
wp_die(
sprintf(
/* translators: %s: SimpleXML */
esc_xml( __( 'Could not generate XML sitemap due to missing %s extension' ) ),
'SimpleXML'
),
esc_xml( __( 'WordPress › Error' ) ),
array(
'response' => 501, // "Not implemented".
)
);
}
}
}
class-wp-sitemaps.php 0000644 00000014402 15044121004 0010621 0 ustar 00 <?php
/**
* Sitemaps: WP_Sitemaps class
*
* This is the main class integrating all other classes.
*
* @package WordPress
* @subpackage Sitemaps
* @since 5.5.0
*/
/**
* Class WP_Sitemaps.
*
* @since 5.5.0
*/
#[AllowDynamicProperties]
class WP_Sitemaps {
/**
* The main index of supported sitemaps.
*
* @since 5.5.0
*
* @var WP_Sitemaps_Index
*/
public $index;
/**
* The main registry of supported sitemaps.
*
* @since 5.5.0
*
* @var WP_Sitemaps_Registry
*/
public $registry;
/**
* An instance of the renderer class.
*
* @since 5.5.0
*
* @var WP_Sitemaps_Renderer
*/
public $renderer;
/**
* WP_Sitemaps constructor.
*
* @since 5.5.0
*/
public function __construct() {
$this->registry = new WP_Sitemaps_Registry();
$this->renderer = new WP_Sitemaps_Renderer();
$this->index = new WP_Sitemaps_Index( $this->registry );
}
/**
* Initiates all sitemap functionality.
*
* If sitemaps are disabled, only the rewrite rules will be registered
* by this method, in order to properly send 404s.
*
* @since 5.5.0
*/
public function init() {
// These will all fire on the init hook.
$this->register_rewrites();
add_action( 'template_redirect', array( $this, 'render_sitemaps' ) );
if ( ! $this->sitemaps_enabled() ) {
return;
}
$this->register_sitemaps();
// Add additional action callbacks.
add_filter( 'robots_txt', array( $this, 'add_robots' ), 0, 2 );
}
/**
* Determines whether sitemaps are enabled or not.
*
* @since 5.5.0
*
* @return bool Whether sitemaps are enabled.
*/
public function sitemaps_enabled() {
$is_enabled = (bool) get_option( 'blog_public' );
/**
* Filters whether XML Sitemaps are enabled or not.
*
* When XML Sitemaps are disabled via this filter, rewrite rules are still
* in place to ensure a 404 is returned.
*
* @see WP_Sitemaps::register_rewrites()
*
* @since 5.5.0
*
* @param bool $is_enabled Whether XML Sitemaps are enabled or not.
* Defaults to true for public sites.
*/
return (bool) apply_filters( 'wp_sitemaps_enabled', $is_enabled );
}
/**
* Registers and sets up the functionality for all supported sitemaps.
*
* @since 5.5.0
*/
public function register_sitemaps() {
$providers = array(
'posts' => new WP_Sitemaps_Posts(),
'taxonomies' => new WP_Sitemaps_Taxonomies(),
'users' => new WP_Sitemaps_Users(),
);
/* @var WP_Sitemaps_Provider $provider */
foreach ( $providers as $name => $provider ) {
$this->registry->add_provider( $name, $provider );
}
}
/**
* Registers sitemap rewrite tags and routing rules.
*
* @since 5.5.0
*/
public function register_rewrites() {
// Add rewrite tags.
add_rewrite_tag( '%sitemap%', '([^?]+)' );
add_rewrite_tag( '%sitemap-subtype%', '([^?]+)' );
// Register index route.
add_rewrite_rule( '^wp-sitemap\.xml$', 'index.php?sitemap=index', 'top' );
// Register rewrites for the XSL stylesheet.
add_rewrite_tag( '%sitemap-stylesheet%', '([^?]+)' );
add_rewrite_rule( '^wp-sitemap\.xsl$', 'index.php?sitemap-stylesheet=sitemap', 'top' );
add_rewrite_rule( '^wp-sitemap-index\.xsl$', 'index.php?sitemap-stylesheet=index', 'top' );
// Register routes for providers.
add_rewrite_rule(
'^wp-sitemap-([a-z]+?)-([a-z\d_-]+?)-(\d+?)\.xml$',
'index.php?sitemap=$matches[1]&sitemap-subtype=$matches[2]&paged=$matches[3]',
'top'
);
add_rewrite_rule(
'^wp-sitemap-([a-z]+?)-(\d+?)\.xml$',
'index.php?sitemap=$matches[1]&paged=$matches[2]',
'top'
);
}
/**
* Renders sitemap templates based on rewrite rules.
*
* @since 5.5.0
*
* @global WP_Query $wp_query WordPress Query object.
*/
public function render_sitemaps() {
global $wp_query;
$sitemap = sanitize_text_field( get_query_var( 'sitemap' ) );
$object_subtype = sanitize_text_field( get_query_var( 'sitemap-subtype' ) );
$stylesheet_type = sanitize_text_field( get_query_var( 'sitemap-stylesheet' ) );
$paged = absint( get_query_var( 'paged' ) );
// Bail early if this isn't a sitemap or stylesheet route.
if ( ! ( $sitemap || $stylesheet_type ) ) {
return;
}
if ( ! $this->sitemaps_enabled() ) {
$wp_query->set_404();
status_header( 404 );
return;
}
// Render stylesheet if this is stylesheet route.
if ( $stylesheet_type ) {
$stylesheet = new WP_Sitemaps_Stylesheet();
$stylesheet->render_stylesheet( $stylesheet_type );
exit;
}
// Render the index.
if ( 'index' === $sitemap ) {
$sitemap_list = $this->index->get_sitemap_list();
$this->renderer->render_index( $sitemap_list );
exit;
}
$provider = $this->registry->get_provider( $sitemap );
if ( ! $provider ) {
return;
}
if ( empty( $paged ) ) {
$paged = 1;
}
$url_list = $provider->get_url_list( $paged, $object_subtype );
// Force a 404 and bail early if no URLs are present.
if ( empty( $url_list ) ) {
$wp_query->set_404();
status_header( 404 );
return;
}
$this->renderer->render_sitemap( $url_list );
exit;
}
/**
* Redirects a URL to the wp-sitemap.xml
*
* @since 5.5.0
* @deprecated 6.7.0 Deprecated in favor of {@see WP_Rewrite::rewrite_rules()}
*
* @param bool $bypass Pass-through of the pre_handle_404 filter value.
* @param WP_Query $query The WP_Query object.
* @return bool Bypass value.
*/
public function redirect_sitemapxml( $bypass, $query ) {
_deprecated_function( __FUNCTION__, '6.7.0' );
// If a plugin has already utilized the pre_handle_404 function, return without action to avoid conflicts.
if ( $bypass ) {
return $bypass;
}
// 'pagename' is for most permalink types, name is for when the %postname% is used as a top-level field.
if ( 'sitemap-xml' === $query->get( 'pagename' )
|| 'sitemap-xml' === $query->get( 'name' )
) {
wp_safe_redirect( $this->index->get_index_url() );
exit();
}
return $bypass;
}
/**
* Adds the sitemap index to robots.txt.
*
* @since 5.5.0
*
* @param string $output robots.txt output.
* @param bool $is_public Whether the site is public.
* @return string The robots.txt output.
*/
public function add_robots( $output, $is_public ) {
if ( $is_public ) {
$output .= "\nSitemap: " . esc_url( $this->index->get_index_url() ) . "\n";
}
return $output;
}
}
|