From bd09d15a2c790c9dc1542791ebd82231e244d6a3 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Wed, 16 Oct 2013 23:26:10 +0000 Subject: [PATCH] Inline documentation for hooks in wp-admin/custom-header.php. Props gizburdt for the initial patch. Fixes #25443. Built from https://develop.svn.wordpress.org/trunk@25821 git-svn-id: http://core.svn.wordpress.org/trunk@25733 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/custom-header.php | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/wp-admin/custom-header.php b/wp-admin/custom-header.php index 9b02a3f033..b6a6e6c9c2 100644 --- a/wp-admin/custom-header.php +++ b/wp-admin/custom-header.php @@ -633,6 +633,11 @@ if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) { @@ -690,7 +695,16 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> $this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) ); - do_action('wp_create_file_in_uploads', $file, $attachment_id); // For replication + /** + * Fires after the header image is set or an error is returned. + * + * @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 + return $this->finished(); } elseif ( $width > $max_width ) { $oitar = $width / $max_width; @@ -698,7 +712,8 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> if ( ! $image || is_wp_error( $image ) ) wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); - $image = apply_filters('wp_create_file_in_uploads', $image, $attachment_id); // For replication + //duplicate_hook + $image = apply_filters( 'wp_create_file_in_uploads', $image, $attachment_id ); // For replication $url = str_replace(basename($url), basename($image), $url); $width = $width / $oitar; @@ -839,7 +854,8 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> if ( ! $cropped || is_wp_error( $cropped ) ) wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); - $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication + //duplicate_hook + $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication $parent = get_post($attachment_id); $parent_url = $parent->guid; @@ -870,10 +886,15 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> // cleanup $medium = str_replace( basename( $original ), 'midsize-' . basename( $original ), $original ); - if ( file_exists( $medium ) ) + if ( file_exists( $medium ) ) { + //duplicate_hook @unlink( apply_filters( 'wp_delete_file', $medium ) ); - if ( empty( $_POST['create-new-attachment'] ) && empty( $_POST['skip-cropping'] ) ) + } + + if ( empty( $_POST['create-new-attachment'] ) && empty( $_POST['skip-cropping'] ) ) { + //duplicate_hook @unlink( apply_filters( 'wp_delete_file', $original ) ); + } return $this->finished(); }