diff -r 34716fd837a4 -r be944660c56a wp/wp-admin/includes/media.php
--- a/wp/wp-admin/includes/media.php Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-admin/includes/media.php Wed Sep 21 18:19:35 2022 +0200
@@ -49,10 +49,10 @@
return $tabs;
}
- $post_id = intval( $_REQUEST['post_id'] );
+ $post_id = (int) $_REQUEST['post_id'];
if ( $post_id ) {
- $attachments = intval( $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $post_id ) ) );
+ $attachments = (int) $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $post_id ) );
}
if ( empty( $attachments ) ) {
@@ -125,8 +125,8 @@
* @param string $align Image CSS alignment property.
* @param string $url Optional. Image src URL. Default empty.
* @param bool|string $rel Optional. Value for rel attribute or whether to add a default value. Default false.
- * @param string|array $size Optional. Image size. Accepts any valid image size, or an array of width
- * and height values in pixels (in that order). Default 'medium'.
+ * @param string|int[] $size Optional. Image size. Accepts any registered image size name, or an array of
+ * width and height values in pixels (in that order). Default 'medium'.
* @param string $alt Optional. Image alt attribute. Default empty.
* @return string The HTML output to insert into the editor.
*/
@@ -138,7 +138,7 @@
if ( is_string( $rel ) ) {
$rel = ' rel="' . esc_attr( $rel ) . '"';
} else {
- $rel = ' rel="attachment wp-att-' . intval( $id ) . '"';
+ $rel = ' rel="attachment wp-att-' . (int) $id . '"';
}
} else {
$rel = '';
@@ -152,6 +152,7 @@
* Filters the image HTML markup to send to the editor when inserting an image.
*
* @since 2.5.0
+ * @since 5.6.0 The `$rel` parameter was added.
*
* @param string $html The image HTML markup to send.
* @param int $id The attachment ID.
@@ -159,11 +160,12 @@
* @param string $title The image title.
* @param string $align The image alignment.
* @param string $url The image source URL.
- * @param string|array $size Size of image. Image size or array of width and height values
- * (in that order). Default 'medium'.
+ * @param string|int[] $size Requested image size. Can be any registered image size name, or
+ * an array of width and height values in pixels (in that order).
* @param string $alt The image alternative, or alt, text.
+ * @param string $rel The image rel attribute.
*/
- $html = apply_filters( 'image_send_to_editor', $html, $id, $caption, $title, $align, $url, $size, $alt );
+ $html = apply_filters( 'image_send_to_editor', $html, $id, $caption, $title, $align, $url, $size, $alt, $rel );
return $html;
}
@@ -174,12 +176,12 @@
* @since 2.6.0
*
* @param string $html The image HTML markup to send.
- * @param integer $id Image attachment ID.
+ * @param int $id Image attachment ID.
* @param string $caption Image caption.
* @param string $title Image title attribute (not used).
* @param string $align Image CSS alignment property.
* @param string $url Image source URL (not used).
- * @param string $size Image size (`thumbnail`, `medium`, `large`, `full`, or added with `add_image_size()`) (not used).
+ * @param string $size Image size (not used).
* @param string $alt Image `alt` attribute (not used).
* @return string The image HTML markup with caption shortcode.
*/
@@ -428,21 +430,23 @@
* @since 2.6.0
* @since 5.3.0 The `$post_id` parameter was made optional.
*
- * @param array $file_array Array similar to a `$_FILES` upload array.
- * @param int $post_id Optional. The post ID the media is associated with.
- * @param string $desc Optional. Description of the side-loaded file. Default null.
- * @param array $post_data Optional. Post data to override. Default empty array.
+ * @param string[] $file_array Array that represents a `$_FILES` upload array.
+ * @param int $post_id Optional. The post ID the media is associated with.
+ * @param string $desc Optional. Description of the side-loaded file. Default null.
+ * @param array $post_data Optional. Post data to override. Default empty array.
* @return int|WP_Error The ID of the attachment or a WP_Error on failure.
*/
function media_handle_sideload( $file_array, $post_id = 0, $desc = null, $post_data = array() ) {
$overrides = array( 'test_form' => false );
- $time = current_time( 'mysql' );
- $post = get_post( $post_id );
-
- if ( $post ) {
- if ( substr( $post->post_date, 0, 4 ) > 0 ) {
+ if ( isset( $post_data['post_date'] ) && substr( $post_data['post_date'], 0, 4 ) > 0 ) {
+ $time = $post_data['post_date'];
+ } else {
+ $post = get_post( $post_id );
+ if ( $post && substr( $post->post_date, 0, 4 ) > 0 ) {
$time = $post->post_date;
+ } else {
+ $time = current_time( 'mysql' );
}
}
@@ -529,8 +533,8 @@
?>
-
+