sanitize_trackback_urls

Sanitize space or carriage return separated URLs that are used to send trackbacks.

Description

(string) sanitize_trackback_urls( (string) $to_ping ); 

Returns (string)

URLs starting with the http or https protocol, separated by a carriage return.

Parameters (1)

0. $to_ping (string)
Space or carriage return separated URLs

Usage

  1. if ( !function_exists( 'sanitize_trackback_urls' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4. // Space or carriage return separated URLs 
  5. $to_ping = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = sanitize_trackback_urls($to_ping); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/formatting.php  
  1. function sanitize_trackback_urls( $to_ping ) { 
  2. $urls_to_ping = preg_split( '/[\r\n\t ]/', trim( $to_ping ), -1, PREG_SPLIT_NO_EMPTY ); 
  3. foreach ( $urls_to_ping as $k => $url ) { 
  4. if ( !preg_match( '#^https?://.#i', $url ) ) 
  5. unset( $urls_to_ping[$k] ); 
  6. $urls_to_ping = array_map( 'esc_url_raw', $urls_to_ping ); 
  7. $urls_to_ping = implode( "\n", $urls_to_ping ); 
  8. /** 
  9. * Filters a list of trackback URLs following sanitization. 
  10. * The string returned here consists of a space or carriage return-delimited list 
  11. * of trackback URLs. 
  12. * @since 3.4.0 
  13. * @param string $urls_to_ping Sanitized space or carriage return separated URLs. 
  14. * @param string $to_ping Space or carriage return separated URLs before sanitization. 
  15. */ 
  16. return apply_filters( 'sanitize_trackback_urls', $urls_to_ping, $to_ping );