/var/www/html_fr/wp-includes/sitemaps.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
 * Sitemaps: Public functions
 *
 * This file contains a variety of public functions developers can use to interact with
 * the XML Sitemaps API.
 *
 * @package WordPress
 * @subpackage Sitemaps
 * @since 5.5.0
 */

/**
 * Retrieves the current Sitemaps server instance.
 *
 * @since 5.5.0
 *
 * @global WP_Sitemaps $wp_sitemaps Global Core Sitemaps instance.
 *
 * @return WP_Sitemaps Sitemaps instance.
 */
function wp_sitemaps_get_server() {
    global 
$wp_sitemaps;

    
// If there isn't a global instance, set and bootstrap the sitemaps system.
    
if ( empty( $wp_sitemaps ) ) {
        
$wp_sitemaps = new WP_Sitemaps();
        
$wp_sitemaps->init();

        
/**
         * Fires when initializing the Sitemaps object.
         *
         * Additional sitemaps should be registered on this hook.
         *
         * @since 5.5.0
         *
         * @param WP_Sitemaps $wp_sitemaps Sitemaps object.
         */
        
do_action'wp_sitemaps_init'$wp_sitemaps );
    }

    return 
$wp_sitemaps;
}

/**
 * Gets an array of sitemap providers.
 *
 * @since 5.5.0
 *
 * @return WP_Sitemaps_Provider[] Array of sitemap providers.
 */
function wp_get_sitemap_providers() {
    
$sitemaps wp_sitemaps_get_server();

    return 
$sitemaps->registry->get_providers();
}

/**
 * Registers a new sitemap provider.
 *
 * @since 5.5.0
 *
 * @param string               $name     Unique name for the sitemap provider.
 * @param WP_Sitemaps_Provider $provider The `Sitemaps_Provider` instance implementing the sitemap.
 * @return bool Whether the sitemap was added.
 */
function wp_register_sitemap_provider$nameWP_Sitemaps_Provider $provider ) {
    
$sitemaps wp_sitemaps_get_server();

    return 
$sitemaps->registry->add_provider$name$provider );
}

/**
 * Gets the maximum number of URLs for a sitemap.
 *
 * @since 5.5.0
 *
 * @param string $object_type Object type for sitemap to be filtered (e.g. 'post', 'term', 'user').
 * @return int The maximum number of URLs.
 */
function wp_sitemaps_get_max_urls$object_type ) {
    
/**
     * Filters the maximum number of URLs displayed on a sitemap.
     *
     * @since 5.5.0
     *
     * @param int    $max_urls    The maximum number of URLs included in a sitemap. Default 2000.
     * @param string $object_type Object type for sitemap to be filtered (e.g. 'post', 'term', 'user').
     */
    
return apply_filters'wp_sitemaps_max_urls'2000$object_type );
}

/**
 * Retrieves the full URL for a sitemap.
 *
 * @since 5.5.1
 *
 * @param string $name         The sitemap name.
 * @param string $subtype_name The sitemap subtype name. Default empty string.
 * @param int    $page         The page of the sitemap. Default 1.
 * @return string|false The sitemap URL or false if the sitemap doesn't exist.
 */
function get_sitemap_url$name$subtype_name ''$page ) {
    
$sitemaps wp_sitemaps_get_server();

    if ( ! 
$sitemaps ) {
        return 
false;
    }

    if ( 
'index' === $name ) {
        return 
$sitemaps->index->get_index_url();
    }

    
$provider $sitemaps->registry->get_provider$name );
    if ( ! 
$provider ) {
        return 
false;
    }

    if ( 
$subtype_name && ! in_array$subtype_namearray_keys$provider->get_object_subtypes() ), true ) ) {
        return 
false;
    }

    
$page absint$page );
    if ( 
>= $page ) {
        
$page 1;
    }

    return 
$provider->get_sitemap_url$subtype_name$page );
}