Changeset 60704 for trunk/src/wp-includes/class-wp-scripts.php
- Timestamp:
- 09/03/2025 10:15:31 PM (6 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-scripts.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-scripts.php
r60690 r60704 425 425 if ( $intended_strategy ) { 426 426 $attr['data-wp-strategy'] = $intended_strategy; 427 } 428 if ( isset( $obj->extra['fetchpriority'] ) && 'auto' !== $obj->extra['fetchpriority'] && $this->is_valid_fetchpriority( $obj->extra['fetchpriority'] ) ) { 429 $attr['fetchpriority'] = $obj->extra['fetchpriority']; 427 430 } 428 431 $tag = $translations . $ie_conditional_prefix . $before_script; … … 832 835 return false; 833 836 } 837 } elseif ( 'fetchpriority' === $key ) { 838 if ( empty( $value ) ) { 839 $value = 'auto'; 840 } 841 if ( ! $this->is_valid_fetchpriority( $value ) ) { 842 _doing_it_wrong( 843 __METHOD__, 844 sprintf( 845 /* translators: 1: $fetchpriority, 2: $handle */ 846 __( 'Invalid fetchpriority `%1$s` defined for `%2$s` during script registration.' ), 847 is_string( $value ) ? $value : gettype( $value ), 848 $handle 849 ), 850 '6.9.0' 851 ); 852 return false; 853 } elseif ( ! $this->registered[ $handle ]->src ) { 854 _doing_it_wrong( 855 __METHOD__, 856 sprintf( 857 /* translators: 1: $fetchpriority, 2: $handle */ 858 __( 'Cannot supply a fetchpriority `%1$s` for script `%2$s` because it is an alias (it lacks a `src` value).' ), 859 is_string( $value ) ? $value : gettype( $value ), 860 $handle 861 ), 862 '6.9.0' 863 ); 864 return false; 865 } 834 866 } 835 867 return parent::add_data( $handle, $key, $value ); … … 870 902 * @since 6.3.0 871 903 * 872 * @param string $strategy The strategy to check.904 * @param string|mixed $strategy The strategy to check. 873 905 * @return bool True if $strategy is one of the delayed strategies, otherwise false. 874 906 */ 875 private function is_delayed_strategy( $strategy ) {907 private function is_delayed_strategy( $strategy ): bool { 876 908 return in_array( 877 909 $strategy, … … 879 911 true 880 912 ); 913 } 914 915 /** 916 * Checks if the provided fetchpriority is valid. 917 * 918 * @since 6.9.0 919 * 920 * @param string|mixed $priority Fetch priority. 921 * @return bool Whether valid fetchpriority. 922 */ 923 private function is_valid_fetchpriority( $priority ): bool { 924 return in_array( $priority, array( 'auto', 'low', 'high' ), true ); 881 925 } 882 926
Note: See TracChangeset
for help on using the changeset viewer.