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