Changeset 63703
- Timestamp:
- 09/17/2026 08:57:16 PM (2 months ago)
- Location:
- branches/5.9
- Files:
-
- 13 edited
-
. (modified) (1 prop)
-
src/js/_enqueues/wp/theme.js (modified) (1 diff)
-
src/wp-admin/includes/ajax-actions.php (modified) (2 diffs)
-
src/wp-admin/includes/class-custom-image-header.php (modified) (4 diffs)
-
src/wp-admin/includes/media.php (modified) (1 diff)
-
src/wp-admin/includes/plugin.php (modified) (1 diff)
-
src/wp-admin/includes/post.php (modified) (1 diff)
-
src/wp-includes/block-template-utils.php (modified) (1 diff)
-
src/wp-includes/class-wp-xmlrpc-server.php (modified) (1 diff)
-
src/wp-includes/customize/class-wp-customize-header-image-setting.php (modified) (2 diffs)
-
src/wp-includes/formatting.php (modified) (1 diff)
-
src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php (modified) (3 diffs)
-
src/wp-includes/theme.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/5.9
- Property svn:mergeinfo changed
/trunk merged: 62658,63656-63657,63659-63660,63663,63665,63669-63670,63672,63675
- Property svn:mergeinfo changed
-
branches/5.9/src/js/_enqueues/wp/theme.js
r53008 r63703 2021 2021 self.view.collection.trigger( 'update' ); 2022 2022 2023 // Open the theme preview. 2023 // Open the theme preview. The slug comes from the URL, so escape it. 2024 2024 self.view.collection.once( 'query:success', function() { 2025 $( 'div [data-slug="' + slug+ '"]' ).trigger( 'click' );2025 $( 'div.theme[data-slug="' + $.escapeSelector( slug ) + '"]' ).trigger( 'click' ); 2026 2026 }); 2027 2027 -
branches/5.9/src/wp-admin/includes/ajax-actions.php
r56875 r63703 1965 1965 check_ajax_referer( 'getpermalink', 'getpermalinknonce' ); 1966 1966 $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; 1967 if ( ! $post_id ) { 1968 // Bypass call to get_preview_post_link() for unspecified post ID. 1969 wp_die( '' ); 1970 } 1971 if ( ! current_user_can( 'edit_post', $post_id ) ) { 1972 wp_die( -1 ); 1973 } 1967 1974 wp_die( get_preview_post_link( $post_id ) ); 1968 1975 } … … 1976 1983 check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' ); 1977 1984 $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; 1978 $title = isset( $_POST['new_title'] ) ? $_POST['new_title'] : ''; 1979 $slug = isset( $_POST['new_slug'] ) ? $_POST['new_slug'] : null; 1985 if ( ! $post_id ) { 1986 // Bypass call to get_sample_permalink_html() for unspecified post ID. 1987 wp_die( '' ); 1988 } 1989 if ( ! current_user_can( 'edit_post', $post_id ) ) { 1990 wp_die( -1 ); 1991 } 1992 $title = isset( $_POST['new_title'] ) ? $_POST['new_title'] : ''; 1993 $slug = isset( $_POST['new_slug'] ) ? $_POST['new_slug'] : null; 1980 1994 wp_die( get_sample_permalink_html( $post_id, $title, $slug ) ); 1981 1995 } -
branches/5.9/src/wp-admin/includes/class-custom-image-header.php
r52285 r63703 557 557 } 558 558 ?> 559 <div id="headimg" style="<?php echo $header_image_style; ?>">559 <div id="headimg" style="<?php echo esc_attr( $header_image_style ); ?>"> 560 560 <?php 561 561 if ( display_header_text() ) { … … 1168 1168 'url' => $choice['url'], 1169 1169 'thumbnail_url' => $choice['url'], 1170 'height' => $choice['height'],1171 'width' => $choice['width'],1170 'height' => absint( $choice['height'] ), 1171 'width' => absint( $choice['width'] ), 1172 1172 ); 1173 1173 … … 1200 1200 } 1201 1201 1202 set_theme_mod( 'header_image', esc_url_raw( $header_image_data['url'] ) ); 1202 $header_image_data['url'] = esc_url_raw( $header_image_data['url'] ); 1203 1204 if ( isset( $header_image_data['thumbnail_url'] ) ) { 1205 $header_image_data['thumbnail_url'] = esc_url_raw( $header_image_data['thumbnail_url'] ); 1206 } 1207 1208 set_theme_mod( 'header_image', $header_image_data['url'] ); 1203 1209 set_theme_mod( 'header_image_data', $header_image_data ); 1204 1210 } … … 1565 1571 1566 1572 foreach ( $header_images as &$header_image ) { 1567 $header_meta = get_post_meta( $header_image['attachment_id'] ); 1568 $header_image['timestamp'] = isset( $header_meta[ $timestamp_key ] ) ? $header_meta[ $timestamp_key ] : ''; 1569 $header_image['alt_text'] = isset( $header_meta[ $alt_text_key ] ) ? $header_meta[ $alt_text_key ] : ''; 1573 $header_image['timestamp'] = get_post_meta( $header_image['attachment_id'], $timestamp_key, true ); 1574 $header_image['alt_text'] = get_post_meta( $header_image['attachment_id'], $alt_text_key, true ); 1570 1575 } 1571 1576 -
branches/5.9/src/wp-admin/includes/media.php
r52332 r63703 3324 3324 if ( $post->post_parent ) { 3325 3325 $post_parent = get_post( $post->post_parent ); 3326 if ( $post_parent ) {3326 if ( $post_parent && current_user_can( 'read_post', $post_parent->ID ) ) { 3327 3327 $uploaded_to_title = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' ); 3328 3328 $uploaded_to_link = get_edit_post_link( $post->post_parent, 'raw' ); -
branches/5.9/src/wp-admin/includes/plugin.php
r52352 r63703 585 585 * 586 586 * @since 3.0.0 587 * 588 * @param string $plugin Path to the plugin file relative to the plugins directory. 587 * @since 7.1.1 The `$plugin` path is normalized with `plugin_basename()` and `trim()`, 588 * matching how `activate_plugin()` resolves it. 589 * 590 * @param string $plugin Path to the plugin file. Accepts a path relative to the plugins 591 * directory, or an absolute path, with or without surrounding whitespace. 589 592 * @return bool True if plugin is network only, false otherwise. 590 593 */ 591 594 function is_network_only_plugin( $plugin ) { 595 // Normalize the path the same way activate_plugin() does, so both agree on the file. 596 $plugin = plugin_basename( trim( $plugin ) ); 597 592 598 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); 593 599 if ( $plugin_data ) { -
branches/5.9/src/wp-admin/includes/post.php
r54545 r63703 23 23 if ( empty( $post_data ) ) { 24 24 $post_data = &$_POST; 25 } 26 27 /* 28 * A raw `ID` on the create path (no `post_ID`) is an attempt to overwrite an 29 * existing post while bypassing the per-post capability checks below, which only 30 * run on the update path. Reject it outright: legitimate post creation never 31 * carries an `ID`. 32 */ 33 if ( ! $update && ! empty( $post_data['ID'] ) ) { 34 if ( 'page' === $post_data['post_type'] ) { 35 return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); 36 } else { 37 return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); 38 } 25 39 } 26 40 -
branches/5.9/src/wp-includes/block-template-utils.php
r52632 r63703 265 265 foreach ( $themes as $theme_slug => $theme_dir ) { 266 266 $template_base_paths = get_block_theme_folders( $theme_slug ); 267 $file_path = $theme_dir . '/' . $template_base_paths[ $template_type ] . '/' . $slug . '.html'; 268 if ( file_exists( $file_path ) ) { 267 $template_dir = $theme_dir . '/' . $template_base_paths[ $template_type ]; 268 $file_path = $template_dir . '/' . $slug . '.html'; 269 $template_file = realpath( $file_path ); 270 $template_root = realpath( $template_dir ); 271 272 if ( 273 false !== $template_file && 274 false !== $template_root && 275 str_starts_with( 276 wp_normalize_path( $template_file ), 277 trailingslashit( wp_normalize_path( $template_root ) ) 278 ) 279 ) { 269 280 $new_template_item = array( 270 281 'slug' => $slug, 271 'path' => $ file_path,282 'path' => $template_file, 272 283 'theme' => $theme_slug, 273 284 'type' => $template_type, -
branches/5.9/src/wp-includes/class-wp-xmlrpc-server.php
r52422 r63703 1440 1440 } 1441 1441 1442 // Reject writes to internal-only builtin post types (e.g. customize_changeset) 1443 // whose intended write path is a dedicated helper, not a generic post API. 1444 $is_internal_only = ( 1445 empty( $post_type->public ) 1446 && empty( $post_type->show_in_rest ) 1447 && ! empty( $post_type->_builtin ) 1448 ); 1449 1450 /** 1451 * Filters whether a post type accepts writes via XML-RPC. 1452 * 1453 * Defaults to false for internal-only builtin post types (public=false, 1454 * show_in_rest=false, _builtin=true), such as customize_changeset, whose 1455 * writes are meant to flow through dedicated helpers. Return true to opt 1456 * a post type back in. 1457 * 1458 * @since 7.1.1 1459 * 1460 * @param bool $allowed Whether the post type accepts XML-RPC writes. 1461 * @param WP_Post_Type $post_type The post type object. 1462 */ 1463 $allowed = apply_filters( 'xmlrpc_allow_post_type_writes', ! $is_internal_only, $post_type ); 1464 1465 if ( ! $allowed ) { 1466 return new IXR_Error( 403, __( 'Sorry, this post type is not supported over XML-RPC.' ) ); 1467 } 1468 1442 1469 $update = ! empty( $post_data['ID'] ); 1443 1470 -
branches/5.9/src/wp-includes/customize/class-wp-customize-header-image-setting.php
r51784 r63703 16 16 * 17 17 * @see WP_Customize_Setting 18 * 19 * @phpstan-type Header_Image_Data array{ 20 * attachment_id?: int, 21 * url?: string, 22 * thumbnail_url?: string, 23 * timestamp?: int, 24 * width?: int, 25 * height?: int, 26 * alt_text?: string, 27 * attachment_parent?: int, 28 * } 18 29 */ 19 30 final class WP_Customize_Header_Image_Setting extends WP_Customize_Setting { … … 51 62 } 52 63 } 64 65 /** 66 * Sanitizes a header value. 67 * 68 * The value is expected to be one of the following: 69 * 70 * - An array of header image data, with the keys `attachment_id`, `url`, `thumbnail_url`, `timestamp`, `width`, 71 * `height`, `alt_text`, and `attachment_parent`, as supplied by {@see get_uploaded_header_images()}. Any other 72 * key is discarded. 73 * - An array with a `choice` key, being the legacy format in which any of the other accepted values is nested. 74 * - The string `remove-header`, `random-default-image`, or `random-uploaded-image`. 75 * - A string corresponding to one of the keys for the array returned by {@see get_uploaded_header_images()}, or 76 * one of the keys for the array passed into {@see register_default_headers()}. 77 * 78 * @since 7.1.1 79 * 80 * @see WP_Customize_Header_Image_Setting::update() 81 * @see Custom_Image_Header::set_header_image() 82 * 83 * @param mixed $value Value to sanitize. 84 * @return array|string|WP_Error|null Sanitized value, or `null`/`WP_Error` if invalid. The array holds 85 * the header image data, or that data nested under a `choice` key, 86 * before the `customize_sanitize_header_image_data` filter, which 87 * may return anything, is applied to it. 88 * 89 * @phpstan-return array<mixed, mixed>|string|WP_Error|null 90 */ 91 public function sanitize( $value ) { 92 /* 93 * The update() method unwraps the legacy `choice` format before handing the value off to 94 * Custom_Image_Header::set_header_image(), so the nested value is what must be sanitized. 95 */ 96 if ( is_array( $value ) && isset( $value['choice'] ) ) { 97 $choice = $this->sanitize_choice( $value['choice'] ); 98 if ( is_null( $choice ) || is_wp_error( $choice ) ) { 99 return $choice; 100 } 101 $value = array( 'choice' => $choice ); 102 } else { 103 $value = $this->sanitize_choice( $value ); 104 if ( is_null( $value ) || is_wp_error( $value ) ) { 105 return $value; 106 } 107 } 108 109 return parent::sanitize( $value ); 110 } 111 112 /** 113 * Sanitizes a header image choice. 114 * 115 * This is the value which is ultimately passed to {@see Custom_Image_Header::set_header_image()}, whether 116 * supplied at the top level of the setting value or nested under its legacy `choice` key. 117 * 118 * @since 7.1.1 119 * 120 * @param mixed $value Value to sanitize. 121 * @return array|string|WP_Error|null Sanitized value, or `null`/`WP_Error` if invalid. 122 * 123 * @phpstan-return Header_Image_Data|string|WP_Error|null 124 */ 125 private function sanitize_choice( $value ) { 126 // Custom_Image_Header::set_header_image() accepts an object in place of an array. 127 if ( is_object( $value ) ) { 128 $value = (array) $value; 129 } 130 131 if ( is_string( $value ) ) { 132 return sanitize_text_field( $value ); 133 } 134 135 if ( ! is_array( $value ) ) { 136 return null; 137 } 138 139 /* 140 * The sanitized value is assembled member by member rather than filtered down from the 141 * supplied one, so that nothing but the members below can end up in it. 142 */ 143 $sanitized = array(); 144 145 if ( isset( $value['attachment_id'] ) ) { 146 if ( ! is_scalar( $value['attachment_id'] ) ) { 147 return null; 148 } 149 $attachment_id = absint( $value['attachment_id'] ); 150 151 /* 152 * A supplied attachment must be an existing image, since its ID is written to postmeta and its 153 * data displayed. Note that an ID of zero must be skipped rather than looked up, as 154 * get_post_mime_type() falls back to the global post when passed an empty value. 155 */ 156 if ( $attachment_id > 0 ) { 157 $mime_type = get_post_mime_type( $attachment_id ); 158 if ( ! is_string( $mime_type ) || ! str_starts_with( $mime_type, 'image/' ) ) { 159 return null; 160 } 161 } 162 163 $sanitized['attachment_id'] = $attachment_id; 164 } 165 166 if ( isset( $value['url'] ) ) { 167 if ( ! is_string( $value['url'] ) ) { 168 return null; 169 } 170 $sanitized['url'] = esc_url_raw( $value['url'] ); 171 if ( '' === $sanitized['url'] ) { 172 return new WP_Error( 'invalid_url', __( 'Invalid URL.' ) ); 173 } 174 } 175 176 if ( isset( $value['thumbnail_url'] ) ) { 177 if ( ! is_string( $value['thumbnail_url'] ) ) { 178 return null; 179 } 180 $sanitized['thumbnail_url'] = esc_url_raw( $value['thumbnail_url'] ); 181 if ( '' === $sanitized['thumbnail_url'] ) { 182 return new WP_Error( 'invalid_url', __( 'Invalid URL.' ) ); 183 } 184 } 185 186 if ( isset( $value['timestamp'] ) ) { 187 if ( ! is_scalar( $value['timestamp'] ) ) { 188 return null; 189 } 190 $sanitized['timestamp'] = absint( $value['timestamp'] ); 191 } 192 193 if ( isset( $value['width'] ) ) { 194 if ( ! is_scalar( $value['width'] ) ) { 195 return null; 196 } 197 $sanitized['width'] = absint( $value['width'] ); 198 } 199 200 if ( isset( $value['height'] ) ) { 201 if ( ! is_scalar( $value['height'] ) ) { 202 return null; 203 } 204 $sanitized['height'] = absint( $value['height'] ); 205 } 206 207 if ( isset( $value['alt_text'] ) ) { 208 if ( ! is_string( $value['alt_text'] ) ) { 209 return null; 210 } 211 $sanitized['alt_text'] = sanitize_text_field( $value['alt_text'] ); 212 } 213 214 if ( isset( $value['attachment_parent'] ) ) { 215 if ( ! is_scalar( $value['attachment_parent'] ) ) { 216 return null; 217 } 218 $sanitized['attachment_parent'] = absint( $value['attachment_parent'] ); 219 } 220 221 return $sanitized; 222 } 53 223 } -
branches/5.9/src/wp-includes/formatting.php
r58483 r63703 557 557 558 558 // If a <blockquote> is wrapped with a <p>, move it inside the <blockquote>. 559 $pee = preg_replace( ' |<p><blockquote([^>]*)>|i', '<blockquote$1><p>', $pee );559 $pee = preg_replace( '!<p><blockquote((?:[^>"\']|"[^"]*"|\'[^\']*\')*)>!i', '<blockquote$1><p>', $pee ); 560 560 $pee = str_replace( '</blockquote></p>', '</p></blockquote>', $pee ); 561 561 -
branches/5.9/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
r51786 r63703 769 769 * 770 770 * @since 4.7.0 771 * @since 7.1.0 Target post permissions are checked when a comment's parent post is changed. 771 772 * 772 773 * @param WP_REST_Request $request Full details about the request. … … 785 786 array( 'status' => rest_authorization_required_code() ) 786 787 ); 788 } 789 790 /* 791 * check_edit_permission() above only establishes that the comment may be 792 * edited where it currently sits, because 'edit_comment' maps to 'edit_post' 793 * on the comment's current parent. When the parent is being changed, the new 794 * parent has to be authorized as well. Without this, a user holding 795 * edit_comment on their own comment could reparent it onto any post, 796 * including posts they can neither read nor edit. 797 */ 798 if ( isset( $request['post'] ) && (int) $request['post'] !== (int) $comment->comment_post_ID ) { 799 $target_check = $this->check_target_post_permission( (int) $request['post'] ); 800 801 if ( is_wp_error( $target_check ) ) { 802 return $target_check; 803 } 787 804 } 788 805 … … 1904 1921 return '' !== $check['comment_content']; 1905 1922 } 1923 1924 /** 1925 * Checks that a post can receive a comment from the current user. 1926 * 1927 * Used when changing the parent post of an existing comment, so that 1928 * attaching a comment to a post is authorized the same way whichever 1929 * path it arrives by. 1930 * 1931 * @since 7.1.0 1932 * 1933 * @param int $post_id Target post ID. 1934 * @return true|WP_Error True if the post can receive the comment, error object otherwise. 1935 */ 1936 protected function check_target_post_permission( $post_id ) { 1937 if ( ! $post_id ) { 1938 return new WP_Error( 1939 'rest_comment_invalid_post_id', 1940 __( 'Sorry, you are not allowed to create this comment without a post.' ), 1941 array( 'status' => 403 ) 1942 ); 1943 } 1944 1945 /* 1946 * A comment needs either comment moderation rights or edit access to the 1947 * post, which is what check_edit_permission() grants on the post a comment 1948 * is moving away from. Requiring the same at the destination means both 1949 * ends of a move are authorized alike. 1950 */ 1951 if ( ! current_user_can( 'moderate_comments' ) && ! current_user_can( 'edit_post', $post_id ) ) { 1952 return new WP_Error( 1953 'rest_cannot_edit', 1954 __( 'Sorry, you are not allowed to edit this comment.' ), 1955 array( 'status' => rest_authorization_required_code() ) 1956 ); 1957 } 1958 1959 $post = get_post( $post_id ); 1960 1961 if ( ! $post ) { 1962 return new WP_Error( 1963 'rest_comment_invalid_post_id', 1964 __( 'Sorry, you are not allowed to create this comment without a post.' ), 1965 array( 'status' => 403 ) 1966 ); 1967 } 1968 1969 /* 1970 * The create-time draft and comments-open rules are deliberately not applied 1971 * here, because moderators move comments onto posts whose discussion has 1972 * closed and onto drafts today. Enforcing them would break that without 1973 * blocking anything the capability check above already permits. 1974 */ 1975 return true; 1976 } 1906 1977 } -
branches/5.9/src/wp-includes/theme.php
r52440 r63703 1452 1452 * 1453 1453 * @since 3.4.0 1454 * @since 7.1.1 The `width` and `height` are cast to non-negative integers. 1454 1455 * 1455 1456 * @global array $_wp_default_headers … … 1490 1491 'video' => get_theme_support( 'custom-header', 'video' ), 1491 1492 ); 1492 return (object) wp_parse_args( $data, $default ); 1493 1494 if ( ! is_array( $data ) && ! is_object( $data ) ) { 1495 $data = array(); 1496 } 1497 $header = (object) wp_parse_args( $data, $default ); 1498 $header->width = absint( $header->width ); 1499 $header->height = absint( $header->height ); 1500 return $header; 1493 1501 } 1494 1502
Note:
See TracChangeset
for help on using the changeset viewer.