| | 108 | OEMBED_AMAZON_FORMAT => array( 'https://read.amazon.com/kp/api/oembed', true ), |
| | 109 | '#https?://(www\.)a.co/.*#i' => array( 'https://read.amazon.com/kp/api/oembed', true ), |
| | 110 | '#https?://(www\.)amz.onl/.*#i' => array( 'https://read.amazon.com/kp/api/oembed', true ), |
| | 111 | '#https?://(www\.)amzn.to/.*#i' => array( 'https://read.amazon.com/kp/api/oembed', true ), |
| | 112 | '#https?://(www\.)amzn.eu/.*#i' => array( 'https://read.amazon.co.uk/kp/api/oembed', true ), |
| | 113 | '#https?://(www\.)amzn.in/.*#i' => array( 'https://read.amazon.in/kp/api/oembed', true ), |
| | 114 | '#https?://(www\.)amzn.asia/.*#i' => array( 'https://read.amazon.com.au/kp/api/oembed', true ), |
| | 115 | '#https?://(www\.)z.cn/.*#i' => array( 'https://read.amazon.cn/kp/api/oembed', true ), |
| | 697 | |
| | 698 | /** |
| | 699 | * Checks if the given URL is an Amazon URL, and if so, alters the |
| | 700 | * provider's subdomain and TLD to match the URL's TLD. |
| | 701 | * |
| | 702 | * These transformations are applied to the oembed endpoint served by |
| | 703 | * one of the read.amazon.com regionalized domains, which services all |
| | 704 | * *.amazon.* URLs for the corresponding region. |
| | 705 | * |
| | 706 | * This method ensures that oEmbed requests for different Amazon |
| | 707 | * marketplaces (.com, .de, .jp, etc) are routed to the correct oEmbed |
| | 708 | * endpoint for those marketplaces. |
| | 709 | * |
| | 710 | * @since 4.6.2 |
| | 711 | * @access public |
| | 712 | * |
| | 713 | * @param string $provider The URL to the default OEmbed provider. |
| | 714 | * @param string $url The URL to the content that is desired to be embedded. |
| | 715 | * |
| | 716 | * @return string The URL to the OEmbed provider. |
| | 717 | */ |
| | 718 | public function _match_amazon_tld( $provider, $url ) { |
| | 719 | if ( 1 !== preg_match( OEMBED_AMAZON_FORMAT, $url, $matches ) ) { |
| | 720 | return $provider; |
| | 721 | } |
| | 722 | |
| | 723 | $tld = $matches[2]; |
| | 724 | switch ( $tld ) { |
| | 725 | case 'de': $subdomain = 'lesen'; break; |
| | 726 | case 'fr': $subdomain = 'lire'; break; |
| | 727 | case 'it': $subdomain = 'leggi'; break; |
| | 728 | case 'es': $subdomain = 'leer'; break; |
| | 729 | case 'com.mx': $subdomain = 'leer'; break; |
| | 730 | case 'com.br': $subdomain = 'ler'; break; |
| | 731 | case 'nl': $subdomain = 'lezen'; break; |
| | 732 | default: $subdomain = 'read'; |
| | 733 | } |
| | 734 | |
| | 735 | return preg_replace( |
| | 736 | '#^https://read.amazon.com/#', |
| | 737 | sprintf( 'https://%s.amazon.%s/', $subdomain, $tld ), |
| | 738 | $provider |
| | 739 | ); |
| | 740 | } |