Ticket #17542: custom-background.diff
| File custom-background.diff, 1.5 KB (added by denzel_chia, 2 years ago) |
|---|
-
custom-background.php
105 105 check_admin_referer('custom-background-reset', '_wpnonce-custom-background-reset'); 106 106 remove_theme_mod('background_image'); 107 107 remove_theme_mod('background_image_thumb'); 108 remove_theme_mod('background_image_attachment_id'); 108 109 $this->updated = true; 109 110 return; 110 111 } … … 114 115 check_admin_referer('custom-background-remove', '_wpnonce-custom-background-remove'); 115 116 set_theme_mod('background_image', ''); 116 117 set_theme_mod('background_image_thumb', ''); 118 //added remove uploaded file. 119 $attachmentid = get_theme_mod('background_image_attachment_id'); 120 wp_delete_attachment($attachmentid,$force_delete = true); 121 set_theme_mod('background_image_attachment_id', ''); 117 122 $this->updated = true; 118 123 return; 119 124 } … … 338 343 'post_title' => $filename, 339 344 'post_content' => $url, 340 345 'post_mime_type' => $type, 341 'guid' => $url, 342 'context' => 'custom-background' 346 'guid' => $url 343 347 ); 344 348 345 349 // Save the data … … 353 357 354 358 $thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' ); 355 359 set_theme_mod('background_image_thumb', esc_url( $thumbnail[0] ) ); 360 361 set_theme_mod('background_image_attachment_id',$id); 356 362 357 363 do_action('wp_create_file_in_uploads', $file, $id); // For replication 358 364 $this->updated = true;