Changeset 55289 for trunk/src/wp-includes/link-template.php
- Timestamp:
- 02/07/2023 06:52:24 PM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/link-template.php
r55276 r55289 4689 4689 return ''; 4690 4690 } 4691 4692 /** 4693 * Returns an array of URL hosts which are considered to be internal hosts. 4694 * 4695 * By default the list of internal hosts is comproside of the PHP_URL_HOST of 4696 * the site's home_url() (as parsed by wp_parse_url()). 4697 * 4698 * This list is used when determining if a specificed URL is a link to a page on 4699 * the site itself or a link offsite (to an external host). This is used, for 4700 * example, when determining if the "nofollow" attribute should be applied to a 4701 * link. 4702 * 4703 * @see wp_is_internal_link 4704 * 4705 * @since 6.2.0 4706 * 4707 * @return string[] An array of URL hosts. 4708 */ 4709 function wp_internal_hosts() { 4710 static $internal_hosts; 4711 4712 if ( empty( $internal_hosts ) ) { 4713 /** 4714 * Filters the array of URL hosts which are considered internal. 4715 * 4716 * @since 6.2.9 4717 * 4718 * @param array $internal_hosts An array of internal URL hostnames. 4719 */ 4720 $internal_hosts = apply_filters( 4721 'wp_internal_hosts', 4722 array( 4723 wp_parse_url( home_url(), PHP_URL_HOST ), 4724 ) 4725 ); 4726 $internal_hosts = array_unique( 4727 array_map( 'strtolower', (array) $internal_hosts ) 4728 ); 4729 } 4730 4731 return $internal_hosts; 4732 } 4733 4734 /** 4735 * Determines whether or not the specified URL is of a host included in the internal hosts list. 4736 * 4737 * @see wp_internal_hosts() 4738 * 4739 * @since 6.2.0 4740 * 4741 * @param string $link The URL to test. 4742 * @return bool Returns true for internal URLs and false for all other URLs. 4743 */ 4744 function wp_is_internal_link( $link ) { 4745 $link = strtolower( $link ); 4746 if ( in_array( wp_parse_url( $link, PHP_URL_SCHEME ), wp_allowed_protocols(), true ) ) { 4747 return in_array( wp_parse_url( $link, PHP_URL_HOST ), wp_internal_hosts(), true ); 4748 } 4749 return false; 4750 }
Note: See TracChangeset
for help on using the changeset viewer.