register_sitemap( $name, $function, $rewrite ); } } /** * Call WPSEO_Sitemaps::register_xsl() if the method exists. * * @since 4.1 * * @param string $name The name of the XSL file. * @param callback $function Function to build your XSL file. * @param string $rewrite Optional. Regular expression to match your sitemap with. */ public static function register_xsl( $name, $function, $rewrite = '' ) { // WPSEO 1.4.23+. if ( isset( $GLOBALS['wpseo_sitemaps'] ) && is_object( $GLOBALS['wpseo_sitemaps'] ) && method_exists( 'WPSEO_Sitemaps', 'register_xsl' ) ) { $GLOBALS['wpseo_sitemaps']->register_xsl( $name, $function, $rewrite ); } } /** * Call WPSEO_Sitemaps::set_sitemap() if the method exists. * * @since 4.1 * * @param string $sitemap The generated sitemap to output. */ public static function set_sitemap( $sitemap ) { // WPSEO 1.4.23+. if ( isset( $GLOBALS['wpseo_sitemaps'] ) && is_object( $GLOBALS['wpseo_sitemaps'] ) && method_exists( 'WPSEO_Sitemaps', 'set_sitemap' ) ) { $GLOBALS['wpseo_sitemaps']->set_sitemap( $sitemap ); } } /** * Call WPSEO_Sitemaps::set_stylesheet() if the method exists. * * @since 4.1 * * @param string $stylesheet Full xml-stylesheet declaration. */ public static function set_stylesheet( $stylesheet ) { if ( isset( $GLOBALS['wpseo_sitemaps'] ) && is_object( $GLOBALS['wpseo_sitemaps'] ) ) { // WPSEO 3.2+. if ( method_exists( 'WPSEO_Sitemaps_Renderer', 'set_stylesheet' ) && property_exists( $GLOBALS['wpseo_sitemaps'], 'renderer' ) && ( $GLOBALS['wpseo_sitemaps']->renderer instanceof WPSEO_Sitemaps_Renderer ) ) { $GLOBALS['wpseo_sitemaps']->renderer->set_stylesheet( $stylesheet ); return; } // WPSEO 1.4.23+. if ( method_exists( $GLOBALS['wpseo_sitemaps'], 'set_stylesheet' ) ) { $GLOBALS['wpseo_sitemaps']->set_stylesheet( $stylesheet ); return; } } } /** * Returns the result of WPSEO_Utils::is_development_mode() if the method exists. * * @since 4.1 * * @return bool */ public static function is_development_mode() { // WPSEO 3.0+. if ( method_exists( 'WPSEO_Utils', 'is_development_mode' ) ) { return WPSEO_Utils::is_development_mode(); } return false; } /** * Returns the result of get_base_url from WPSEO_Sitemaps_Router if the method exists, * otherwise it will return the result from the deprecated wpseo_xml_sitemaps_base_url() function. * * @since 4.1 * * @param string $sitemap Sitemap file name. * * @return string */ public static function xml_sitemaps_base_url( $sitemap ) { // WPSEO 3.2+. if ( method_exists( 'WPSEO_Sitemaps_Router', 'get_base_url' ) ) { return WPSEO_Sitemaps_Router::get_base_url( $sitemap ); } if ( function_exists( 'wpseo_xml_sitemaps_base_url' ) ) { return wpseo_xml_sitemaps_base_url( $sitemap ); } } /** * Call WPSEO_Sitemaps::ping_search_engines() if the method exists, * otherwise it will call the deprecated wpseo_ping_search_engines() function. * * @since 4.1 * * @param string $sitemapurl Sitemap URL. * * @return void */ public static function ping_search_engines( $sitemapurl = null ) { // WPSEO 3.2+. if ( method_exists( 'WPSEO_Sitemaps', 'ping_search_engines' ) ) { WPSEO_Sitemaps::ping_search_engines( $sitemapurl ); return; } if ( function_exists( 'wpseo_ping_search_engines' ) ) { wpseo_ping_search_engines( $sitemapurl ); return; } } /** * Wrapper function to invalidate a cached sitemap. * * @since 4.1 * * @param null|string $type The type to get the key for. Null for all caches. * * @return void */ public static function invalidate_cache_storage( $type = null ) { // WPSEO 3.2+. if ( method_exists( 'WPSEO_Sitemaps_Cache_Validator', 'invalidate_storage' ) ) { WPSEO_Sitemaps_Cache_Validator::invalidate_storage( $type ); return; } // WPSEO 1.8.0+. if ( method_exists( 'WPSEO_Utils', 'clear_sitemap_cache' ) ) { WPSEO_Utils::clear_sitemap_cache( $type ); return; } } /** * Wrapper function to invalidate a sitemap type. * * @since 4.1 * * @param string $type Sitemap type to invalidate. * * @return void */ public static function invalidate_sitemap( $type ) { // WPSEO 3.2+. if ( method_exists( 'WPSEO_Sitemaps_Cache', 'invalidate' ) ) { WPSEO_Sitemaps_Cache::invalidate( $type ); return; } // WPSEO 1.5.4+. if ( function_exists( 'wpseo_invalidate_sitemap_cache' ) ) { wpseo_invalidate_sitemap_cache( $type ); return; } } /** * Call WPSEO_Sitemaps_Cache::register_clear_on_option_update() if the method exists, * otherwise it will call the deprecated WPSEO_Utils::register_cache_clear_option() function. * * @since 4.1 * * @param string $option Option name. * @param string $type Sitemap type. * * @return void */ public static function register_cache_clear_option( $option, $type = '' ) { // WPSEO 3.2+. if ( method_exists( 'WPSEO_Sitemaps_Cache', 'register_clear_on_option_update' ) ) { WPSEO_Sitemaps_Cache::register_clear_on_option_update( $option, $type ); return; } // WPSEO 2.2+. if ( method_exists( 'WPSEO_Utils', 'register_cache_clear_option' ) ) { WPSEO_Utils::register_cache_clear_option( $option, $type ); return; } } }