WordPress 4.4
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-site-icon.php
index c71845936e723542ef3920b91bbfe274bf880700..8c06db64595561615d8bceb522750655f9788362 100644 (file)
@@ -1,6 +1,14 @@
 <?php
 /**
- * Class for implementing site icon functionality.
+ * Administration API: WP_Site_Icon class
+ *
+ * @package WordPress
+ * @subpackage Administration
+ * @since 4.3.0
+ */
+
+/**
+ * Core class used to implement site icon functionality.
  *
  * @since 4.3.0
  */
@@ -80,7 +88,7 @@ class WP_Site_Icon {
         */
        public function create_attachment_object( $cropped, $parent_attachment_id ) {
                $parent     = get_post( $parent_attachment_id );
-               $parent_url = $parent->guid;
+               $parent_url = wp_get_attachment_url( $parent->ID );
                $url        = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
 
                $size       = @getimagesize( $cropped );
@@ -221,10 +229,12 @@ class WP_Site_Icon {
         * @return array|null|string The attachment metadata value, array of values, or null.
         */
        public function get_post_metadata( $value, $post_id, $meta_key, $single ) {
-               $site_icon_id = get_option( 'site_icon' );
+               if ( $single && '_wp_attachment_backup_sizes' === $meta_key ) {
+                       $site_icon_id = get_option( 'site_icon' );
 
-               if ( $post_id == $site_icon_id && '_wp_attachment_backup_sizes' == $meta_key && $single ) {
-                       add_filter( 'intermediate_image_sizes', array( $this, 'intermediate_image_sizes' ) );
+                       if ( $post_id == $site_icon_id ) {
+                               add_filter( 'intermediate_image_sizes', array( $this, 'intermediate_image_sizes' ) );
+                       }
                }
 
                return $value;