525 | | static $accessible_hosts; |
526 | | static $wildcard_regex = false; |
527 | | if ( null == $accessible_hosts ) { |
528 | | $accessible_hosts = preg_split('|,\s*|', WP_ACCESSIBLE_HOSTS); |
| 530 | /** |
| 531 | * Filter the list of accessible hosts. |
| 532 | * |
| 533 | * @since 3.8 |
| 534 | * |
| 535 | * @param array $wp_accessible_hosts List of accessible hosts. |
| 536 | * @param string $uri The URL being accessed. |
| 537 | * @param array $check The pasesed URL being accessed. |
| 538 | */ |
| 539 | $accessible_hosts = apply_filters( 'wp_http_accessible_hosts', $wp_accessible_hosts, $uri, $check ); |
530 | | if ( false !== strpos(WP_ACCESSIBLE_HOSTS, '*') ) { |
531 | | $wildcard_regex = array(); |
532 | | foreach ( $accessible_hosts as $host ) |
533 | | $wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) ); |
534 | | $wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i'; |
535 | | } |
| 541 | // Check if there's an exact match |
| 542 | if ( in_array( $accessible_hosts, $check['host'] ) ) |
| 543 | return false; // do not block |
| 544 | |
| 545 | // Check to see if there's a wildcard match |
| 546 | foreach ( $accessible_hosts as $host ) { |
| 547 | // Skip non-wildcard entries |
| 548 | if ( false === strpos( $host, '*' ) ) |
| 549 | continue; |
| 550 | |
| 551 | $regex = str_replace( '\*', '.+', preg_quote( $host, '!' ) ); |
| 552 | if ( preg_match( '!^(' . $regex . ')$!i', $check['host'] ) ) |
| 553 | return false; // do not block |