| | 116 | self::$oembed_amazon_format => array( 'https://read.amazon.com/kp/api/oembed', true ), |
| | 117 | '#https?://(www\.)?a.co/.*#i' => array( 'https://read.amazon.com/kp/api/oembed', true ), |
| | 118 | '#https?://(www\.)?amz.onl/.*#i' => array( 'https://read.amazon.com/kp/api/oembed', true ), |
| | 119 | '#https?://(www\.)?amzn.to/.*#i' => array( 'https://read.amazon.com/kp/api/oembed', true ), |
| | 120 | '#https?://(www\.)?amzn.eu/.*#i' => array( 'https://read.amazon.co.uk/kp/api/oembed', true ), |
| | 121 | '#https?://(www\.)?amzn.in/.*#i' => array( 'https://read.amazon.in/kp/api/oembed', true ), |
| | 122 | '#https?://(www\.)?amzn.asia/.*#i' => array( 'https://read.amazon.com.au/kp/api/oembed', true ), |
| | 123 | '#https?://(www\.)?z.cn/.*#i' => array( 'https://read.amazon.cn/kp/api/oembed', true ), |
| | 710 | |
| | 711 | /** |
| | 712 | * Checks if the given URL is an Amazon URL, and if so, alters the |
| | 713 | * provider's subdomain and TLD to match the URL's TLD. |
| | 714 | * |
| | 715 | * These transformations are applied to the oEmbed endpoint served by |
| | 716 | * one of the read.amazon.com regionalized domains, which services all |
| | 717 | * *.amazon.* URLs for the corresponding region. |
| | 718 | * |
| | 719 | * This method ensures that oEmbed requests for different Amazon |
| | 720 | * marketplaces (.com, .de, .jp, etc) are routed to the correct oEmbed |
| | 721 | * endpoint for those marketplaces. |
| | 722 | * |
| | 723 | * @since 4.7.0 |
| | 724 | * @access public |
| | 725 | * |
| | 726 | * @param string $provider The URL to the default oEmbed provider. |
| | 727 | * @param string $url The URL to the content that is desired to be embedded. |
| | 728 | * @return string The URL to the oEmbed provider. |
| | 729 | */ |
| | 730 | public function _match_amazon_tld( $provider, $url ) { |
| | 731 | if ( 1 !== preg_match( self::$oembed_amazon_format, $url, $matches ) ) { |
| | 732 | return $provider; |
| | 733 | } |
| | 734 | |
| | 735 | $tld = $matches[2]; |
| | 736 | switch ( $tld ) { |
| | 737 | case 'de': |
| | 738 | $subdomain = 'lesen'; |
| | 739 | break; |
| | 740 | case 'fr': |
| | 741 | $subdomain = 'lire'; |
| | 742 | break; |
| | 743 | case 'it': |
| | 744 | $subdomain = 'leggi'; |
| | 745 | break; |
| | 746 | case 'es': |
| | 747 | case 'com.mx': |
| | 748 | $subdomain = 'leer'; |
| | 749 | break; |
| | 750 | case 'com.br': |
| | 751 | $subdomain = 'ler'; |
| | 752 | break; |
| | 753 | case 'nl': |
| | 754 | $subdomain = 'lezen'; |
| | 755 | break; |
| | 756 | default: |
| | 757 | $subdomain = 'read'; |
| | 758 | } |
| | 759 | |
| | 760 | return preg_replace( |
| | 761 | '#^https://read.amazon.com/#', |
| | 762 | sprintf( 'https://%s.amazon.%s/', $subdomain, $tld ), |
| | 763 | $provider |
| | 764 | ); |
| | 765 | } |