| 715 | // Support updates for any themes using the `Update URI` header field. |
| 716 | foreach ( $themes as $theme_stylesheet => $theme_data ) { |
| 717 | if ( ! $theme_data['UpdateURI'] || isset( $new_update->response[ $theme_stylesheet ] ) ) { |
| 718 | continue; |
| 719 | } |
| 720 | |
| 721 | $hostname = wp_parse_url( esc_url_raw( $theme_data['UpdateURI'] ), PHP_URL_HOST ); |
| 722 | |
| 723 | /** |
| 724 | * Filters the update response for a given theme hostname. |
| 725 | * |
| 726 | * The dynamic portion of the hook name, `$hostname`, refers to the hostname |
| 727 | * of the URI specified in the `Update URI` header field. |
| 728 | * |
| 729 | * @since 6.0.0 |
| 730 | * |
| 731 | * @param array|false $update { |
| 732 | * The theme update data with the latest details. Default false. |
| 733 | * |
| 734 | * @type string $id Optional. ID of the theme for update purposes, should be a URI |
| 735 | * specified in the `Update URI` header field. |
| 736 | * @type string $theme Directory name of the theme. |
| 737 | * @type string $version The version of the theme. |
| 738 | * @type string $url The URL for details of the theme. |
| 739 | * @type string $package Optional. The update ZIP for the theme. |
| 740 | * @type string $tested Optional. The version of WordPress the theme is tested against. |
| 741 | * @type string $requires_php Optional. The version of PHP which the theme requires. |
| 742 | * @type bool $autoupdate Optional. Whether the theme should automatically update. |
| 743 | * @type array $translations { |
| 744 | * Optional. List of translation updates for the theme. |
| 745 | * |
| 746 | * @type string $language The language the translation update is for. |
| 747 | * @type string $version The version of the theme this translation is for. |
| 748 | * This is not the version of the language file. |
| 749 | * @type string $updated The update timestamp of the translation file. |
| 750 | * Should be a date in the `YYYY-MM-DD HH:MM:SS` format. |
| 751 | * @type string $package The ZIP location containing the translation update. |
| 752 | * @type string $autoupdate Whether the translation should be automatically installed. |
| 753 | * } |
| 754 | * } |
| 755 | * @param array $theme_data Theme headers. |
| 756 | * @param string $theme_stylesheet Theme stylesheet. |
| 757 | * @param array $locales Installed locales to look translations for. |
| 758 | */ |
| 759 | $update = apply_filters( "update_themes_{$hostname}", false, $theme_data, $theme_stylesheet, $locales ); |
| 760 | |
| 761 | if ( ! $update ) { |
| 762 | continue; |
| 763 | } |
| 764 | |
| 765 | $update = (object) $update; |
| 766 | |
| 767 | // Is it valid? We require at least a version. |
| 768 | if ( ! isset( $update->version ) ) { |
| 769 | continue; |
| 770 | } |
| 771 | |
| 772 | // These should remain constant. |
| 773 | $update->id = $theme_data['UpdateURI']; |
| 774 | |
| 775 | // WordPress needs the version field specified as 'new_version'. |
| 776 | if ( ! isset( $update->new_version ) ) { |
| 777 | $update->new_version = $update->version; |
| 778 | } |
| 779 | |
| 780 | // Handle any translation updates. |
| 781 | if ( ! empty( $update->translations ) ) { |
| 782 | foreach ( $update->translations as $translation ) { |
| 783 | if ( isset( $translation['language'], $translation['package'] ) ) { |
| 784 | $translation['type'] = 'theme'; |
| 785 | $translation['slug'] = isset( $update->theme ) ? $update->theme : $update->id; |
| 786 | |
| 787 | $new_update->translations[] = $translation; |
| 788 | } |
| 789 | } |
| 790 | } |
| 791 | |
| 792 | unset( $new_update->no_update[ $theme_stylesheet ], $new_update->response[ $theme_stylesheet ] ); |
| 793 | |
| 794 | if ( version_compare( $update->new_version, $theme_data['Version'], '>' ) ) { |
| 795 | $new_update->response[ $theme_stylesheet ] = (array) $update; |
| 796 | } else { |
| 797 | $new_update->no_update[ $theme_stylesheet ] = (array) $update; |
| 798 | } |
| 799 | } |
| 800 | |