[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Sitemaps: WP_Sitemaps_Registry class 4 * 5 * Handles registering sitemap providers. 6 * 7 * @package WordPress 8 * @subpackage Sitemaps 9 * @since 5.5.0 10 */ 11 12 /** 13 * Class WP_Sitemaps_Registry. 14 * 15 * @since 5.5.0 16 */ 17 #[AllowDynamicProperties] 18 class WP_Sitemaps_Registry { 19 /** 20 * Registered sitemap providers. 21 * 22 * @since 5.5.0 23 * 24 * @var WP_Sitemaps_Provider[] Array of registered sitemap providers. 25 */ 26 private $providers = array(); 27 28 /** 29 * Adds a new sitemap provider. 30 * 31 * @since 5.5.0 32 * 33 * @param string $name Name of the sitemap provider. 34 * @param WP_Sitemaps_Provider $provider Instance of a WP_Sitemaps_Provider. 35 * @return bool Whether the provider was added successfully. 36 */ 37 public function add_provider( $name, WP_Sitemaps_Provider $provider ) { 38 if ( isset( $this->providers[ $name ] ) ) { 39 return false; 40 } 41 42 /** 43 * Filters the sitemap provider before it is added. 44 * 45 * @since 5.5.0 46 * 47 * @param WP_Sitemaps_Provider $provider Instance of a WP_Sitemaps_Provider. 48 * @param string $name Name of the sitemap provider. 49 */ 50 $provider = apply_filters( 'wp_sitemaps_add_provider', $provider, $name ); 51 if ( ! $provider instanceof WP_Sitemaps_Provider ) { 52 return false; 53 } 54 55 $this->providers[ $name ] = $provider; 56 57 return true; 58 } 59 60 /** 61 * Returns a single registered sitemap provider. 62 * 63 * @since 5.5.0 64 * 65 * @param string $name Sitemap provider name. 66 * @return WP_Sitemaps_Provider|null Sitemap provider if it exists, null otherwise. 67 */ 68 public function get_provider( $name ) { 69 if ( ! is_string( $name ) || ! isset( $this->providers[ $name ] ) ) { 70 return null; 71 } 72 73 return $this->providers[ $name ]; 74 } 75 76 /** 77 * Returns all registered sitemap providers. 78 * 79 * @since 5.5.0 80 * 81 * @return WP_Sitemaps_Provider[] Array of sitemap providers. 82 */ 83 public function get_providers() { 84 return $this->providers; 85 } 86 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sun Dec 22 08:20:01 2024 | Cross-referenced by PHPXref |