- Visit your site to see how it looks.' ), home_url( '/' ) );
- ?>
-
-
-
+ if ( ! empty( $this->updated ) ) {
+ $updated_message = sprintf(
+ /* translators: %s: Home URL. */
+ __( 'Header updated. Visit your site to see how it looks.' ),
+ esc_url( home_url( '/' ) )
+ );
+ wp_admin_notice(
+ $updated_message,
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated' ),
+ )
+ );
+ }
+ ?>
@@ -696,7 +712,7 @@
-
+
@@ -761,7 +777,7 @@
$default_color = '';
if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) {
$default_color = get_theme_support( 'custom-header', 'default-text-color' );
- if ( $default_color && false === strpos( $default_color, '#' ) ) {
+ if ( $default_color && ! str_contains( $default_color, '#' ) ) {
$default_color = '#' . $default_color;
}
}
@@ -769,7 +785,7 @@
$default_color_attr = $default_color ? ' data-default-color="' . esc_attr( $default_color ) . '"' : '';
$header_textcolor = display_header_text() ? get_header_textcolor() : get_theme_support( 'custom-header', 'default-text-color' );
- if ( $header_textcolor && false === strpos( $header_textcolor, '#' ) ) {
+ if ( $header_textcolor && ! str_contains( $header_textcolor, '#' ) ) {
$header_textcolor = '#' . $header_textcolor;
}
@@ -805,7 +821,7 @@
}
/**
- * Display second step of custom header image page.
+ * Displays second step of custom header image page.
*
* @since 2.1.0
*/
@@ -868,14 +884,16 @@
$this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) );
/**
- * Fires after the header image is set or an error is returned.
+ * Filters the attachment file path after the custom header or background image is set.
+ *
+ * Used for file replication.
*
* @since 2.1.0
*
* @param string $file Path to the file.
* @param int $attachment_id Attachment ID.
*/
- do_action( 'wp_create_file_in_uploads', $file, $attachment_id ); // For replication.
+ $file = apply_filters( 'wp_create_file_in_uploads', $file, $attachment_id ); // For replication.
return $this->finished();
} elseif ( $width > $max_width ) {
@@ -916,7 +934,7 @@
-
+
@@ -948,7 +966,7 @@
/**
- * Upload the file to be cropped in the second step.
+ * Uploads the file to be cropped in the second step.
*
* @since 3.4.0
*/
@@ -989,7 +1007,7 @@
}
/**
- * Display third step of custom header image page.
+ * Displays third step of custom header image page.
*
* @since 2.1.0
* @since 4.4.0 Switched to using wp_get_attachment_url() instead of the guid
@@ -1059,7 +1077,7 @@
/** This filter is documented in wp-admin/includes/class-custom-image-header.php */
$cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
- $attachment = $this->create_attachment_object( $cropped, $attachment_id );
+ $attachment = wp_copy_parent_attachment_properties( $cropped, $attachment_id, 'custom-header' );
if ( ! empty( $_POST['create-new-attachment'] ) ) {
unset( $attachment['ID'] );
@@ -1085,7 +1103,7 @@
}
/**
- * Display last step of custom header image page.
+ * Displays last step of custom header image page.
*
* @since 2.1.0
*/
@@ -1095,7 +1113,7 @@
}
/**
- * Display the page based on the current step.
+ * Displays the page based on the current step.
*
* @since 2.1.0
*/
@@ -1140,16 +1158,17 @@
}
/**
- * Choose a header image, selected from existing uploaded and default headers,
- * or provide an array of uploaded header data (either new, or from media library).
+ * Chooses a header image, selected from existing uploaded and default headers,
+ * or provides an array of uploaded header data (either new, or from media library).
*
* @since 3.4.0
*
* @param mixed $choice Which header image to select. Allows for values of 'random-default-image',
- * for randomly cycling among the default images; 'random-uploaded-image', for randomly cycling
- * among the uploaded images; the key of a default image registered for that theme; and
- * the key of an image uploaded for that theme (the attachment ID of the image).
- * Or an array of arguments: attachment_id, url, width, height. All are required.
+ * for randomly cycling among the default images; 'random-uploaded-image',
+ * for randomly cycling among the uploaded images; the key of a default image
+ * registered for that theme; and the key of an image uploaded for that theme
+ * (the attachment ID of the image). Or an array of arguments: attachment_id,
+ * url, width, height. All are required.
*/
final public function set_header_image( $choice ) {
if ( is_array( $choice ) || is_object( $choice ) ) {
@@ -1159,7 +1178,7 @@
return;
}
- $choice['url'] = esc_url_raw( $choice['url'] );
+ $choice['url'] = sanitize_url( $choice['url'] );
$header_image_data = (object) array(
'attachment_id' => $choice['attachment_id'],
@@ -1197,12 +1216,12 @@
}
}
- set_theme_mod( 'header_image', esc_url_raw( $header_image_data['url'] ) );
+ set_theme_mod( 'header_image', sanitize_url( $header_image_data['url'] ) );
set_theme_mod( 'header_image_data', $header_image_data );
}
/**
- * Remove a header image.
+ * Removes a header image.
*
* @since 3.4.0
*/
@@ -1211,7 +1230,7 @@
}
/**
- * Reset a header image to the default image for the theme.
+ * Resets a header image to the default image for the theme.
*
* This method does not do anything if the theme does not have a default header image.
*
@@ -1241,7 +1260,7 @@
}
/**
- * Calculate width and height based on what the currently selected theme supports.
+ * Calculates width and height based on what the currently selected theme supports.
*
* @since 3.9.0
*
@@ -1292,15 +1311,17 @@
}
/**
- * Create an attachment 'object'.
+ * Creates an attachment 'object'.
*
* @since 3.9.0
+ * @deprecated 6.5.0
*
* @param string $cropped Cropped image URL.
* @param int $parent_attachment_id Attachment ID of parent image.
* @return array An array with attachment object data.
*/
final public function create_attachment_object( $cropped, $parent_attachment_id ) {
+ _deprecated_function( __METHOD__, '6.5.0', 'wp_copy_parent_attachment_properties()' );
$parent = get_post( $parent_attachment_id );
$parent_url = wp_get_attachment_url( $parent->ID );
$url = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url );
@@ -1321,7 +1342,7 @@
}
/**
- * Insert an attachment and its metadata.
+ * Inserts an attachment and its metadata.
*
* @since 3.9.0
*
@@ -1402,7 +1423,7 @@
/** This filter is documented in wp-admin/includes/class-custom-image-header.php */
$cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
- $attachment = $this->create_attachment_object( $cropped, $attachment_id );
+ $attachment = wp_copy_parent_attachment_properties( $cropped, $attachment_id, 'custom-header' );
$previous = $this->get_previous_crop( $attachment );
@@ -1571,7 +1592,7 @@
}
/**
- * Get the ID of a previous crop from the same base image.
+ * Gets the ID of a previous crop from the same base image.
*
* @since 4.9.0
*