Changeset 52348
- Timestamp:
- 12/09/2021 03:11:17 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/theme.php
r52330 r52348 1194 1194 $width = absint( $header->width ); 1195 1195 $height = absint( $header->height ); 1196 $alt = ''; 1196 1197 1197 1198 // Use alternative text assigned to the image, if available. Otherwise, leave it empty. 1198 if ( ! empty( $header->attachment_id ) && is_string( get_post_meta( $header->attachment_id, '_wp_attachment_image_alt', true ) ) ) { 1199 $alt = get_post_meta( $header->attachment_id, '_wp_attachment_image_alt', true ); 1200 } else { 1201 $alt = ''; 1199 if ( ! empty( $header->attachment_id ) ) { 1200 $image_alt = get_post_meta( $header->attachment_id, '_wp_attachment_image_alt', true ); 1201 1202 if ( is_string( $image_alt ) ) { 1203 $alt = $image_alt; 1204 } 1202 1205 } 1203 1206 … … 1219 1222 if ( is_array( $image_meta ) ) { 1220 1223 $srcset = wp_calculate_image_srcset( $size_array, $header->url, $image_meta, $header->attachment_id ); 1221 $sizes = ! empty( $attr['sizes'] ) ? $attr['sizes'] : wp_calculate_image_sizes( $size_array, $header->url, $image_meta, $header->attachment_id ); 1224 1225 if ( ! empty( $attr['sizes'] ) ) { 1226 $sizes = $attr['sizes']; 1227 } else { 1228 $sizes = wp_calculate_image_sizes( $size_array, $header->url, $image_meta, $header->attachment_id ); 1229 } 1222 1230 1223 1231 if ( $srcset && $sizes ) { … … 1282 1290 */ 1283 1291 function _get_random_header_data() { 1292 global $_wp_default_headers; 1284 1293 static $_wp_random_header = null; 1285 1294 1286 1295 if ( empty( $_wp_random_header ) ) { 1287 global $_wp_default_headers;1288 1296 $header_image_mod = get_theme_mod( 'header_image', '' ); 1289 1297 $headers = array(); … … 1307 1315 $_wp_random_header = (object) $headers[ array_rand( $headers ) ]; 1308 1316 1309 $_wp_random_header->url = sprintf( $_wp_random_header->url, get_template_directory_uri(), get_stylesheet_directory_uri() ); 1310 $_wp_random_header->thumbnail_url = sprintf( $_wp_random_header->thumbnail_url, get_template_directory_uri(), get_stylesheet_directory_uri() ); 1317 $_wp_random_header->url = sprintf( 1318 $_wp_random_header->url, 1319 get_template_directory_uri(), 1320 get_stylesheet_directory_uri() 1321 ); 1322 1323 $_wp_random_header->thumbnail_url = sprintf( 1324 $_wp_random_header->thumbnail_url, 1325 get_template_directory_uri(), 1326 get_stylesheet_directory_uri() 1327 ); 1311 1328 } 1312 1329 … … 1408 1425 $header_index = $header->ID; 1409 1426 1410 $header_images[ $header_index ] = array(); 1411 $header_images[ $header_index ]['attachment_id'] = $header->ID; 1412 $header_images[ $header_index ]['url'] = $url; 1413 $header_images[ $header_index ]['thumbnail_url'] = $url; 1414 $header_images[ $header_index ]['alt_text'] = get_post_meta( $header->ID, '_wp_attachment_image_alt', true ); 1415 $header_images[ $header_index ]['attachment_parent'] = isset( $header_data['attachment_parent'] ) ? $header_data['attachment_parent'] : ''; 1427 $header_images[ $header_index ] = array(); 1428 $header_images[ $header_index ]['attachment_id'] = $header->ID; 1429 $header_images[ $header_index ]['url'] = $url; 1430 $header_images[ $header_index ]['thumbnail_url'] = $url; 1431 $header_images[ $header_index ]['alt_text'] = get_post_meta( $header->ID, '_wp_attachment_image_alt', true ); 1432 1433 if ( isset( $header_data['attachment_parent'] ) ) { 1434 $header_images[ $header_index ]['attachment_parent'] = $header_data['attachment_parent']; 1435 } else { 1436 $header_images[ $header_index ]['attachment_parent'] = ''; 1437 } 1416 1438 1417 1439 if ( isset( $header_data['width'] ) ) { … … 1504 1526 function unregister_default_headers( $header ) { 1505 1527 global $_wp_default_headers; 1528 1506 1529 if ( is_array( $header ) ) { 1507 1530 array_map( 'unregister_default_headers', $header ); … … 1839 1862 ?> 1840 1863 <style<?php echo $type_attr; ?> id="wp-custom-css"> 1841 <?php echo strip_tags( $styles ); // Note that esc_html() cannot be used because `div > span` is not interpreted properly. ?> 1864 <?php 1865 // Note that esc_html() cannot be used because `div > span` is not interpreted properly. 1866 echo strip_tags( $styles ); 1867 ?> 1842 1868 </style> 1843 1869 <?php … … 1940 1966 * Args. 1941 1967 * 1942 * @type string $preprocessed Pre-processed CSS, stored in `post_content_filtered`. Normally empty string. Optional. 1943 * @type string $stylesheet Stylesheet (child theme) to update. Optional, defaults to current theme/stylesheet. 1968 * @type string $preprocessed Optional. Pre-processed CSS, stored in `post_content_filtered`. 1969 * Normally empty string. 1970 * @type string $stylesheet Optional. Stylesheet (child theme) to update. 1971 * Defaults to current theme/stylesheet. 1944 1972 * } 1945 1973 * @return WP_Post|WP_Error Post on success, error on failure. … … 1960 1988 1961 1989 /** 1962 * Filters the `css` (`post_content`) and `preprocessed` (`post_content_filtered`) args for a `custom_css` post being updated. 1990 * Filters the `css` (`post_content`) and `preprocessed` (`post_content_filtered`) args 1991 * for a `custom_css` post being updated. 1963 1992 * 1964 1993 * This filter can be used by plugin that offer CSS pre-processors, to store the original … … 1982 2011 * 1983 2012 * @type string $css CSS stored in `post_content`. 1984 * @type string $preprocessed Pre-processed CSS stored in `post_content_filtered`. Normally empty string. 2013 * @type string $preprocessed Pre-processed CSS stored in `post_content_filtered`. 2014 * Normally empty string. 1985 2015 * } 1986 2016 * @param array $args { … … 2168 2198 array( 2169 2199 '<strong>' . _x( 'Address', 'Theme starter content' ) . "</strong>\n", 2170 _x( '123 Main Street', 'Theme starter content' ) . "\n" . _x( 'New York, NY 10001', 'Theme starter content' ) . "\n\n", 2200 _x( '123 Main Street', 'Theme starter content' ) . "\n", 2201 _x( 'New York, NY 10001', 'Theme starter content' ) . "\n\n", 2171 2202 '<strong>' . _x( 'Hours', 'Theme starter content' ) . "</strong>\n", 2172 _x( 'Monday–Friday: 9:00AM–5:00PM', 'Theme starter content' ) . "\n" . _x( 'Saturday & Sunday: 11:00AM–3:00PM', 'Theme starter content' ), 2203 _x( 'Monday–Friday: 9:00AM–5:00PM', 'Theme starter content' ) . "\n", 2204 _x( 'Saturday & Sunday: 11:00AM–3:00PM', 'Theme starter content' ), 2173 2205 ) 2174 2206 ), … … 2372 2404 2373 2405 $content[ $type ][ $sidebar_id ][] = $widget; 2374 } elseif ( is_string( $widget ) && ! empty( $core_content[ $type ] ) && ! empty( $core_content[ $type ][ $widget ] ) ) { 2406 } elseif ( is_string( $widget ) 2407 && ! empty( $core_content[ $type ] ) 2408 && ! empty( $core_content[ $type ][ $widget ] ) 2409 ) { 2375 2410 $content[ $type ][ $sidebar_id ][] = $core_content[ $type ][ $widget ]; 2376 2411 } … … 2399 2434 2400 2435 $content[ $type ][ $nav_menu_location ]['items'][] = $nav_menu_item; 2401 } elseif ( is_string( $nav_menu_item ) && ! empty( $core_content[ $type ] ) && ! empty( $core_content[ $type ][ $nav_menu_item ] ) ) { 2436 } elseif ( is_string( $nav_menu_item ) 2437 && ! empty( $core_content[ $type ] ) 2438 && ! empty( $core_content[ $type ][ $nav_menu_item ] ) 2439 ) { 2402 2440 $content[ $type ][ $nav_menu_location ]['items'][] = $core_content[ $type ][ $nav_menu_item ]; 2403 2441 } … … 2559 2597 $args[0] = array_intersect( $args[0], array_keys( $post_formats ) ); 2560 2598 } else { 2561 _doing_it_wrong( "add_theme_support( 'post-formats' )", __( 'You need to pass an array of post formats.' ), '5.6.0' ); 2599 _doing_it_wrong( 2600 "add_theme_support( 'post-formats' )", 2601 __( 'You need to pass an array of post formats.' ), 2602 '5.6.0' 2603 ); 2562 2604 return false; 2563 2605 } … … 2570 2612 $args = array( 0 => array( 'comment-list', 'comment-form', 'search-form' ) ); 2571 2613 } elseif ( ! isset( $args[0] ) || ! is_array( $args[0] ) ) { 2572 _doing_it_wrong( "add_theme_support( 'html5' )", __( 'You need to pass an array of types.' ), '3.6.1' ); 2614 _doing_it_wrong( 2615 "add_theme_support( 'html5' )", 2616 __( 'You need to pass an array of types.' ), 2617 '3.6.1' 2618 ); 2573 2619 return false; 2574 2620 } … … 2811 2857 */ 2812 2858 function _custom_logo_header_styles() { 2813 if ( ! current_theme_supports( 'custom-header', 'header-text' ) && get_theme_support( 'custom-logo', 'header-text' ) && ! get_theme_mod( 'header_text', true ) ) { 2859 if ( ! current_theme_supports( 'custom-header', 'header-text' ) 2860 && get_theme_support( 'custom-logo', 'header-text' ) 2861 && ! get_theme_mod( 'header_text', true ) 2862 ) { 2814 2863 $classes = (array) get_theme_support( 'custom-logo', 'header-text' ); 2815 2864 $classes = array_map( 'sanitize_html_class', $classes ); … … 2850 2899 function get_theme_support( $feature, ...$args ) { 2851 2900 global $_wp_theme_features; 2901 2852 2902 if ( ! isset( $_wp_theme_features[ $feature ] ) ) { 2853 2903 return false; … … 3167 3217 3168 3218 if ( is_array( $args['show_in_rest'] ) ) { 3169 if ( isset( $args['show_in_rest']['prepare_callback'] ) && ! is_callable( $args['show_in_rest']['prepare_callback'] ) ) { 3219 if ( isset( $args['show_in_rest']['prepare_callback'] ) 3220 && ! is_callable( $args['show_in_rest']['prepare_callback'] ) 3221 ) { 3170 3222 return new WP_Error( 3171 3223 'invalid_rest_prepare_callback', … … 3286 3338 function check_theme_switched() { 3287 3339 $stylesheet = get_option( 'theme_switched' ); 3340 3288 3341 if ( $stylesheet ) { 3289 3342 $old_theme = wp_get_theme( $stylesheet ); … … 3315 3368 do_action( 'after_switch_theme', $stylesheet, $old_theme ); 3316 3369 } 3370 3317 3371 flush_rewrite_rules(); 3318 3372 … … 3354 3408 * the values should contain any characters needing slashes anyway. 3355 3409 */ 3356 $keys = array( 'changeset_uuid', 'customize_changeset_uuid', 'customize_theme', 'theme', 'customize_messenger_channel', 'customize_autosaved' ); 3410 $keys = array( 3411 'changeset_uuid', 3412 'customize_changeset_uuid', 3413 'customize_theme', 3414 'theme', 3415 'customize_messenger_channel', 3416 'customize_autosaved', 3417 ); 3357 3418 $input_vars = array_merge( 3358 3419 wp_array_slice_assoc( $_GET, $keys ), … … 3410 3471 3411 3472 require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; 3412 $GLOBALS['wp_customize'] = new WP_Customize_Manager( compact( 'changeset_uuid', 'theme', 'messenger_channel', 'settings_previewed', 'autosaved', 'branching' ) ); 3473 $GLOBALS['wp_customize'] = new WP_Customize_Manager( 3474 compact( 3475 'changeset_uuid', 3476 'theme', 3477 'messenger_channel', 3478 'settings_previewed', 3479 'autosaved', 3480 'branching', 3481 ) 3482 ); 3413 3483 } 3414 3484 … … 3622 3692 3623 3693 /** 3624 * Makes sure that auto-draft posts get their post_date bumped or status changed to draft to prevent premature garbage-collection. 3694 * Makes sure that auto-draft posts get their post_date bumped or status changed 3695 * to draft to prevent premature garbage-collection. 3625 3696 * 3626 3697 * When a changeset is updated but remains an auto-draft, ensure the post_date
Note: See TracChangeset
for help on using the changeset viewer.