equal
deleted
inserted
replaced
10 /** |
10 /** |
11 * Core class used to implement site icon functionality. |
11 * Core class used to implement site icon functionality. |
12 * |
12 * |
13 * @since 4.3.0 |
13 * @since 4.3.0 |
14 */ |
14 */ |
|
15 #[AllowDynamicProperties] |
15 class WP_Site_Icon { |
16 class WP_Site_Icon { |
16 |
17 |
17 /** |
18 /** |
18 * The minimum size of the site icon. |
19 * The minimum size of the site icon. |
19 * |
20 * |
75 |
76 |
76 /** |
77 /** |
77 * Creates an attachment 'object'. |
78 * Creates an attachment 'object'. |
78 * |
79 * |
79 * @since 4.3.0 |
80 * @since 4.3.0 |
|
81 * @deprecated 6.5.0 |
80 * |
82 * |
81 * @param string $cropped Cropped image URL. |
83 * @param string $cropped Cropped image URL. |
82 * @param int $parent_attachment_id Attachment ID of parent image. |
84 * @param int $parent_attachment_id Attachment ID of parent image. |
83 * @return array An array with attachment object data. |
85 * @return array An array with attachment object data. |
84 */ |
86 */ |
85 public function create_attachment_object( $cropped, $parent_attachment_id ) { |
87 public function create_attachment_object( $cropped, $parent_attachment_id ) { |
|
88 _deprecated_function( __METHOD__, '6.5.0', 'wp_copy_parent_attachment_properties()' ); |
|
89 |
86 $parent = get_post( $parent_attachment_id ); |
90 $parent = get_post( $parent_attachment_id ); |
87 $parent_url = wp_get_attachment_url( $parent->ID ); |
91 $parent_url = wp_get_attachment_url( $parent->ID ); |
88 $url = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url ); |
92 $url = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url ); |
89 |
93 |
90 $size = wp_getimagesize( $cropped ); |
94 $size = wp_getimagesize( $cropped ); |
198 * @since 4.3.0 |
202 * @since 4.3.0 |
199 * |
203 * |
200 * @param int $post_id Attachment ID. |
204 * @param int $post_id Attachment ID. |
201 */ |
205 */ |
202 public function delete_attachment_data( $post_id ) { |
206 public function delete_attachment_data( $post_id ) { |
203 $site_icon_id = get_option( 'site_icon' ); |
207 $site_icon_id = (int) get_option( 'site_icon' ); |
204 |
208 |
205 if ( $site_icon_id && $post_id == $site_icon_id ) { |
209 if ( $site_icon_id && $post_id === $site_icon_id ) { |
206 delete_option( 'site_icon' ); |
210 delete_option( 'site_icon' ); |
207 } |
211 } |
208 } |
212 } |
209 |
213 |
210 /** |
214 /** |
219 * @param bool $single Whether to return only the first value of the specified `$meta_key`. |
223 * @param bool $single Whether to return only the first value of the specified `$meta_key`. |
220 * @return array|null|string The attachment metadata value, array of values, or null. |
224 * @return array|null|string The attachment metadata value, array of values, or null. |
221 */ |
225 */ |
222 public function get_post_metadata( $value, $post_id, $meta_key, $single ) { |
226 public function get_post_metadata( $value, $post_id, $meta_key, $single ) { |
223 if ( $single && '_wp_attachment_backup_sizes' === $meta_key ) { |
227 if ( $single && '_wp_attachment_backup_sizes' === $meta_key ) { |
224 $site_icon_id = get_option( 'site_icon' ); |
228 $site_icon_id = (int) get_option( 'site_icon' ); |
225 |
229 |
226 if ( $post_id == $site_icon_id ) { |
230 if ( $post_id === $site_icon_id ) { |
227 add_filter( 'intermediate_image_sizes', array( $this, 'intermediate_image_sizes' ) ); |
231 add_filter( 'intermediate_image_sizes', array( $this, 'intermediate_image_sizes' ) ); |
228 } |
232 } |
229 } |
233 } |
230 |
234 |
231 return $value; |
235 return $value; |